MDL-20636 Manual comment popup comment.php now works.
This commit is contained in:
@@ -608,7 +608,7 @@ class quiz_attempt {
|
||||
public function get_display_options($reviewing) {
|
||||
if ($reviewing) {
|
||||
if (is_null($this->reviewoptions)) {
|
||||
$this->reviewoptions = quiz_get_reviewoptions($this->get_quiz(),
|
||||
$this->reviewoptions = quiz_get_review_options($this->get_quiz(),
|
||||
$this->attempt, $this->quizobj->get_context());
|
||||
}
|
||||
return $this->reviewoptions;
|
||||
|
||||
+62
-53
@@ -1,4 +1,20 @@
|
||||
<?php
|
||||
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -6,65 +22,59 @@
|
||||
* @package mod
|
||||
* @subpackage quiz
|
||||
* @copyright gustav delius 2006
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('locallib.php');
|
||||
require_once('../../config.php');
|
||||
require_once('locallib.php');
|
||||
|
||||
$attemptid = required_param('attempt', PARAM_INT); // attempt id
|
||||
$questionid = required_param('question', PARAM_INT); // question id
|
||||
$attemptid = required_param('attempt', PARAM_INT); // attempt id
|
||||
$slot = required_param('slot', PARAM_INT); // question number in attempt
|
||||
|
||||
$PAGE->set_url('/mod/quiz/comment.php', array('attempt'=>$attemptid, 'question'=>$questionid));
|
||||
$PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot));
|
||||
|
||||
$attemptobj = quiz_attempt::create($attemptid);
|
||||
$attemptobj = quiz_attempt::create($attemptid);
|
||||
|
||||
/// Can only grade finished attempts.
|
||||
if (!$attemptobj->is_finished()) {
|
||||
print_error('attemptclosed', 'quiz');
|
||||
// Can only grade finished attempts.
|
||||
if (!$attemptobj->is_finished()) {
|
||||
print_error('attemptclosed', 'quiz');
|
||||
}
|
||||
|
||||
// Check login and permissions.
|
||||
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
|
||||
$attemptobj->require_capability('mod/quiz:grade');
|
||||
|
||||
// Log this action.
|
||||
add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' .
|
||||
$attemptobj->get_attemptid() . '&slot=' . $slot,
|
||||
$attemptobj->get_quizid(), $attemptobj->get_cmid());
|
||||
|
||||
// Print the page header
|
||||
$PAGE->set_pagelayout('popup');
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($attemptobj->get_question_name($slot)));
|
||||
|
||||
// Process any data that was submitted.
|
||||
if (data_submitted() && confirm_sesskey()) {
|
||||
if (optional_param('submit', false, PARAM_BOOL)) {
|
||||
// TODO better error handling.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$attemptobj->process_all_actions(time());
|
||||
$transaction->allow_commit();
|
||||
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
|
||||
close_window(2, true);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check login and permissions.
|
||||
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
|
||||
$attemptobj->require_capability('mod/quiz:grade');
|
||||
|
||||
/// Load the questions and states.
|
||||
$questionids = array($questionid);
|
||||
$attemptobj->load_questions($questionids);
|
||||
$attemptobj->load_question_states($questionids);
|
||||
|
||||
/// 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());
|
||||
|
||||
/// Print the page header
|
||||
$PAGE->set_pagelayout('popup');
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($attemptobj->get_question($questionid)->name));
|
||||
|
||||
/// Process any data that was submitted.
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
$error = $attemptobj->process_comment($questionid,
|
||||
$data->response['comment'], FORMAT_HTML, $data->response['grade']);
|
||||
|
||||
/// If success, notify and print a close button.
|
||||
if (!is_string($error)) {
|
||||
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
|
||||
close_window(2, true);
|
||||
}
|
||||
|
||||
/// Otherwise, display the error and fall throug to re-display the form.
|
||||
echo $OUTPUT->notification($error);
|
||||
}
|
||||
|
||||
/// Print the comment form.
|
||||
echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
|
||||
$attemptobj->question_print_comment_fields($questionid, 'response');
|
||||
// Print the comment form.
|
||||
echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
|
||||
echo $attemptobj->render_question_for_commenting($slot);
|
||||
?>
|
||||
<div>
|
||||
<input type="hidden" name="attempt" value="<?php echo $attemptobj->get_attemptid(); ?>" />
|
||||
<input type="hidden" name="question" value="<?php echo $questionid; ?>" />
|
||||
<input type="hidden" name="slot" value="<?php echo $slot; ?>" />
|
||||
<input type="hidden" name="slots" value="<?php echo $slot; ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
|
||||
</div>
|
||||
<fieldset class="hidden">
|
||||
@@ -75,14 +85,13 @@
|
||||
</div>
|
||||
<fieldset class="felement fgroup">
|
||||
<input id="id_submitbutton" type="submit" name="submit" value="<?php print_string('save', 'quiz'); ?>"/>
|
||||
<input id="id_cancel" type="button" value="<?php print_string('cancel'); ?>" onclick="close_window"/>
|
||||
<input id="id_cancel" type="button" value="<?php print_string('cancel'); ?>" onclick="close_window()"/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
echo '</form>';
|
||||
echo '</form>';
|
||||
|
||||
/// End of the page.
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
// End of the page.
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+1
-1
@@ -800,7 +800,7 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
|
||||
}
|
||||
}
|
||||
|
||||
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
|
||||
$options = quiz_get_review_options($quiz, $attempt, $context);
|
||||
|
||||
$tmpactivity = new stdClass;
|
||||
|
||||
|
||||
@@ -1041,18 +1041,20 @@ function quiz_attempt_state($quiz, $attempt) {
|
||||
*
|
||||
* @return mod_quiz_display_options
|
||||
*/
|
||||
function quiz_get_reviewoptions($quiz, $attempt, $context) {
|
||||
function quiz_get_review_options($quiz, $attempt, $context) {
|
||||
$options = mod_quiz_display_options::make_from_quiz($quiz, quiz_attempt_state($quiz, $attempt));
|
||||
|
||||
$options->readonly = true;
|
||||
$options->flags = quiz_get_flag_option($attempt, $context);
|
||||
$options->questionreviewlink = '/mod/quiz/reviewquestion.php?attempt=' . $attempt->id;
|
||||
$options->questionreviewlink = new moodle_url('/mod/quiz/reviewquestion.php',
|
||||
array('attempt' => $attempt->id));
|
||||
|
||||
// Show a link to the comment box only for closed attempts
|
||||
if ($attempt->timefinish && !$attempt->preview && !is_null($context) &&
|
||||
has_capability('mod/quiz:grade', $context)) {
|
||||
$options->manualcomment = question_display_options::VISIBLE;
|
||||
$options->manualcommentlink = '/mod/quiz/comment.php?attempt=' . $attempt->id;
|
||||
$options->manualcommentlink = new moodle_url('/mod/quiz/comment.php',
|
||||
array('attempt' => $attempt->id));
|
||||
}
|
||||
|
||||
if (!is_null($context) && !$attempt->preview && has_capability('mod/quiz:viewreports', $context) &&
|
||||
|
||||
@@ -381,7 +381,7 @@ class quiz_grading_report extends quiz_default_report {
|
||||
// with only one question there is only one entry in this array
|
||||
$state = &$states[$question->id];
|
||||
|
||||
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
|
||||
$options = quiz_get_review_options($quiz, $attempt, $context);
|
||||
unset($options->questioncommentlink);
|
||||
$options->readonly = 1;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class quiz_overview_report extends quiz_default_report {
|
||||
$fakeattempt->preview = false;
|
||||
$fakeattempt->timefinish = $quiz->timeopen;
|
||||
$fakeattempt->userid = 0;
|
||||
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $this->context);
|
||||
$reviewoptions = quiz_get_review_options($quiz, $fakeattempt, $this->context);
|
||||
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
|
||||
|
||||
$download = optional_param('download', '', PARAM_ALPHA);
|
||||
|
||||
@@ -27,7 +27,7 @@ class quiz_responses_report extends quiz_default_report {
|
||||
$fakeattempt->preview = false;
|
||||
$fakeattempt->timefinish = $quiz->timeopen;
|
||||
$fakeattempt->userid = 0;
|
||||
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $context);
|
||||
$reviewoptions = quiz_get_review_options($quiz, $fakeattempt, $context);
|
||||
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
|
||||
|
||||
$download = optional_param('download', '', PARAM_ALPHA);
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ if ($attempts) {
|
||||
|
||||
// One row for each attempt
|
||||
foreach ($attempts as $attempt) {
|
||||
$attemptoptions = quiz_get_reviewoptions($quiz, $attempt, $context);
|
||||
$attemptoptions = quiz_get_review_options($quiz, $attempt, $context);
|
||||
$row = array();
|
||||
|
||||
// Add the attempt number, making it a link, if appropriate.
|
||||
|
||||
@@ -71,7 +71,7 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
|
||||
|
||||
$commentfield = $qa->get_behaviour_field_name('comment');
|
||||
|
||||
list($commenttext, $commentformat) = $this->qa->get_manual_comment();
|
||||
list($commenttext, $commentformat) = $qa->get_manual_comment();
|
||||
$comment = print_textarea(can_use_html_editor(), 10, 80, null, null, $commentfield, $commenttext, 0, true);
|
||||
$comment = html_writer::tag('div', html_writer::tag('div',
|
||||
html_writer::tag('label', get_string('comment', 'question'), array('for' => $commentfield)),
|
||||
@@ -136,10 +136,9 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
|
||||
$output .= get_string('commentx', 'question', $qa->get_behaviour()->format_comment());
|
||||
}
|
||||
if ($options->manualcommentlink) {
|
||||
$strcomment = get_string('commentormark', 'question');
|
||||
$link = link_to_popup_window($options->manualcommentlink .
|
||||
'&slot=' . $qa->get_slot(),
|
||||
'commentquestion', $strcomment, 600, 800, $strcomment, 'none', true);
|
||||
$url = new moodle_url($options->manualcommentlink, array('slot' => $qa->get_slot()));
|
||||
$link = $this->output->action_link($url, get_string('commentormark', 'question'),
|
||||
new popup_action('click', $url, 'commentquestion', array('width' => 600, 'height' => 800)));
|
||||
$output .= html_writer::tag('div', $link, array('class' => 'commentlink'));
|
||||
}
|
||||
return $output;
|
||||
|
||||
@@ -70,8 +70,8 @@ DONE mod/quiz/attempt.php | 742 ++----
|
||||
DONE mod/quiz/attempt_close_js.php | 27 -
|
||||
DONE mod/quiz/attemptlib.php | 1219 +++++++++
|
||||
mod/quiz/backuplib.php | 16 +-
|
||||
mod/quiz/comment.php | 171 +-
|
||||
mod/quiz/config.html | 304 ++-
|
||||
DONE mod/quiz/comment.php | 171 +-
|
||||
DONE mod/quiz/config.html | 304 ++-
|
||||
DONE mod/quiz/db/access.php | 19 +-
|
||||
DONE mod/quiz/db/install.xml | 191 +-
|
||||
DONE mod/quiz/db/mysql.php | 1163 --------
|
||||
|
||||
Reference in New Issue
Block a user