Timer stops at 1 sec

Timer stops at 1 sec

by Jack Eapen -
Number of replies: 4

Hi

i have a problem with the quiz timer in Moodle 1.6

the timer countdown simply stops at 00:01 and a javascript error icon is coming on the status bar. when i click on that what i can see is "object doesnt support this method or property" . but if click on any question no. link or so, then the time ends and the page is redirected to review.php

any help, plz

 

Jack

Average of ratings: -
In reply to Jack Eapen

Re: Timer stops at 1 sec

by Ravi M -

HI

 I got a fix for this just comment the line " document.forms['responseform'].onsubmit();" in the function countdown_clock  (This is avilable in mod/quiz/timer.js )

In reply to Ravi M

Re: Timer stops at 1 sec

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
When you report bugs like this (involving JavaScript), please say which browser and operating system you are using.

Can you try applying the following patch, and see if that fixes it. I think this is the right fix.

Thanks,

Tim.

Index: mod/quiz/timer.js
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/timer.js,v
retrieving revision 1.7
diff -u -r1.7 timer.js
--- mod/quiz/timer.js	5 May 2006 06:44:32 -0000	1.7
+++ mod/quiz/timer.js	4 Jul 2006 17:20:34 -0000
@@ -13,11 +13,14 @@
 	// @EC PF : time left according to client
 	quizTimerValue = Math.floor( (ec_quiz_finish - ec_now_epoch) /1000 );

-    if(quizTimerValue == 0) {
+    if(quizTimerValue <= 0) {
         clearTimeout(timeout_id);
-        document.forms['responseform'].timeup.value = 1;
-        document.forms['responseform'].onsubmit();
-        document.forms['responseform'].submit();
+        var ourForm = document.forms['responseform'];
+        ourForm.timeup.value = 1;
+        if (ourForm.onsubmit) {
+	        ourForm.onsubmit();
+	    }
+        ourForm.submit();
     }

     now = quizTimerValue;
Index: mod/quiz/attempt.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/attempt.php,v
retrieving revision 1.90
diff -u -r1.90 attempt.php
--- mod/quiz/attempt.php	6 Jun 2006 14:29:05 -0000	1.90
+++ mod/quiz/attempt.php	4 Jul 2006 17:20:34 -0000
@@ -490,11 +490,12 @@
         ?>
         <script language="javascript" type="text/javascript">
         function navigate(page) {
-            document.responseform.page.value=page;
-            if (document.responseform.onsubmit) {
-	            document.responseform.onsubmit();
+            var ourForm = document.forms['responseform'];
+            ourForm.page.value=page;
+            if (ourForm.onsubmit) {
+	            ourForm.onsubmit();
 	        }
-            document.responseform.submit();
+            ourForm.submit();
         }
         </script>
         <?php

In reply to Tim Hunt

Re: Timer stops at 1 sec

by Maria B. -
Using:

1. Windows XP
2. FireFox, Opera, IE

It doesn't work, although with some earlier version of Moodle (1.5.6) everything was OK!