From 75984fb22611352942e6d11b09a982c80f23f3a1 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 24 Apr 2023 20:07:38 +0800 Subject: [PATCH] MDL-77766 qtype_multichoice: Respect showstandardinstruction * When showstandardinstruction is set to no, replace the standard instruction with the generic "Answer" text for the answer options fieldset's legend. --- question/type/multichoice/renderer.php | 6 ++++-- question/type/multichoice/tests/walkthrough_test.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/question/type/multichoice/renderer.php b/question/type/multichoice/renderer.php index 59f821eba15..287ca32162d 100644 --- a/question/type/multichoice/renderer.php +++ b/question/type/multichoice/renderer.php @@ -149,11 +149,13 @@ abstract class qtype_multichoice_renderer_base extends qtype_with_combined_feedb $result .= html_writer::tag('div', $question->format_questiontext($qa), array('class' => 'qtext')); - $questionnumber = $options->add_question_identifier_to_label($this->prompt(), true, true); $result .= html_writer::start_tag('fieldset', array('class' => 'ablock no-overflow visual-scroll-x')); - $legendclass = 'sr-only'; if ($question->showstandardinstruction == 1) { $legendclass = ''; + $questionnumber = $options->add_question_identifier_to_label($this->prompt(), true, true); + } else { + $questionnumber = $options->add_question_identifier_to_label(get_string('answer'), true, true); + $legendclass = 'sr-only'; } $legendattrs = [ 'class' => 'prompt h6 font-weight-normal ' . $legendclass, diff --git a/question/type/multichoice/tests/walkthrough_test.php b/question/type/multichoice/tests/walkthrough_test.php index 51d100b048a..61239422a62 100644 --- a/question/type/multichoice/tests/walkthrough_test.php +++ b/question/type/multichoice/tests/walkthrough_test.php @@ -302,7 +302,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->render(); // Check for 'Show standard instruction'. - $standardinstruction = \html_writer::tag('legend', get_string('selectmulti', 'qtype_multichoice'), [ + $standardinstruction = \html_writer::tag('legend', get_string('answer'), [ 'class' => 'prompt h6 font-weight-normal sr-only' ]); $this->assertStringContainsString($standardinstruction, $this->currentoutput);