Get all courses' instructors

Get all courses' instructors

by Patrick Johanneson -
Number of replies: 6

Hi,

To try and clean up a rather overgrown Moodle instance, I'm trying to get a list of all courses with their instructors. Does anyone know of a SQL query that will do this, or a PHP command (or set of commands) that might help me out?

Thanks.

Average of ratings: -
In reply to Patrick Johanneson

Get all courses' instructors

by Mary Cooch (personal account) -
Picture of Documentation writers Picture of Testers
You could probably do this with the standard Custom reports feature from Site administration > Reports > Custom reports
Average of ratings: Useful (1)
In reply to Mary Cooch (personal account)

Get all courses' instructors

by Patrick Johanneson -
Is it possible to get the User and Course IDs (ie, the `id` fields from the database tables) in the Custom Reports? The end goal is to be able to remove stale courses and users, and we have scripts that will do that, but they need to be given the DB id fields.
In reply to Patrick Johanneson

Get all courses' instructors

by Shirley Gregorczyk -
Picture of Particularly helpful Moodlers
Using Custom Reports, the primary keys are not available. I asked for this functionality in the previous tracker application, and it seems to have vanished. The primary keys are critical data for the administrators.
You will need to use My SQL to create a query for the role = instructor with the course and user ids.
In reply to Shirley Gregorczyk

Get all courses' instructors

by Shirley Gregorczyk -
Picture of Particularly helpful Moodlers
Found this in ad-hoc contributed reports - you might need to modify it a little -
https://docs.moodle.org/404/en/ad-hoc_contributed_reports#All_teachers_and_courses
Average of ratings: Useful (2)
In reply to Shirley Gregorczyk

Get all courses' instructors

by Patrick Johanneson -
This looks like a giant step in the right direction. Thanks!