]> git.mjollnir.org Git - moodle.git/commitdiff
quiz editing: MDL-17296 improve display of open and closde dates on the editing page.
authortjhunt <tjhunt>
Fri, 9 Jan 2009 03:17:18 +0000 (03:17 +0000)
committertjhunt <tjhunt>
Fri, 9 Jan 2009 03:17:18 +0000 (03:17 +0000)
lang/en_utf8/quiz.php
mod/quiz/accessrules.php
mod/quiz/editlib.php

index 2ecde429eeef90eda464378a13238932b028440d..e2b693354d9721f4bb3e3a21a663ba9e0eadbae6 100644 (file)
@@ -134,8 +134,10 @@ $string['choosedatasetproperties'] = 'Choose dataset properties';
 $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';
@@ -457,6 +459,8 @@ $string['onlyteachersexport'] = 'Only teachers can export questions';
 $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';
@@ -530,6 +534,8 @@ $string['quizclose'] = 'Close the quiz';
 $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';
index 7ef4cec21a857f8c729e6a4cd61f9e2b83aa13ca..0d215d36c0a28708255da1b2cfbf5cc0c9c6f9aa 100644 (file)
@@ -510,17 +510,6 @@ class open_close_date_access_rule extends quiz_access_rule_base {
         }
         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);
-    }
 }
 
 /**
index 867e983b627c955ffa27006ccd6f9c624e29d86e..fbbd9cdc264fc6a5e7dbcbf4c9b9f92c8f323860 100644 (file)
@@ -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