diff --git a/renderer.php b/renderer.php index 4f952d82..7c34308a 100644 --- a/renderer.php +++ b/renderer.php @@ -283,12 +283,12 @@ protected function create_radio_mc_answer( $output = html_writer::start_tag('fieldset', ['class' => 'multichoice_answer']); // Inside the fieldset, we put the accessibility label, following the example of core's multichoice - // question type, i. e. the label is inside a with class 'sr-only', wrapped in a . + // question type, i. e. the label is inside a with class 'visually-hidden', wrapped in a . // TODO: we should use visually-hidden after dropping Moodle 4.5. - $output .= html_writer::start_tag('legend', ['class' => 'sr-only']); + $output .= html_writer::start_tag('legend', ['class' => 'visually-hidden']); $output .= html_writer::span( $this->generate_accessibility_label_text($answerindex, $part->numbox, $part->partindex, $question->numparts), - 'sr-only' + 'visually-hidden' ); $output .= html_writer::end_tag('legend'); @@ -422,7 +422,7 @@ protected function get_css_properties(array $options): string { protected function create_label_for_input(string $text, string $inputid, array $additionalattributes = []): array { $labelid = 'lbl_' . str_replace(':', '__', $inputid); $attributes = [ - 'class' => 'subq sr-only', + 'class' => 'subq visually-hidden', 'for' => $inputid, 'id' => $labelid, ]; diff --git a/tests/renderer_test.php b/tests/renderer_test.php index 5434e0bb..994313c7 100644 --- a/tests/renderer_test.php +++ b/tests/renderer_test.php @@ -727,7 +727,7 @@ public function test_render_mce_question(): void { new \question_contains_tag_with_attribute('select', 'name', $this->quba->get_field_prefix($this->slot) . '0_0'), $this->get_does_not_contain_specific_feedback_expectation(), new \question_contains_tag_with_contents('label', 'Answer'), - new \question_contains_tag_with_attribute('label', 'class', 'subq sr-only'), + new \question_contains_tag_with_attribute('label', 'class', 'subq visually-hidden'), ); $this->check_output_contains_selectoptions( $this->get_contains_select_expectation('0_0', ['Dog', 'Cat', 'Bird', 'Fish'], 0) @@ -894,8 +894,8 @@ public function test_render_mc_accessibility_labels(): void { $q = $this->get_test_formulas_question('testmc'); $this->start_attempt_at_question($q, 'immediatefeedback', 1); $this->check_current_output( - new \question_contains_tag_with_attribute('legend', 'class', 'sr-only'), - new \question_contains_tag_with_attribute('span', 'class', 'sr-only'), + new \question_contains_tag_with_attribute('legend', 'class', 'visually-hidden'), + new \question_contains_tag_with_attribute('span', 'class', 'visually-hidden'), new \question_contains_tag_with_contents('span', 'Answer'), ); @@ -905,7 +905,7 @@ public function test_render_mc_accessibility_labels(): void { $q->parts[0]->answer = '[1, 1]'; $this->start_attempt_at_question($q, 'immediatefeedback', 1); $this->check_current_output( - new \question_contains_tag_with_attribute('legend', 'class', 'sr-only'), + new \question_contains_tag_with_attribute('legend', 'class', 'visually-hidden'), new \question_contains_tag_with_contents('span', 'Answer field 1'), new \question_contains_tag_with_contents('label', 'Answer field 2'), ); @@ -919,7 +919,7 @@ public function test_render_mc_accessibility_labels(): void { $this->start_attempt_at_question($q, 'immediatefeedback', 1); $this->check_current_output( - new \question_contains_tag_with_attribute('legend', 'class', 'sr-only'), + new \question_contains_tag_with_attribute('legend', 'class', 'visually-hidden'), new \question_contains_tag_with_contents('span', 'Answer field 1 for part 1'), new \question_contains_tag_with_contents('label', 'Answer field 2 for part 1'), new \question_contains_tag_with_contents('span', 'Answer field 1 for part 2'),