From cd9ca8540969d6b3b76baeb7c5d8c2e035edc97d Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Thu, 23 Mar 2006 19:32:24 +0000 Subject: [PATCH] Timer now uses the client's clock. Patch contributed by Phillip Franks, see bug 4967 --- mod/quiz/jstimer.php | 6 ++++++ mod/quiz/timer.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mod/quiz/jstimer.php b/mod/quiz/jstimer.php index b88977fe90..1a0d7641a3 100644 --- a/mod/quiz/jstimer.php +++ b/mod/quiz/jstimer.php @@ -12,6 +12,12 @@ var timesup = ""; var quizclose = timeclose - time()) - $timerstartvalue; ?>; // in seconds var quizTimerValue = ; // 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 + ; + // --> diff --git a/mod/quiz/timer.js b/mod/quiz/timer.js index bdb9e960fe..a45284424a 100644 --- a/mod/quiz/timer.js +++ b/mod/quiz/timer.js @@ -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); -- 2.39.5