Commit | Line | Data |
---|---|---|
a09f21d0 | 1 | <?php |
8f37f7fb TH |
2 | // This file is part of Moodle - http://moodle.org/ |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
36e413e3 | 17 | /** |
18 | * This page prints a summary of a quiz attempt before it is submitted. | |
19 | * | |
ba643847 | 20 | * @package mod |
8f37f7fb | 21 | * @subpackage quiz |
ba643847 TH |
22 | * @copyright 2009 The Open University |
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
36e413e3 | 24 | */ |
25 | ||
ba643847 | 26 | |
78e7a3dd | 27 | require_once(dirname(__FILE__) . '/../../config.php'); |
28 | require_once($CFG->dirroot . '/mod/quiz/locallib.php'); | |
36e413e3 | 29 | |
30 | $attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise. | |
a09f21d0 | 31 | |
eb02301a | 32 | $PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid)); |
a09f21d0 | 33 | |
990650f9 | 34 | $attemptobj = quiz_attempt::create($attemptid); |
36e413e3 | 35 | |
8f37f7fb | 36 | // Check login. |
56ed242b | 37 | require_login($attemptobj->get_course(), false, $attemptobj->get_cm()); |
36e413e3 | 38 | |
8f37f7fb | 39 | // If this is not our own attempt, display an error. |
36e413e3 | 40 | if ($attemptobj->get_userid() != $USER->id) { |
41 | print_error('notyourattempt', 'quiz', $attemptobj->view_url()); | |
42 | } | |
43 | ||
8f37f7fb TH |
44 | // Check capabilites. |
45 | if (!$attemptobj->is_preview_user()) { | |
46 | $attemptobj->require_capability('mod/quiz:attempt'); | |
47 | } | |
48 | ||
49 | // If the attempt is already closed, redirect them to the review page. | |
36e413e3 | 50 | if ($attemptobj->is_finished()) { |
51 | redirect($attemptobj->review_url()); | |
52 | } | |
53 | ||
eb02301a | 54 | if ($attemptobj->is_preview_user()) { |
73eba4be | 55 | navigation_node::override_active_url($attemptobj->start_attempt_url()); |
eb02301a TH |
56 | } |
57 | ||
8f37f7fb | 58 | // Check access. |
36e413e3 | 59 | $accessmanager = $attemptobj->get_access_manager(time()); |
60 | $messages = $accessmanager->prevent_access(); | |
bcd42560 | 61 | $output = $PAGE->get_renderer('mod_quiz'); |
b10c38a3 | 62 | if (!$attemptobj->is_preview_user() && $messages) { |
36e413e3 | 63 | print_error('attempterror', 'quiz', $attemptobj->view_url(), |
bcd42560 | 64 | $output->print_messages($messages)); |
36e413e3 | 65 | } |
b10c38a3 | 66 | $accessmanager->do_password_check($attemptobj->is_preview_user()); |
36e413e3 | 67 | |
8f37f7fb TH |
68 | $displayoptions = $attemptobj->get_display_options(false); |
69 | ||
70 | // Log this page view. | |
55ca80ed TH |
71 | add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', |
72 | 'summary.php?attempt=' . $attemptobj->get_attemptid(), | |
36e413e3 | 73 | $attemptobj->get_quizid(), $attemptobj->get_cmid()); |
74 | ||
8f37f7fb | 75 | // Print the page header |
56ed242b SH |
76 | if (empty($attemptobj->get_quiz()->showblocks)) { |
77 | $PAGE->blocks->show_only_fake_blocks(); | |
78 | } | |
79 | ||
b10c38a3 | 80 | if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { |
78e7a3dd | 81 | $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . |
82 | format_string($attemptobj->get_quiz_name()), ''); | |
55ca80ed TH |
83 | } else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { |
84 | $PAGE->set_title($attemptobj->get_course()->shortname . ': ' . | |
85 | format_string($attemptobj->get_quiz_name())); | |
56ed242b | 86 | $PAGE->set_heading($attemptobj->get_course()->fullname); |
a09f21d0 | 87 | $PAGE->set_cacheable(false); |
36e413e3 | 88 | } else { |
babfb615 | 89 | $PAGE->navbar->add(get_string('summaryofattempt', 'quiz')); |
03da0c39 | 90 | $PAGE->set_title(format_string($attemptobj->get_quiz_name())); |
56ed242b | 91 | $PAGE->set_heading($attemptobj->get_course()->fullname); |
36e413e3 | 92 | } |
93 | ||
8f37f7fb | 94 | // Print heading. |
36e413e3 | 95 | |
36e413e3 | 96 | $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time()); |
babfb615 | 97 | echo $output->summary_page($attemptobj, $displayoptions); |