Dear Experts,
I have this handy query - borrowed for the ad-hoc contributions page. Each result is slightly overstated, as it includes my completion - when I launched the course and tested the course behaviors. How do I exclude completions that were done by non-enrolled students? I have tried inserting the %%FILTER_COURSEENROLLEDSTUDENTS%% after the WHERE statement - which results in a query error.
Truly puzzled, Shirley
SELECT DISTINCT
c.fullname AS Course,
COUNT(cp.timecompleted) AS Completions
FROM prefix_course_completions AS cp
JOIN prefix_course AS c ON cp.course = c.id
JOIN prefix_user AS u ON cp.userid = u.id
WHERE (c.visible = 1)
AND (u.deleted = 0) AND (u.suspended = 0)
GROUP BY c.id
ORDER BY c.fullname