2009-10-16 03:20:38 +00:00
|
|
|
<?php
|
2011-02-09 19:07:57 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2006-04-07 16:00:29 +00:00
|
|
|
/**
|
2008-09-04 09:22:37 +00:00
|
|
|
* This page allows the teacher to enter a manual grade for a particular question.
|
|
|
|
* This page is expected to only be used in a popup window.
|
2011-01-29 14:03:02 +00:00
|
|
|
*
|
2014-02-16 11:59:15 +13:00
|
|
|
* @package mod_quiz
|
|
|
|
* @copyright gustav delius 2006
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2007-11-07 12:35:33 +00:00
|
|
|
*/
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('locallib.php');
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
$attemptid = required_param('attempt', PARAM_INT);
|
|
|
|
$slot = required_param('slot', PARAM_INT); // The question number in the attempt.
|
2018-01-09 09:38:54 +07:00
|
|
|
$cmid = optional_param('cmid', null, PARAM_INT);
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
$PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot));
|
2009-10-16 03:20:38 +00:00
|
|
|
|
2018-01-09 09:38:54 +07:00
|
|
|
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
|
2016-01-13 13:37:15 +00:00
|
|
|
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
// Can only grade finished attempts.
|
|
|
|
if (!$attemptobj->is_finished()) {
|
|
|
|
print_error('attemptclosed', 'quiz');
|
|
|
|
}
|
2007-08-17 12:49:28 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
// Check login and permissions.
|
2012-04-22 17:41:47 +02:00
|
|
|
require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
|
2011-02-09 19:07:57 +00:00
|
|
|
$attemptobj->require_capability('mod/quiz:grade');
|
2008-03-07 12:35:10 +00:00
|
|
|
|
2012-05-04 12:40:21 +01:00
|
|
|
// Print the page header.
|
2011-02-09 19:07:57 +00:00
|
|
|
$PAGE->set_pagelayout('popup');
|
2016-01-13 13:37:15 +00:00
|
|
|
$PAGE->set_title(get_string('manualgradequestion', 'quiz', array(
|
|
|
|
'question' => format_string($attemptobj->get_question_name($slot)),
|
|
|
|
'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student))));
|
2013-11-05 18:52:24 +08:00
|
|
|
$PAGE->set_heading($attemptobj->get_course()->fullname);
|
|
|
|
$output = $PAGE->get_renderer('mod_quiz');
|
|
|
|
echo $output->header();
|
|
|
|
|
|
|
|
// Prepare summary information about this question attempt.
|
|
|
|
$summarydata = array();
|
|
|
|
|
2016-01-13 13:37:15 +00:00
|
|
|
// Student name.
|
|
|
|
$userpicture = new user_picture($student);
|
|
|
|
$userpicture->courseid = $attemptobj->get_courseid();
|
|
|
|
$summarydata['user'] = array(
|
|
|
|
'title' => $userpicture,
|
|
|
|
'content' => new action_link(new moodle_url('/user/view.php', array(
|
|
|
|
'id' => $student->id, 'course' => $attemptobj->get_courseid())),
|
|
|
|
fullname($student, true)),
|
|
|
|
);
|
|
|
|
|
2013-11-05 18:52:24 +08:00
|
|
|
// Quiz name.
|
|
|
|
$summarydata['quizname'] = array(
|
|
|
|
'title' => get_string('modulename', 'quiz'),
|
|
|
|
'content' => format_string($attemptobj->get_quiz_name()),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Question name.
|
|
|
|
$summarydata['questionname'] = array(
|
|
|
|
'title' => get_string('question', 'quiz'),
|
|
|
|
'content' => $attemptobj->get_question_name($slot),
|
|
|
|
);
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
// Process any data that was submitted.
|
|
|
|
if (data_submitted() && confirm_sesskey()) {
|
2012-08-09 19:42:57 +01:00
|
|
|
if (optional_param('submit', false, PARAM_BOOL) && question_engine::is_manual_grade_in_range($attemptobj->get_uniqueid(), $slot)) {
|
2011-02-09 19:07:57 +00:00
|
|
|
$transaction = $DB->start_delegated_transaction();
|
MDL-3030 quiz overdue handling: trigger automatic state transitions.
Here, we catch all the places where a student might be accessing their
own attempts, and make sure any automatic state transitions that
should happen, do happen, before the student sees the attempt.
The places where we need to check this are view.php, startattempt.php
and processattempt.php.
We do not really need to check attempt.php or summary.php, because if
the student is on one of those pages, the JavaScript timer will
auto-submit when time expires, taking them to processattempt.php,
which will do the acutal work.
We intentionally do not trigger state transition when a teacher is
looking at a student's quiz attemp. We will trigger state transitions
on cron, but that is still to do.
Also, the body of the process_... methods still needs to be written.
2012-04-18 19:18:55 +01:00
|
|
|
$attemptobj->process_submitted_actions(time());
|
2011-02-09 19:07:57 +00:00
|
|
|
$transaction->allow_commit();
|
2013-12-16 20:15:51 -08:00
|
|
|
|
|
|
|
// Log this action.
|
|
|
|
$params = array(
|
|
|
|
'objectid' => $attemptobj->get_question_attempt($slot)->get_question()->id,
|
|
|
|
'courseid' => $attemptobj->get_courseid(),
|
|
|
|
'context' => context_module::instance($attemptobj->get_cmid()),
|
|
|
|
'other' => array(
|
|
|
|
'quizid' => $attemptobj->get_quizid(),
|
|
|
|
'attemptid' => $attemptobj->get_attemptid(),
|
|
|
|
'slot' => $slot
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$event = \mod_quiz\event\question_manually_graded::create($params);
|
|
|
|
$event->trigger();
|
|
|
|
|
2013-11-05 18:52:24 +08:00
|
|
|
echo $output->notification(get_string('changessaved'), 'notifysuccess');
|
2011-02-09 19:07:57 +00:00
|
|
|
close_window(2, true);
|
|
|
|
die;
|
2006-04-07 16:00:29 +00:00
|
|
|
}
|
2011-02-09 19:07:57 +00:00
|
|
|
}
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2013-11-05 18:52:24 +08:00
|
|
|
// Print quiz information.
|
|
|
|
echo $output->review_summary_table($summarydata, 0);
|
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
// Print the comment form.
|
2011-04-04 20:11:29 +01:00
|
|
|
echo '<form method="post" class="mform" id="manualgradingform" action="' .
|
|
|
|
$CFG->wwwroot . '/mod/quiz/comment.php">';
|
2011-02-09 19:07:57 +00:00
|
|
|
echo $attemptobj->render_question_for_commenting($slot);
|
2008-12-10 09:11:30 +00:00
|
|
|
?>
|
|
|
|
<div>
|
2011-01-29 14:03:02 +00:00
|
|
|
<input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" />
|
2011-02-09 19:07:57 +00:00
|
|
|
<input type="hidden" name="slot" value="<?php echo $slot; ?>" />
|
|
|
|
<input type="hidden" name="slots" value="<?php echo $slot; ?>" />
|
2008-12-10 09:11:30 +00:00
|
|
|
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
|
|
|
</div>
|
|
|
|
<fieldset class="hidden">
|
|
|
|
<div>
|
2012-05-28 11:05:49 +08:00
|
|
|
<div class="fitem fitem_actionbuttons fitem_fsubmit">
|
|
|
|
<fieldset class="felement fsubmit">
|
2017-05-18 16:49:01 +08:00
|
|
|
<input id="id_submitbutton" type="submit" name="submit" class="btn btn-primary" value="<?php
|
2011-04-04 20:11:29 +01:00
|
|
|
print_string('save', 'quiz'); ?>"/>
|
2008-12-10 09:11:30 +00:00
|
|
|
</fieldset>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<?php
|
2011-02-09 19:07:57 +00:00
|
|
|
echo '</form>';
|
2011-09-14 20:25:31 +01:00
|
|
|
$PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module());
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2011-02-09 19:07:57 +00:00
|
|
|
// End of the page.
|
2013-11-05 18:52:24 +08:00
|
|
|
echo $output->footer();
|