forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-71466 admin: Add custom user field support to role screens
Implements custom user field support within the 'check capabilities' and 'assign roles' screens.
- Loading branch information
1 parent
a5f0b35
commit 9bc588a
Showing
7 changed files
with
157 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
@core @core_admin | ||
Feature: Staff can assign user roles | ||
In order to assign users to roles at site or activity module level | ||
As an admin | ||
I can add and remove users from the roles | ||
|
||
Background: | ||
Given the following "custom profile fields" exist: | ||
| datatype | shortname | name | | ||
| text | frog | Favourite frog | | ||
And the following config values are set as admin: | ||
| showuseridentity | email,profile_field_frog | | ||
And the following "users" exist: | ||
| username | firstname | lastname | email | profile_field_frog | | ||
| user1 | User | One | one@example.com | Kermit | | ||
| user2 | User | Two | two@example.com | Tree | | ||
And the following "courses" exist: | ||
| shortname | fullname | | ||
| C1 | Course 1 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| user1 | C1 | student | | ||
| user2 | C1 | student | | ||
And the following "activities" exist: | ||
| activity | name | course | idnumber | | ||
| page | TestPage | C1 | page1 | | ||
|
||
@javascript | ||
Scenario: Enrol at system level using custom field search | ||
When I am on the "C1" "Course" page logged in as "admin" | ||
And I navigate to "Users > Permissions > Assign system roles" in site administration | ||
And I follow "Manager" | ||
And I set the field "addselect_searchtext" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label*='Potential users matching'][label*=' (1)']" "css_element" should exist | ||
And I set the field "addselect" to "User One (one@example.com, Kermit)" | ||
And I press "Add" | ||
And I should see "User One" in the "#removeselect" "css_element" | ||
|
||
@javascript | ||
Scenario: Unenrol at system level using custom field search | ||
Given the following "role assigns" exist: | ||
| user | role | contextlevel | reference | | ||
| user1 | manager | System | | | ||
When I am on the "C1" "Course" page logged in as "admin" | ||
And I navigate to "Users > Permissions > Assign system roles" in site administration | ||
And I follow "Manager" | ||
And I set the field "removeselect_searchtext" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label*='Existing users matching'][label*=' (1)']" "css_element" should exist | ||
And I set the field "removeselect" to "User One (one@example.com, Kermit)" | ||
And I press "Remove" | ||
And I should not see "User One" in the "#removeselect" "css_element" | ||
|
||
@javascript | ||
Scenario: Enrol at activity level using custom field search | ||
When I am on the "page1" "Activity" page logged in as "admin" | ||
And I navigate to "Locally assigned roles" in current page administration | ||
And I follow "Teacher" | ||
And I set the field "addselect_searchtext" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label*='Potential users matching'][label*=' (1)']" "css_element" should exist | ||
And I set the field "addselect" to "User One (one@example.com, Kermit)" | ||
And I press "Add" | ||
And I should see "User One" in the "#removeselect" "css_element" | ||
|
||
@javascript | ||
Scenario: Unenrol at activity level using custom field search | ||
Given the following "role assigns" exist: | ||
| user | role | contextlevel | reference | | ||
| user1 | editingteacher | Activity module | page1 | | ||
When I am on the "page1" "Activity" page logged in as "admin" | ||
And I navigate to "Locally assigned roles" in current page administration | ||
And I follow "Teacher" | ||
And I set the field "removeselect_searchtext" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label*='Users in this Activity module matching'][label*=' (1)']" "css_element" should exist | ||
And I set the field "removeselect" to "User One (one@example.com, Kermit)" | ||
And I press "Remove" | ||
And I should not see "User One" in the "#removeselect" "css_element" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@core @core_admin | ||
Feature: Staff can check user permissions | ||
In order to find out whether a user can or can't do something | ||
As an admin | ||
I can check their permissions in a particular context | ||
|
||
Background: | ||
Given the following "custom profile fields" exist: | ||
| datatype | shortname | name | | ||
| text | frog | Favourite frog | | ||
And the following config values are set as admin: | ||
| showuseridentity | email,profile_field_frog | | ||
And the following "users" exist: | ||
| username | firstname | lastname | email | profile_field_frog | | ||
| user1 | User | One | one@example.com | Kermit | | ||
| user2 | User | Two | two@example.com | Tree | | ||
| user3 | User | Three | thr@example.com | Kermit | | ||
And the following "courses" exist: | ||
| shortname | fullname | | ||
| C1 | Course 1 | | ||
| C2 | Course 2 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| user1 | C1 | editingteacher | | ||
| user2 | C1 | editingteacher | | ||
| user3 | C2 | editingteacher | | ||
|
||
@javascript | ||
Scenario: Search for a user (enrolled on the course) by custom field and select them to see permissions | ||
When I am on the "C1" "Course" page logged in as "admin" | ||
And I navigate to "Users > Permissions > Check permissions" in current page administration | ||
And I set the field "Search" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label='Matching enrolled users (1)']" "css_element" should exist | ||
And I should see "User One (one@example.com, Kermit)" | ||
And I should not see "User Two" | ||
And I set the field "reportuser" to "User One (one@example.com, Kermit)" | ||
And I press "Show this user's permissions" | ||
And I should see "Permissions for user User One" | ||
And I should see "Yes" in the "Add a new forum" "table_row" | ||
|
||
@javascript | ||
Scenario: Search for a user (not enrolled on the course) by custom field and select them to see permissions | ||
When I am on the "C1" "Course" page logged in as "admin" | ||
And I navigate to "Users > Permissions > Check permissions" in current page administration | ||
And I set the field "Search" to "Kermit" | ||
# The Behat 'I should see' step doesn't work for optgroup labels. | ||
Then "optgroup[label*='Potential users matching'][label*=' (1)']" "css_element" should exist | ||
And I should see "User Three (thr@example.com, Kermit)" | ||
And I should not see "User Two" | ||
And I set the field "reportuser" to "User Three (thr@example.com, Kermit)" | ||
And I press "Show this user's permissions" | ||
Then I should see "Permissions for user User Three" | ||
And I should see "No" in the "Add a new forum" "table_row" |