Index: temp_moodle_dev/moodle/mod/quiz/attempt.php =================================================================== diff -u -r89659faa9ee2ac5d9c25fa5524f6925d923f00b3 -raca9f00eec05f594be36b6397b9c363742db6022 --- temp_moodle_dev/moodle/mod/quiz/attempt.php (.../attempt.php) (revision 89659faa9ee2ac5d9c25fa5524f6925d923f00b3) +++ temp_moodle_dev/moodle/mod/quiz/attempt.php (.../attempt.php) (revision aca9f00eec05f594be36b6397b9c363742db6022) @@ -60,8 +60,8 @@ $ispreviewing = has_capability('mod/quiz:preview', $context); // if no questions have been set up yet redirect to edit.php - if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) { - redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id); + if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) { + redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id); } if (!$ispreviewing) { @@ -85,31 +85,32 @@ /// Check number of attempts $numberofpreviousattempts = count_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1"); - - if ($quiz->attempts and $numberofpreviousattempts >= $quiz->attempts) { - print_error('nomoreattempts', 'quiz', "view.php?id={$cm->id}"); + if (!empty($quiz->attempts) and $numberofpreviousattempts >= $quiz->attempts) { + print_error('nomoreattempts', 'quiz', "view.php?id={$cm->id}"); } /// Check subnet access - if (!$ispreviewing && $quiz->subnet && !address_in_subnet(getremoteaddr(), $quiz->subnet)) { - print_error('subneterror', 'quiz', "view.php?id={$cm->id}"); + if (!$ispreviewing && !empty($quiz->subnet) && !address_in_subnet(getremoteaddr(), $quiz->subnet)) { + print_error("subneterror", "quiz", "view.php?id=$cm->id"); } /// Check password access if ($ispreviewing && $forcenew) { unset($SESSION->passwordcheckedquizzes[$quiz->id]); } - if ($quiz->password and empty($SESSION->passwordcheckedquizzes[$quiz->id])) { + if (!empty($quiz->password) and empty($SESSION->passwordcheckedquizzes[$quiz->id])) { $enteredpassword = optional_param('quizpassword', '', PARAM_RAW); if (optional_param('cancelpassword', false)) { - redirect($CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id); + // User clicked cancel in the password form. + redirect($CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id); } else if (strcmp($quiz->password, $enteredpassword) === 0) { // User entered the correct password. $SESSION->passwordcheckedquizzes[$quiz->id] = true; } else { - - $url = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . $quiz->id; + // User entered the wrong password, or has not entered one yet. + $url = $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . $quiz->id; + if (empty($popup)) { print_header('', '', '', 'quizpassword'); } @@ -122,7 +123,6 @@ if (!empty($enteredpassword)) { echo '
', get_string('passworderror', 'quiz'), '
'; } - ?>