}
/**
- * Print each message in an array, each surrounded by <p>, </p> tags.
+ * Print each message in an array, surrounded by <p>, </p> tags.
*
* @param array $messages the array of message strings.
* @param boolean $return if true, return a string, instead of outputting.
}
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);
+ }
}
/**
?></span>
| <span class="quizopeningstatus">
<?php
- print_timing_information($quiz,true);
+ $accessrule = new open_close_date_access_rule(new quiz($quiz, NULL, NULL, false), time());
+ $accessrule->print_timing_information();
?></span><?php
// If questions are shuffled, notify the user about the
// question order not making much sense
// return the number of successfully sent emails
return $emailresult['good'];
}
-//TODO: refactor; http://tracker.moodle.org/browse/MDL-17296
-function print_timing_information($quiz,$showopenstatus=false){
- $timenow = time();
- $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose));
- if ($available) {
- if ($quiz->timelimit) {
- echo get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."</p>";
- }
- if ($quiz->timeopen) {
- echo get_string('quizopens', 'quiz'), ': ', userdate($quiz->timeopen);
- }
- if ($quiz->timeclose) {
- echo get_string('quizcloses', 'quiz'), ': ', userdate($quiz->timeclose);
- }
- if($showopenstatus){
- if(!$quiz->timelimit && !$quiz->timeopen && !$quiz->timeclose){
- echo get_string('quizopened', 'quiz');
- }
- }
- } else if ($timenow < $quiz->timeopen) {
- echo get_string("quiznotavailable", "quiz", userdate($quiz->timeopen));
- } else {
- echo get_string("quizclosed", "quiz", userdate($quiz->timeclose));
- }
- return $available;
-}
/**
* Clean the question layout from various possible anomalies:
* - Remove consecutive ","'s