2 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
5 <script text
="text/javascript">
7 /// This Javascript clock provides a little countdown in the title bar
10 var timerRunning
= false;
11 var secondsleft
= <?php
echo $secondsleft ?
>;
12 var titleafter
= '<?php echo format_string($quiz->name) ?>';
13 var titlebefore
= '<?php echo get_string("countdown", "quiz").": " ?>';
14 var alertmessage
= '<?php print_string("countdownfinished", "quiz") ?>';
15 var alertmessage10
= '<?php print_string("countdowntenminutes", "quiz") ?>';
17 function stopclock() {
19 clearTimeout(timerID
);
24 function startclock() {
31 secondsleft
= secondsleft
- 1;
33 if (secondsleft
== 600) {
34 alert(alertmessage10
);
37 if (secondsleft
== 0) {
39 document
.title
= titleafter
;
40 return alert(alertmessage
);
43 current
= secondsleft
;
45 var hours
= Math
.floor( current
/ 3600 );
46 current
= current
- (hours
*3600);
48 var minutes
= Math
.floor( current
/ 60 );
49 current
= current
- (minutes
*60);
51 var seconds
= current
;
53 var timeValue
= "" + hours
;
54 timeValue +
= ((minutes
< 10) ?
":0" : ":") + minutes
;
55 timeValue +
= ((seconds
< 10) ?
":0" : ":") + seconds
;
57 document
.title
= titlebefore+timeValue+
' '+titleafter
;
58 timerID
= setTimeout("showtime()",1000);
63 document
.onLoad
= startclock();