quiz timer js: Fix typo (that was not causing problems)
[moodle.git] / mod / quiz / summary.php
CommitLineData
36e413e3 1<?php // $Id$
2/**
3 * This page prints a summary of a quiz attempt before it is submitted.
4 *
5 * @author Tim Hunt others.
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7 * @package quiz
8 */
9
78e7a3dd 10require_once(dirname(__FILE__) . '/../../config.php');
11require_once($CFG->dirroot . '/mod/quiz/locallib.php');
36e413e3 12
13$attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise.
14$attemptobj = new quiz_attempt($attemptid);
15
78e7a3dd 16/// Check login.
36e413e3 17require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
18
19/// If this is not our own attempt, display an error.
20if ($attemptobj->get_userid() != $USER->id) {
21 print_error('notyourattempt', 'quiz', $attemptobj->view_url());
22}
23
78e7a3dd 24/// If the attempt is alreadyuj closed, redirect them to the review page.
36e413e3 25if ($attemptobj->is_finished()) {
26 redirect($attemptobj->review_url());
27}
28
29/// Check access.
30$accessmanager = $attemptobj->get_access_manager(time());
31$messages = $accessmanager->prevent_access();
b10c38a3 32if (!$attemptobj->is_preview_user() && $messages) {
36e413e3 33 print_error('attempterror', 'quiz', $attemptobj->view_url(),
34 $accessmanager->print_messages($messages, true));
35}
b10c38a3 36$accessmanager->do_password_check($attemptobj->is_preview_user());
36e413e3 37
38/// Log this page view.
39add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', 'summary.php?attempt=' . $attemptobj->get_attemptid(),
40 $attemptobj->get_quizid(), $attemptobj->get_cmid());
41
42/// Load the questions and states.
43$attemptobj->load_questions();
44$attemptobj->load_question_states();
45
46/// Print the page header
ac324e05 47require_js('mod/quiz/quiz.js');
36e413e3 48$title = get_string('summaryofattempt', 'quiz');
b10c38a3 49if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
78e7a3dd 50 $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' .
51 format_string($attemptobj->get_quiz_name()), '');
36e413e3 52} else {
53 print_header_simple(format_string($attemptobj->get_quiz_name()), '',
54 $attemptobj->navigation($title), '', '', true, $attemptobj->update_module_button());
55}
56
57/// Print tabs if they should be there.
b10c38a3 58if ($attemptobj->is_preview_user()) {
36e413e3 59 $currenttab = 'preview';
60 include('tabs.php');
61}
62
63/// Print heading.
64print_heading(format_string($attemptobj->get_quiz_name()));
b10c38a3 65if ($attemptobj->is_preview_user()) {
78e7a3dd 66 $attemptobj->print_restart_preview_button();
36e413e3 67}
68print_heading($title);
69
70/// Prepare the summary table header
71$table->class = 'generaltable quizsummaryofattempt';
72$table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
73$table->align = array('left', 'left');
74$table->size = array('', '');
75$scorescolumn = $attemptobj->get_review_options()->scores;
76if ($scorescolumn) {
77 $table->head[] = get_string('marks', 'quiz');
78 $table->align[] = 'left';
79 $table->size[] = '';
80}
81$table->data = array();
82
83/// Get the summary info for each question.
84$questionids = $attemptobj->get_question_ids();
85foreach ($attemptobj->get_question_iterator() as $number => $question) {
b9b3aa94 86 if ($question->length == 0) {
87 continue;
88 }
e41a7d28 89 $flag = '';
90 if ($attemptobj->is_question_flagged($question->id)) {
91 $flag = ' <img src="' . $CFG->pixpath . '/i/flagged.png" alt="' .
92 get_string('flagged', 'question') . '" class="questionflag" />';
93 }
94 $row = array('<a href="' . $attemptobj->attempt_url($question->id) . '">' . $number . $flag . '</a>',
78e7a3dd 95 get_string($attemptobj->get_question_status($question->id), 'quiz'));
36e413e3 96 if ($scorescolumn) {
97 $row[] = $attemptobj->get_question_score($question->id);
98 }
99 $table->data[] = $row;
100}
101
102/// Print the summary table.
103print_table($table);
104
105/// Finish attempt button.
106echo "<div class=\"submitbtns mdl-align\">\n";
107$options = array(
9f9eec1e 108 'attempt' => $attemptobj->get_attemptid(),
36e413e3 109 'finishattempt' => 1,
110 'timeup' => 0,
111 'questionids' => '',
9f9eec1e 112 'sesskey' => sesskey(),
36e413e3 113);
9f9eec1e 114print_single_button($attemptobj->processattempt_url(), $options, get_string('finishattempt', 'quiz'),
36e413e3 115 'post', '', false, '', false, get_string('confirmclose', 'quiz'));
116echo "</div>\n";
117
118/// Finish the page
119$accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time());
b10c38a3 120if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
36e413e3 121 print_footer('empty');
122} else {
78e7a3dd 123 print_footer($attemptobj->get_course());
36e413e3 124}
125
126?>