Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDL-77062 reportbuilder: Add filters/conditions for completion entity #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions course/classes/reportbuilder/local/entities/completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,45 @@ protected function get_all_filters(): array {
date::DATE_CURRENT,
]);

// Time enrolled/started filter and condition.
$fields = ['timeenrolled', 'timestarted'];
foreach ($fields as $field) {
$filters[] = (new filter(
date::class,
$field,
new lang_string($field, 'enrol'),
$this->get_entity_name(),
"{$coursecompletion}.{$field}"
))
->add_joins($this->get_joins())
->set_limited_operators([
date::DATE_ANY,
date::DATE_NOT_EMPTY,
date::DATE_EMPTY,
date::DATE_RANGE,
date::DATE_LAST,
date::DATE_CURRENT,
]);
}

// Time reaggregated filter and condition.
$filters[] = (new filter(
date::class,
'reaggregate',
new lang_string('timereaggregated', 'enrol'),
$this->get_entity_name(),
"{$coursecompletion}.reaggregate"
))
->add_joins($this->get_joins())
->set_limited_operators([
date::DATE_ANY,
date::DATE_NOT_EMPTY,
date::DATE_EMPTY,
date::DATE_RANGE,
date::DATE_LAST,
date::DATE_CURRENT,
]);

return $filters;
}
}
22 changes: 22 additions & 0 deletions course/tests/reportbuilder/datasource/participants_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ public function filters_data_provider(): array {
],
'Lionel'
],
[
'completion:timeenrolled',
[
'completion:timeenrolled_operator' => date::DATE_NOT_EMPTY,
],
'Lionel'
],
[
'completion:timestarted',
[
'completion:timestarted_operator' => date::DATE_NOT_EMPTY,
],
'Lionel'
],
[
'completion:reaggregate',
[
'completion:reaggregate_operator' => date::DATE_NOT_EMPTY,
],
'Lionel'
],
];
}

Expand Down Expand Up @@ -254,6 +275,7 @@ public function test_report_filters(string $filter, array $filtervalues, string
// Mark course as completed for the user.
$ccompletion = new completion_completion(array('course' => $course->id, 'userid' => $user1->id));
$ccompletion->mark_enrolled($timestart);
$ccompletion->mark_inprogress($timestart);
$ccompletion->mark_complete($timecompleted);

// Set some last access value for the user in the course.
Expand Down