mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-75349 course: include groups entity data in participants report.
This commit is contained in:
parent
b10b89ec74
commit
6c9b4d1e24
2 changed files with 28 additions and 0 deletions
|
@ -22,6 +22,7 @@ use core_course\reportbuilder\local\entities\course_category;
|
|||
use core_course\reportbuilder\local\entities\access;
|
||||
use core_course\reportbuilder\local\entities\completion;
|
||||
use core_course\reportbuilder\local\entities\enrolment;
|
||||
use core_group\reportbuilder\local\entities\group;
|
||||
use core_reportbuilder\datasource;
|
||||
use core_reportbuilder\local\entities\course;
|
||||
use core_reportbuilder\local\entities\user;
|
||||
|
@ -72,6 +73,26 @@ class participants extends datasource {
|
|||
$userentity->add_join("LEFT JOIN {user} {$user} ON {$userenrolment}.userid = {$user}.id AND {$user}.deleted = 0");
|
||||
$this->add_entity($userentity);
|
||||
|
||||
// Join group entity.
|
||||
$groupentity = (new group())
|
||||
->set_table_alias('context', $courseentity->get_table_alias('context'));
|
||||
$groups = $groupentity->get_table_alias('groups');
|
||||
|
||||
// Sub-select for all course group members.
|
||||
$groupsinnerselect = "
|
||||
SELECT grs.*, grms.userid
|
||||
FROM {groups} grs
|
||||
JOIN {groups_members} grms ON grms.groupid = grs.id";
|
||||
|
||||
$this->add_entity($groupentity
|
||||
->add_join($courseentity->get_context_join())
|
||||
->add_joins($userentity->get_joins())
|
||||
->add_join("
|
||||
LEFT JOIN ({$groupsinnerselect}) {$groups}
|
||||
ON {$groups}.courseid = {$course}.id
|
||||
AND {$groups}.userid = {$user}.id")
|
||||
);
|
||||
|
||||
// Join completion entity.
|
||||
$completionentity = new completion();
|
||||
$completion = $completionentity->get_table_alias('course_completion');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue