Skip to content

Commit

Permalink
Merge branch 'MDL-80384-main' of https://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Mar 26, 2024
2 parents b283ca3 + da27f51 commit 638de60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
31 changes: 10 additions & 21 deletions course/format/templates/local/content/cm/cmicon.mustache
Expand Up @@ -21,8 +21,6 @@
Example context (json):
{
"uservisible": true,
"url": "#",
"icon": "../../../pix/help.svg",
"iconclass": "",
"purpose": "content",
Expand All @@ -32,22 +30,13 @@
"showtooltip": 1
}
}}
{{#url}}
{{#uservisible}}
<a href="{{url}}"
class="activity-icon activityiconcontainer smaller {{purpose}} {{#branded}}isbranded{{/branded}} btn btn-link courseicon align-self-start mr-2"
{{#showtooltip}}data-toggle="tooltip" title="{{{pluginname}}}" data-placement="top"{{/showtooltip}}
>
<img src="{{{icon}}}" class="activityicon {{iconclass}}"
alt="{{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}}"
>
</a>
{{/uservisible}}
{{^uservisible}}
<div class="activity-icon activityiconcontainer smaller {{purpose}} {{#branded}}isbranded{{/branded}} courseicon align-self-start mr-2">
<img src="{{{icon}}}" class="activityicon {{iconclass}}"
alt="{{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}}"
>
</div>
{{/uservisible}}
{{/url}}
<div class="activity-icon activityiconcontainer smaller {{purpose}} {{#branded}}isbranded{{/branded}} courseicon align-self-start mr-2">
<img
src="{{{icon}}}"
class="activityicon {{iconclass}}"
data-region="activity-icon"
data-id="{{cmid}}"
alt="{{#showtooltip}}{{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}}{{/showtooltip}}"
{{#showtooltip}}title="{{{pluginname}}}"{{/showtooltip}}
>
</div>
15 changes: 5 additions & 10 deletions course/format/tests/behat/activity_icon_tooltip.feature
Expand Up @@ -25,20 +25,15 @@ 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 "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 "body>.tooltip" "css_element" should not exist
And the "title" attribute of "Activity sample 1" "core_courseformat > Activity icon" should not be set
And the "title" attribute of "Activity sample 2" "core_courseformat > Activity icon" should not be set
And I turn editing mode on
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 should see "Page" in the "body>.tooltip" "css_element"
Then the "title" attribute of "Activity sample 1" "core_courseformat > Activity icon" should contain "Assignment"
And the "title" attribute of "Activity sample 2" "core_courseformat > Activity icon" should contain "Page"

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 "Assignment icon" "link" in the "Activity sample 1" "activity"
Then "body>.tooltip" "css_element" should not exist
Then the "title" attribute of "Activity sample 1" "core_courseformat > Activity icon" should not be set

Scenario: Student cannot see the activity icon link if does not have access.
Given I am on the "Activity sample 2" "page activity editing" page logged in as "admin"
Expand Down
3 changes: 3 additions & 0 deletions course/format/tests/behat/behat_courseformat.php
Expand Up @@ -44,6 +44,9 @@ public static function get_partial_named_selectors(): array {
new behat_component_named_selector('Activity visibility', [
".//*[@data-activityname=%locator%]//*[@data-region='visibility']",
]),
new behat_component_named_selector('Activity icon', [
".//*[@data-activityname=%locator%]//*[@data-region='activity-icon']",
]),
];
}
}

0 comments on commit 638de60

Please sign in to comment.