Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/reviewquestion.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 
00028 require_once(dirname(__FILE__) . '/../../config.php');
00029 require_once('locallib.php');
00030 
00031 $attemptid = required_param('attempt', PARAM_INT); // attempt id
00032 $slot = required_param('slot', PARAM_INT); // question number in usage
00033 $seq = optional_param('step', null, PARAM_INT); // sequence number
00034 
00035 $baseurl = new moodle_url('/mod/quiz/reviewquestion.php',
00036         array('attempt' => $attemptid, 'slot' => $slot));
00037 $currenturl = new moodle_url($baseurl);
00038 if ($seq !== 0) {
00039     $currenturl->param('step', $seq);
00040 }
00041 $PAGE->set_url($currenturl);
00042 
00043 $attemptobj = quiz_attempt::create($attemptid);
00044 
00045 // Check login.
00046 require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
00047 $attemptobj->check_review_capability();
00048 
00049 $accessmanager = $attemptobj->get_access_manager(time());
00050 $options = $attemptobj->get_display_options(true);
00051 
00052 $PAGE->set_pagelayout('popup');
00053 $output = $PAGE->get_renderer('mod_quiz');
00054 
00055 // Check permissions.
00056 if ($attemptobj->is_own_attempt()) {
00057     if (!$attemptobj->is_finished()) {
00058         echo $output->review_question_not_allowed(get_string('cannotreviewopen', 'quiz'));
00059         die();
00060     } else if (!$options->attempt) {
00061         echo $output->review_question_not_allowed(
00062                 $attemptobj->cannot_review_message());
00063         die();
00064     }
00065 
00066 } else if (!$attemptobj->is_review_allowed()) {
00067     throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'noreviewattempt');
00068 }
00069 
00070 // Prepare summary informat about this question attempt.
00071 $summarydata = array();
00072 
00073 // Quiz name.
00074 $summarydata['quizname'] = array(
00075     'title'   => get_string('modulename', 'quiz'),
00076     'content' => format_string($attemptobj->get_quiz_name()),
00077 );
00078 
00079 // Question name.
00080 $summarydata['questionname'] = array(
00081     'title'   => get_string('question', 'quiz'),
00082     'content' => $attemptobj->get_question_name($slot),
00083 );
00084 
00085 // Other attempts at the quiz.
00086 if ($attemptobj->has_capability('mod/quiz:viewreports')) {
00087     $attemptlist = $attemptobj->links_to_other_attempts($baseurl);
00088     if ($attemptlist) {
00089         $summarydata['attemptlist'] = array(
00090             'title'   => get_string('attempts', 'quiz'),
00091             'content' => $attemptlist,
00092         );
00093     }
00094 }
00095 
00096 // Timestamp of this action.
00097 $timestamp = $attemptobj->get_question_action_time($slot);
00098 if ($timestamp) {
00099     $summarydata['timestamp'] = array(
00100         'title'   => get_string('completedon', 'quiz'),
00101         'content' => userdate($timestamp),
00102     );
00103 }
00104 
00105 echo $output->review_question_page($attemptobj, $slot, $seq,
00106         $attemptobj->get_display_options(true), $summarydata);
 All Data Structures Namespaces Files Functions Variables Enumerations