From ea697ca8a0c821a18afb43dddf82083c3bfdbcff Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 5 Jan 2023 22:16:20 +1100 Subject: [PATCH] MDL-76603 gradingform_rubric: fix roles - set the role of table to none - moved aria-label from element (that doesn't has role="none") to the element that has the radiogroup role - if it's not radiogroup/radio, it is list/listitem - removed aria-label from the rubric table and used caption instead --- grade/grading/form/rubric/renderer.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/grade/grading/form/rubric/renderer.php b/grade/grading/form/rubric/renderer.php index dc52ad6374c..6017a553ea6 100644 --- a/grade/grading/form/rubric/renderer.php +++ b/grade/grading/form/rubric/renderer.php @@ -119,7 +119,10 @@ class gradingform_rubric_renderer extends plugin_renderer_base { $criteriontemplate .= html_writer::tag('td', $description, $descriptiontdparams); // Levels table. - $levelsrowparams = array('id' => '{NAME}-criteria-{CRITERION-id}-levels'); + $levelsrowparams = [ + 'id' => '{NAME}-criteria-{CRITERION-id}-levels', + 'aria-label' => get_string('levelsgroup', 'gradingform_rubric'), + ]; // Add radiogroup role only when not previewing or editing. $isradiogroup = !in_array($mode, [ gradingform_rubric_controller::DISPLAY_EDIT_FULL, @@ -127,15 +130,13 @@ class gradingform_rubric_renderer extends plugin_renderer_base { gradingform_rubric_controller::DISPLAY_PREVIEW, gradingform_rubric_controller::DISPLAY_PREVIEW_GRADED, ]); - if ($isradiogroup) { - $levelsrowparams['role'] = 'radiogroup'; - } + $levelsrowparams['role'] = $isradiogroup ? 'radiogroup' : 'list'; $levelsrow = html_writer::tag('tr', $levelsstr, $levelsrowparams); - $levelstableparams = array( + $levelstableparams = [ 'id' => '{NAME}-criteria-{CRITERION-id}-levels-table', - 'aria-label' => get_string('levelsgroup', 'gradingform_rubric') - ); + 'role' => 'none', + ]; $levelsstrtable = html_writer::tag('table', $levelsrow, $levelstableparams); $levelsclass = 'levels'; if (isset($criterion['error_levels'])) { @@ -311,7 +312,11 @@ class gradingform_rubric_renderer extends plugin_renderer_base { } else { $tdattributes['aria-checked'] = 'false'; } + } else { + $tdattributes['role'] = 'listitem'; } + } else { + $tdattributes['role'] = 'listitem'; } $leveltemplateparams = array( @@ -395,11 +400,12 @@ class gradingform_rubric_renderer extends plugin_renderer_base { $rubrictemplate = html_writer::start_tag('div', array('id' => 'rubric-{NAME}', 'class' => 'clearfix gradingform_rubric'.$classsuffix)); // Rubric table. - $rubrictableparams = array( + $rubrictableparams = [ 'class' => 'criteria', 'id' => '{NAME}-criteria', - 'aria-label' => get_string('rubric', 'gradingform_rubric')); - $rubrictable = html_writer::tag('table', $criteriastr, $rubrictableparams); + ]; + $caption = html_writer::tag('caption', get_string('rubric', 'gradingform_rubric'), ['class' => 'sr-only']); + $rubrictable = html_writer::tag('table', $caption . $criteriastr, $rubrictableparams); $rubrictemplate .= $rubrictable; if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FULL) { $value = get_string('addcriterion', 'gradingform_rubric');