diff --git a/server/vbv_lernwelt/dashboard/graphql/types/attendance.py b/server/vbv_lernwelt/dashboard/graphql/types/attendance.py index d6bb1e22..3f7488ae 100644 --- a/server/vbv_lernwelt/dashboard/graphql/types/attendance.py +++ b/server/vbv_lernwelt/dashboard/graphql/types/attendance.py @@ -52,15 +52,21 @@ def attendance_day_presences( url = f"/course/{course_session.course.slug}/cockpit/attendance?id={attendance_day.learning_content.id}&courseSessionId={course_session.id}" - participants_total = CourseSessionUser.objects.filter( - course_session=course_session, role=CourseSessionUser.Role.MEMBER - ).count() - + participant_user_ids = [ + str(user_id) + for user_id in CourseSessionUser.objects.filter( + course_session=course_session, role=CourseSessionUser.Role.MEMBER + ).values_list("user_id", flat=True) + ] + participants_total = len(participant_user_ids) participants_present = len( [ participant for participant in attendance_day.attendance_user_list if participant["status"] == AttendanceUserStatus.PRESENT.value + # in the `attendance_user_list` are users present, which are not + # (anymore) in the course session -> so we need to filter them out + and participant["user_id"] in participant_user_ids ] )