/** * Renders the main bit of the review page. * * @param array $summarydata contain row data for table * @param int $page current page number * @param mod_quiz_display_options $displayoptions instance of mod_quiz_display_options * @param $content contains each question * @param quiz_attempt $attemptobj instance of quiz_attempt * @param bool $showall if true display attempt on one page */ public function review_form($page, $showall, $displayoptions, $content, $attemptobj) { if ($displayoptions->flags != question_display_options::EDITABLE) { return $content; } $this->page->requires->js_init_call('M.mod_quiz.init_review_form', null, false, quiz_get_js_module()); $output = ''; $output .= html_writer::start_tag('form', array('action' => $attemptobj->review_url(null, $page, $showall), 'method' => 'post', 'class' => 'questionflagsaveform')); $output .= html_writer::start_tag('div'); $output .= $content; $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $output .= html_writer::start_tag('div', array('class' => 'submitbtns')); $output .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'questionflagsavebutton', 'name' => 'savingflags', 'value' => get_string('saveflags', 'question'))); $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('form'); return $output; }
/** * Creates a next page arrow or the finishing link * * @param quiz_attempt $attemptobj instance of quiz_attempt * @param int $page the current page * @param bool $lastpage if true current page is the last page */ public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage) { if ($lastpage) { $nav = $this->finish_review_link($attemptobj->view_url()); } else { $nav = link_arrow_right(get_string('next'), $attemptobj->review_url(null, $page + 1)); } return html_writer::tag('div', $nav, array('class' => 'submitbtns')); }
* @package quiz */ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/mod/quiz/locallib.php'; $attemptid = required_param('attempt', PARAM_INT); // 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');
/** * Creates the navigation links/buttons at the bottom of the reivew attempt page. * * Note, the name of this function is no longer accurate, but when the design * changed, it was decided to keep the old name for backwards compatibility. * * @param quiz_attempt $attemptobj instance of quiz_attempt * @param int $page the current page * @param bool $lastpage if true current page is the last page * @param bool|null $showall if true, the URL will be to review the entire attempt on one page, * and $page will be ignored. If null, a sensible default will be chosen. * * @return string HTML fragment. */ public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage, $showall = null) { $nav = ''; if ($page > 0) { $nav .= link_arrow_left(get_string('navigateprevious', 'quiz'), $attemptobj->review_url(null, $page - 1, $showall), false, 'mod_quiz-prev-nav'); } if ($lastpage) { $nav .= $this->finish_review_link($attemptobj); } else { $nav .= link_arrow_right(get_string('navigatenext', 'quiz'), $attemptobj->review_url(null, $page + 1, $showall), false, 'mod_quiz-next-nav'); } return html_writer::tag('div', $nav, array('class' => 'submitbtns')); }
} } /// 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); redirect($attemptobj->review_url(0, $page, $showall)); } /// Log this review. add_to_log($attemptobj->get_courseid(), 'quiz', 'review', 'review.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid()); /// Work out appropriate title. if ($attemptobj->is_preview_user() && $attemptobj->is_own_attempt()) { $strreviewtitle = get_string('reviewofpreview', 'quiz'); } else { $strreviewtitle = get_string('reviewofattempt', 'quiz', $attemptobj->get_attempt_number()); } /// Arrange for the navigation to be displayed. $navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall); $firstregion = reset($PAGE->blocks->get_regions()); $PAGE->blocks->add_pretend_block($navbc, $firstregion); /// Print the page header $headtags = $attemptobj->get_html_head_contributions($page);
if ($qid = optional_param('q', 0, PARAM_INTEGER)) { if (!($cm = get_coursemodule_from_instance('quiz', $qid))) { print_error('invalidquizid', 'quiz'); } redirect($CFG->wwwroot . '/mod/quiz/startattempt.php?cmid=' . $cm->id . '&sesskey=' . sesskey()); } } /// Get submitted parameters. $attemptid = required_param('attempt', PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $attemptobj = new quiz_attempt($attemptid); /// Check login. require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm()); /// Check that this attempt belongs to this user. if ($attemptobj->get_userid() != $USER->id) { redirect($attemptobj->review_url(0, $page)); } /// Update QCA Object -- New $record = $DB->get_record('quiz_course_activation', array('username' => $USER->username, 'attemptid' => NULL)); if (!empty($record)) { $record->attemptid = $attemptid; $DB->update_record('quiz_course_activation', $record); } /// Check capabilites. if ($attemptobj->is_preview_user()) { } else { $attemptobj->require_capability('mod/quiz:attempt'); } /// If the attempt is already closed, send them to the review page. if ($attemptobj->is_finished()) { redirect($attemptobj->review_url(0, $page));