MDL-77766 qtype_truefalse: Respect showstandardinstruction

* When showstandardinstruction is set to no, replace the standard
instruction with the generic "Answer" text for the answer options
fieldset's legend.
This commit is contained in:
Jun Pataleta 2023-04-24 20:07:57 +08:00
parent 75984fb226
commit 35e69b6ae8
2 changed files with 5 additions and 3 deletions

View File

@ -100,11 +100,13 @@ class qtype_truefalse_renderer extends qtype_renderer {
array('class' => 'qtext'));
$result .= html_writer::start_tag('fieldset', array('class' => 'ablock'));
$legendclass = 'sr-only';
if (!empty($question->showstandardinstruction)) {
$legendclass = '';
$questionnumber = $options->add_question_identifier_to_label(get_string('selectone', 'qtype_truefalse'), true, true);
} else {
$legendclass = 'sr-only';
$questionnumber = $options->add_question_identifier_to_label(get_string('answer'), true, true);
}
$questionnumber = $options->add_question_identifier_to_label(get_string('selectone', 'qtype_truefalse'), true, true);
$result .= html_writer::tag('legend', $questionnumber,
array('class' => 'prompt h6 font-weight-normal ' . $legendclass));

View File

@ -155,7 +155,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base {
$this->render();
// Check for 'Show standard instruction'.
$standardinstruction = \html_writer::tag('legend', get_string('selectone', 'qtype_truefalse'), [
$standardinstruction = \html_writer::tag('legend', get_string('answer'), [
'class' => 'prompt h6 font-weight-normal sr-only'
]);
$this->assertStringContainsString($standardinstruction, $this->currentoutput);