MDL-31036 mod_assign: Don't strip quickgrading feedback of special chars

This commit is contained in:
Zachary Durber 2015-01-28 13:55:45 +08:00
parent 4c27f52d91
commit 75d08f0291
2 changed files with 9 additions and 7 deletions

View file

@ -96,7 +96,7 @@ class assign_feedback_comments extends assign_feedback_plugin {
} }
// Note that this handles the difference between empty and not in the quickgrading // Note that this handles the difference between empty and not in the quickgrading
// form at all (hidden column). // form at all (hidden column).
$newvalue = optional_param('quickgrade_comments_' . $userid, false, PARAM_TEXT); $newvalue = optional_param('quickgrade_comments_' . $userid, false, PARAM_RAW);
return ($newvalue !== false) && ($newvalue != $commenttext); return ($newvalue !== false) && ($newvalue != $commenttext);
} }
@ -176,17 +176,16 @@ class assign_feedback_comments extends assign_feedback_plugin {
public function save_quickgrading_changes($userid, $grade) { public function save_quickgrading_changes($userid, $grade) {
global $DB; global $DB;
$feedbackcomment = $this->get_feedback_comments($grade->id); $feedbackcomment = $this->get_feedback_comments($grade->id);
$feedbackpresent = optional_param('quickgrade_comments_' . $userid, false, PARAM_TEXT) !== false; $quickgradecomments = optional_param('quickgrade_comments_' . $userid, null, PARAM_RAW);
if (!$feedbackpresent) { if (!$quickgradecomments) {
// Nothing to save (e.g. hidden column).
return true; return true;
} }
if ($feedbackcomment) { if ($feedbackcomment) {
$feedbackcomment->commenttext = optional_param('quickgrade_comments_' . $userid, '', PARAM_TEXT); $feedbackcomment->commenttext = $quickgradecomments;
return $DB->update_record('assignfeedback_comments', $feedbackcomment); return $DB->update_record('assignfeedback_comments', $feedbackcomment);
} else { } else {
$feedbackcomment = new stdClass(); $feedbackcomment = new stdClass();
$feedbackcomment->commenttext = optional_param('quickgrade_comments_' . $userid, '', PARAM_TEXT); $feedbackcomment->commenttext = $quickgradecomments;
$feedbackcomment->commentformat = FORMAT_HTML; $feedbackcomment->commentformat = FORMAT_HTML;
$feedbackcomment->grade = $grade->id; $feedbackcomment->grade = $grade->id;
$feedbackcomment->assignment = $this->assignment->get_instance()->id; $feedbackcomment->assignment = $this->assignment->get_instance()->id;
@ -485,7 +484,7 @@ class assign_feedback_comments extends assign_feedback_plugin {
* @return external_description|null * @return external_description|null
*/ */
public function get_external_parameters() { public function get_external_parameters() {
$editorparams = array('text' => new external_value(PARAM_TEXT, 'The text for this feedback.'), $editorparams = array('text' => new external_value(PARAM_RAW, 'The text for this feedback.'),
'format' => new external_value(PARAM_INT, 'The format for this feedback')); 'format' => new external_value(PARAM_INT, 'The format for this feedback'));
$editorstructure = new external_single_structure($editorparams); $editorstructure = new external_single_structure($editorparams);
return array('assignfeedbackcomments_editor' => $editorstructure); return array('assignfeedbackcomments_editor' => $editorstructure);

View file

@ -1,4 +1,7 @@
This files describes API changes in the assign code. This files describes API changes in the assign code.
=== 2.9 ===
* External parameter now returns PARAM_RAW instead of PARAM_TEXT for webservices using feedback comments.
=== 2.8 === === 2.8 ===
* Some DB changes were made to simplify the SQL required to query the latest attempt. * Some DB changes were made to simplify the SQL required to query the latest attempt.
- The assign_submission table now has a column "latest" which is set to 1 for the latest submission attempt. - The assign_submission table now has a column "latest" which is set to 1 for the latest submission attempt.