At the start of this year we used an enrollment script combined with meta coursing to get our students onto the correct courses.
I'm trying to produce a report that looks at every course on our site and counts the number of students enrolled (and compares it to the number of resources/ activity etc). The problem I'm having is that the students who were linked through the meta course are not being counted by my query.
For some reason, the only people being counted are the ones with the option to delete their enrollment (see attached image - the teacher can be deleted, the students cannot)
The query I've written is below:
COUNT (userid) as 'Students'
, mdl_context.instanceid as 'CourseID'
, mdl_course.fullname as 'CourseName'
join [moodle].[dbo].[mdl_context] on mdl_role_assignments.contextid = mdl_context.id
join [Moodle].[dbo].mdl_course on mdl_context.instanceid = mdl_course.id
join [Moodle].[dbo].mdl_user on mdl_role_assignments.userid = mdl_user.id
where mdl_context.contextlevel = '50' and roleid = '5'
group by mdl_context.instanceid, mdl_course.fullname
order by CourseName asc
Is there another table that counts meta enrollments? I am sure I've checked all the likely suspects.
I hope this isn't the wrong place for this query. Apologies if it is.