From 59d5458c7f9bd7c6bc5c3e5c1c8cfee341c63e54 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 21 Aug 2023 21:38:34 +0800 Subject: [PATCH 1/3] MDL-79059 mod_data: Fix presets accessibility issues * Add sr-only column headers for the select and actions columns. * Define unique IDs for the preset name links using array indices. * Label the radio buttons via aria-labelledby attribute pointing to the ID of the preset's link. --- mod/data/classes/output/presets.php | 3 +- mod/data/templates/presets.mustache | 46 ++++++++++++++++------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/mod/data/classes/output/presets.php b/mod/data/classes/output/presets.php index 8eb9542c607..2f3b856c40b 100644 --- a/mod/data/classes/output/presets.php +++ b/mod/data/classes/output/presets.php @@ -90,7 +90,7 @@ class presets implements templatable, renderable { */ private function get_presets(renderer_base $output): array { $presets = []; - foreach ($this->presets as $preset) { + foreach ($this->presets as $index => $preset) { $presetname = $preset->name; $userid = $preset instanceof preset ? $preset->get_userid() : $preset->userid; if (!empty($userid)) { @@ -120,6 +120,7 @@ class presets implements templatable, renderable { 'description' => $preset->description, 'userid' => $userid, 'actions' => $actions, + 'presetindex' => $index, ]; } diff --git a/mod/data/templates/presets.mustache b/mod/data/templates/presets.mustache index 50433eefa3e..5d51ea965e6 100644 --- a/mod/data/templates/presets.mustache +++ b/mod/data/templates/presets.mustache @@ -35,7 +35,8 @@ "description": "Use this preset to collect images", "userid": 0, "url": "http://www.example.com", - "actions": [] + "actions": [], + "presetindex": 0 }, { "id": 2, @@ -45,7 +46,8 @@ "fullname": "Preset saved manually (admin)", "userid": 2, "url": "http://www.example.com", - "actions": [] + "actions": [], + "presetindex": 1 } ] } @@ -60,30 +62,34 @@ - + - + {{#presets}} - - - - - - + + + + + + {{/presets}}
+ {{#str}}select{{/str}} + {{#str}} name {{/str}} {{#str}} description {{/str}} + {{#str}}actions{{/str}} +
- - - {{fullname}} - {{description}} - {{#actions}} -
- {{>core/action_menu}} -
- {{/actions}} -
+ + + {{fullname}} + {{description}} + {{#actions}} +
+ {{>core/action_menu}} +
+ {{/actions}} +
From f9c46d0026788b0f1d760d7a41c88d6670347534 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 21 Aug 2023 21:44:19 +0800 Subject: [PATCH 2/3] MDL-79059 mod_data: Enclose preset options within a fieldset Enclosing the radio buttons in a fieldset to provide additional context to the purpose of the fields. --- mod/data/templates/presets.mustache | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mod/data/templates/presets.mustache b/mod/data/templates/presets.mustache index 5d51ea965e6..d8df0533474 100644 --- a/mod/data/templates/presets.mustache +++ b/mod/data/templates/presets.mustache @@ -59,8 +59,10 @@ - - +
+ {{#str}}presets, mod_data{{/str}} +
+ - - + + {{#presets}} {{/presets}} - -
{{#str}}select{{/str}} @@ -71,8 +73,8 @@ {{#str}}actions{{/str}}
@@ -91,8 +93,9 @@
+ + + {{< core/sticky_footer }} {{$ stickycontent }} From 896d5fd05a6947282760edc95e8462065023ceb1 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 21 Aug 2023 22:41:22 +0800 Subject: [PATCH 3/3] MDL-79059 core: Use full name as alt text for user picture links When the user picture is being rendered as a link but the user's full name is not being included in the link and the alt text turns out to be empty, we could end up with a link without a discernible text. This is an accessibility issue that will affect screen reader users. If this is the case, use the full name as the user picture's alt text. --- lib/outputrenderers.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 59bfce5ce7d..cecc624bf9a 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2656,10 +2656,18 @@ class core_renderer extends renderer_base { $alt = ''; if ($userpicture->alttext) { if (!empty($user->imagealt)) { - $alt = $user->imagealt; + $alt = trim($user->imagealt); } } + // If the user picture is being rendered as a link but without the full name, an empty alt text for the user picture + // would mean that the link displayed will not have any discernible text. This becomes an accessibility issue, + // especially to screen reader users. Use the user's full name by default for the user picture's alt-text if this is + // the case. + if ($userpicture->link && !$userpicture->includefullname && empty($alt)) { + $alt = fullname($user); + } + if (empty($userpicture->size)) { $size = 35; } else if ($userpicture->size === true or $userpicture->size == 1) {