$quiz->timelimit = round($quiz->timelimit);
$quiz->id = $quiz->instance;
-
if (!update_record("quiz", $quiz)) {
return false; // some error occurred
}
//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.
<td align="right"><b><?php print_string("delay1", "quiz") ?>:</b></td>
<td align="left">
<?php
- choose_from_menu($timedelayoptions, "delay1", "$form->delay1", "");
- helpbutton("timedelay1", get_string("delay1","quiz"), "quiz");
- ?>
+ choose_from_menu($timedelayoptions, "delay1", "$form->delay1", "");
+ helpbutton("timedelay1", get_string("delay1","quiz"), "quiz");
+ ?>
</td>
</tr>
<?php } else $fix=1 ?>
<td align="right"><b><?php print_string("delay2", "quiz") ?>:</b></td>
<td align="left">
<?php
- choose_from_menu($timedelayoptions, "delay2", "$form->delay2", "");
- helpbutton("timedelay2", get_string("delay2","quiz"), "quiz");
- ?>
+ choose_from_menu($timedelayoptions, "delay2", "$form->delay2", "");
+ helpbutton("timedelay2", get_string("delay2","quiz"), "quiz");
+ ?>
</td>
</tr>
<?php } else $fix=1 ?>
<td align="right"><b><?php print_string("delay1", "quiz") ?>:</b></td>
<td align="left">
<?php
- choose_from_menu($timedelayoptions, "timedelay", "$form->delay1", "");
+ choose_from_menu($timedelayoptions, "delay1", "$form->delay1", "");
helpbutton("timedelay1", get_string("delay1","quiz"), "quiz");
?>
</td>
<td align="right"><b><?php print_string("delay2", "quiz") ?>:</b></td>
<td align="left">
<?php
- choose_from_menu($timedelayoptions, "timedelay", "$form->delay2", "");
+ choose_from_menu($timedelayoptions, "delay2", "$form->delay2", "");
helpbutton("timedelay2", get_string("delay2","quiz"), "quiz");
?>
</td>
$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");
$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";
echo "<br />";
echo "</p>";
- echo "<div align=\"center\">";
-
- include("view_js.php");
-
- echo "</div>\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 "<div align=\"center\">";
+ if($numattempts == 1 && $quiz->delay1) {
+ if ($timenow - $quiz->delay1 > $lastattempt) {
+ include("view_js.php");
+ }
+ else {
+ $notify_msg = get_string('temporaryblocked', 'quiz') . '<b>'. userdate($lastattempt + $quiz->delay1). '<b>';
+ 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') . '<b>'. userdate($lastattempt + $quiz->delay2). '<b>';
+ print_simple_box($notify_msg, "center");
+ }
+ }
+ else {
+ include("view_js.php");
+ }
+ echo "</div>\n";
+ }
+ else {
+ echo "<div align=\"center\">";
+ include("view_js.php");
+ echo "</div>\n";
+ }
}
} else {
print_heading(get_string("nomoreattempts", "quiz"));