diff --git a/generic/views.py b/generic/views.py index 5db2b7b7..2c1f028a 100644 --- a/generic/views.py +++ b/generic/views.py @@ -1042,10 +1042,10 @@ class ExamViews(View, LoginRequiredMixin): by_question = defaultdict(dict) unmarked = set() - questions = exam.exam_questions.all() + questions = exam.exam_questions.all().prefetch_related("answers") # We could prefect the CidUserAnswers.answers here (if we didn't cache them) - cid_user_answers = self.CidUserAnswer.objects.select_related("question").prefetch_related().filter( + cid_user_answers = self.CidUserAnswer.objects.select_related("question").filter( question__in=questions, exam__id=pk )