mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-80807' of https://github.com/paulholden/moodle
This commit is contained in:
commit
1d23446a1b
@ -1,97 +0,0 @@
|
||||
@core_reportbuilder @javascript
|
||||
Feature: Manage custom reports for cohorts
|
||||
In order to manage custom reports for cohorts
|
||||
As an admin and user
|
||||
I need to create new, view and edit existing reports
|
||||
|
||||
Background:
|
||||
Given the following "cohorts" exist:
|
||||
| name | idnumber | contextid |
|
||||
| Another one | AO | 1 |
|
||||
| MDL-62161 | 62161 | 1 |
|
||||
| New system cohort | NSC | 1 |
|
||||
| MDL-62162 | 62162 | 1 |
|
||||
| Other cohort | LC | 3 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| user1 | Alice | Last1 | user1@example.com |
|
||||
| user2 | Carlos | Last2 | user2@example.com |
|
||||
| user3 | Paul | Last3 | user3@example.com |
|
||||
| user4 | Juan | Last4 | user4@example.com |
|
||||
| user5 | Pedro | Last5 | user5@example.com |
|
||||
| user6 | Luis | Last6 | user6@example.com |
|
||||
| user7 | David | Last7 | user7@example.com |
|
||||
| user8 | Zoe | Last8 | user8@example.com |
|
||||
And the following "cohort members" exist:
|
||||
| user | cohort |
|
||||
| user1 | AO |
|
||||
| user2 | AO |
|
||||
| user3 | AO |
|
||||
| user4 | AO |
|
||||
| user5 | 62161 |
|
||||
| user6 | 62161 |
|
||||
| user7 | NSC |
|
||||
| user8 | NSC |
|
||||
And the following "core_reportbuilder > Reports" exist:
|
||||
| name | source | default |
|
||||
| My report | core_cohort\reportbuilder\datasource\cohorts | 0 |
|
||||
And the following "core_reportbuilder > Columns" exist:
|
||||
| report | uniqueidentifier |
|
||||
| My report | cohort:context |
|
||||
| My report | cohort:name |
|
||||
|
||||
Scenario: Add condition to cohorts report
|
||||
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I change window size to "large"
|
||||
When I click on "Show/hide 'Conditions'" "button"
|
||||
Then I should see "There are no conditions selected" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I set the field "Select a condition" to "Category"
|
||||
And I should see "Added condition 'Category'"
|
||||
And I should not see "There are no conditions selected" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I set the following fields in the "Category" "core_reportbuilder > Condition" to these values:
|
||||
| Category operator | Is equal to |
|
||||
| Category value | 3 |
|
||||
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
|
||||
And I should see "Conditions applied"
|
||||
And I should see "Other cohort" in the "reportbuilder-table" "table"
|
||||
And I should not see "MDL-62162" in the "reportbuilder-table" "table"
|
||||
|
||||
Scenario: Use filters in cohorts report
|
||||
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I change window size to "large"
|
||||
When I click on "Show/hide 'Filters'" "button"
|
||||
Then I should see "There are no filters selected" in the "[data-region='settings-filters']" "css_element"
|
||||
And I set the field "Select a filter" to "Name"
|
||||
And I should see "Other cohort" in the ".reportbuilder-table" "css_element"
|
||||
And I should see "MDL-62162" in the ".reportbuilder-table" "css_element"
|
||||
When I click on "Switch to preview mode" "button"
|
||||
And I click on "Filters" "button" in the "[data-region='core_reportbuilder/report-header']" "css_element"
|
||||
And I set the following fields in the "Name" "core_reportbuilder > Filter" to these values:
|
||||
| Name operator | Contains |
|
||||
| Name value | Another |
|
||||
And I click on "Apply" "button" in the "[data-region='core_reportbuilder/report-header']" "css_element"
|
||||
Then the following should exist in the "reportbuilder-table" table:
|
||||
| Category | Name |
|
||||
| System | Another one |
|
||||
And the following should not exist in the "reportbuilder-table" table:
|
||||
| Category | Name |
|
||||
| Miscellaneous | Other cohort |
|
||||
|
||||
Scenario: Use sorting and aggregations in cohorts report
|
||||
Given the following "core_reportbuilder > Columns" exist:
|
||||
| report | uniqueidentifier |
|
||||
| My report | user:lastname |
|
||||
And I change window size to "large"
|
||||
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I set the field "Rename column 'Last name'" to "Member count"
|
||||
And I set the "Last name" column aggregation to "Count"
|
||||
And I click on "Show/hide 'Sorting'" "button"
|
||||
And I click on "Move sorting for column 'Last name'" "button"
|
||||
And I click on "To the top of the list" "link" in the "Move sorting for column 'Last name'" "dialogue"
|
||||
And I click on "Enable initial sorting for column 'Last name'" "checkbox"
|
||||
# "New system cohort" has fewer members than "Another one" cohort.
|
||||
And "New system cohort" "table_row" should appear before "Another one" "table_row"
|
||||
When I click on "Sort column 'Last name' descending" "button"
|
||||
Then I should see "Updated sorting for column 'Last name'"
|
||||
# Switching sort direction should now show "Another one" cohort ahead of "New system cohort".
|
||||
And "Another one" "table_row" should appear before "New system cohort" "table_row"
|
@ -54,25 +54,21 @@ class avg_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
$generator->create_column(
|
||||
['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => avg::get_class_name()]
|
||||
);
|
||||
// Report columns, aggregated/sorted by user suspended.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:suspended',
|
||||
'aggregation' => avg::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_suspended' => '0.0',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_suspended' => '0.5',
|
||||
],
|
||||
], $content);
|
||||
['Bob', '0.5'],
|
||||
['Admin', '0.0'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,24 +53,20 @@ class count_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user lastname.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname', 'aggregation' => count::get_class_name()]
|
||||
);
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:lastname',
|
||||
'aggregation' => count::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_lastname' => 1,
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_lastname' => 3,
|
||||
],
|
||||
], $content);
|
||||
['Bob', 3],
|
||||
['Admin', 1],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
}
|
||||
|
@ -53,27 +53,21 @@ class countdistinct_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user lastname.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:lastname',
|
||||
'aggregation' => countdistinct::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_lastname' => 1,
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_lastname' => 2,
|
||||
],
|
||||
], $content);
|
||||
['Bob', 2],
|
||||
['Admin', 1],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,28 +57,22 @@ class groupconcat_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user lastname.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:lastname',
|
||||
'aggregation' => groupconcat::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_ASC,
|
||||
]);
|
||||
|
||||
// Assert lastname column was aggregated, and sorted predictably.
|
||||
// Assert lastname column was aggregated, and itself also sorted predictably.
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_lastname' => 'User',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_lastname' => 'Apple, Banana, Banana',
|
||||
],
|
||||
], $content);
|
||||
['Bob', 'Apple, Banana, Banana'],
|
||||
['Admin', 'User'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,28 +67,22 @@ class groupconcatdistinct_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user lastname.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:lastname',
|
||||
'aggregation' => groupconcatdistinct::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_ASC,
|
||||
]);
|
||||
|
||||
// Assert lastname column was aggregated, and sorted predictably.
|
||||
// Assert lastname column was aggregated, and itself also sorted predictably.
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_lastname' => 'User',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_lastname' => 'Apple, Banana',
|
||||
],
|
||||
], $content);
|
||||
['Bob', 'Apple, Banana'],
|
||||
['Admin', 'User'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,24 +52,20 @@ class max_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
$generator->create_column(
|
||||
['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => max::get_class_name()]
|
||||
);
|
||||
// Report columns, aggregated/sorted by user suspended.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:suspended',
|
||||
'aggregation' => max::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_suspended' => 'No',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_suspended' => 'Yes',
|
||||
],
|
||||
], $content);
|
||||
['Bob', 'Yes'],
|
||||
['Admin', 'No'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
}
|
||||
|
@ -45,31 +45,27 @@ class min_test extends core_reportbuilder_testcase {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Test subjects.
|
||||
$this->getDataGenerator()->create_user(['firstname' => 'Admin', 'suspended' => 1]);
|
||||
$this->getDataGenerator()->create_user(['firstname' => 'Bob', 'suspended' => 1]);
|
||||
$this->getDataGenerator()->create_user(['firstname' => 'Bob', 'suspended' => 0]);
|
||||
|
||||
/** @var core_reportbuilder_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user suspended.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => min::get_class_name()]
|
||||
);
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:suspended',
|
||||
'aggregation' => min::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_suspended' => 'No',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_suspended' => 'No',
|
||||
],
|
||||
], $content);
|
||||
['Bob', 'Yes'],
|
||||
['Admin', 'No'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
}
|
||||
|
@ -52,24 +52,20 @@ class percent_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user suspended.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => percent::get_class_name()]
|
||||
);
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:suspended',
|
||||
'aggregation' => percent::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_suspended' => '0.0%',
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_suspended' => '50.0%',
|
||||
],
|
||||
], $content);
|
||||
['Bob', '50.0%'],
|
||||
['Admin', '0.0%'],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
}
|
||||
|
@ -55,25 +55,21 @@ class sum_test extends core_reportbuilder_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
|
||||
|
||||
// First column, sorted.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]);
|
||||
|
||||
// This is the column we'll aggregate.
|
||||
// Report columns, aggregated/sorted by user suspended.
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']);
|
||||
$generator->create_column([
|
||||
'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => sum::get_class_name()
|
||||
'reportid' => $report->get('id'),
|
||||
'uniqueidentifier' => 'user:suspended',
|
||||
'aggregation' => sum::get_class_name(),
|
||||
'sortenabled' => 1,
|
||||
'sortdirection' => SORT_DESC,
|
||||
]);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_suspended' => 0,
|
||||
],
|
||||
[
|
||||
'c0_firstname' => 'Bob',
|
||||
'c1_suspended' => 2,
|
||||
],
|
||||
], $content);
|
||||
['Bob', 2],
|
||||
['Admin', 0],
|
||||
], array_map('array_values', $content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user