MDL-55815 quiz review: after close should beat immediately after

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.
This commit is contained in:
Tim Hunt 2016-08-31 12:55:18 +01:00
parent daf6becfb0
commit d0f8daef12
2 changed files with 7 additions and 4 deletions

View 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;
}
}

View 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],