Detailed ACTIONs for each ROLE (TEACHER, NON-EDITING TEACHER and STUDENT)

Detailed ACTIONs for each ROLE (TEACHER, NON-EDITING TEACHER and STUDENT)

by Ricardo Caiado -
Number of replies: 0
Picture of Particularly helpful Moodlers
Moodle 3.10+
PostgreSQL 12

What´s wrong?

https://docs.moodle.org/311/en/ad-hoc_contributed_reports#Detailed_ACTIONs_for_each_ROLE_.28TEACHER.2C_NON-EDITING_TEACHER_and_STUDENT.29

SELECT r.name, l.action, COUNT( l.userid ) AS counter
FROM prefix_log AS l
JOIN prefix_context AS context ON context.instanceid = l.course AND context.contextlevel = 50
JOIN prefix_role_assignments AS ra ON l.userid = ra.userid AND ra.contextid = context.id
JOIN prefix_role AS r ON ra.roleid = r.id
WHERE ra.roleid IN ( 3, 4, 5 )
GROUP BY roleid, l.action

------------------------------------

Error when executing the query: Error reading from database ERROR: column "r.name" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: SELECT r.name, l.action, COUNT( l.userid ) AS counter ^ SELECT r.name, l.action, COUNT( l.userid ) AS counter FROM mdl_log AS l JOIN mdl_context AS context ON context.instanceid = l.course AND context.contextlevel = 50 JOIN mdl_role_assignments AS ra ON l.userid = ra.userid AND ra.contextid = context.id JOIN mdl_role AS r ON ra.roleid = r.id WHERE ra.roleid IN ( 3, 4, 5 ) GROUP BY roleid, l.action LIMIT 2 [array egg]
Average of ratings: -