Skip to content

Commit

Permalink
MDL-74205 navigation: Don't show participants link to user if he has …
Browse files Browse the repository at this point in the history
…no permission.
  • Loading branch information
ilyatregubov committed Mar 30, 2022
1 parent efda17d commit 053785f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions blocks/navigation/tests/behat/participants_link.feature
Expand Up @@ -37,6 +37,35 @@ Feature: Displaying the link to the Participants page
And "Student One" "link" should exist
And "Student Two" "link" should not exist

@javascript
Scenario: Course participants link is displayed to users depending on role permissions settings
And I log in as "admin"
And I am on "Course1" course homepage with editing mode on
And I add a "Forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I am on the "Course1" "enrolment methods" page
And I click on "Edit" "link" in the "Guest access" "table_row"
And I set the following fields to these values:
| Allow guest access | Yes |
And I press "Save changes"
And I log out
When I log in as "guest"
And I am on "Course1" course homepage
Then I should not see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should not see "Participants" in the "Navigation" "block"
And I log out
And I log in as "admin"
And I set the following system permissions of "Guest" role:
| capability | permission |
| moodle/course:viewparticipants | Allow |
And I log in as "guest"
And I am on "Course1" course homepage
And I should see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should see "Participants" in the "Navigation" "block"

Scenario: Site participants link is displayed to admins
When I log in as "admin"
Then "Participants" "link" should exist in the "Navigation" "block"
Expand Down
4 changes: 2 additions & 2 deletions lib/navigationlib.php
Expand Up @@ -2939,8 +2939,8 @@ public function add_course_essentials($coursenode, stdClass $course) {
if ($navoptions->notes) {
$participants->add(get_string('notes', 'notes'), new moodle_url('/notes/index.php', array('filtertype' => 'course', 'filterselect' => $course->id)), self::TYPE_SETTING, null, 'currentcoursenotes');
}
} else if (count($this->extendforuser) > 0 || $this->page->course->id == $course->id) {
$participants = $coursenode->add(get_string('participants'), null, self::TYPE_CONTAINER, get_string('participants'), 'participants');
} else if (count($this->extendforuser) > 0) {
$coursenode->add(get_string('participants'), null, self::TYPE_CONTAINER, get_string('participants'), 'participants');
}

// Badges.
Expand Down

0 comments on commit 053785f

Please sign in to comment.