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

This commit will add missing fields as Time enrolled/started/reaggregated
in the filter/condition area for the completion entity when creating a course participants
as a report source in the Report Builder.
This commit is contained in:
guillermogomez 2023-01-27 14:23:11 -05:00
parent 880462a168
commit 43c64bc141
2 changed files with 61 additions and 0 deletions

View File

@ -275,6 +275,45 @@ class completion extends base {
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;
}
}

View File

@ -210,6 +210,27 @@ class participants_test extends core_reportbuilder_testcase {
],
'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'
],
];
}
@ -254,6 +275,7 @@ class participants_test extends core_reportbuilder_testcase {
// 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.