diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 84990dd98cb..70a94470704 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -174,7 +174,6 @@ function quiz_update_instance($quiz) { $quiz->timelimit = round($quiz->timelimit); $quiz->id = $quiz->instance; - if (!update_record("quiz", $quiz)) { return false; // some error occurred } diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html index 16f996b4c85..868004e9eeb 100644 --- a/mod/quiz/mod.html +++ b/mod/quiz/mod.html @@ -70,11 +70,12 @@ //enforced time delay between quiz attempts add-on //delay1: time delay between first and second attempt //delay2: time delay between second and additional quiz attempt - if(!isset($form->delay1)) { - $form->delay1 = 0; + //enforced delay attempt between quiz + if (!isset($form->delay1)) { + $form->delay1 = $CFG->quiz_delay1; } - if(!isset($form->delay2)) { - $form->delay2 = 0; + if (!isset($form->delay2)) { + $form->delay2 = $CFG->quiz_delay2; } $fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin. @@ -344,9 +345,9 @@ : delay1", ""); - helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); - ?> + choose_from_menu($timedelayoptions, "delay1", "$form->delay1", ""); + helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); + ?> @@ -356,9 +357,9 @@ : delay2", ""); - helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); - ?> + choose_from_menu($timedelayoptions, "delay2", "$form->delay2", ""); + helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); + ?> @@ -584,7 +585,7 @@ : delay1", ""); + choose_from_menu($timedelayoptions, "delay1", "$form->delay1", ""); helpbutton("timedelay1", get_string("delay1","quiz"), "quiz"); ?> @@ -596,7 +597,7 @@ : delay2", ""); + choose_from_menu($timedelayoptions, "delay2", "$form->delay2", ""); helpbutton("timedelay2", get_string("delay2","quiz"), "quiz"); ?> diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 60d0e15362f..37681f19451 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -10,7 +10,7 @@ $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or $q = optional_param('q', 0, PARAM_INT); // quiz ID $edit = optional_param('edit', ''); - + if ($id) { if (! $cm = get_record("course_modules", "id", $id)) { error("There is no coursemodule with id $id"); @@ -160,7 +160,7 @@ $strtimetaken = get_string("timetaken", "quiz"); $strtimecompleted = get_string("timecompleted", "quiz"); $strgrade = get_string("grade"); - $strmarks = get_string('marks', 'quiz'); + $strmarks = get_string('marks', 'quiz'); $strbestgrade = $QUIZ_GRADE_METHOD[$quiz->grademethod]; $windowoptions = "left=0, top=0, channelmode=yes, fullscreen=yes, scrollbars=yes, resizeable=no, directories=no, toolbar=no, titlebar=no, location=no, status=no, menubar=no"; @@ -311,11 +311,41 @@ echo "
"; echo "

"; - echo "
"; - - include("view_js.php"); - - echo "
\n"; + if ($quiz->delay1 or $quiz->delay2) { + //quiz enforced time delay + $lastattempt_obj = get_record_select('quiz_attempts', "quiz = $quiz->id AND attempt = $numattempts AND userid = $USER->id", 'timefinish'); + if ($lastattempt_obj) { + $lastattempt = $lastattempt_obj->timefinish; + } + echo "
"; + if($numattempts == 1 && $quiz->delay1) { + if ($timenow - $quiz->delay1 > $lastattempt) { + include("view_js.php"); + } + else { + $notify_msg = get_string('temporaryblocked', 'quiz') . ''. userdate($lastattempt + $quiz->delay1). ''; + print_simple_box($notify_msg, "center"); + } + } + else if($numattempts > 1 && $quiz->delay2) { + if ($timenow - $quiz->delay2 > $lastattempt) { + include("view_js.php"); + } + else { + $notify_msg = get_string('temporaryblocked', 'quiz') . ''. userdate($lastattempt + $quiz->delay2). ''; + print_simple_box($notify_msg, "center"); + } + } + else { + include("view_js.php"); + } + echo "
\n"; + } + else { + echo "
"; + include("view_js.php"); + echo "
\n"; + } } } else { print_heading(get_string("nomoreattempts", "quiz"));