From dd7113a212f0981f0b44a01d7347e1f7a5448952 Mon Sep 17 00:00:00 2001 From: danghieu1407 Date: Thu, 13 Mar 2025 10:30:02 +0700 Subject: [PATCH] MDL-84708 question: Fixing layout answer box issue causing images --- .../ordering/tests/output/feedback_test.php | 18 ++++++++++++------ .../output/formulation_and_controls_test.php | 6 +++--- question/type/questionbase.php | 8 ++++---- question/type/rendererbase.php | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/question/type/ordering/tests/output/feedback_test.php b/question/type/ordering/tests/output/feedback_test.php index 62c2ec540e4..2a817fa5837 100644 --- a/question/type/ordering/tests/output/feedback_test.php +++ b/question/type/ordering/tests/output/feedback_test.php @@ -139,7 +139,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { 'specificgradedetailfeedback' => [ 'showpartialwrong' => 0, ], - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => false, @@ -197,7 +198,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { 'totalscore' => 28, 'totalmaxscore' => 30, ], - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => true, @@ -216,7 +218,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { 'specificgradedetailfeedback' => [ 'showpartialwrong' => 0, ], - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => false, @@ -229,7 +232,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { qtype_ordering_question::GRADING_RELATIVE_ALL_PREVIOUS_AND_NEXT, ['rot' => 'horizontal', 'inprogress' => false, 'feedback' => false], [ - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => true, @@ -294,7 +298,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { 'totalscore' => 20, 'totalmaxscore' => 30, ], - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => true, @@ -354,7 +359,8 @@ final class feedback_test extends qbehaviour_walkthrough_test_base { 'totalscore' => 1, 'totalmaxscore' => 5, ], - 'generalfeedback' => 'The correct answer is "Modular Object Oriented Dynamic Learning Environment".', + 'generalfeedback' => '
The correct answer is ' . + '"Modular Object Oriented Dynamic Learning Environment".
', 'rightanswer' => [ 'hascorrectresponse' => true, 'showcorrect' => true, diff --git a/question/type/ordering/tests/output/formulation_and_controls_test.php b/question/type/ordering/tests/output/formulation_and_controls_test.php index dd50a4a9441..6cb1dd2fc46 100644 --- a/question/type/ordering/tests/output/formulation_and_controls_test.php +++ b/question/type/ordering/tests/output/formulation_and_controls_test.php @@ -107,7 +107,7 @@ final class formulation_and_controls_test extends advanced_testcase { 'horizontal', [ 'readonly' => false, - 'questiontext' => 'Put these words in order', + 'questiontext' => '
Put these words in order
', 'responsename' => 'q0:_response_0', 'responseid' => 'id_q0_response_0', 'value' => 'ordering_item_ac5fc041de63c8c5b34d0aabb96cf33d,' . @@ -168,7 +168,7 @@ final class formulation_and_controls_test extends advanced_testcase { 'vertical', [ 'readonly' => false, - 'questiontext' => 'Put these words in order', + 'questiontext' => '
Put these words in order
', 'responsename' => 'q0:_response_0', 'responseid' => 'id_q0_response_0', 'value' => 'ordering_item_497031794414a552435f90151ac3b54b,' . @@ -229,7 +229,7 @@ final class formulation_and_controls_test extends advanced_testcase { 'horizontal', [ 'readonly' => false, - 'questiontext' => 'Put these words in order', + 'questiontext' => '
Put these words in order
', 'responsename' => 'q0:_response_0', 'responseid' => 'id_q0_response_0', 'value' => 'ordering_item_ac5fc041de63c8c5b34d0aabb96cf33d,' . diff --git a/question/type/questionbase.php b/question/type/questionbase.php index bf67b336e9e..d11b81dc6ed 100644 --- a/question/type/questionbase.php +++ b/question/type/questionbase.php @@ -459,14 +459,14 @@ abstract class question_definition { /** @return the result of applying {@link format_text()} to the question text. */ public function format_questiontext($qa) { - return $this->format_text($this->questiontext, $this->questiontextformat, - $qa, 'question', 'questiontext', $this->id); + return html_writer::tag('div', $this->format_text($this->questiontext, $this->questiontextformat, + $qa, 'question', 'questiontext', $this->id), ['class' => 'clearfix']); } /** @return the result of applying {@link format_text()} to the general feedback. */ public function format_generalfeedback($qa) { - return $this->format_text($this->generalfeedback, $this->generalfeedbackformat, - $qa, 'question', 'generalfeedback', $this->id); + return html_writer::tag('div', $this->format_text($this->generalfeedback, $this->generalfeedbackformat, + $qa, 'question', 'generalfeedback', $this->id), ['class' => 'clearfix']); } /** diff --git a/question/type/rendererbase.php b/question/type/rendererbase.php index 436d835160d..29836b577d0 100644 --- a/question/type/rendererbase.php +++ b/question/type/rendererbase.php @@ -103,7 +103,7 @@ abstract class qtype_renderer extends plugin_renderer_base { if ($options->feedback) { $output .= html_writer::nonempty_tag('div', $this->specific_feedback($qa), - array('class' => 'specificfeedback')); + ['class' => 'specificfeedback clearfix']); $hint = $qa->get_applicable_hint(); }