MDL-55815 quiz review: after close should beat immediately after
authorTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 31 Aug 2016 11:55:18 +0000 (12:55 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 31 Aug 2016 11:55:21 +0000 (12:55 +0100)
This only arises in specific situations: student submitted less than 2
mintues before time close, or when a teacher previews after the close
date. However, in those cases, the old behaviour was confusing. Now,
'After the quiz is closed' takes priority.

mod/quiz/locallib.php
mod/quiz/tests/locallib_test.php

index 55c7240..fcd70f8 100644 (file)
@@ -1368,12 +1368,12 @@ function quiz_get_flag_option($attempt, $context) {
 function quiz_attempt_state($quiz, $attempt) {
     if ($attempt->state == quiz_attempt::IN_PROGRESS) {
         return mod_quiz_display_options::DURING;
+    } else if ($quiz->timeclose && time() >= $quiz->timeclose) {
+        return mod_quiz_display_options::AFTER_CLOSE;
     } else if (time() < $attempt->timefinish + 120) {
         return mod_quiz_display_options::IMMEDIATELY_AFTER;
-    } else if (!$quiz->timeclose || time() < $quiz->timeclose) {
-        return mod_quiz_display_options::LATER_WHILE_OPEN;
     } else {
-        return mod_quiz_display_options::AFTER_CLOSE;
+        return mod_quiz_display_options::LATER_WHILE_OPEN;
     }
 }
 
index 760e6a5..8fa40e6 100644 (file)
@@ -58,10 +58,13 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
     public function quiz_attempt_state_data_provider() {
         return [
             [quiz_attempt::IN_PROGRESS, null, null, mod_quiz_display_options::DURING],
-            [quiz_attempt::FINISHED, -10, null, mod_quiz_display_options::IMMEDIATELY_AFTER],
+            [quiz_attempt::FINISHED, -90, null, mod_quiz_display_options::IMMEDIATELY_AFTER],
             [quiz_attempt::FINISHED, -7200, null, mod_quiz_display_options::LATER_WHILE_OPEN],
             [quiz_attempt::FINISHED, -7200, 3600, mod_quiz_display_options::LATER_WHILE_OPEN],
+            [quiz_attempt::FINISHED, -30, 30, mod_quiz_display_options::IMMEDIATELY_AFTER],
+            [quiz_attempt::FINISHED, -90, -30, mod_quiz_display_options::AFTER_CLOSE],
             [quiz_attempt::FINISHED, -7200, -3600, mod_quiz_display_options::AFTER_CLOSE],
+            [quiz_attempt::FINISHED, -90, -3600, mod_quiz_display_options::AFTER_CLOSE],
             [quiz_attempt::ABANDONED, -10000000, null, mod_quiz_display_options::LATER_WHILE_OPEN],
             [quiz_attempt::ABANDONED, -7200, 3600, mod_quiz_display_options::LATER_WHILE_OPEN],
             [quiz_attempt::ABANDONED, -7200, -3600, mod_quiz_display_options::AFTER_CLOSE],