MDL-58827 user: add institution & department filters.

This commit is contained in:
Paul Holden 2019-11-05 00:16:13 +00:00
parent d7699706da
commit 8d09b8cab6
2 changed files with 20 additions and 6 deletions

View File

@ -6,11 +6,11 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
Background:
Given the following "users" exist:
| username | firstname | lastname | email | auth | confirmed | lastip |
| user1 | User | One | one@example.com | manual | 0 | 127.0.1.1 |
| user2 | User | Two | two@example.com | ldap | 1 | 0.0.0.0 |
| user3 | User | Three | three@example.com | manual | 1 | 0.0.0.0 |
| user4 | User | Four | four@example.com | ldap | 0 | 127.0.1.2 |
| username | firstname | lastname | email | auth | confirmed | lastip | institution | department |
| user1 | User | One | one@example.com | manual | 0 | 127.0.1.1 | moodle | red |
| user2 | User | Two | two@example.com | ldap | 1 | 0.0.0.0 | moodle | blue |
| user3 | User | Three | three@example.com | manual | 1 | 0.0.0.0 | | |
| user4 | User | Four | four@example.com | ldap | 0 | 127.0.1.2 | | |
And the following "cohorts" exist:
| name | idnumber |
| Cohort 1 | CH1 |
@ -104,3 +104,15 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
And I should see "User Two"
And I should see "User Three"
And I should see "User Four"
Scenario: Filter users by institution and department
When I set the field "id_institution" to "moodle"
And I press "Add filter"
Then I should see "User One"
And I should see "User Two"
And I should not see "User Three"
And I should not see "User Four"
And I set the field "id_department" to "red"
And I press "Add filter"
And I should see "User One"
And I should not see "User Two"

View File

@ -69,7 +69,7 @@ class user_filtering {
'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1,
'anycourses' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1,
'neveraccessed' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1,
'idnumber' => 1, 'lastip' => 1);
'idnumber' => 1, 'institution' => 1, 'department' => 1, 'lastip' => 1);
// Get the config which filters the admin wanted to show by default.
$userfiltersdefault = get_config('core', 'userfiltersdefault');
@ -173,6 +173,8 @@ class user_filtering {
case 'nevermodified': return new user_filter_checkbox('nevermodified', get_string('nevermodified', 'filters'), $advanced, array('timemodified', 'timecreated'), array('timemodified_sck', 'timemodified_eck'));
case 'cohort': return new user_filter_cohort($advanced);
case 'idnumber': return new user_filter_text('idnumber', get_string('idnumber'), $advanced, 'idnumber');
case 'institution': return new user_filter_text('institution', get_string('institution'), $advanced, 'institution');
case 'department': return new user_filter_text('department', get_string('department'), $advanced, 'department');
case 'lastip': return new user_filter_text('lastip', get_string('lastip'), $advanced, 'lastip');
case 'auth':
$plugins = core_component::get_plugin_list('auth');