MDL-51923 enrol: Enrolment list filter 'No Group' shows incorrect count

With contributions from John Okely
This commit is contained in:
Rajneel Totaram 2015-10-27 18:07:12 +12:00 committed by John Okely
parent 9382ac38d6
commit 494fec0071
2 changed files with 11 additions and 6 deletions

View File

@ -172,7 +172,11 @@ class course_enrolment_manager {
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);
}

View File

@ -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 |