mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-53072 group: minor changes to existing code
1) Tidied up conditional check and put additional variable on new line. 2) Prevented change of the default behaviour for 'groups_get_potential_members()'. 3) Added another behat test.
This commit is contained in:
parent
4cb32a243d
commit
3ee812fab4
@ -96,12 +96,11 @@ if ($editform->is_cancelled()) {
|
||||
$source['groupid'] = $data->groupid;
|
||||
}
|
||||
|
||||
$onlyactive = true;
|
||||
if (!$data->includeonlyactiveenrol && has_capability('moodle/course:viewsuspendedusers', $context)) {
|
||||
$onlyactive = false;
|
||||
}
|
||||
// Display only active users if the option was selected or they do not have the capability to view suspended users.
|
||||
$onlyactive = !empty($data->includeonlyactiveenrol) || !has_capability('moodle/course:viewsuspendedusers', $context);
|
||||
|
||||
$users = groups_get_potential_members($data->courseid, $data->roleid, $source, $orderby, !empty($data->notingroup), $onlyactive);
|
||||
$users = groups_get_potential_members($data->courseid, $data->roleid, $source, $orderby, !empty($data->notingroup),
|
||||
$onlyactive);
|
||||
$usercnt = count($users);
|
||||
|
||||
if ($data->allocateby == 'random') {
|
||||
|
@ -722,7 +722,7 @@ function groups_get_possible_roles($context) {
|
||||
*/
|
||||
function groups_get_potential_members($courseid, $roleid = null, $source = null,
|
||||
$orderby = 'lastname ASC, firstname ASC',
|
||||
$notingroup = null, $onlyactiveenrolments = true) {
|
||||
$notingroup = null, $onlyactiveenrolments = false) {
|
||||
global $DB;
|
||||
|
||||
$context = context_course::instance($courseid);
|
||||
|
@ -154,4 +154,21 @@ Feature: Automatic creation of groups
|
||||
And I set the field "Auto create based on" to "Members per group"
|
||||
When I set the field "Group/member count" to "11"
|
||||
And I press "Preview"
|
||||
Then I should see "Suspended student 11"
|
||||
Then I should see "Suspended student 11"
|
||||
|
||||
Scenario: Do not display 'Include only active enrolments' if user does not have the 'moodle/course:viewsuspendedusers' capability
|
||||
Given I log out
|
||||
And I log in as "admin"
|
||||
And I set the following system permissions of "Teacher" role:
|
||||
| capability | permission |
|
||||
| moodle/course:viewsuspendedusers | Prevent |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
When I press "Auto-create groups"
|
||||
Then I should not see "Include only active enrolments"
|
||||
And I set the field "Group/member count" to "11"
|
||||
And I press "Preview"
|
||||
And I should not see "Suspended Student 11"
|
||||
|
Loading…
x
Reference in New Issue
Block a user