MDL-78708 core_courseformat: Fix activity icon link shown without access
In course page activity icon was showing as a link even when the user does not have access to the activity. This commit fixes this behaviour checking if activity is visible for the user and showing the icon without link if not.
This commit is contained in:
@@ -79,6 +79,7 @@ class cmicon implements named_templatable, renderable {
|
||||
$iconurl = $mod->get_icon_url();
|
||||
$iconclass = $iconurl->get_param('filtericon') ? '' : 'nofilter';
|
||||
$data = [
|
||||
'uservisible' => $mod->uservisible,
|
||||
'url' => $mod->url,
|
||||
'icon' => $iconurl,
|
||||
'iconclass' => $iconclass,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"uservisible": true,
|
||||
"url": "#",
|
||||
"icon": "../../../pix/help.svg",
|
||||
"iconclass": "",
|
||||
@@ -30,10 +31,17 @@
|
||||
}
|
||||
}}
|
||||
{{#url}}
|
||||
<a href="{{url}}"
|
||||
class="activity-icon activityiconcontainer smaller {{purpose}} btn btn-link courseicon align-self-start mr-2"
|
||||
{{#pluginname}}data-toggle="tooltip" title="{{{pluginname}}}" data-placement="top"{{/pluginname}}
|
||||
>
|
||||
<img src="{{{icon}}}" class="activityicon {{iconclass}}" alt="{{{modname}}} icon">
|
||||
</a>
|
||||
{{#uservisible}}
|
||||
<a href="{{url}}"
|
||||
class="activity-icon activityiconcontainer smaller {{purpose}} btn btn-link courseicon align-self-start mr-2"
|
||||
{{#pluginname}}data-toggle="tooltip" title="{{{pluginname}}}" data-placement="top"{{/pluginname}}
|
||||
>
|
||||
<img src="{{{icon}}}" class="activityicon {{iconclass}}" alt="{{{modname}}} icon">
|
||||
</a>
|
||||
{{/uservisible}}
|
||||
{{^uservisible}}
|
||||
<div class="activity-icon activityiconcontainer smaller {{purpose}} courseicon align-self-start mr-2">
|
||||
<img src="{{{icon}}}" class="activityicon {{iconclass}}" alt="{{{modname}}} icon">
|
||||
</div>
|
||||
{{/uservisible}}
|
||||
{{/url}}
|
||||
|
||||
@@ -39,3 +39,16 @@ Feature: 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"
|
||||
Then "body>.tooltip" "css_element" should not exist
|
||||
|
||||
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"
|
||||
When I expand all fieldsets
|
||||
And I press "Add restriction..."
|
||||
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
||||
And I set the field "direction" to "until"
|
||||
And I set the field "x[year]" to "2013"
|
||||
And I set the field "x[month]" to "March"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user