def PutStudentAttendance(self,
                             student_id: int,
                             start_date: str = None,
                             end_date: str = None,
                             status: str = None):
        """Put the student attendance based on start date and end date and student id"""
        if not start_date or not end_date:
            start_date = end_date = utils.GetTodaysDateAsStartAndEndDate()

        transaction_mgr = TransactionalManager()
        db_conn = transaction_mgr.GetDatabaseConnection("READWRITE")
        attendance_dao = AttendanceDao(db_conn)
        attendance_dates_status_map = attendance_dao.PutAttendanceByStudentId(
            student_id, start_date, end_date, status)
        transaction_mgr.save()
    def PostStudentsAttendance(self,
                               class_id: int,
                               updated_by: int,
                               roll_no: int,
                               start_date: str = None,
                               end_date: str = None,
                               status: str = None):
        """Post the student attendance based on start date and end date and student id"""
        if not start_date or not end_date:
            start_date = end_date = utils.GetTodaysDateAsStartAndEndDate()

        transaction_mgr = TransactionalManager()
        db_conn = transaction_mgr.GetDatabaseConnection("READWRITE")
        attendance_dao = AttendanceDao(db_conn)

        attendance_dates_status_map = attendance_dao.PostAttendanceByClassId(
            class_id, updated_by, roll_no, start_date, end_date, status)
        transaction_mgr.save()
    def GetStudentAttendance(self,
                             student_id: int,
                             start_date: str = None,
                             end_date: str = None):
        """Get the student attendance based on start date and end date."""
        if not start_date or not end_date:
            start_date = end_date = utils.GetTodaysDateAsStartAndEndDate()

        transaction_mgr = TransactionalManager()
        db_conn = transaction_mgr.GetDatabaseConnection("READWRITE")
        attendance_dao = AttendanceDao(db_conn)

        # Make dao request to get the data.
        attendance_dates_status_map = attendance_dao.GetAttendanceByStudentId(
            student_id, start_date, end_date)
        for attendance_records in attendance_dates_status_map:
            attendance_records['attendance_date'] = attendance_records[
                'attendance_date'].strftime("%Y-%m-%d")

        return attendance_dates_status_map