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".
This commit is contained in:
Juan Segarra Montesinos
2017-09-14 13:31:30 +08:00
committed by Andrew Nicols
parent 3393db1467
commit 3e55e065fe
2 changed files with 39 additions and 2 deletions
@@ -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 = '/<textarea [^>]+name="[^"]+-comment"[^>]+>\*one\n\*two\n\*three\n/';
$this->displayoptions->manualcomment = question_display_options::EDITABLE;
$this->check_current_output(
new question_pattern_expectation($preg)
);
}
}
-2
View File
@@ -80,8 +80,6 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
$formats[$fid] = $strformats[$fid];
}
$commenttext = format_text($commenttext, $commentformat, array('para' => false));
$editor->set_text($commenttext);
$editor->use_editor($id, array('context' => $options->context));