How can i get Get courses for a teacher

How can i get Get courses for a teacher

by Sikander Nawaz -
Number of replies: 1

upon login I want to list all the courses where this user is enrolled as a teacher, 

can someone help me how can i do that . 


Thanks 

Average of ratings: -
In reply to Sikander Nawaz

Re: How can i get Get courses for a teacher

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Take a look at the following page. It gives many examples of SQL reports. I didn't see one specifically for your requirement but it should be possible to put what you need together.

Essentially what you want to do is to:
  1. Get a list of all the courses in which a user is enrolled.
  2. Loop through each of these courses to see if they have a teacher role. If not, remove the course from the list.
  3. Display the list.
There are examples of code in Moodle on how to do all of these, just perhaps not a together in one place.

As for displaying it when the user logs in, put the report in a block on your home page or dashboard.