Dear Moodlers,
I am completely debutant in the SQL codes.
But I learn fast. If I need help.
I will need to take out of my Moodle the report which contains :
the names of the users (role user) who participated in the courses (ordered by categories ) in certain between April and June 2020.
I have found code like that but I don't manage to make it work. it says :
SELECT COUNT(DISTINCT lra.userid) AS learners, COUNT(DISTINCT tra.userid) AS teachers
FROM prefix_course AS c #, mdl_course_categories AS cats
LEFT JOIN prefix_context AS ctx ON c.id = ctx.instanceid
JOIN prefix_role_assignments AS lra ON lra.contextid = ctx.id
JOIN prefix_role_assignments AS tra ON tra.contextid = ctx.id
JOIN prefix_course_categories AS cats ON c.category = cats.id
WHERE c.category = cats.id
AND (
cats.path LIKE '%/2434/%' #Replace CATEGORYID WITH the category id you want TO COUNT (eg: 80)
OR cats.path LIKE '%/2434'
)
AND lra.roleid=5
AND tra.roleid=3
Can you help?
Thank you in advance,
Gosia