From 250e71d96747693f40eb7db6eb40ba166b897a96 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 28 Jul 2003 08:58:47 +0000 Subject: [PATCH] When a quiz is closing within the next 24 hours, a small countdown is shown in the titlebar (drawn with javascript). An alert is shown at ten minutes, and zero minutes. This doesn't prevent students from doing anything, but it serves as a reminder and just looks cool. ;-) --- lang/en/quiz.php | 3 +++ mod/quiz/attempt.php | 11 ++++++-- mod/quiz/jsclock.php | 63 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 mod/quiz/jsclock.php 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 @@ +