fix: filter out participants which are not anymore in the course session
This commit is contained in:
parent
eb845e830a
commit
f3da6d3c9d
|
|
@ -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
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue