Last active
August 14, 2017 13:49
-
-
Save mackensen/aa63cd831e031b635ea1eaaa1d9c6e43 to your computer and use it in GitHub Desktop.
All active Moodle courses in a given term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT c.fullname, | |
c.shortname, | |
c.idnumber | |
FROM prefix_course c | |
WHERE EXISTS | |
(SELECT cc.id | |
FROM prefix_course_categories cc | |
WHERE cc.id=c.category | |
AND cc.parent=:term | |
LIMIT 1) | |
AND (EXISTS | |
(SELECT id | |
FROM prefix_logstore_standard_log lsl | |
WHERE lsl.courseid=c.id | |
AND (lsl.crud='c' | |
OR lsl.crud='u') | |
AND lsl.userid <> 0 | |
AND lsl.userid <> 2 | |
LIMIT 1) | |
AND NOT EXISTS | |
(SELECT id | |
FROM prefix_enrol e | |
WHERE e.enrol='meta' | |
AND (e.courseid=c.id | |
OR e.customint1=c.id) | |
LIMIT 1) | |
OR EXISTS | |
(SELECT id | |
FROM prefix_enrol e | |
WHERE e.enrol='meta' | |
AND e.customint1=c.id | |
LIMIT 1)) | |
AND NOT EXISTS | |
(SELECT id | |
FROM prefix_enrol e | |
WHERE e.enrol='meta' | |
AND e.courseid=c.id) | |
AND c.shortname NOT LIKE 'EXCL%' | |
AND c.fullname NOT LIKE '%Independent%' | |
AND c.fullname NOT LIKE '%Thesis%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment