MDL-15750 - After the close date, the teacher cannot preview a quiz becuase the timer thinks the time is already up. Also, move the timer in to the new navigation block.

This commit is contained in:
tjhunt 2008-07-22 11:37:01 +00:00
parent 5bbf20b48d
commit 5533791abc
5 changed files with 24 additions and 55 deletions

View File

@ -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!';

View File

@ -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) {

View File

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

View File

@ -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);
}
};

View File

@ -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,