Merge branch 'MDL-28012' of git://github.com/timhunt/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-06-24 00:31:53 +02:00
commit 2e27e2d64a
2 changed files with 33 additions and 21 deletions

View file

@ -1237,44 +1237,55 @@ function quiz_print_grading_form($quiz, $pageurl, $tabindex) {
*/ */
function quiz_print_status_bar($quiz) { function quiz_print_status_bar($quiz) {
global $CFG; global $CFG;
$numberofquestions = quiz_number_of_questions_in_quiz($quiz->questions);
?><div class="statusbar"><span class="totalpoints"> $bits = array();
<?php echo get_string('totalpointsx', 'quiz',
quiz_format_grade($quiz, $quiz->sumgrades)) ?></span> $bits[] = html_writer::tag('span',
| <span class="numberofquestions"> get_string('totalpointsx', 'quiz', quiz_format_grade($quiz, $quiz->sumgrades)),
<?php array('class' => 'totalpoints'));
echo get_string('numquestionsx', 'quiz', $numberofquestions);
?></span> $bits[] = html_writer::tag('span',
<?php get_string('numquestionsx', 'quiz', quiz_number_of_questions_in_quiz($quiz->questions)),
// Current status of the quiz, with open an close dates as a tool tip. array('class' => 'numberofquestions'));
$currentstatus = get_string('quizisopen', 'quiz');
$dates = array();
$timenow = time(); $timenow = time();
// Exact open and close dates for the tool-tip.
$dates = array();
if ($quiz->timeopen > 0) { if ($quiz->timeopen > 0) {
if ($timenow > $quiz->timeopen) { if ($timenow > $quiz->timeopen) {
$dates[] = get_string('quizopenedon', 'quiz', userdate($quiz->timeopen)); $dates[] = get_string('quizopenedon', 'quiz', userdate($quiz->timeopen));
} else { } else {
$dates[] = get_string('quizwillopen', 'quiz', userdate($quiz->timeopen)); $dates[] = get_string('quizwillopen', 'quiz', userdate($quiz->timeopen));
print_string('quizisclosed', 'quiz');
} }
} }
if ($quiz->timeclose > 0) { if ($quiz->timeclose > 0) {
if ($timenow > $quiz->timeclose) { if ($timenow > $quiz->timeclose) {
$dates[] = get_string('quizclosed', 'quiz', userdate($quiz->timeclose)); $dates[] = get_string('quizclosed', 'quiz', userdate($quiz->timeclose));
print_string('quizisclosed', 'quiz');
} else { } else {
$dates[] = get_string('quizcloseson', 'quiz', userdate($quiz->timeclose)); $dates[] = get_string('quizcloseson', 'quiz', userdate($quiz->timeclose));
$currentstatus = get_string('quizisopenwillclose', 'quiz',
userdate($quiz->timeclose, get_string('strftimedatetimeshort', 'langconfig')));
} }
} }
if (empty($dates)) { if (empty($dates)) {
$dates[] = get_string('alwaysavailable', 'quiz'); $dates[] = get_string('alwaysavailable', 'quiz');
} }
$dates = implode(', ', $dates); $tooltip = implode(', ', $dates);;
echo ' | <span class="quizopeningstatus" title="' . $dates . '">' . $currentstatus . '</span>';
?> // Brief summary on the page.
</div> if ($timenow < $quiz->timeopen) {
<?php $currentstatus = get_string('quizisclosedwillopen', 'quiz',
userdate($quiz->timeclose, get_string('strftimedatetimeshort', 'langconfig')));
} else if ($quiz->timeclose && $timenow <= $quiz->timeclose) {
$currentstatus = get_string('quizisopenwillclose', 'quiz',
userdate($quiz->timeclose, get_string('strftimedatetimeshort', 'langconfig')));
} else if ($quiz->timeclose && $timenow > $quiz->timeclose) {
$currentstatus = get_string('quizisclosed', 'quiz');
} else {
$currentstatus = get_string('quizisopen', 'quiz');
}
$bits[] = html_writer::tag('span', $currentstatus,
array('class' => 'quizopeningstatus', 'title' => implode(', ', $dates)));
echo html_writer::tag('div', implode(' | ', $bits), array('class' => 'statusbar'));
} }

View file

@ -555,6 +555,7 @@ $string['quiz:grade'] = 'Grade quizzes manually';
$string['quiz:ignoretimelimits'] = 'Ignores time limit on quizzes'; $string['quiz:ignoretimelimits'] = 'Ignores time limit on quizzes';
$string['quizisclosed'] = 'This quiz is closed'; $string['quizisclosed'] = 'This quiz is closed';
$string['quizisopen'] = 'This quiz is open'; $string['quizisopen'] = 'This quiz is open';
$string['quizisclosedwillopen'] = 'Quiz closed (opens {$a})';
$string['quizisopenwillclose'] = 'Quiz open (closes {$a})'; $string['quizisopenwillclose'] = 'Quiz open (closes {$a})';
$string['quiz:manage'] = 'Manage quizzes'; $string['quiz:manage'] = 'Manage quizzes';
$string['quiz:manageoverrides'] = 'Manage quiz overrides'; $string['quiz:manageoverrides'] = 'Manage quiz overrides';