diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index e0210c30cac..66f7bea64ac 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -596,7 +596,7 @@ $string['temporaryblocked'] = 'You are temporarily not allowed to re-attempt the $string['time'] = 'Time'; $string['timecompleted'] = 'Completed'; $string['timedelay'] = 'You are not allowed to do the quiz since you have not passed the time delay before attempting another quiz'; -$string['timeleft'] = 'Time Remaining'; +$string['timeleft'] = 'Time left'; $string['timelimit'] = 'Time limit'; $string['timelimitmin'] = 'Time limit (minutes)'; $string['timelimitexeeded'] = 'Sorry! Quiz time limit exceeded!'; diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index 0c91c6d3f4a..cc48b9c01b0 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -498,6 +498,14 @@ class open_close_date_access_rule extends quiz_access_rule_base { return $this->_quiz->timeclose && $this->_timenow > $this->_quiz->timeclose; } public function time_left($attempt, $timenow) { + // If this is a teacher preview after the close date, do not show + // the time. + if ($attempt->preview && $timenow > $this->_quiz->timeclose) { + return false; + } + + // Otherwise, return to the time left until the close date, providing + // that is less than QUIZ_SHOW_TIME_BEFORE_DEADLINE if ($this->_quiz->timeclose) { $timeleft = $this->_quiz->timeclose - $timenow; if ($timeleft < QUIZ_SHOW_TIME_BEFORE_DEADLINE) { diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 7d7166f6a89..ea054359848 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -828,8 +828,12 @@ class quiz_attempt_nav_panel extends quiz_nav_panel_base { } protected function get_end_bits() { - return '<input type="submit" name="gotosummary" value="' . + $output = ''; + $output .= '<input type="submit" name="gotosummary" value="' . get_string('endtest', 'quiz') . '" class="endtestlink" />'; + $output .= '<div id="quiz-timer">' . get_string('timeleft', 'quiz') . + ' <span id="quiz-time-left"></span></div>'; + return $output; } } diff --git a/mod/quiz/quiz.js b/mod/quiz/quiz.js index 6201bbffecd..ca6b450f26b 100644 --- a/mod/quiz/quiz.js +++ b/mod/quiz/quiz.js @@ -42,15 +42,6 @@ quiz_timer = { // Once time has run out. timeoutid: null, - // Desired position of the top of timer_outer: 100px from the top of the window. - targettop: 100, - - // How often we check to positing and adjust it. Delay in milliseconds. - movedelay: 100, - - // Last known postion of timer_outer. - oldtop: this.target_top, - // Colours used to change the timer bacground colour when time had nearly run out. // This array is indexed by number of seconds left. finalcolours: [ @@ -79,12 +70,14 @@ quiz_timer = { quiz_timer.endtime = new Date().getTime() + timeleft*1000; // Get references to some bits of the DOM we need. - quiz_timer.timerouter = document.getElementById('quiz-timer-outer'), - quiz_timer.timerdisplay = document.getElementById('quiz-timer-display'), + quiz_timer.timerouter = document.getElementById('quiz-timer'), + quiz_timer.timerdisplay = document.getElementById('quiz-time-left'), quiz_timer.quizform = document.getElementById('responseform'), - // Get things starte. - quiz_timer.move(); + // Make the timer visible. + quiz_timer.timerouter.style.display = 'block'; + + // Get things started. quiz_timer.update_time(); }, @@ -148,35 +141,6 @@ quiz_timer = { // Arrange for this method to be called again soon. quiz_timer.timeoutid = setTimeout(quiz_timer.update_time, quiz_timer.updatedelay); - }, - - // Function to keep the clock in the same place on the screen. - move: function() { - // Work out where the top of the window is. - var pos; - if (window.innerHeight) { - pos = window.pageYOffset - } else if (document.documentElement && document.documentElement.scrollTop) { - pos = document.documentElement.scrollTop - } else if (document.body) { - pos = document.body.scrollTop - } - - // We want the timer target_top pixels from the top of the window, - // or the top of the document, whichever is lower. - pos += quiz_timer.targettop; - if (pos < quiz_timer.targettop) { - pos = quiz_timer.targettop; - } - - // Only move the timer if the window has stopped moving, and the position has stabilised. - if (pos == quiz_timer.oldtop) { - quiz_timer.timerouter.style.top = pos + 'px'; - } - quiz_timer.oldtop = pos; - - // Arrange for this method to be called again soon. - setTimeout(quiz_timer.move, quiz_timer.movedelay); } }; diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 741f6180c31..ed5aa90e774 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -3842,18 +3842,11 @@ body#mod-forum-search .introcontent { margin-top: 1.5em; } -#mod-quiz-attempt #quiz-timer-outer { - position: absolute; - width: 150px; - top: 100px; - left: 10px; - padding: 0.25em 0; - border-width: 1px; - border-style: solid; +#mod-quiz-attempt #quiz-timer { + display: none; } -#mod-quiz-attempt #quiz-timer-outer h3, -#mod-quiz-attempt #quiz-timer-outer p { - margin: 0; +#mod-quiz-attempt #quiz-time-left { + font-weight: bold; } body#question-preview .quemodname,