MDL-76849 qtype_truefalse: Include question number in answer fields
* Improve accessibility as well by grouping the radio buttons in a fieldset.
This commit is contained in:
@@ -99,11 +99,14 @@ class qtype_truefalse_renderer extends qtype_renderer {
|
||||
$result .= html_writer::tag('div', $question->format_questiontext($qa),
|
||||
array('class' => 'qtext'));
|
||||
|
||||
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
|
||||
$result .= html_writer::start_tag('fieldset', array('class' => 'ablock'));
|
||||
$legendclass = 'sr-only';
|
||||
if (!empty($question->showstandardinstruction)) {
|
||||
$result .= html_writer::tag('div', get_string('selectone', 'qtype_truefalse'),
|
||||
array('class' => 'prompt'));
|
||||
$legendclass = '';
|
||||
}
|
||||
$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));
|
||||
|
||||
$result .= html_writer::start_tag('div', array('class' => 'answer'));
|
||||
$result .= html_writer::tag('div', $radiotrue . ' ' . $truefeedbackimg,
|
||||
@@ -112,7 +115,7 @@ class qtype_truefalse_renderer extends qtype_renderer {
|
||||
array('class' => 'r1' . $falseclass));
|
||||
$result .= html_writer::end_tag('div'); // Answer.
|
||||
|
||||
$result .= html_writer::end_tag('div'); // Ablock.
|
||||
$result .= html_writer::end_tag('fieldset'); // Ablock.
|
||||
|
||||
if ($qa->get_state() == question_state::$invalid) {
|
||||
$result .= html_writer::nonempty_tag('div',
|
||||
|
||||
@@ -155,7 +155,9 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base {
|
||||
$this->render();
|
||||
|
||||
// Check for 'Show standard instruction'.
|
||||
$standardinstruction = get_string('selectone', 'qtype_truefalse');
|
||||
$this->assertStringNotContainsString($standardinstruction, $this->currentoutput);
|
||||
$standardinstruction = \html_writer::tag('legend', get_string('selectone', 'qtype_truefalse'), [
|
||||
'class' => 'prompt h6 font-weight-normal sr-only'
|
||||
]);
|
||||
$this->assertStringContainsString($standardinstruction, $this->currentoutput);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user