Permalink
Browse files

quiz delays MDL-20956 don't let overdue attempts + delays block stude…

…nts.

Suppose a quiz has a 60 min time limit, and an enforced delay of 60 mins between attempts.

Suppose a sudent starts an attempt, and then closes their browser, and then comes back 2 hours later. When they try to restart the quiz, it is submitted immediately by the timer.

Now they are blocked out for the next hour.

After this change, they would no longer be blocked, becuse if their attemtp had been submitted at the end of the first hour, then they would already have waited an hour.

That is, we compare the current time with both $lastattempt->timefinish + $delay and $lastattempt->timestart + $timelimit + $delay.
  • Loading branch information...
1 parent dd2e755 commit 96666fb36af5eec89be1acdae8ee959f4373373d @timhunt timhunt committed Aug 6, 2010
Showing with 9 additions and 1 deletion.
  1. +6 −1 mod/quiz/attempt.php
  2. +3 −0 mod/quiz/view.php
@@ -151,9 +151,14 @@
$numattempts = 0;
}
$timenow = time();
- $lastattempt_obj = get_record_select('quiz_attempts', "quiz = $quiz->id AND attempt = $numattempts AND userid = $USER->id", 'timefinish');
+ $lastattempt_obj = get_record_select('quiz_attempts',
+ "quiz = $quiz->id AND attempt = $numattempts AND userid = $USER->id",
+ 'timefinish, timestart');
if ($lastattempt_obj) {
$lastattempt = $lastattempt_obj->timefinish;
+ if ($quiz->timelimit > 0) {
+ $lastattempt = min($lastattempt, $lastattempt_obj->timestart + $quiz->timelimit*60);
+ }
}
if ($numattempts == 1 && !empty($quiz->delay1)) {
if ($timenow - $quiz->delay1 < $lastattempt) {
View
@@ -368,6 +368,9 @@
$tempunavailable = '';
$lastattempt = end($attempts);
$lastattempttime = $lastattempt->timefinish;
+ if ($quiz->timelimit > 0) {
+ $lastattempttime = min($lastattempttime, $lastattempt->timestart + $quiz->timelimit*60);
+ }
if ($numattempts == 1 && $quiz->delay1 && $timenow <= $lastattempttime + $quiz->delay1) {
$tempunavailable = get_string('temporaryblocked', 'quiz') .
' <strong>'. userdate($lastattempttime + $quiz->delay1). '</strong>';

0 comments on commit 96666fb

Please sign in to comment.