QUERY_ENROLMENTS="SELECT u.username AS username, c.shortname AS courseid, ue.timecreated AS timecreated FROM mdl_user_enrolments ue JOIN mdl_user u ON u.id = ue.userid JOIN mdl_enrol e ON ue.enrolid = e.id JOIN mdl_course c ON e.courseid = c.id"
QUERY_COURSE_CONTEXT="SELECT * FROM mdl_context WHERE contextlevel = 50 AND instanceid = %s"
QUERY_COURSE_CONTEXT_REVERSE="SELECT * FROM mdl_context WHERE id = %s"
QUERY_COURSE_FIELDS="SELECT * FROM mdl_customfield_category cat JOIN mdl_customfield_field fld ON fld.categoryid = cat.id JOIN mdl_customfield_data dat ON dat.fieldid = fld.id"
QUERY_COURSE_MODULES="SELECT * FROM mdl_course_modules WHERE course = %s"
QUERY_MODULE_COMPLETION="SELECT * FROM mdl_course_modules_completion WHERE coursemoduleid = %s"