Hi Team,
In database , where will be the id of the user who created the course is saved ?
Please help me to go forward. I wan to get the id of the user who created aparticular course.
Thanks in advance.
Regards,
jerin
This information is not stored directly in Moodle - you may be able to retrieve it from the logs.
You haven't mentioned a Moodle version number, so I will assume you are using Moodle 2.9.
The log event you are looking for is \core\event\course_created ( https://docs.moodle.org/dev/Event_2#Existing_events ). You will need to create an instance of \core\log\sql_reader ( https://docs.moodle.org/dev/Migrating_log_access_in_reports ) and then use that to do a search for the relevant event. The 'userid' for that event will be the user who created the course.
Thanks for quick reply.
My intention is that , I want to limit the course display ( custom page ) according to the courses created by him .
Any other way for that?
moodle version - 2.8
Thanks in advance.
Regards,
jerin
Well, you could create an event handler that keeps a record in your own DB table of each of the courses created by a particular user (and pre-populate this list using the method outlined in my original reply).
You could then quickly join with this table to produce a list of courses created by a particular user (although, it would normally be more interesting to have a list of courses where the user was, for example, an editing teacher - just because you didn't create a course, does not mean it is not now relevant to you; similarly just because you did create a course, does not mean it is still relevant).
I'd go with Davo's suggestion - Create a specific role (which may be a variation of the editing teacher role, or could just be the editing teacher) and simply display courses in which the user has that role.