diff --git a/question/behaviour/adaptive/tests/walkthrough_test.php b/question/behaviour/adaptive/tests/walkthrough_test.php index 60474a31f9b..41107e6fd92 100644 --- a/question/behaviour/adaptive/tests/walkthrough_test.php +++ b/question/behaviour/adaptive/tests/walkthrough_test.php @@ -158,7 +158,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b $this->get_contains_correct_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php index b44f6e3a211..aebbcf7a9c0 100644 --- a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php +++ b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php @@ -124,7 +124,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou $this->get_contains_correct_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/deferredcbm/tests/walkthrough_test.php b/question/behaviour/deferredcbm/tests/walkthrough_test.php index 69b7cd13333..36cc73c965b 100644 --- a/question/behaviour/deferredcbm/tests/walkthrough_test.php +++ b/question/behaviour/deferredcbm/tests/walkthrough_test.php @@ -95,7 +95,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_contains_correct_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/deferredfeedback/tests/walkthrough_test.php b/question/behaviour/deferredfeedback/tests/walkthrough_test.php index 45c6c9ac80f..1bc806709fd 100644 --- a/question/behaviour/deferredfeedback/tests/walkthrough_test.php +++ b/question/behaviour/deferredfeedback/tests/walkthrough_test.php @@ -92,7 +92,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug $this->quba->get_response_summary($this->slot)); // Process a manual comment. - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(1); diff --git a/question/behaviour/immediatecbm/tests/walkthrough_test.php b/question/behaviour/immediatecbm/tests/walkthrough_test.php index 4154dde5758..66e58d6defc 100644 --- a/question/behaviour/immediatecbm/tests/walkthrough_test.php +++ b/question/behaviour/immediatecbm/tests/walkthrough_test.php @@ -109,7 +109,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->get_contains_correct_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 0.5); + $this->manual_grade('Not good enough!', 0.5, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); @@ -176,7 +176,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->get_contains_mc_radio_expectation(2, false, false)); // Process a manual comment. - $this->manual_grade('Not good enough!', 0.5); + $this->manual_grade('Not good enough!', 0.5, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/immediatefeedback/tests/walkthrough_test.php b/question/behaviour/immediatefeedback/tests/walkthrough_test.php index 4708dde876e..708052175d0 100644 --- a/question/behaviour/immediatefeedback/tests/walkthrough_test.php +++ b/question/behaviour/immediatefeedback/tests/walkthrough_test.php @@ -116,7 +116,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou $this->get_contains_correct_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 0.5); + $this->manual_grade('Not good enough!', 0.5, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); @@ -185,7 +185,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou $this->get_contains_mc_radio_expectation(2, false, false)); // Process a manual comment. - $this->manual_grade('Not good enough!', 0.5); + $this->manual_grade('Not good enough!', 0.5, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/informationitem/tests/walkthrough_test.php b/question/behaviour/informationitem/tests/walkthrough_test.php index 544d3d96eae..3cdb4947bcd 100644 --- a/question/behaviour/informationitem/tests/walkthrough_test.php +++ b/question/behaviour/informationitem/tests/walkthrough_test.php @@ -74,7 +74,7 @@ class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough $this->get_contains_general_feedback_expectation($description)); // Process a manual comment. - $this->manual_grade('Not good enough!', null); + $this->manual_grade('Not good enough!', null, FORMAT_HTML); $this->check_current_state(question_state::$manfinished); $this->check_current_mark(null); @@ -83,6 +83,6 @@ class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough // Check that trying to process a manual comment with a grade causes an exception. $this->setExpectedException('moodle_exception'); - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); } } diff --git a/question/behaviour/interactive/tests/walkthrough_test.php b/question/behaviour/interactive/tests/walkthrough_test.php index ee23cf8acbe..7e11e48cc27 100644 --- a/question/behaviour/interactive/tests/walkthrough_test.php +++ b/question/behaviour/interactive/tests/walkthrough_test.php @@ -157,7 +157,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_no_hint_visible_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 0.5); + $this->manual_grade('Not good enough!', 0.5, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrpartial); diff --git a/question/behaviour/manualgraded/tests/walkthrough_test.php b/question/behaviour/manualgraded/tests/walkthrough_test.php index 41e20766f3c..6ef97941cb1 100644 --- a/question/behaviour/manualgraded/tests/walkthrough_test.php +++ b/question/behaviour/manualgraded/tests/walkthrough_test.php @@ -90,7 +90,7 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->quba->get_response_summary($this->slot)); // Process a manual comment. - $this->manual_grade('Not good enough!', 10); + $this->manual_grade('Not good enough!', 10, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrright); @@ -182,7 +182,7 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->get_does_not_contain_specific_feedback_expectation()); // Process a manual comment. - $this->manual_grade('Not good enough!', 1); + $this->manual_grade('Not good enough!', 1, FORMAT_HTML); $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(1); @@ -223,14 +223,14 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te // Process a blank manual comment. Ensure it does not change the state. $numsteps = $this->get_step_count(); - $this->manual_grade('', ''); + $this->manual_grade('', '', FORMAT_HTML); $this->check_step_count($numsteps); $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); // Process a comment, but with the mark blank. Should be recorded, but // not change the mark. - $this->manual_grade('I am not sure what grade to award.', ''); + $this->manual_grade('I am not sure what grade to award.', '', FORMAT_HTML); $this->check_step_count($numsteps + 1); $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); @@ -239,7 +239,7 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te preg_quote('I am not sure what grade to award.', '/') . '/')); // Now grade it. - $this->manual_grade('Pretty good!', '9.00000'); + $this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML); $this->check_step_count($numsteps + 2); $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(9); @@ -247,13 +247,13 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te new question_pattern_expectation('/' . preg_quote('Pretty good!', '/') . '/')); // Process the same data again, and make sure it does not add a step. - $this->manual_grade('Pretty good!', '9.00000'); + $this->manual_grade('Pretty good!', '9.00000', FORMAT_HTML); $this->check_step_count($numsteps + 2); $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(9); // Now set the mark back to blank. - $this->manual_grade('Actually, I am not sure any more.', ''); + $this->manual_grade('Actually, I am not sure any more.', '', FORMAT_HTML); $this->check_step_count($numsteps + 3); $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); @@ -303,7 +303,7 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->quba->get_response_summary($this->slot)); // Process a blank comment and a grade of 0. - $this->manual_grade('', 0); + $this->manual_grade('', 0, FORMAT_HTML); // Verify. $this->check_current_state(question_state::$mangrwrong); diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php index a5a12d11eed..68211ed26a8 100644 --- a/question/engine/questionattempt.php +++ b/question/engine/questionattempt.php @@ -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; diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index 22bc3b87213..c09083e2a9b 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -647,9 +647,9 @@ class question_usage_by_activity { * @param number $mark the mark that is being assigned. Can be null to just * add a comment. */ - public function manual_grade($slot, $comment, $mark) { + public function manual_grade($slot, $comment, $mark, $commentformat = null) { $qa = $this->get_question_attempt($slot); - $qa->manual_grade($comment, $mark); + $qa->manual_grade($comment, $mark, $commentformat); $this->observer->notify_attempt_modified($qa); } diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index 494dbc86ddc..db9c02d5186 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -653,8 +653,8 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase { $this->quba->process_action($this->slot, $data); } - protected function manual_grade($comment, $mark) { - $this->quba->manual_grade($this->slot, $comment, $mark); + protected function manual_grade($comment, $mark, $commentformat = null) { + $this->quba->manual_grade($this->slot, $comment, $mark, $commentformat); } protected function check_current_state($state) { diff --git a/question/engine/tests/unitofwork_test.php b/question/engine/tests/unitofwork_test.php index aa68a570ffa..f83de5ca6e4 100644 --- a/question/engine/tests/unitofwork_test.php +++ b/question/engine/tests/unitofwork_test.php @@ -174,7 +174,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base { public function test_process_action() { - $this->quba->manual_grade($this->slot, 'Acutally, that is not quite right', 0.5); + $this->quba->manual_grade($this->slot, 'Acutally, that is not quite right', 0.5, FORMAT_HTML); // Here, however, were we are adding a step to an existing qa, we do need to track that. $this->assertEquals(0, count($this->observer->get_attempts_added()));