Hello MySQL experts,
The delivered Grade>Results report is perfect to find the abandoned attempts, but I am tasked with examining 200+ courses.
I heavily borrowed for the ad-hoc contributed reports to get to this - but it does not filter as much as I need.
I only want incomplete, quiz attempts, unfortunately I am not skilled enough to tweak this query - What am I missing to exclude the activities that are not quizzes?
SELECT
u.username As 'User',
c.shortname AS 'Course',
m.name AS Activitytype,
CASE
WHEN m.name = 'quiz' THEN (SELECT name FROM prefix_quiz WHERE id = cm.instance)
END AS Activityname,
CASE
WHEN cm.completion = 0 THEN '0 None'
END AS Activtycompletiontype,
CASE
WHEN cm.instance = 0 THEN 'In Progress'
END AS 'Progress',
DATE_FORMAT(FROM_UNIXTIME(cmc.timemodified), '%Y-%m-%d %H:%i') AS 'When'
FROM prefix_course_modules_completion cmc
JOIN prefix_user u ON cmc.userid = u.id
JOIN prefix_course_modules cm ON cmc.coursemoduleid = cm.id
JOIN prefix_course c ON cm.course = c.id
JOIN prefix_modules m ON cm.module = m.id
WHERE u.id > 2
and (c.visible = 1)
AND u.deleted = 0 AND u.suspended = 0
%%FILTER_USERS:u.username%%
%%FILTER_SEARCHTEXT:m.name:~%%
%%FILTER_STARTTIME:cmc.timemodified:>%% %%FILTER_ENDTIME:cmc.timemodified:<%%
ORDER BY u.username