[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/quiz/ -> summary.php (source)

   1  <?php
   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  
  17  /**
  18   * This page prints a summary of a quiz attempt before it is submitted.
  19   *
  20   * @package   mod_quiz
  21   * @copyright 2009 The Open University
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  
  26  require_once(__DIR__ . '/../../config.php');
  27  require_once($CFG->dirroot . '/mod/quiz/locallib.php');
  28  
  29  $attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise.
  30  
  31  $PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid));
  32  
  33  $attemptobj = quiz_attempt::create($attemptid);
  34  
  35  // Check login.
  36  require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
  37  
  38  // Check that this attempt belongs to this user.
  39  if ($attemptobj->get_userid() != $USER->id) {
  40      if ($attemptobj->has_capability('mod/quiz:viewreports')) {
  41          redirect($attemptobj->review_url(null));
  42      } else {
  43          throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'notyourattempt');
  44      }
  45  }
  46  
  47  // Check capabilites.
  48  if (!$attemptobj->is_preview_user()) {
  49      $attemptobj->require_capability('mod/quiz:attempt');
  50  }
  51  
  52  if ($attemptobj->is_preview_user()) {
  53      navigation_node::override_active_url($attemptobj->start_attempt_url());
  54  }
  55  
  56  // Check access.
  57  $accessmanager = $attemptobj->get_access_manager(time());
  58  $accessmanager->setup_attempt_page($PAGE);
  59  $output = $PAGE->get_renderer('mod_quiz');
  60  $messages = $accessmanager->prevent_access();
  61  if (!$attemptobj->is_preview_user() && $messages) {
  62      print_error('attempterror', 'quiz', $attemptobj->view_url(),
  63              $output->access_messages($messages));
  64  }
  65  if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
  66      redirect($attemptobj->start_attempt_url(null));
  67  }
  68  
  69  $displayoptions = $attemptobj->get_display_options(false);
  70  
  71  // If the attempt is now overdue, or abandoned, deal with that.
  72  $attemptobj->handle_if_time_expired(time(), true);
  73  
  74  // If the attempt is already closed, redirect them to the review page.
  75  if ($attemptobj->is_finished()) {
  76      redirect($attemptobj->review_url());
  77  }
  78  
  79  // Arrange for the navigation to be displayed.
  80  if (empty($attemptobj->get_quiz()->showblocks)) {
  81      $PAGE->blocks->show_only_fake_blocks();
  82  }
  83  
  84  $navbc = $attemptobj->get_navigation_panel($output, 'quiz_attempt_nav_panel', -1);
  85  $regions = $PAGE->blocks->get_regions();
  86  $PAGE->blocks->add_fake_block($navbc, reset($regions));
  87  
  88  $PAGE->navbar->add(get_string('summaryofattempt', 'quiz'));
  89  $PAGE->set_title($attemptobj->get_quiz_name());
  90  $PAGE->set_heading($attemptobj->get_course()->fullname);
  91  
  92  // Display the page.
  93  echo $output->summary_page($attemptobj, $displayoptions);
  94  
  95  // Log this page view.
  96  $attemptobj->fire_attempt_summary_viewed_event();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1