Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/summary.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 require_once(dirname(__FILE__) . '/../../config.php');
00028 require_once($CFG->dirroot . '/mod/quiz/locallib.php');
00029 
00030 $attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise.
00031 
00032 $PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid));
00033 
00034 $attemptobj = quiz_attempt::create($attemptid);
00035 
00036 // Check login.
00037 require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
00038 
00039 // If this is not our own attempt, display an error.
00040 if ($attemptobj->get_userid() != $USER->id) {
00041     print_error('notyourattempt', 'quiz', $attemptobj->view_url());
00042 }
00043 
00044 // Check capabilites.
00045 if (!$attemptobj->is_preview_user()) {
00046     $attemptobj->require_capability('mod/quiz:attempt');
00047 }
00048 
00049 // If the attempt is already closed, redirect them to the review page.
00050 if ($attemptobj->is_finished()) {
00051     redirect($attemptobj->review_url());
00052 }
00053 
00054 if ($attemptobj->is_preview_user()) {
00055     navigation_node::override_active_url($attemptobj->start_attempt_url());
00056 }
00057 
00058 // Check access.
00059 $accessmanager = $attemptobj->get_access_manager(time());
00060 $messages = $accessmanager->prevent_access();
00061 $output = $PAGE->get_renderer('mod_quiz');
00062 if (!$attemptobj->is_preview_user() && $messages) {
00063     print_error('attempterror', 'quiz', $attemptobj->view_url(),
00064             $output->access_messages($messages));
00065 }
00066 if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
00067     redirect($attemptobj->start_attempt_url(null, $page));
00068 }
00069 
00070 $displayoptions = $attemptobj->get_display_options(false);
00071 
00072 // Log this page view.
00073 add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary',
00074         'summary.php?attempt=' . $attemptobj->get_attemptid(),
00075         $attemptobj->get_quizid(), $attemptobj->get_cmid());
00076 
00077 // Arrange for the navigation to be displayed.
00078 if (empty($attemptobj->get_quiz()->showblocks)) {
00079     $PAGE->blocks->show_only_fake_blocks();
00080 }
00081 
00082 $navbc = $attemptobj->get_navigation_panel($output, 'quiz_attempt_nav_panel', -1);
00083 $firstregion = reset($PAGE->blocks->get_regions());
00084 $PAGE->blocks->add_fake_block($navbc, $firstregion);
00085 
00086 $PAGE->navbar->add(get_string('summaryofattempt', 'quiz'));
00087 $PAGE->set_title(format_string($attemptobj->get_quiz_name()));
00088 $PAGE->set_heading($attemptobj->get_course()->fullname);
00089 $accessmanager->setup_attempt_page($PAGE);
00090 
00091 // Display the page.
00092 
00093 $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time(), $output);
00094 echo $output->summary_page($attemptobj, $displayoptions);
 All Data Structures Namespaces Files Functions Variables Enumerations