error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
}
+/// Check subnet access
+ if ($quiz->subnet and !address_in_subnet($_SERVER['REMOTE_ADDR'], $quiz->subnet)) {
+ error(get_string("subneterror", "quiz"), "view.php?id=$cm->id");
+ }
+
+/// Check password access
+ if ($quiz->password) {
+ if (empty($_POST['quizpassword'])) {
+
+ echo "<form name=\"passwordform\" method=\"post\" action=\"attempt.php?q=$quiz->id\">\n";
+ print_simple_box_start("center");
+
+ echo "<div align=\"center\">\n";
+ print_string("requirepasswordmessage", "quiz");
+ echo "<br /><br />\n";
+ echo " <input name=\"quizpassword\" type=\"password\" value=\"\">";
+ echo " <input name=\"submit\" type=\"submit\" value=\"".get_string("ok")."\">\n";
+ echo "</div>\n";
+
+ print_simple_box_end();
+ echo "</form>\n";
+
+ print_footer();
+ exit;
+
+ } else {
+ if (strcmp($quiz->password, $_POST['quizpassword']) !== 0) {
+ error(get_string("passworderror", "quiz"), "view.php?id=$cm->id");
+ }
+ unset($_POST); /// needed so as not to confuse later code dealing with submitted answers
+ }
+ }
+
+
/// BEGIN EDIT Get time limit if any.
$timelimit = $quiz->timelimit * 60;
}
return $answers;
}
+
?>
if (!isset($form->questions)) {
$form->questions = "";
}
+ if (!isset($form->password)) {
+ $form->password = "";
+ }
+ if (!isset($form->subnet)) {
+ $form->subnet = "";
+ }
?>
?>
</td>
</tr>
+<tr valign=top>
+ <td align=right><p><b><?php print_string("requirepassword", "quiz") ?>:</b></p></td>
+ <td>
+ <input type="text" name="password" size=40 value="<?php p($form->password) ?>">
+ <?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right><p><b><?php print_string("requiresubnet", "quiz") ?>:</b></p></td>
+ <td>
+ <input type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
+ <?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
+ </td>
+</tr>
+
</table>
<input type="hidden" name=questions value="<?php p($form->questions) ?>">
<!-- these hidden variables are always the same -->
$strconfirmstartattempt = addslashes(get_string("confirmstartattempt","quiz"));
echo "<br />";
echo "<div align=\"center\">";
- // BEGIN EDIT
- if($quiz->timelimit) {
+ if ($quiz->timelimit) {
include("view_js.php");
} else {
- print_single_button("attempt.php", $options, get_string("attemptquiznow","quiz"));
+ print_single_button("attempt.php", $options, get_string("attemptquiznow","quiz"));
}
echo "</div>\n";
- // END EDIT
echo "</p>";
}
} else {