Report Query - All users, all courses completion status - Moodle 3.8.2+

Report Query - All users, all courses completion status - Moodle 3.8.2+

by Dave Emsley -
Number of replies: 2

Hi All,

I've currently struggling to produce a query that gets a full report for ALL the users, on all courses ever with their completion (or otherwise) status.

Can anyone point me in the direction I'd need please?

Cheers

Dave

Average of ratings: -
In reply to Dave Emsley

Re: Report Query - All users, all courses completion status - Moodle 3.8.2+

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Dave, Can you share what you've got so far?

In reply to Mark Johnson

Re: Report Query - All users, all courses completion status - Moodle 3.8.2+

by Dave Emsley -
Getting enrolments:
$sql = " SELECT * FROM {user_enrolments} ue
JOIN {enrol} e ON ue.enrolid = e.id
LEFT JOIN {course} c ON e.courseid = c.id
WHERE ue.userid = :value";

But then having to get the grades separately:

$sql = " SELECT * FROM {grade_grades} gg
JOIN {grade_items} gi ON gi.id = gg.itemid
WHERE gg.userid = :userid
AND gi.courseid = :courseid";

Hope that makes sense,

Dave