Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MySQL query for ad-hoc Moodle queries to count quizzes -
SELECT u.lastname, u.firstname, u.idnumber,
FROM prefix_quiz_attempts attempts
JOIN prefix_quiz quiz
JOIN prefix_course_modules cm
AND state='finished'
AND (attempts.sumgrades / quiz.sumgrades * quiz.grade) >= :minimum_grade
) AS quizcount
FROM prefix_user u
HAVING quizcount>0
ORDER BY u.lastname ASC, u.firstname ASC

This comment has been minimized.

Copy link
Owner Author

commented Jan 23, 2015

Quick update. Instead of always multiplying the points times 100 (last line in the subquery) it's multiplying times the total points available for the quiz. If it's 100, it won't make any difference. But that way, if you have a quiz that's not out of 100 points the math will still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.