I have a question relating to a SQL command - I need to get a list of all students that are enrolled in a Moodle course, but I also need to find out how each student was enrolled i.e. Manual, Banner Plugin, etc, this is the SQL that I currently have but I cant seem to get the enrol part ?
Were on Moodle 3.1
Thanks Conor.
SELECT
c.id AS courseid,
c.idnumber AS crn,
c.fullname,
u.username,
u.firstname,
u.lastname,
u.email
FROM mdl_role_assignments ra
JOIN mdl_user u ON u.id = ra.userid
JOIN mdl_role r ON r.id = ra.roleid
JOIN mdl_context cxt ON cxt.id = ra.contextid
JOIN mdl_course c ON c.id = cxt.instanceid
WHERE ra.userid = u.id
AND ra.contextid = cxt.id
AND cxt.contextlevel = 50
AND cxt.instanceid = c.id
AND roleid = 46
ORDER BY c.id