Moodle SQL
Handy queries for Moodle.
Count number of users who are are in courses:
select count(distinct ra.userid) from mdl_role_assignments ra,mdl_context c
where ra.contextid=c.id and c.contextlevel=50
Show users who are users in Moodle, but not in a class:
select * from mdl_user where not exists (select * from mdl_user_lastaccess where mdl_user.id = mdl_user_lastaccess.id);
Number of users who have classes:
select count(distinct ra.userid) from mdl_role_assignments ra,mdl_context c
where ra.contextid=c.id and c.contextlevel=50</div>
where ra.contextid=c.id and c.contextlevel=50</div>
Comments
Comments powered by Disqus