def update_attendance(meeting_doc: MeetingDocument,
                      attendance: StudentMeetingAttendance):
    st_query = StudentDocument.objects(id=attendance.student_id)
    if len(st_query) < 1:
        print(
            "ERROR: update_student_attendance, could not find Student Document"
        )
    else:
        student = st_query[0]
        student.meetings_registered[str(
            attendance.meeting_id)] = attendance.attended
        update_count = 1 if attendance.attended else -1
        update_meeting_count(student,
                             meeting_doc.session_level,
                             attended=update_count)
        student.save()

    index = student_meeting_index(meeting_doc, attendance.student_id)
    if index is not None:
        meeting_doc.students[index]["attended"] = attendance.attended
        meeting_doc.save()
    else:
        print(
            "ERROR: update_student_attendance, student not registered for meeting"
        )
示例#2
0
def remove_student_from_meeting(
    meeting_doc: MeetingDocument, student_id: PydanticObjectId
):
    index = student_meeting_index(meeting_doc, student_id)
    if index is not None:
        del meeting_doc.students[index]
        meeting_doc.save()
    else:
        print("ERROR: remove_student_from_meeting student not found in MeetingDocument")