$string['choices'] = "Available choices";
$string['correctanswer'] = "Correct answer";
$string['correctanswers'] = "Correct answers";
+$string['countdown'] = "Countdown";
+$string['countdownfinished'] = "The quiz is closing, you should submit your answers now.";
+$string['countdowntenminutes'] = "The quiz will be closing in ten minutes.";
$string['createmultiple'] = "Create multiple questions";
$string['createnewquestion'] = "Create new question";
$string['custom'] = "Custom format";
}
print_heading(get_string("attempt", "quiz", $numattempts));
-
print_simple_box(text_to_html($quiz->intro), "CENTER");
+/// Add the javascript timer in the title bar if the closing time appears close
+
+ $secondsleft = $quiz->timeclose - time();
+ if ($secondsleft > 0 and $secondsleft < 24*3600) { // less than a day remaining
+ include("jsclock.php");
+ }
+
+
/// Print all the questions
- echo "<BR>";
+ echo "<br />";
if (! quiz_print_quiz_questions($quiz)) {
print_continue("view.php?id=$cm->id");
--- /dev/null
+<script language="javascript">\r
+<!--\r
+/// This Javascript clock provides a little countdown in the title bar\r
+\r
+var timerID = null;\r
+var timerRunning = false;\r
+var secondsleft = <?php echo $secondsleft ?>;\r
+var titleafter = '<?php echo $quiz->name ?>';\r
+var titlebefore = '<?php echo get_string("countdown", "quiz").": " ?>';\r
+var alertmessage = '<?php print_string("countdownfinished", "quiz") ?>';\r
+var alertmessage10 = '<?php print_string("countdowntenminutes", "quiz") ?>';\r
+\r
+function stopclock() {\r
+ if (timerRunning) {\r
+ clearTimeout(timerID);\r
+ timerRunning = false;\r
+ }\r
+}\r
+\r
+function startclock() {\r
+ stopclock();\r
+ showtime();\r
+}\r
+\r
+function showtime() {\r
+\r
+ secondsleft = secondsleft - 1;\r
+\r
+ if (secondsleft == 600) {\r
+ alert(alertmessage10);\r
+ }\r
+\r
+ if (secondsleft == 0) {\r
+ stopclock();\r
+ document.title = titleafter;\r
+ return alert(alertmessage);\r
+\r
+ } else {\r
+ current = secondsleft;\r
+\r
+ var hours = Math.floor( current / 3600 );\r
+ current = current - (hours*3600);\r
+ \r
+ var minutes = Math.floor( current / 60 );\r
+ current = current - (minutes*60);\r
+ \r
+ var seconds = current;\r
+ \r
+ var timeValue = "" + hours;\r
+ timeValue += ((minutes < 10) ? ":0" : ":") + minutes;\r
+ timeValue += ((seconds < 10) ? ":0" : ":") + seconds;\r
+ \r
+ document.title = titlebefore+timeValue+' '+titleafter;\r
+ timerID = setTimeout("showtime()",1000);\r
+ timerRunning = true;\r
+ }\r
+}\r
+\r
+document.onLoad = startclock();\r
+\r
+\r
+// -- End of JavaScript code -------------- -->\r
+</script>\r