Skip to content

Commit

Permalink
MDL-77766 qtype_multichoice: Respect showstandardinstruction
Browse files Browse the repository at this point in the history
* When showstandardinstruction is set to no, replace the standard
instruction with the generic "Answer" text for the answer options
fieldset's legend.
  • Loading branch information
junpataleta committed Apr 24, 2023
1 parent 2caed29 commit bd8df1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions question/type/multichoice/renderer.php
Expand Up @@ -149,11 +149,13 @@ public function formulation_and_controls(question_attempt $qa,
$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,
Expand Down
2 changes: 1 addition & 1 deletion question/type/multichoice/tests/walkthrough_test.php
Expand Up @@ -302,7 +302,7 @@ public function test_deferredfeedback_feedback_multichoice_multi_showstandarduns
$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);
Expand Down

0 comments on commit bd8df1a

Please sign in to comment.