MDL-43929 question manual grading: keep comment when validation fails.

If the validation failed, so the manual grading page was re-displayed
with a validation error, then any comment that had just been typed in
was getting lost. This fixes that.
This commit is contained in:
Tim Hunt
2014-02-07 21:55:05 +00:00
parent 974c2cdc03
commit 1eb470fc42
3 changed files with 23 additions and 2 deletions
+21
View File
@@ -1284,6 +1284,27 @@ class question_attempt {
return array(null, null);
}
/**
* This is used by the manual grading code, particularly in association with
* validation. If there is a comment submitted in the request, then use that,
* otherwise use the latest comment for this question.
* @return number the current mark for this question.
* {@link get_fraction()} * {@link get_max_mark()}.
*/
public function get_current_manual_comment() {
$comment = $this->get_submitted_var($this->get_behaviour_field_name('comment'), PARAM_RAW);
if (is_null($comment)) {
return $this->get_manual_comment();
} else {
$commentformat = $this->get_submitted_var(
$this->get_behaviour_field_name('commentformat'), PARAM_INT);
if ($commentformat === null) {
$commentformat = FORMAT_HTML;
}
return array($comment, $commentformat);
}
}
/**
* Break down a student response by sub part and classification.
* See also {@link question_type::get_possible_responses()}