MDL-29254 Fixed whitespace
[moodle.git] / mod / quiz / comment.php
blob4736946ed266ae8daaf67bf1b96a76ae104a37d2
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.
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/>.
17 /**
18 * This page allows the teacher to enter a manual grade for a particular question.
19 * This page is expected to only be used in a popup window.
21 * @package mod
22 * @subpackage quiz
23 * @copyright gustav delius 2006
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once('../../config.php');
28 require_once('locallib.php');
30 $attemptid = required_param('attempt', PARAM_INT); // attempt id
31 $slot = required_param('slot', PARAM_INT); // question number in attempt
33 $PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot));
35 $attemptobj = quiz_attempt::create($attemptid);
37 // Can only grade finished attempts.
38 if (!$attemptobj->is_finished()) {
39 print_error('attemptclosed', 'quiz');
42 // Check login and permissions.
43 require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
44 $attemptobj->require_capability('mod/quiz:grade');
46 // Log this action.
47 add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' .
48 $attemptobj->get_attemptid() . '&slot=' . $slot,
49 $attemptobj->get_quizid(), $attemptobj->get_cmid());
51 // Print the page header
52 $PAGE->set_pagelayout('popup');
53 echo $OUTPUT->header();
54 echo $OUTPUT->heading(format_string($attemptobj->get_question_name($slot)));
56 // Process any data that was submitted.
57 if (data_submitted() && confirm_sesskey()) {
58 if (optional_param('submit', false, PARAM_BOOL)) {
59 $transaction = $DB->start_delegated_transaction();
60 $attemptobj->process_all_actions(time());
61 $transaction->allow_commit();
62 echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
63 close_window(2, true);
64 die;
68 // Print the comment form.
69 echo '<form method="post" class="mform" id="manualgradingform" action="' .
70 $CFG->wwwroot . '/mod/quiz/comment.php">';
71 echo $attemptobj->render_question_for_commenting($slot);
73 <div>
74 <input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" />
75 <input type="hidden" name="slot" value="<?php echo $slot; ?>" />
76 <input type="hidden" name="slots" value="<?php echo $slot; ?>" />
77 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
78 </div>
79 <fieldset class="hidden">
80 <div>
81 <div class="fitem">
82 <div class="fitemtitle">
83 <div class="fgrouplabel"><label> </label></div>
84 </div>
85 <fieldset class="felement fgroup">
86 <input id="id_submitbutton" type="submit" name="submit" value="<?php
87 print_string('save', 'quiz'); ?>"/>
88 </fieldset>
89 </div>
90 </div>
91 </fieldset>
92 <?php
93 echo '</form>';
94 $PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module());
96 // End of the page.
97 echo $OUTPUT->footer();