From d387f50fcdd8ede4433d344ee4b588837a875b4a Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 18 Jan 2019 18:00:42 +0000 Subject: [PATCH] MDL-64590 questions: wrong comments shown in the state history table --- question/behaviour/behaviourbase.php | 6 ++-- .../manualgraded/tests/walkthrough_test.php | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/question/behaviour/behaviourbase.php b/question/behaviour/behaviourbase.php index 3b9943f62bc..34b08acd0b0 100644 --- a/question/behaviour/behaviourbase.php +++ b/question/behaviour/behaviourbase.php @@ -539,13 +539,13 @@ abstract class question_behaviour { /** * @return string a summary of a manual comment action. - * @param unknown_type $step + * @param question_attempt_step $step */ protected function summarise_manual_comment($step) { $a = new stdClass(); if ($step->has_behaviour_var('comment')) { - list($comment, $commentformat, $commentstep) = $this->qa->get_manual_comment(); - $comment = question_utils::to_plain_text($comment, $commentformat); + $comment = question_utils::to_plain_text($step->get_behaviour_var('comment'), + $step->get_behaviour_var('commentformat')); $a->comment = shorten_text($comment, 200); } else { $a->comment = ''; diff --git a/question/behaviour/manualgraded/tests/walkthrough_test.php b/question/behaviour/manualgraded/tests/walkthrough_test.php index c47e2053e1b..fac2a0b32df 100644 --- a/question/behaviour/manualgraded/tests/walkthrough_test.php +++ b/question/behaviour/manualgraded/tests/walkthrough_test.php @@ -657,4 +657,36 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->render(); $this->check_output_contains_text_input('-mark', '0.3333333'); } + + public function test_manual_grading_history_display() { + global $PAGE; + + // The current text editor depends on the users profile setting - so it needs a valid user. + $this->setAdminUser(); + // Required to init a text editor. + $PAGE->set_url('/'); + + // Create an essay question graded out of 15 and attempt it. + $essay = test_question_maker::make_an_essay_question(); + $this->start_attempt_at_question($essay, 'deferredfeedback', 10); + $this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML)); + $this->quba->finish_all_questions(); + + // Verify. + $this->check_current_state(question_state::$needsgrading); + + // Process an initial grade and comment. + $this->manual_grade('First comment', '5.0', FORMAT_HTML); + + // Process a second grade and comment. + $this->manual_grade('Second comment', '7.0', FORMAT_HTML); + + // Verify. + $this->check_current_state(question_state::$mangrpartial); + $this->check_current_mark(7); + $this->displayoptions->history = question_display_options::VISIBLE; + $this->render(); + $this->check_output_contains('Manually graded 5 with comment: First comment'); + $this->check_output_contains('Manually graded 7 with comment: Second comment'); + } }