Skip to content

Commit

Permalink
quiz editing: MDL-17296 improve display of open and closde dates on t…
Browse files Browse the repository at this point in the history
…he editing page.
  • Loading branch information
tjhunt committed Jan 9, 2009
1 parent 041a4b0 commit e476804
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
6 changes: 6 additions & 0 deletions lang/en_utf8/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@
$string['choosefile'] = 'Choose a file';
$string['close'] = 'Close window';
$string['closebeforeopen'] = 'Could not update the quiz. You have specified a close date before the open date.';
$string['closedat'] = 'closed: $a';
$string['closepreview'] = 'Close preview';
$string['closereview'] = 'Close review';
$string['closesat'] = 'closes: $a';
$string['comment'] = 'Comment';
$string['commentorgrade'] = 'Make comment or override grade';
$string['comments'] = 'Comments';
Expand Down Expand Up @@ -457,6 +459,8 @@
$string['onlyteachersimport'] = 'Only teachers with editing rights can import questions';
$string['open'] = 'Started';
$string['openclosedatesupdated'] = 'Quiz open and close dates updated';
$string['openedat'] = 'opened: $a';
$string['opensat'] = 'opens: $a';
$string['optional'] = 'optional';
$string['orderandpaging'] = 'Order and paging';
$string['orderingquiz'] = 'Order and paging';
Expand Down Expand Up @@ -530,6 +534,8 @@
$string['quizclosed'] = 'This quiz closed on $a';
$string['quizcloses'] = 'Quiz closes';
$string['quizcloseson'] = 'This quiz will close at $a';
$string['quizisclosed'] = 'This quiz is closed ($a)';
$string['quizisopen'] = 'This quiz is open ($a)';
$string['quiznavigation'] = 'Quiz navigation';
$string['quiznotavailable'] = 'The quiz will not be available until $a';
$string['quizopen'] = 'Open the quiz';
Expand Down
11 changes: 0 additions & 11 deletions mod/quiz/accessrules.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,6 @@ public function time_left($attempt, $timenow) {
}
return false;
}
/**
* Output information about this quiz's open and close dates, and whether
* the quiz is currently open.
*/
public function print_timing_information() {
$messages = $this->description();
if (!$this->prevent_access()) {
$messages[] = get_string('quizopened', 'quiz');
}
echo implode(' | ', $messages);
}
}

/**
Expand Down
31 changes: 29 additions & 2 deletions mod/quiz/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,35 @@ function quiz_print_status_bar($quiz){
?></span>
| <span class="quizopeningstatus">
<?php
$accessrule = new open_close_date_access_rule(new quiz($quiz, NULL, NULL, false), time());
$accessrule->print_timing_information();
$available = true;
$dates = array();
$timenow = time();
$dateformat = get_string('strftimedatetimeshort');
if ($quiz->timeopen > 0) {
if ($timenow > $quiz->timeopen) {
$dates[] = get_string('openedat', 'quiz', userdate($quiz->timeopen, $dateformat));
} else {
$dates[] = get_string('opensat', 'quiz', userdate($quiz->timeopen, $dateformat));
$available = false;
}
}
if ($quiz->timeclose > 0) {
if ($timenow > $quiz->timeclose) {
$dates[] = get_string('closedat', 'quiz', userdate($quiz->timeclose, $dateformat));
$available = false;
} else {
$dates[] = get_string('closesat', 'quiz', userdate($quiz->timeclose, $dateformat));
}
}
if (empty($dates)) {
$dates[] = get_string('alwaysavailable', 'quiz');
}
$dates = implode(', ', $dates);
if ($available) {
print_string('quizisopen', 'quiz', $dates);
} else {
print_string('quizisclosed', 'quiz', $dates);
}
?></span><?php
// If questions are shuffled, notify the user about the
// question order not making much sense
Expand Down

0 comments on commit e476804

Please sign in to comment.