-
Improvement
-
Resolution: Fixed
-
Minor
-
3.1.4, 3.9
-
MOODLE_31_STABLE, MOODLE_39_STABLE
-
MOODLE_310_STABLE
-
MDL-58926-ajax-timer -
If the teacher edits the time limit or close date of a quiz in progress, then students with the quiz open in their browser do not necessarily see the chagne in time, so the timer may auto-submit their work before necessary, or too late.
Original issue, which is now handled by MDL-68970:
We got feedback of several students, reporting that the quiz timer jumps or even resets in their attempts. We figured out, that it comes with the unintentionally use of browsers shortcuts for the 'back button' . Some browsers have shortcuts like the 'backspace' or Alt+Arrowkeys to navigate trough the browsers history. Unintentionally the problem can occur if students try to delete content in an question using 'backspace' without having focus in that textarea.
Steps to reproduce using Chrome:
1) start an attempt
2 ) navigate to summary.php and wait 1 Minute (just to see it better)
3) use ALT+Leftkey and then ALT+Rightkey to see the timer jumping (the page should not reload)
We fixed this issue on our installation, so I can give you a proposal for a patch :
— a/mod/quiz/renderer.php
+++ b/mod/quiz/renderer.php
@@ -283,6 +283,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
public function countdown_timer(quiz_attempt $attemptobj, $timenow) {
$timeleft = $attemptobj->get_time_left_display($timenow);
+ $quizduration = $attemptobj->get_quiz()->timelimit;
if ($timeleft !== false) {
$ispreview = $attemptobj->is_preview();
$timerstartvalue = $timeleft;
@@ -291,7 +292,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
// this will just have the effect of causing the quiz to be submitted immediately.
$timerstartvalue = max($timerstartvalue, 1);
}
- $this->initialise_timer($timerstartvalue, $ispreview);
+ $this->initialise_timer($attemptobj->get_attempt()->timestart, $ispreview, $quizduration);
}
return html_writer::tag('div', get_string('timeleft', 'quiz') . ' ' .
@@ -568,8 +569,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
- Output the JavaScript required to initialise the countdown timer.
- @param int $timerstartvalue time remaining, in seconds.
*/
- public function initialise_timer($timerstartvalue, $ispreview) {
- $options = array($timerstartvalue, (bool)$ispreview);
+ public function initialise_timer($attemptstart, $ispreview, $quizduration) {
+ $options = array(($attemptstart + $quizduration)*1000, (bool)$ispreview);
$this->page->requires->js_init_call('M.mod_quiz.timer.init', $options, false, quiz_get_js_module());
}
— a/mod/quiz/module.js
+++ b/mod/quiz/module.js
@@ -63,9 +63,9 @@ M.mod_quiz.timer = {
- @param start, the timer starting time, in seconds.
- @param preview, is this a quiz preview?
*/
- init: function(Y, start, preview) {
+ init: function(Y, end, preview) {
M.mod_quiz.timer.Y = Y; - M.mod_quiz.timer.endtime = M.pageloadstarttime.getTime() + start*1000;
+ M.mod_quiz.timer.endtime = end;
M.mod_quiz.timer.preview = preview;
M.mod_quiz.timer.update();
Y.one('#quiz-timer').setStyle('display', 'block');
- has a non-specific relationship to
-
MDL-68970 Pages during a quiz attempt should not be cached, so forwards/back do not lead to errors
- Closed
- has been marked as being related by
-
MDL-27570 Quiz time limit changes are not reflected in active quiz attempts without page refresh
- Closed
- is duplicated by
-
MDL-68398 Timed quiz - Incorrect time displayed after clicking on browser ← and →
- Closed