MDL-82529 cohort: Add custom field filters to Cohorts system report

This commit is contained in:
David Carrillo 2024-07-18 16:46:55 +02:00
parent 5c135b614d
commit 78153dd73a
No known key found for this signature in database
GPG Key ID: 250DD1C373361672
2 changed files with 25 additions and 8 deletions

View File

@ -188,12 +188,7 @@ class cohorts extends system_report {
* unique identifier
*/
protected function add_filters(): void {
$filters = [
'cohort:name',
'cohort:idnumber',
'cohort:description',
];
$this->add_filters_from_entities($filters);
$this->add_filters_from_entity('cohort', ['name', 'idnumber', 'description', 'customfield*']);
}
/**

View File

@ -65,6 +65,15 @@ Feature: View cohort list
@javascript
Scenario: Cohorts list can be filtered
Given the following "custom field categories" exist:
| name | component | area | itemid |
| Newcat | core_cohort | cohort | 0 |
And the following "custom fields" exist:
| name | category | type | shortname | description | configdata |
| Field checkbox | Newcat | checkbox | checkbox | | |
And the following "cohorts" exist:
| name | idnumber | contextlevel | reference | customfield_checkbox |
| Cohort with CF | CH4 | Category | CAT1 | 1 |
When I log in as "admin"
And I navigate to "Users > Accounts > Cohorts" in site administration
And I follow "All cohorts"
@ -73,11 +82,24 @@ Feature: View cohort list
| Name operator | Contains |
| Name value | category 1 |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then the following should exist in the "reportbuilder-table" table:
Then the following should exist in the "Cohorts" table:
| Category | Name |
| Cat 1 | Cohort in category 1 |
And the following should not exist in the "reportbuilder-table" table:
And the following should not exist in the "Cohorts" table:
| Category | Name |
| Cat 2 | Cohort in category 2 |
| Cat 3 | Cohort in category 3 |
| System | System cohort |
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I set the following fields in the "Field checkbox" "core_reportbuilder > Filter" to these values:
| Field checkbox operator | Yes |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And the following should exist in the "Cohorts" table:
| Category | Name |
| Cat 1 | Cohort with CF |
And the following should not exist in the "Cohorts" table:
| Category | Name |
| Cat 1 | Cohort in category 1 |
| Cat 2 | Cohort in category 2 |
| Cat 3 | Cohort in category 3 |
| System | System cohort |