Last active
January 27, 2026 16:01
-
-
Save georgekinnear/107e5a1419e8bcbd01efde2227fcd823 to your computer and use it in GitHub Desktop.
Moodle SQL: All attempt steps in a quiz - not just the last for each student
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| qa.*, | |
| qas_last.*, | |
| qas_last.timecreated AS stepdate, | |
| u.email, | |
| u.firstname, | |
| u.lastname | |
| FROM {course_modules} cm | |
| JOIN {quiz_attempts} quiza ON quiza.quiz = cm.instance | |
| JOIN {question_usages} qu ON qu.id = quiza.uniqueid | |
| JOIN {question_attempts} qa ON qa.questionusageid = qu.id | |
| LEFT JOIN {question_attempt_steps} qas_last ON qas_last.questionattemptid = qa.id | |
| LEFT JOIN {user} u ON qas_last.userid = u.id | |
| WHERE | |
| cm.id = :quiz_id | |
| ORDER BY | |
| u.username, | |
| qas_last.timecreated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment