Reporting

These are various SQL statements built to extract data from Moodle.  They are listed here to reduct the time to build special reports.

List of enrolled students

SELECT u.id, u.username, u.firstname, u.lastname,
                 u.email, ue.enrolid,e.courseid,
                 c.category, c.shortname,c.fullname,
                 cc.name AS catname
            FROM mdl_user AS u
                 JOIN mdl_user_enrolments AS ue ON (u.id=ue.userid)
                 JOIN mdl_enrol AS e ON (e.id=ue.enrolid)
                 JOIN mdl_course AS c ON (e.courseid=c.id)
                 JOIN mdl_course_categories AS cc ON (c.category=cc.id)
           WHERE u.deleted=0
           ORDER BY c.category,c.shortname,u.lastname,u.firstname
Taxonomy: