1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 02:16:06 +02:00

Timer now uses the client's clock. Patch contributed by Phillip Franks, see bug 4967

This commit is contained in:
gustav_delius 2006-03-23 19:32:24 +00:00
parent b8770bc0a5
commit cd9ca85409
2 changed files with 12 additions and 1 deletions

@ -12,6 +12,12 @@ var timesup = "<?php print_string("timesup","quiz");?>";
var quizclose = <?php echo ($quiz->timeclose - time()) - $timerstartvalue; ?>; // in seconds
var quizTimerValue = <?php echo $timerstartvalue; ?>; // in seconds
parseInt(quizTimerValue);
// @EC PF : client time when page was opened
var ec_page_start = new Date().getTime();
// @EC PF : client time when quiz should end
var ec_quiz_finish = ec_page_start + <?php echo ($timerstartvalue * 1000); ?>;
// -->
</script>
<script language="javascript" type="text/javascript" src="timer.js"></script>

@ -6,7 +6,12 @@
//
function countdown_clock(theTimer) {
var timeout_id = null;
quizTimerValue = quizTimerValue - 1;
// @EC PF : current client time
var ec_now_epoch = new Date().getTime();
// @EC PF : time left according to client
quizTimerValue = Math.floor( (ec_quiz_finish - ec_now_epoch) /1000 );
if(quizTimerValue == 0) {
clearTimeout(timeout_id);