Skip to content

Commit

Permalink
MDL-51923 enrol: Enrolment list filter 'No Group' shows incorrect count
Browse files Browse the repository at this point in the history
With contributions from John Okely
  • Loading branch information
rjnl authored and John Okely committed Oct 28, 2015
1 parent 9382ac3 commit 494fec0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion enrol/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ public function get_total_users() {
FROM {user} u
JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid $instancessql)
JOIN {enrol} e ON (e.id = ue.enrolid)
LEFT JOIN {groups_members} gm ON u.id = gm.userid
LEFT JOIN {groups_members} gm ON u.id = gm.userid AND gm.groupid IN (
SELECT g.id
FROM {groups} g
WHERE g.courseid = e.courseid
)
WHERE $filtersql";
$this->totalusers = (int)$DB->count_records_sql($sqltotal, $params);
}
Expand Down
11 changes: 6 additions & 5 deletions enrol/tests/behat/filter_enrolled_users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ Feature: Enrolled users can be filtered by group
And I should see "<expected3>"
And I should not see "<notexpected1>"
And I should not see "<notexpected2>"
And I should see "<expected4>"

# Note the 'XX-IGNORE-XX' elements are for when there is less than 2 'not expected' items.
Examples:
| group | expected1 | expected2 | expected3 | notexpected1 | notexpected2 |
| All participants | Student 1 | Student 2 | Student 3 | XX-IGNORE-XX | XX-IGNORE-XX |
| No group | Student 1 | | | Student 2 | Student 3 |
| Group 1 | Student 2 | | | Student 1 | Student 3 |
| Group 2 | Student 2 | Student 3 | | Student 1 | XX-IGNORE-XX |
| group | expected1 | expected2 | expected3 | expected4 | notexpected1 | notexpected2 |
| All participants | Student 1 | Student 2 | Student 3 | 4 enrolled users | XX-IGNORE-XX | XX-IGNORE-XX |
| No group | Student 1 | | | 2 enrolled users | Student 2 | Student 3 |
| Group 1 | Student 2 | | | 1 enrolled users | Student 1 | Student 3 |
| Group 2 | Student 2 | Student 3 | | 2 enrolled users | Student 1 | XX-IGNORE-XX |

0 comments on commit 494fec0

Please sign in to comment.