diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php
index <HASH>..<HASH> 100644
--- a/mod/quiz/lib.php
+++ b/mod/quiz/lib.php
@@ -590,7 +590,7 @@ function quiz_get_user_attempts($quizids, $userid, $status = 'finished', $includ
 
     return $DB->get_records_select('quiz_attempts',
             "quiz $insql AND userid = :userid" . $previewclause . $statuscondition,
-            $params, 'attempt ASC');
+            $params, 'quiz, attempt ASC');
 }
 
 /**
MDL-<I> quiz: Ensure user attempts are deterministic for testing.