} else { $nexturl = $attemptobj->attempt_url(0, $nextpage); } /// We treat automatically closed attempts just like normally closed attempts if ($timeup) { $finishattempt = 1; } /// Check login. require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm()); confirm_sesskey(); /// Check that this attempt belongs to this user. if ($attemptobj->get_userid() != $USER->id) { quiz_error($attemptobj->get_quiz(), 'notyourattempt'); } /// Check capabilites. if (!$attemptobj->is_preview_user()) { $attemptobj->require_capability('mod/quiz:attempt'); } /// If the attempt is already closed, send them to the review page. if ($attemptobj->is_finished()) { quiz_error($attemptobj->get_quiz(), 'attemptalreadyclosed'); } /// Don't log - we will end with a redirect to a page that is logged. /// Get the list of questions needed by this page. if (!empty($submittedquestionids)) { $submittedquestionids = explode(',', $submittedquestionids); } else { $submittedquestionids = array(); } if ($finishattempt) { $questionids = $attemptobj->get_question_ids();
// The attempt to summarise. $attemptobj = new quiz_attempt($attemptid); /// Check login. require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm()); /// If this is not our own attempt, display an error. if ($attemptobj->get_userid() != $USER->id) { print_error('notyourattempt', 'quiz', $attemptobj->view_url()); } /// If the attempt is alreadyuj closed, redirect them to the review page. if ($attemptobj->is_finished()) { redirect($attemptobj->review_url()); } /// Check access. $accessmanager = $attemptobj->get_access_manager(time()); $messages = $accessmanager->prevent_access(); if (!$attemptobj->is_preview_user() && $messages) { print_error('attempterror', 'quiz', $attemptobj->view_url(), $accessmanager->print_messages($messages, true)); } $accessmanager->do_password_check($attemptobj->is_preview_user()); /// Log this page view. add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', 'summary.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid()); /// Load the questions and states. $attemptobj->load_questions(); $attemptobj->load_question_states(); /// Print the page header require_js('mod/quiz/quiz.js'); $title = get_string('summaryofattempt', 'quiz'); if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), ''); } else { print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($title), '', '', true, $attemptobj->update_module_button());
/// Create an object to manage all the other (non-roles) access rules. $accessmanager = $attemptobj->get_access_manager(time()); $options = $attemptobj->get_review_options(); /// Permissions checks for normal users who do not have quiz:viewreports capability. if (!$attemptobj->has_capability('mod/quiz:viewreports')) { /// Can't review other users' attempts. if (!$attemptobj->is_own_attempt()) { quiz_error($attemptobj->get_quiz(), 'notyourattempt'); } /// Can't review during the attempt - send them back to the attempt page. if (!$attemptobj->is_finished()) { redirect($attemptobj->attempt_url(0, $page)); } /// Can't review unless Students may review -> Responses option is turned on. if (!$options->responses) { $accessmanager->back_to_view_page($attemptobj->is_preview_user(), $accessmanager->cannot_review_message($options)); } } /// Load the questions and states needed by this page. if ($showall) { $questionids = $attemptobj->get_question_ids(); } else { $questionids = $attemptobj->get_question_ids($page); } $attemptobj->load_questions($questionids); $attemptobj->load_question_states($questionids); /// Save the flag states, if they are being changed. if ($options->flags == QUESTION_FLAGSEDITABLE && optional_param('savingflags', false, PARAM_BOOL)) { confirm_sesskey(); $formdata = data_submitted(); question_save_flags($formdata, $attemptid, $questionids);