diff --git a/badges/classes/output/manage_badge_action_bar.php b/badges/classes/output/manage_badge_action_bar.php index a887bffe903..ecf30c790bb 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' => 'sr-only']); + $elements['urlselect'] = $badgenavselect; } foreach ($elements as $key => $element) { $elements[$key] = $element->export_for_template($output); diff --git a/badges/renderer.php b/badges/renderer.php index 9649ce8f6d3..fd141faf7e4 100644 --- a/badges/renderer.php +++ b/badges/renderer.php @@ -187,10 +187,22 @@ class core_badges_renderer extends plugin_renderer_base { $dl[get_string('createdon', 'search')] = userdate($badge->timecreated); $dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large'); $dl[get_string('imageauthorname', 'badges')] = $badge->imageauthorname; - $dl[get_string('imageauthoremail', 'badges')] = - html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' . $badge->imageauthoremail)); - $dl[get_string('imageauthorurl', 'badges')] = - html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank')); + $dl[get_string('imageauthoremail', 'badges')] = ''; + if (trim($badge->imageauthoremail)) { + $dl[get_string('imageauthoremail', 'badges')] = html_writer::tag( + 'a', + $badge->imageauthoremail, + ['href' => 'mailto:' . $badge->imageauthoremail], + ); + } + $dl[get_string('imageauthorurl', 'badges')] = ''; + if (trim($badge->imageauthorurl)) { + $dl[get_string('imageauthorurl', 'badges')] = html_writer::link( + $badge->imageauthorurl, + $badge->imageauthorurl, + ['target' => '_blank'], + ); + } $dl[get_string('imagecaption', 'badges')] = $badge->imagecaption; $tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id); $dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, ''); @@ -200,12 +212,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. 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 bb1bcddf34d..ae507226312 100644 --- a/badges/tests/behat/view_badge.feature +++ b/badges/tests/behat/view_badge.feature @@ -24,6 +24,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 @@ -44,6 +45,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. diff --git a/lang/en/badges.php b/lang/en/badges.php index 3f5f4ec37fb..0410bc83c4f 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['badgeimage_help'] = 'The image should be at least 300 x 300 pixels in size. It will be displayed as 300 x 300 pixels on the badge page and 100 x 100 pixels on the user\'s profile page.';