[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 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. 20 * 21 * @package mod_quiz 22 * @copyright gustav delius 2006 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once('../../config.php'); 27 require_once ('locallib.php'); 28 29 $attemptid = required_param('attempt', PARAM_INT); 30 $slot = required_param('slot', PARAM_INT); // The question number in the attempt. 31 32 $PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot)); 33 34 $attemptobj = quiz_attempt::create($attemptid); 35 $student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); 36 37 // Can only grade finished attempts. 38 if (!$attemptobj->is_finished()) { 39 print_error('attemptclosed', 'quiz'); 40 } 41 42 // Check login and permissions. 43 require_login($attemptobj->get_course(), false, $attemptobj->get_cm()); 44 $attemptobj->require_capability('mod/quiz:grade'); 45 46 // Print the page header. 47 $PAGE->set_pagelayout('popup'); 48 $PAGE->set_title(get_string('manualgradequestion', 'quiz', array( 49 'question' => format_string($attemptobj->get_question_name($slot)), 50 'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student)))); 51 $PAGE->set_heading($attemptobj->get_course()->fullname); 52 $output = $PAGE->get_renderer('mod_quiz'); 53 echo $output->header(); 54 55 // Prepare summary information about this question attempt. 56 $summarydata = array(); 57 58 // Student name. 59 $userpicture = new user_picture($student); 60 $userpicture->courseid = $attemptobj->get_courseid(); 61 $summarydata['user'] = array( 62 'title' => $userpicture, 63 'content' => new action_link(new moodle_url('/user/view.php', array( 64 'id' => $student->id, 'course' => $attemptobj->get_courseid())), 65 fullname($student, true)), 66 ); 67 68 // Quiz name. 69 $summarydata['quizname'] = array( 70 'title' => get_string('modulename', 'quiz'), 71 'content' => format_string($attemptobj->get_quiz_name()), 72 ); 73 74 // Question name. 75 $summarydata['questionname'] = array( 76 'title' => get_string('question', 'quiz'), 77 'content' => $attemptobj->get_question_name($slot), 78 ); 79 80 // Process any data that was submitted. 81 if (data_submitted() && confirm_sesskey()) { 82 if (optional_param('submit', false, PARAM_BOOL) && question_engine::is_manual_grade_in_range($attemptobj->get_uniqueid(), $slot)) { 83 $transaction = $DB->start_delegated_transaction(); 84 $attemptobj->process_submitted_actions(time()); 85 $transaction->allow_commit(); 86 87 // Log this action. 88 $params = array( 89 'objectid' => $attemptobj->get_question_attempt($slot)->get_question()->id, 90 'courseid' => $attemptobj->get_courseid(), 91 'context' => context_module::instance($attemptobj->get_cmid()), 92 'other' => array( 93 'quizid' => $attemptobj->get_quizid(), 94 'attemptid' => $attemptobj->get_attemptid(), 95 'slot' => $slot 96 ) 97 ); 98 $event = \mod_quiz\event\question_manually_graded::create($params); 99 $event->trigger(); 100 101 echo $output->notification(get_string('changessaved'), 'notifysuccess'); 102 close_window(2, true); 103 die; 104 } 105 } 106 107 // Print quiz information. 108 echo $output->review_summary_table($summarydata, 0); 109 110 // Print the comment form. 111 echo '<form method="post" class="mform" id="manualgradingform" action="' . 112 $CFG->wwwroot . '/mod/quiz/comment.php">'; 113 echo $attemptobj->render_question_for_commenting($slot); 114 ?> 115 <div> 116 <input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" /> 117 <input type="hidden" name="slot" value="<?php echo $slot; ?>" /> 118 <input type="hidden" name="slots" value="<?php echo $slot; ?>" /> 119 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" /> 120 </div> 121 <fieldset class="hidden"> 122 <div> 123 <div class="fitem fitem_actionbuttons fitem_fsubmit"> 124 <fieldset class="felement fsubmit"> 125 <input id="id_submitbutton" type="submit" name="submit" value="<?php 126 print_string('save', 'quiz'); ?>"/> 127 </fieldset> 128 </div> 129 </div> 130 </fieldset> 131 <?php 132 echo '</form>'; 133 $PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module()); 134 135 // End of the page. 136 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |