Getting number of enrolled courses for users

Getting number of enrolled courses for users

by Mahmood Naderan -
Number of replies: 3

I would like to know how can I fetch all users who have enrolled in more than 10 courses. Unfortunately, some teachers don't know or are lazy to close the self registration and some students intentionally enrol in many courses for their own reasons.

Is there any sql query for that?

Average of ratings: -
In reply to Mahmood Naderan

Re: Getting number of enrolled courses for users

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Have you looked at some of these: List of SQL Contributed reports
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Getting number of enrolled courses for users

by Mahmood Naderan -
Thank you. The user course list [1] is the same as course details in profile. I didn't find that in my google's search.
In order to get a count for all users and compare to a threshold, one way is to call the query from bash for u.id=1 to 9000 and then do some post processing. Not hard, but if you know a better way, please let me know.

[1] https://docs.moodle.org/38/en/ad-hoc_contributed_reports#User.27s_courses
In reply to Mahmood Naderan

Re: Getting number of enrolled courses for users

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Why not simply write the SQL query that produces your desired results?  The Moodle database is a regular relational database.  The list of contributed reports can be used as a starting point.

Average of ratings: Useful (2)