$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 ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), $headtags); } else { print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($strreviewtitle), '', $headtags, true, $attemptobj->update_module_button()); } echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib /// Print tabs if they should be there.
/** * Check that attempt results are as specified in $result. * * @param array $result row of data read from csv file. * @param quiz_attempt $attemptobj the attempt object loaded from db. * @throws coding_exception */ protected function check_attempt_results($result, $attemptobj) { foreach ($result as $fieldname => $value) { if ($value === '!NULL!') { $value = null; } switch ($fieldname) { case 'quizattempt': break; case 'attemptnumber': $this->assertEquals($value, $attemptobj->get_attempt_number()); break; case 'slots': foreach ($value as $slotno => $slottests) { foreach ($slottests as $slotfieldname => $slotvalue) { switch ($slotfieldname) { case 'mark': $this->assertEquals(round($slotvalue, 2), $attemptobj->get_question_mark($slotno), "Mark for slot {$slotno} of attempt {$result['quizattempt']}."); break; default: throw new coding_exception('Unknown slots sub field column in csv file ' . s($slotfieldname)); } } } break; case 'finished': $this->assertEquals((bool) $value, $attemptobj->is_finished()); break; case 'summarks': $this->assertEquals($value, $attemptobj->get_sum_marks(), "Sum of marks of attempt {$result['quizattempt']}."); break; case 'quizgrade': // Check quiz grades. $grades = quiz_get_user_grades($attemptobj->get_quiz(), $attemptobj->get_userid()); $grade = array_shift($grades); $this->assertEquals($value, $grade->rawgrade, "Quiz grade for attempt {$result['quizattempt']}."); break; case 'gradebookgrade': // Check grade book. $gradebookgrades = grade_get_grades($attemptobj->get_courseid(), 'mod', 'quiz', $attemptobj->get_quizid(), $attemptobj->get_userid()); $gradebookitem = array_shift($gradebookgrades->items); $gradebookgrade = array_shift($gradebookitem->grades); $this->assertEquals($value, $gradebookgrade->grade, "Gradebook grade for attempt {$result['quizattempt']}."); break; default: throw new coding_exception('Unknown column in csv file ' . s($fieldname)); } } }
/// This action used to be 'continue attempt' but the database field has only 15 characters. add_to_log($attemptobj->get_courseid(), 'quiz', 'continue attemp', 'review.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid()); /// Get the list of questions needed by this page. $questionids = $attemptobj->get_question_ids($page); /// Check. if (empty($questionids)) { quiz_error($quiz, 'noquestionsfound'); } /// Load those questions and the associated states. $attemptobj->load_questions($questionids); $attemptobj->load_question_states($questionids); /// Print the quiz page //////////////////////////////////////////////////////// // Print the page header require_js(array('yui_yahoo', 'yui_event')); require_js('mod/quiz/quiz.js'); $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); $headtags = $attemptobj->get_html_head_contributions($page); if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), $headtags); } else { print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($title), '', $headtags, true, $attemptobj->update_module_button()); } echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib if ($attemptobj->is_preview_user()) { /// Show the tab bar. $currenttab = 'preview'; include 'tabs.php'; /// Heading and tab bar. print_heading(get_string('previewquiz', 'quiz', format_string($quiz->name))); $attemptobj->print_restart_preview_button();