Merge branch 'MDL-55667-master-participantslink' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2016-08-29 16:53:46 +02:00
commit ff536f4b37
2 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,45 @@
@block @block_navigation
Feature: Displaying the link to the Participants page
In order to see the course / site participants
As a student / admin respectively
I need a link to the Participants page be displayed (but only if I can access that page)
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | One | student1@example.com |
| student2 | Student | Two | student2@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
@javascript
Scenario: Course participants link is displayed to enrolled students after expanding the course node
When I log in as "student1"
And I expand "C1" node
Then "Participants" "link" should exist in the "Navigation" "block"
And I navigate to "Participants" node in "My courses > C1"
And I should see "Participants"
And "Student One" "link" should exist
And "Student Two" "link" should not exist
Scenario: Site participants link is displayed to admins
When I log in as "admin"
Then "Participants" "link" should exist in the "Navigation" "block"
And I navigate to "Participants" node in "Site pages"
And I should see "Participants"
And "Student One" "link" should exist
And "Student Two" "link" should exist
@javascript
Scenario: Site participants link is not displayed to students (MDL-55667)
Given I log in as "admin"
And I set the following administration settings values:
| defaultfrontpageroleid | Student (student) |
And I log out
When I log in as "student2"
And I expand "Site pages" node
Then "Participants" "link" should not exist in the "Navigation" "block"

View File

@ -2600,6 +2600,7 @@ class global_navigation extends navigation_node {
}
$sitecontext = context_system::instance();
$isfrontpage = ($course->id == SITEID);
// Hidden node that we use to determine if the front page navigation is loaded.
// This required as there are not other guaranteed nodes that may be loaded.
@ -2608,8 +2609,8 @@ class global_navigation extends navigation_node {
// Participants.
// If this is the site course, they need to have moodle/site:viewparticipants at the site level.
// If no, then they need to have moodle/course:viewparticipants at the course level.
if ((($course->id == SITEID) && has_capability('moodle/site:viewparticipants', $sitecontext)) ||
has_capability('moodle/course:viewparticipants', context_course::instance($course->id))) {
if (($isfrontpage && has_capability('moodle/site:viewparticipants', $sitecontext)) ||
(!$isfrontpage && has_capability('moodle/course:viewparticipants', context_course::instance($course->id)))) {
$coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants');
}