From 2ded484de8598fd1c09000ed80f2289fee7bfac3 Mon Sep 17 00:00:00 2001 From: Seb Palmer Date: Fri, 4 Oct 2024 16:24:54 +0000 Subject: [PATCH] 2315 bujgfix: teacher dashboard don't show levels for independent students --- game/views/level_selection.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/game/views/level_selection.py b/game/views/level_selection.py index 208e0b587..03549ef52 100644 --- a/game/views/level_selection.py +++ b/game/views/level_selection.py @@ -194,22 +194,23 @@ def levels(request, language): get_shared_level(level, attempts) ) else: - student_class = level.owner.student.class_field - class_teacher = student_class.teacher.new_user - - # get levels shared by students in the current user's classes - if class_teacher == user: - directly_shared_levels.append( - get_shared_level(level, attempts, student_class) - ) - # get levels shared by students in the other teachers' classes - else: - if class_teacher not in indirectly_shared_levels: - indirectly_shared_levels[class_teacher] = [] - - indirectly_shared_levels[class_teacher].append( - get_shared_level(level, attempts, student_class) - ) + if not level.owner.student.is_independent(): + student_class = level.owner.student.class_field + class_teacher = student_class.teacher.new_user + + # get levels shared by students in the current user's classes + if class_teacher == user: + directly_shared_levels.append( + get_shared_level(level, attempts, student_class) + ) + # get levels shared by students in the other teachers' classes + else: + if class_teacher not in indirectly_shared_levels: + indirectly_shared_levels[class_teacher] = [] + + indirectly_shared_levels[class_teacher].append( + get_shared_level(level, attempts, student_class) + ) # if user is a student or a standard teacher, just get levels shared with them directly. else: directly_shared_levels.append(get_shared_level(level, attempts))