From cd70aa32f2580d425df8de62aaf338d014926ca3 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 1 Jun 2006 14:27:37 +0000 Subject: [PATCH] Bug 5247: stop people creating tests with a close date before the open date. --- lang/en_utf8/quiz.php | 1 + mod/quiz/lib.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 87a56913c6..b43e4b09bb 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -102,6 +102,7 @@ $string['correctanswerlength'] = 'Significant Figures'; $string['correctanswers'] = 'Correct answers'; $string['correctanswershows'] = 'Correct answer shows'; $string['corrresp'] = 'Correct Response'; +$string['closebeforeopen'] = 'Could not update the quiz. You have specified a close date before the open date.'; $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.'; diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 3b263d30bf..7c4df55c31 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -78,6 +78,10 @@ function quiz_add_instance($quiz) { $quiz->availableminute); } + if ($quiz->timeopen != 0 && $quiz->timeclose != 0 && $quiz->timeclose < $quiz->timeopen) { + return get_string('closebeforeopen', 'quiz'); + } + $quiz->timelimit = round($quiz->timelimit); if (empty($quiz->name)) { @@ -171,6 +175,10 @@ function quiz_update_instance($quiz) { $quiz->availableminute); } + if ($quiz->timeopen != 0 && $quiz->timeclose != 0 && $quiz->timeclose < $quiz->timeopen) { + return get_string('closebeforeopen', 'quiz'); + } + $quiz->timelimit = round($quiz->timelimit); $quiz->id = $quiz->instance; -- 2.39.5