Enhance user marking query to ensure distinct exams and order by name for better organization
This commit is contained in:
+8
-4
@@ -289,12 +289,16 @@ def user_marking_partial(request, exam_type: str):
|
||||
return HttpResponse("Unknown exam type", status=400)
|
||||
|
||||
# Exams where user is an author or an authorised marker
|
||||
exams_qs = ExamModel.objects.filter(
|
||||
archive=False, exam_mode=True
|
||||
).filter(Q(author=user) | Q(markers=user)).prefetch_related("author", "markers")
|
||||
exams_qs = (
|
||||
ExamModel.objects.filter(archive=False, exam_mode=True)
|
||||
.filter(Q(author=user) | Q(markers=user))
|
||||
.distinct()
|
||||
.order_by("name")
|
||||
.prefetch_related("author", "markers")
|
||||
)
|
||||
|
||||
exams_data = []
|
||||
for exam in exams_qs.order_by("name"):
|
||||
for exam in exams_qs:
|
||||
has_unmarked = False
|
||||
unmarked_count = 0
|
||||
# iterate questions and use their helper to count unmarked answers when available
|
||||
|
||||
Reference in New Issue
Block a user