From 6d9a45f38815bbf9f95bae8e73263b273d2ed0f6 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 11 Jul 2023 15:29:28 +0100 Subject: [PATCH] MDL-76123 course: multilingual module icon alt text attribute. --- .../classes/output/local/content/cm/cmicon.php | 6 ++---- .../templates/local/content/cm/cmicon.mustache | 13 +++++++++---- .../tests/behat/activity_icon_tooltip.feature | 12 ++++++------ lang/en/moodle.php | 1 + 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/course/format/classes/output/local/content/cm/cmicon.php b/course/format/classes/output/local/content/cm/cmicon.php index f9363040ddc27..cab679e6ca512 100644 --- a/course/format/classes/output/local/content/cm/cmicon.php +++ b/course/format/classes/output/local/content/cm/cmicon.php @@ -84,13 +84,11 @@ public function export_for_template(\renderer_base $output): array { 'icon' => $iconurl, 'iconclass' => $iconclass, 'modname' => $mod->modname, + 'pluginname' => get_string('pluginname', 'mod_' . $mod->modname), + 'showtooltip' => $this->format->show_editor(), 'purpose' => plugin_supports('mod', $mod->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER), ]; - if ($this->format->show_editor()) { - $data['pluginname'] = get_string('pluginname', 'mod_' . $mod->modname); - } - return $data; } diff --git a/course/format/templates/local/content/cm/cmicon.mustache b/course/format/templates/local/content/cm/cmicon.mustache index 4a77d7a84a3f4..8d4451a3d076b 100644 --- a/course/format/templates/local/content/cm/cmicon.mustache +++ b/course/format/templates/local/content/cm/cmicon.mustache @@ -27,21 +27,26 @@ "iconclass": "", "purpose": "content", "modname": "resource", - "pluginname": "File" + "pluginname": "File", + "showtooltip": 1 } }} {{#url}} {{#uservisible}} - {{{modname}}} icon + {{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}} {{/uservisible}} {{^uservisible}}
- {{{modname}}} icon + {{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}}
{{/uservisible}} {{/url}} diff --git a/course/format/tests/behat/activity_icon_tooltip.feature b/course/format/tests/behat/activity_icon_tooltip.feature index 383446a7cf714..861ec2fb998e2 100644 --- a/course/format/tests/behat/activity_icon_tooltip.feature +++ b/course/format/tests/behat/activity_icon_tooltip.feature @@ -25,19 +25,19 @@ Feature: Activity type tooltip. Scenario: Teacher can see the activity type tooltip only while editing. Given I am on the "C1" "Course" page logged in as "teacher1" - And I hover over the "assign icon" "link" in the "Activity sample 1" "activity" + And I hover over the "Assignment icon" "link" in the "Activity sample 1" "activity" And "body>.tooltip" "css_element" should not exist - And I hover over the "page icon" "link" in the "Activity sample 2" "activity" + And I hover over the "Page icon" "link" in the "Activity sample 2" "activity" And "body>.tooltip" "css_element" should not exist And I turn editing mode on - When I hover over the "assign icon" "link" in the "Activity sample 1" "activity" + When I hover over the "Assignment icon" "link" in the "Activity sample 1" "activity" Then I should see "Assignment" in the "body>.tooltip" "css_element" - And I hover over the "page icon" "link" in the "Activity sample 2" "activity" + And I hover over the "Page icon" "link" in the "Activity sample 2" "activity" And I should see "Page" in the "body>.tooltip" "css_element" Scenario: Student cannot see the activity type tooltip. Given I am on the "C1" "Course" page logged in as "student1" - When I hover over the "assign icon" "link" in the "Activity sample 1" "activity" + When I hover over the "Assignment icon" "link" in the "Activity sample 1" "activity" Then "body>.tooltip" "css_element" should not exist Scenario: Student cannot see the activity icon link if does not have access. @@ -51,4 +51,4 @@ Feature: Activity type tooltip. And I press "Save and return to course" And I log out And I am on the "C1" "Course" page logged in as "student1" - Then "page icon" "link" should not exist in the "Activity sample 2" "activity" + Then "Page icon" "link" should not exist in the "Activity sample 2" "activity" diff --git a/lang/en/moodle.php b/lang/en/moodle.php index b989715647ce7..da7bf6c701664 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -34,6 +34,7 @@ $string['activities_help'] = 'Activities, such as forums, quizzes and wikis, enable interactive content to be added to the course.'; $string['activity'] = 'Activity'; $string['activityclipboard'] = 'Moving this activity: {$a}'; +$string['activityicon'] = '{$a} icon'; $string['activityiscurrentlyhidden'] = 'Sorry, this activity is currently hidden'; $string['activityheader'] = 'Activity menu'; $string['activitymodule'] = 'Activity module';