From 8d8af19af0fd3560ecbefed9db44649783e79837 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 21 Jun 2023 22:20:03 +0800 Subject: [PATCH 1/3] MDL-78542 mod_url: Use the module name for the URL resource's link text --- mod/url/locallib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mod/url/locallib.php b/mod/url/locallib.php index b3998efae91..02ac7568eba 100644 --- a/mod/url/locallib.php +++ b/mod/url/locallib.php @@ -277,7 +277,7 @@ function url_print_workaround($url, $cm, $course) { } echo '
'; - print_string('clicktoopen', 'url', "$fullurl"); + print_string('clicktoopen', 'url', html_writer::link($fullurl, format_string($cm->name))); echo '
'; echo $OUTPUT->footer(); @@ -289,7 +289,6 @@ function url_print_workaround($url, $cm, $course) { * @param object $url * @param object $cm * @param object $course - * @return does not return */ function url_display_embed($url, $cm, $course) { global $PAGE, $OUTPUT; @@ -298,7 +297,7 @@ function url_display_embed($url, $cm, $course) { $fullurl = url_get_full_url($url, $cm, $course); $title = $url->name; - $link = html_writer::tag('a', $fullurl, array('href'=>str_replace('&', '&', $fullurl))); + $link = html_writer::link($fullurl, format_string($cm->name)); $clicktoopen = get_string('clicktoopen', 'url', $link); $moodleurl = new moodle_url($fullurl); From e8b3a7e766f62855f1ede2752284f0c27f38d816 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 21 Jun 2023 22:54:09 +0800 Subject: [PATCH 2/3] MDL-78542 mod_url: Add a help text for URL resource name field Add a help text explaining that the URL resource's name field will be used for the link text. Also add basic guidelines about naming links for the benefit of screen reader users. --- mod/url/lang/en/url.php | 6 ++++++ mod/url/mod_form.php | 1 + 2 files changed, 7 insertions(+) diff --git a/mod/url/lang/en/url.php b/mod/url/lang/en/url.php index 15ac7e07a54..dd2934ff37b 100644 --- a/mod/url/lang/en/url.php +++ b/mod/url/lang/en/url.php @@ -64,6 +64,12 @@ There are a number of display options for the URL, such as embedded or opening i Note that URLs can also be added to any other resource or activity type through the text editor.'; $string['modulename_link'] = 'mod/url/view'; $string['modulenameplural'] = 'URLs'; +$string['name'] = 'Name'; +$string['name_help'] = 'This will serve as the link text for the URL. + +Enter a meaningful text that concisely describes the URL\'s purpose. + +Avoid using the word "link". This will help screen reader users as screen readers announce links (e.g. "Moodle.org, link") so there\'s no need to include the word "link" in the name field.'; $string['page-mod-url-x'] = 'Any URL module page'; $string['parameterinfo'] = '&parameter=variable'; $string['parametersheader'] = 'URL variables'; diff --git a/mod/url/mod_form.php b/mod/url/mod_form.php index eb3d2d0a191..099b8978231 100644 --- a/mod/url/mod_form.php +++ b/mod/url/mod_form.php @@ -38,6 +38,7 @@ class mod_url_mod_form extends moodleform_mod { //------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'48')); + $mform->addHelpButton('name', 'name', 'url'); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { From 88e8e0a5ca7d1c66cd6e0f068a14306789297a53 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 22 Jun 2023 09:51:21 +0800 Subject: [PATCH 3/3] MDL-78542 mod_url: clicktoopen lang string fix - Improve the grammatical structure of the lang string. - Remove the mention of "link", for sighted users, it should already be obvious that it's a link. For screen reader users, screen readers already announce links. So it would be confusing for them to hear something like "Click 'Moodle.org, link' link to open resource" --- mod/url/lang/en/url.php | 2 +- mod/url/tests/behat/url_activity_completion.feature | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/url/lang/en/url.php b/mod/url/lang/en/url.php index dd2934ff37b..a8ca6fb0ea2 100644 --- a/mod/url/lang/en/url.php +++ b/mod/url/lang/en/url.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['clicktoopen'] = 'Click {$a} link to open resource.'; +$string['clicktoopen'] = 'Click on {$a} to open the resource.'; $string['configdisplayoptions'] = 'Select all options that should be available, existing settings are not modified. Hold CTRL key to select multiple fields.'; $string['configframesize'] = 'When a web page or an uploaded file is displayed within a frame, this value is the height (in pixels) of the top frame (which contains the navigation).'; $string['configrolesinparams'] = 'Should customised role names (from the course settings) be available as variables for URL parameters?'; diff --git a/mod/url/tests/behat/url_activity_completion.feature b/mod/url/tests/behat/url_activity_completion.feature index b2da6473ff3..f87c4c816b5 100644 --- a/mod/url/tests/behat/url_activity_completion.feature +++ b/mod/url/tests/behat/url_activity_completion.feature @@ -31,7 +31,9 @@ Feature: View activity completion information in the URL resource | completionview | 1 | | display | 0 | When I am on the "Music history" "url activity" page logged in as teacher1 - Then "Music history" should have the "View" completion condition + Then "Music history" "link" should exist + And I should see "Click on Music history to open the resource." + And "Music history" should have the "View" completion condition Scenario: View automatic completion items in automatic display mode as student Given the following "activity" exists: