MDL-38311 questions: manual grading API should accept commentformat

Comment format (FORMAT_...) was correctly being processed when the
manual grading happened as the result of a form submission. It was only
when done using the question_usage or question_attempt API method that
there was no way to specify the format. (Although I think the only place
this API as used was in the unit tests.)

Note that question_attempt::manual_grade API had to change, but I don't
think that is a real API change. Calling code should be using
question_usage::question_attempt, which is backwards compatible.

Note that now, if you don't pass format, then no error is generated, but
a developer debugging message is generated.
This commit is contained in:
Tim Hunt
2013-03-05 11:57:42 +00:00
parent 215c1897a4
commit 0d1fccaf15
13 changed files with 33 additions and 28 deletions
+9 -4
View File
@@ -1114,14 +1114,19 @@ class question_attempt {
/**
* Perform a manual grading action on this attempt.
* @param $comment the comment being added.
* @param $mark the new mark. (Optional, if not given, then only a comment is added.)
* @param string $comment the comment being added.
* @param float $mark the new mark. If null, then only a comment is added.
* @param int $commentformat the FORMAT_... for $comment. Must be given.
* @param int $timestamp the time to record for the action. (If not given, use now.)
* @param int $userid the user to attribute the aciton to. (If not given, use the current user.)
* @return unknown_type
*/
public function manual_grade($comment, $mark, $timestamp = null, $userid = null) {
public function manual_grade($comment, $mark, $commentformat = null, $timestamp = null, $userid = null) {
$submitteddata = array('-comment' => $comment);
if (is_null($commentformat)) {
debugging('You should pass $commentformat to manual_grade.', DEBUG_DEVELOPER);
$commentformat = FORMAT_HTML;
}
$submitteddata['-commentformat'] = $commentformat;
if (!is_null($mark)) {
$submitteddata['-mark'] = $mark;
$submitteddata['-maxmark'] = $this->maxmark;