2006-04-07 16:00:29 +00:00
|
|
|
<?php // $Id$
|
|
|
|
/**
|
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.
|
|
|
|
* *
|
2007-11-07 12:35:33 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
|
|
|
* @package quiz
|
|
|
|
*/
|
2006-04-07 16:00:29 +00:00
|
|
|
|
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('locallib.php');
|
|
|
|
|
|
|
|
$attemptid =required_param('attempt', PARAM_INT); // attempt id
|
|
|
|
$questionid =required_param('question', PARAM_INT); // question id
|
|
|
|
|
2008-09-04 09:22:37 +00:00
|
|
|
$attemptobj = new quiz_attempt($attemptid);
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Can only grade finished attempts.
|
|
|
|
if (!$attemptobj->is_finished()) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('attemptclosed', 'quiz');
|
2006-04-07 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Check login and permissions.
|
|
|
|
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
|
|
|
|
$attemptobj->require_capability('mod/quiz:grade');
|
2007-08-17 12:49:28 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Load the questions and states.
|
|
|
|
$questionids = array($questionid);
|
|
|
|
$attemptobj->load_questions($questionids);
|
|
|
|
$attemptobj->load_question_states($questionids);
|
2008-03-07 12:35:10 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Log this action.
|
|
|
|
add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' .
|
|
|
|
$attemptobj->get_attemptid() . '&question=' . $questionid,
|
|
|
|
$attemptobj->get_quizid(), $attemptobj->get_cmid());
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Print the page header
|
2006-04-07 16:00:29 +00:00
|
|
|
print_header();
|
2008-09-18 07:39:10 +00:00
|
|
|
print_heading(format_string($attemptobj->get_question($questionid)->name));
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Process any data that was submitted.
|
2006-04-07 16:00:29 +00:00
|
|
|
if ($data = data_submitted() and confirm_sesskey()) {
|
2008-09-18 07:39:10 +00:00
|
|
|
$error = $attemptobj->process_comment($questionid,
|
|
|
|
$data->response['comment'], $data->response['grade']);
|
2008-05-15 16:02:12 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// If success, notify and print a close button.
|
|
|
|
if (!is_string($error)) {
|
|
|
|
notify(get_string('changessaved'), 'notifysuccess');
|
|
|
|
close_window_button('closewindow', false, true);
|
2008-05-15 16:02:12 +00:00
|
|
|
print_footer();
|
|
|
|
exit;
|
2006-04-07 16:00:29 +00:00
|
|
|
}
|
2008-09-18 07:39:10 +00:00
|
|
|
|
|
|
|
/// Otherwise, display the error and fall throug to re-display the form.
|
|
|
|
notify($error);
|
2006-04-07 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// Print the comment form.
|
|
|
|
echo '<form method="post" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
|
|
|
|
$attemptobj->question_print_comment_fields($questionid, 'response');
|
|
|
|
echo '<input type="hidden" name="attempt" value="' . $attemptobj->get_uniqueid() . '" />';
|
|
|
|
echo '<input type="hidden" name="question" value="' . $questionid . '" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
|
|
|
echo '<input type="submit" name="submit" value="' . get_string('save', 'quiz') . '" />';
|
|
|
|
echo '</form>';
|
2006-04-07 16:00:29 +00:00
|
|
|
|
2008-09-18 07:39:10 +00:00
|
|
|
/// End of the page.
|
2006-04-07 16:00:29 +00:00
|
|
|
print_footer();
|
|
|
|
?>
|