From f380f3f560ec80193ecf4350f365bbb905319825 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 29 Aug 2025 21:51:35 +0800 Subject: [PATCH 1/3] MDL-86498 badges: Accessibility coverage for badge details and overview --- badges/tests/behat/badge_overview.feature | 21 +++++++++++++++++++++ badges/tests/behat/view_badge.feature | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 badges/tests/behat/badge_overview.feature diff --git a/badges/tests/behat/badge_overview.feature b/badges/tests/behat/badge_overview.feature new file mode 100644 index 00000000000..1969682fde2 --- /dev/null +++ b/badges/tests/behat/badge_overview.feature @@ -0,0 +1,21 @@ +@core @core_badges +Feature: Badge overview + In order to view a badge's information + As an user with the capability to view badges + I need to access the badge overview page + + Background: + Given the following config values are set as admin: + | badges_defaultissuername | Test Badge Site | + + @javascript @accessibility @_file_upload + Scenario: Test accessibility of badge overview page + Given I log in as "admin" + And I navigate to "Badges > Add a new badge" in site administration + And I set the following fields to these values: + | Name | Cool badge | + | Description | Badge for cool people | + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager + And I press "Create badge" + When I select "Overview" from the "Badges navigation" singleselect + Then the "region-main" "region" should meet accessibility standards with "best-practice" extra tests diff --git a/badges/tests/behat/view_badge.feature b/badges/tests/behat/view_badge.feature index e09d74017c1..5c2ac909b3d 100644 --- a/badges/tests/behat/view_badge.feature +++ b/badges/tests/behat/view_badge.feature @@ -23,6 +23,7 @@ Feature: Display badges And I log in as "admin" And I navigate to "Badges > Manage badges" in site administration + @accessibility Scenario: Display badge without expired date # Enable the badge. Given I press "Enable access" action in the "Testing system badge" report row @@ -43,6 +44,7 @@ Feature: Display badges And I follow "More details" And I should see "Catalan" And I should see "1.1" + And the page should meet accessibility standards with "best-practice" extra tests Scenario: Display badge with ALL criteria # Add another criterion and enable the badge. From 6c06b5f1ef520ee086359cc63ed1722e60a4f639 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 29 Aug 2025 21:52:17 +0800 Subject: [PATCH 2/3] MDL-86498 badges: Add label for badge navigation url_select --- badges/classes/output/manage_badge_action_bar.php | 4 +++- lang/en/badges.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/badges/classes/output/manage_badge_action_bar.php b/badges/classes/output/manage_badge_action_bar.php index a887bffe903..06e2367367e 100644 --- a/badges/classes/output/manage_badge_action_bar.php +++ b/badges/classes/output/manage_badge_action_bar.php @@ -69,7 +69,9 @@ class manage_badge_action_bar extends base_action_bar { $elements['button'] = new single_button(new moodle_url('/badges/index.php', $params), get_string('back'), 'get'); $badgenav = $this->generate_badge_navigation(); if ($badgenav) { - $elements['urlselect'] = new url_select($badgenav, $this->page->url->out(false), null); + $badgenavselect = new url_select($badgenav, $this->page->url->out(false), null); + $badgenavselect->set_label(get_string('badgesnavigation', 'badges'), ['class' => 'visually-hidden']); + $elements['urlselect'] = $badgenavselect; } foreach ($elements as $key => $element) { $elements[$key] = $element->export_for_template($output); diff --git a/lang/en/badges.php b/lang/en/badges.php index f46d259b476..d692d29d759 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -145,6 +145,7 @@ $string['backpackapiurl'] = 'Backpack API URL'; $string['backpackweburl'] = 'Backpack URL'; $string['backpackprovider'] = 'Backpack provider'; $string['badges'] = 'Badges'; +$string['badgesnavigation'] = 'Badges navigation'; $string['badgedetails'] = 'Badge details'; $string['badgeimage'] = 'Image'; $string['badgeimageinfo'] = 'For best results, upload a square image with a minimum size of 300 x 300 pixels.'; From c8ac5fd27d3a4893379cc184bc5ec43e0cd76737 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 29 Aug 2025 22:59:06 +0800 Subject: [PATCH 3/3] MDL-86498 badges: Empty string for empty links --- badges/renderer.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/badges/renderer.php b/badges/renderer.php index 43979dcff1e..4f7fcdf1413 100644 --- a/badges/renderer.php +++ b/badges/renderer.php @@ -195,12 +195,22 @@ class core_badges_renderer extends plugin_renderer_base { $display .= $this->heading(get_string('issuerdetails', 'badges'), 3); $dl = array(); $dl[get_string('issuername', 'badges')] = $badge->issuername; - $dl[get_string('contact', 'badges')] = html_writer::tag('a', $badge->issuercontact, array('href' => 'mailto:' . $badge->issuercontact)); - $dl[get_string('issuerurl', 'badges')] = html_writer::tag( - 'a', - $badge->issuerurl, - ['href' => $badge->issuerurl, 'target' => '_blank'], - ); + $dl[get_string('contact', 'badges')] = ''; + if (trim($badge->issuercontact)) { + $dl[get_string('contact', 'badges')] = html_writer::tag( + 'a', + $badge->issuercontact, + ['href' => 'mailto:' . $badge->issuercontact], + ); + } + $dl[get_string('issuerurl', 'badges')] = ''; + if (trim($badge->issuerurl)) { + $dl[get_string('issuerurl', 'badges')] = html_writer::tag( + 'a', + $badge->issuerurl, + ['href' => $badge->issuerurl, 'target' => '_blank'], + ); + } $display .= $this->definition_list($dl); // Issuance details if any.