From 8ddfc963b98a6f0bcd12ccf4172c447f7ff0de8f Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Tue, 9 Jun 2020 12:36:11 +0800 Subject: [PATCH] MDL-68984 user: Ensure first/last name filtering is always applied This ensures the firstname and surname filtering is applied in addition to any other filtering, rather than using the filterset join type. --- user/classes/table/participants_search.php | 4 ++-- user/tests/behat/filter_participants.feature | 22 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/user/classes/table/participants_search.php b/user/classes/table/participants_search.php index 0d944832325..1970c21c7a2 100644 --- a/user/classes/table/participants_search.php +++ b/user/classes/table/participants_search.php @@ -265,9 +265,9 @@ class participants_search { } } - // Add any supplied additional WHERE clauses. + // Add any supplied additional forced WHERE clauses. if (!empty($additionalwhere)) { - $wheres[] = $additionalwhere; + $innerwhere .= " AND ({$additionalwhere})"; $params = array_merge($params, $additionalparams); } diff --git a/user/tests/behat/filter_participants.feature b/user/tests/behat/filter_participants.feature index 5e243dd879e..60475cd92d1 100644 --- a/user/tests/behat/filter_participants.feature +++ b/user/tests/behat/filter_participants.feature @@ -664,3 +664,25 @@ Feature: Course participants can be filtered And I should not see "Student 2" in the "participants" "table" And I should not see "Student 3" in the "participants" "table" And I should not see "Teacher 1" in the "participants" "table" + + @javascript + Scenario: Initials filtering is always applied in addition to any other filtering + Given I log in as "teacher1" + And I am on "Course 2" course homepage + And I navigate to course participants + And I should see "Student 1" in the "participants" "table" + And I should see "Student 2" in the "participants" "table" + And I should see "Student 3" in the "participants" "table" + And I should see "Trendy Learnson" in the "participants" "table" + And I should see "Teacher 1" in the "participants" "table" + When I set the field "Match" in the "Filter 1" "fieldset" to "Any" + And I set the field "type" in the "Filter 1" "fieldset" to "Role" + And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset" + And I click on "Student" "list_item" + And I click on "Apply filters" "button" + When I click on "T" "link" in the ".firstinitial" "css_element" + Then I should see "Trendy Learnson" in the "participants" "table" + And I should not see "Student 1" in the "participants" "table" + And I should not see "Student 2" in the "participants" "table" + And I should not see "Student 3" in the "participants" "table" + And I should not see "Teacher 1" in the "participants" "table"