From 2352074dc0e471a7da7671258a6c67f4dd319877 Mon Sep 17 00:00:00 2001 From: Juan Segarra Montesinos Date: Sat, 14 Nov 2015 09:54:11 +0100 Subject: [PATCH] MDL-52131 qbehaviour: respect manualcomment format The format of a manual comment in a question is respected when the preferred editor is "Plain text area". --- .../manualgraded/tests/walkthrough_test.php | 39 +++++++++++++++++++ question/behaviour/rendererbase.php | 2 - 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/question/behaviour/manualgraded/tests/walkthrough_test.php b/question/behaviour/manualgraded/tests/walkthrough_test.php index 837797cf8e8..d63030c9248 100644 --- a/question/behaviour/manualgraded/tests/walkthrough_test.php +++ b/question/behaviour/manualgraded/tests/walkthrough_test.php @@ -583,4 +583,43 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug $this->expectException('coding_exception'); $this->manual_grade('Comment', '10.1', FORMAT_HTML); } + + public function test_manual_graded_displays_proper_comment_format () { + + 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. + $essay = test_question_maker::make_an_essay_question(); + $this->start_attempt_at_question($essay, 'deferredfeedback', 10); + + // Check the right model is being used. + $this->assertEquals('manualgraded', $this->quba->get_question_attempt( + $this->slot)->get_behaviour_name()); + + // Simulate some data submitted by the student. + $this->process_submission( + array( + 'answer' => "A submission!", + 'answerformat' => FORMAT_PLAIN + ) + ); + + // Finish the attempt. + $this->quba->finish_all_questions(); + + // Write a manual comment in markdown. + $this->manual_grade("*one\n*two\n*three\n", 10, FORMAT_MARKDOWN); + + // Check that feedback contains the original markdown format. + $preg = '/