|
Moodle
2.2.1
http://www.collinsharper.com
|
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('../../config.php'); 00028 require_once('locallib.php'); 00029 00030 $attemptid = required_param('attempt', PARAM_INT); // attempt id 00031 $slot = required_param('slot', PARAM_INT); // question number in attempt 00032 00033 $PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot)); 00034 00035 $attemptobj = quiz_attempt::create($attemptid); 00036 00037 // Can only grade finished attempts. 00038 if (!$attemptobj->is_finished()) { 00039 print_error('attemptclosed', 'quiz'); 00040 } 00041 00042 // Check login and permissions. 00043 require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm()); 00044 $attemptobj->require_capability('mod/quiz:grade'); 00045 00046 // Log this action. 00047 add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' . 00048 $attemptobj->get_attemptid() . '&slot=' . $slot, 00049 $attemptobj->get_quizid(), $attemptobj->get_cmid()); 00050 00051 // Print the page header 00052 $PAGE->set_pagelayout('popup'); 00053 echo $OUTPUT->header(); 00054 echo $OUTPUT->heading(format_string($attemptobj->get_question_name($slot))); 00055 00056 // Process any data that was submitted. 00057 if (data_submitted() && confirm_sesskey()) { 00058 if (optional_param('submit', false, PARAM_BOOL)) { 00059 $transaction = $DB->start_delegated_transaction(); 00060 $attemptobj->process_all_actions(time()); 00061 $transaction->allow_commit(); 00062 echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); 00063 close_window(2, true); 00064 die; 00065 } 00066 } 00067 00068 // Print the comment form. 00069 echo '<form method="post" class="mform" id="manualgradingform" action="' . 00070 $CFG->wwwroot . '/mod/quiz/comment.php">'; 00071 echo $attemptobj->render_question_for_commenting($slot); 00072 ?> 00073 <div> 00074 <input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" /> 00075 <input type="hidden" name="slot" value="<?php echo $slot; ?>" /> 00076 <input type="hidden" name="slots" value="<?php echo $slot; ?>" /> 00077 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" /> 00078 </div> 00079 <fieldset class="hidden"> 00080 <div> 00081 <div class="fitem"> 00082 <div class="fitemtitle"> 00083 <div class="fgrouplabel"><label> </label></div> 00084 </div> 00085 <fieldset class="felement fgroup"> 00086 <input id="id_submitbutton" type="submit" name="submit" value="<?php 00087 print_string('save', 'quiz'); ?>"/> 00088 </fieldset> 00089 </div> 00090 </div> 00091 </fieldset> 00092 <?php 00093 echo '</form>'; 00094 $PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module()); 00095 00096 // End of the page. 00097 echo $OUTPUT->footer();