MDL-80537 question bank: escape plain text display of question text

This commit is contained in:
Tim Hunt 2024-01-08 18:06:58 +00:00
parent f30110b5eb
commit cefcedebcb
2 changed files with 11 additions and 11 deletions

View File

@ -58,8 +58,8 @@ class question_text_row extends row_base {
if ($this->preference !== question_text_format::OFF) {
$text = '';
if ($this->preference === question_text_format::PLAIN) {
$text = question_utils::to_plain_text($question->questiontext,
$question->questiontextformat, ['noclean' => true, 'para' => false, 'filter' => false]);
$text = s(question_utils::to_plain_text($question->questiontext,
$question->questiontextformat, ['noclean' => true, 'para' => false, 'filter' => false]));
} else if ($this->preference === question_text_format::FULL) {
$text = question_rewrite_question_preview_urls($question->questiontext, $question->id,
$question->contextid, 'question', 'questiontext', $question->id,

View File

@ -13,26 +13,26 @@ Feature: Use the qbank plugin manager page for viewquestiontext
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the <span class="totestforhtml">first</span> question |
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the <span class="totestforhtml">first</span> &lt;question&gt; |
@javascript
Scenario: Display of plain question text can be turned on and off
When I am on the "Test quiz" "mod_quiz > question bank" page logged in as admin
And I set the field "Show question text in the question list?" to "text only"
Then I should see "Answer the first question"
And ".totestforhtml" "css_element" should not exist in the "Answer the first question" "table_row"
Then I should see "Answer the first <question>"
And ".totestforhtml" "css_element" should not exist in the "Answer the first <question>" "table_row"
And I set the field "Show question text in the question list?" to "No"
And I should not see "Answer the first question"
And I should not see "Answer the first <question>"
@javascript
Scenario: Display of full question text can be turned on and off
When I am on the "Test quiz" "mod_quiz > question bank" page logged in as admin
And I set the field "Show question text in the question list?" to "with images"
Then I should see "Answer the first question"
And ".totestforhtml" "css_element" should exist in the "Answer the first question" "table_row"
Then I should see "Answer the first <question>"
And ".totestforhtml" "css_element" should exist in the "Answer the first <question>" "table_row"
And I set the field "Show question text in the question list?" to "No"
And I should not see "Answer the first question"
And I should not see "Answer the first <question>"
@javascript
Scenario: Option does not show if the plugin is disabled
@ -54,4 +54,4 @@ Feature: Use the qbank plugin manager page for viewquestiontext
And I click on "Enable" "link" in the "View question text" "table_row"
And I am on the "Test quiz" "mod_quiz > question bank" page
When I set the field "Show question text in the question list?" to "text only"
And I should see "Answer the first question"
And I should see "Answer the first <question>"