SQL to find users that created foruns in specific course

SQL to find users that created foruns in specific course

by Fernando Ribeiro -
Number of replies: 0

Hello everyone, I m need create an report containing some information about tutors, in moodle version 3.4.

And one of the information I need is to find the amount of forums, quizzes, tasks, wikis etc ... that each tutor created for each course. I'm starting the forum, but I'm not getting the results do not match. For example, to find the number of forums in the course, I run:

SELECT count(*)  FROM mdl_forum f WHERE f.course = 2 

The code above return 11 records (foruns). To find each entry, "forum", modules i run:

SELECT cm.id FROM mdl_course_modules cm WHERE cm.course = 2 AND cm.module = 9

Again it return 11 records to module foruns, and till here all appears fine, but none information about user that created forum. To got userid i look on "prefix_logstore_standard_log" to find all entries  with same identifier to course_module, cmid, and check action or eventname. For this i do:

SELECT * FROM mdl_logstore_standard_log l WHERE l.objecttable = 'course_sections' and l.courseid = 2

AND l.objectid IN (SELECT cm.section FROM mdl_course_modules cm WHERE cm.course = 2 AND cm.module = 9)

But in this step i got too many records with "eventname" or "action"  with value "updated" and just one with create. 


Anyone can help me please understand how can i got the user that add one forum (prefix_forum) entry.


TKS ANYWAY



Average of ratings: -