diff --git a/lang/en/quiz.php b/lang/en/quiz.php
index be6ed3791c2..8c562f5c4fb 100644
--- a/lang/en/quiz.php
+++ b/lang/en/quiz.php
@@ -40,6 +40,9 @@ $string['choice'] = "Choice";
$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";
diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php
index 03b80fffcb8..c16c8818ef9 100644
--- a/mod/quiz/attempt.php
+++ b/mod/quiz/attempt.php
@@ -173,13 +173,20 @@
}
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 "
";
+ echo "
";
if (! quiz_print_quiz_questions($quiz)) {
print_continue("view.php?id=$cm->id");
diff --git a/mod/quiz/jsclock.php b/mod/quiz/jsclock.php
new file mode 100644
index 00000000000..3929452980b
--- /dev/null
+++ b/mod/quiz/jsclock.php
@@ -0,0 +1,63 @@
+