Ejemplo n.º 1
0
def displayScheduleAdmin():
    printLogEntry("Running displayScheduleAdmin()")
    uploadClassScheduleFormDetails = uploadClassScheduleForm()
    propagateClassAttendanceLogsFormDetails = propagateClassAttendanceLogsForm(
    )
    propagateClassAttendanceLogsFormDetails.schoolYear.choices = getSchoolYear(
    )
    propagateClassAttendanceLogsFormDetails.semester.choices = getSemester()
    deleteClassScheduleFormDetails = deleteClassScheduleForm()
    deleteClassScheduleFormDetails.schoolYear.choices = getSchoolYear()
    deleteClassScheduleFormDetails.semester.choices = getSemester()
    deleteClassScheduleFormDetails.yearOfGraduation.choices = getYearOfGraduation(
    )
    downloadClassScheduleFormDetails = downloadClassScheduleForm()
    downloadClassScheduleFormDetails.schoolYear.choices = getSchoolYear()
    downloadClassScheduleFormDetails.semester.choices = getSemester()
    downloadClassAttendanceFormDetails = downloadClassAttendanceForm()
    downloadClassAttendanceFormDetails.schoolYear.choices = getSchoolYear()
    downloadClassAttendanceFormDetails.semester.choices = getSemester()
    downloadClassAttendanceFormDetails.teacherName.choices = getTeachers()
    addSingleClassScheduleDetails = addSingleClassSchedule()
    addSingleClassScheduleDetails.schoolYear.choices = getSchoolYear()
    addSingleClassScheduleDetails.semester.choices = getSemester()
    addSingleClassScheduleDetails.teacherName.choices = getTeachers()
    addSingleClassScheduleDetails.studentName.choices = getStudents()
    addSingleClassScheduleDetails.campus.choices = getCampusChoices()
    addSingleClassScheduleDetails.className.choices = getClassNames()
    addSingleClassScheduleDetails.classDays.choices = [
        ("M", "M"),
        ("T", "T"),
        ("W", "W"),
        ("R", "R"),
        ("F", "F"),
    ]
    if request.method == "POST":
        printLogEntry("form= " + str(request.form))

    if "submitUploadClassSchedule" in request.form:
        if uploadClassScheduleFormDetails.validate_on_submit():
            printLogEntry("Upload Form Submitted")
            if uploadClassScheduleFormDetails.csvClassScheduleFile.data:
                uploadedScheduleFile = save_File(
                    uploadClassScheduleFormDetails.csvClassScheduleFile.data,
                    "Uploaded_Schedule_File.csv",
                )
                uploadSchedules(uploadedScheduleFile)
                return redirect(
                    url_for("scheduleAdmin_bp.displayScheduleAdmin"))
    printFormErrors(uploadClassScheduleFormDetails)
    if "submitPropagatelassAttendanceLogs" in request.form:
        if propagateClassAttendanceLogsFormDetails.validate_on_submit():
            printLogEntry("Propagate Form Submitted")
            schoolYear = int(
                propagateClassAttendanceLogsFormDetails.schoolYear.data)
            semester = propagateClassAttendanceLogsFormDetails.semester.data
            startDate = propagateClassAttendanceLogsFormDetails.startDate.data
            endDate = propagateClassAttendanceLogsFormDetails.endDate.data
            print(
                "schoolYear=",
                schoolYear,
                "semester=",
                semester,
                "startDate=",
                startDate,
                "endDate=",
                endDate,
            )
            propagateClassSchedule(startDate, endDate, schoolYear, semester)
            return redirect(url_for("scheduleAdmin_bp.displayScheduleAdmin"))
    printFormErrors(propagateClassAttendanceLogsFormDetails)
    if "submitDeleteClassScheduleForm" in request.form:
        if deleteClassScheduleFormDetails.validate_on_submit():
            if (deleteClassScheduleFormDetails.confirmDeleteClassSchedule.data
                    == "DELETE"):
                printLogEntry("Delete Class Schedule Form Submitted")
                schoolYear = deleteClassScheduleFormDetails.schoolYear.data
                semester = deleteClassScheduleFormDetails.semester.data
                yearOfGraduation = deleteClassScheduleFormDetails.yearOfGraduation.data
                print(
                    "SchoolYear=",
                    schoolYear,
                    " Semester=",
                    semester,
                    yearOfGraduation,
                )
                deleteClassSchedule(schoolYear, semester, yearOfGraduation)
                deleteClassScheduleFormDetails.confirmDeleteClassSchedule.data = ""
                # deleteClassScheduleFormDetails.process()
                return redirect(
                    url_for("scheduleAdmin_bp.displayScheduleAdmin"))
            else:
                deleteClassScheduleFormDetails.confirmDeleteClassSchedule.data = ""
                printLogEntry("Type DELETE in the text box to confirm delete")
    if "submitAddSingleClassSchedule" in request.form:
        if addSingleClassScheduleDetails.validate_on_submit():
            printLogEntry("Add Single Class Schedule submitted")
            schoolYear = addSingleClassScheduleDetails.schoolYear.data
            semester = addSingleClassScheduleDetails.semester.data
            chattStateANumber = addSingleClassScheduleDetails.studentName.data
            teacherLastName = addSingleClassScheduleDetails.teacherName.data
            className = addSingleClassScheduleDetails.className.data
            classDaysList = addSingleClassScheduleDetails.classDays.data
            classDays = ""
            for classDay in classDaysList:
                classDays = classDays + classDay
            startTime = addSingleClassScheduleDetails.startTime.data
            endTime = addSingleClassScheduleDetails.endTime.data
            online = addSingleClassScheduleDetails.online.data
            indStudy = addSingleClassScheduleDetails.indStudy.data
            comment = addSingleClassScheduleDetails.comment.data
            googleCalendarEventID = (
                addSingleClassScheduleDetails.googleCalendarEventID.data)
            campus = "STEM School"
            staffID = None

            print(
                schoolYear,
                semester,
                chattStateANumber,
                teacherLastName,
                className,
                classDays,
                startTime,
                endTime,
                online,
                indStudy,
                comment,
                googleCalendarEventID,
            )
            addClassSchedule(
                schoolYear,
                semester,
                chattStateANumber,
                campus,
                className,
                teacherLastName,
                staffID,
                online,
                indStudy,
                classDays,
                startTime,
                endTime,
                comment,
                googleCalendarEventID,
            )
            return redirect(url_for("scheduleAdmin_bp.displayScheduleAdmin"))

    if "submitDownloadClassScheduleForm" in request.form:
        if downloadClassScheduleFormDetails.validate_on_submit():
            schoolYear = downloadClassScheduleFormDetails.schoolYear.data
            semester = downloadClassScheduleFormDetails.semester.data
            printLogEntry("Download Class Schedule Form Submitted")
            print(
                "SchoolYear=",
                schoolYear,
                " Semester=",
                semester,
            )
            return downloadClassSchedule(schoolYear, semester)
    if "submitDownloadClassAttendanceForm" in request.form:
        if downloadClassAttendanceFormDetails.validate_on_submit():
            schoolYear = downloadClassAttendanceFormDetails.schoolYear.data
            semester = downloadClassAttendanceFormDetails.semester.data
            teacherName = downloadClassAttendanceFormDetails.teacherName.data
            startDate = downloadClassAttendanceFormDetails.startDate.data
            endDate = downloadClassAttendanceFormDetails.endDate.data
            printLogEntry("Download Class Attendance Form Submitted")
            print(
                "SchoolYear=",
                schoolYear,
                " Semester=",
                semester,
                " teacherName=",
                teacherName,
                " startDate=",
                startDate,
                " endDate=",
                endDate,
            )
            return downloadClassAttendanceLog(schoolYear, semester,
                                              teacherName, startDate, endDate)
    return render_template(
        "scheduleadmin.html",
        title="Schedule Admin",
        propagateClassAttendanceLogsForm=
        propagateClassAttendanceLogsFormDetails,
        uploadClassScheduleForm=uploadClassScheduleFormDetails,
        deleteClassScheduleForm=deleteClassScheduleFormDetails,
        downloadClassScheduleForm=downloadClassScheduleFormDetails,
        downloadClassAttendanceForm=downloadClassAttendanceFormDetails,
        addSingleClassSchedule=addSingleClassScheduleDetails,
    )
Ejemplo n.º 2
0
def displayP2MTAdmin():
    printLogEntry("Running displayP2MTAdmin()")
    addStudentFormDetails = addStudentForm()
    selectStudentToEditFormDetails = selectStudentToEditForm()
    selectStudentToEditFormDetails.studentName.choices = getStudentsById()
    downloadStudentListFormDetails = downloadStudentListForm()
    uploadStudentListFormDetails = uploadStudentListForm()
    deleteStudentFormDetails = deleteStudentForm()
    deleteStudentFormDetails.studentName.choices = getStudents()
    selectParentsToEditFormDetails = selectParentsToEditForm()
    selectParentsToEditFormDetails.studentName.choices = getStudents()
    downloadParentsListFormDetails = downloadParentsListForm()
    uploadParentsListFormDetails = uploadParentsListForm()
    addStaffFormDetails = addStaffForm()
    selectStaffToEditFormDetails = selectStaffToEditForm()
    selectStaffToEditFormDetails.staffName.choices = getStaffFromFacultyAndStaff(
    )
    downloadStaffListFormDetails = downloadStaffListForm()
    uploadStaffListFormDetails = uploadStaffListForm()
    deleteStaffFormDetails = deleteStaffForm()
    deleteStaffFormDetails.staffName.choices = getStaffFromFacultyAndStaff()

    # Retrieve staff info for display (except for system account)
    staffInfo = FacultyAndStaff.query.filter(
        FacultyAndStaff.lastName != "System").order_by(
            FacultyAndStaff.lastName.asc())

    if request.method == "POST":
        printLogEntry("form= " + str(request.form))
    if "submitAddStudent" in request.form:
        if addStudentFormDetails.validate_on_submit():
            printLogEntry("Add Student submitted")
            firstName = addStudentFormDetails.firstName.data
            lastName = addStudentFormDetails.lastName.data
            chattStateANumber = addStudentFormDetails.chattStateANumber.data
            email = addStudentFormDetails.email.data
            yearOfGraduation = int(addStudentFormDetails.yearOfGraduation.data)
            house = addStudentFormDetails.house.data
            googleCalendarId = addStudentFormDetails.googleCalendarId.data

            addStudentToDatabase(
                chattStateANumber,
                firstName,
                lastName,
                email,
                house,
                yearOfGraduation,
                googleCalendarId,
            )
            return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
    printFormErrors(addStudentFormDetails)

    if "submitStudentToEdit" in request.form:
        if selectStudentToEditFormDetails.validate_on_submit:
            printLogEntry("Student to Edit Form Submitted")
            student_id = int(selectStudentToEditFormDetails.studentName.data)
            print("student_id = ", student_id)
            return redirect(
                url_for("p2mtAdmin_bp.updateStudent", student_id=student_id))
    printFormErrors(selectStudentToEditFormDetails)

    if "submitDownloadStudentListForm" in request.form:
        if downloadStudentListFormDetails.validate_on_submit():
            printLogEntry("Download Student List Form Submitted")
            return downloadStudentList()

    if "submitUploadStudentList" in request.form:
        if uploadStudentListFormDetails.validate_on_submit():
            printLogEntry("Upload Student List Form Submitted")
            if uploadStudentListFormDetails.csvStudentListFile.data:
                uploadedStudentListFile = save_File(
                    uploadStudentListFormDetails.csvStudentListFile.data,
                    "Uploaded_StudentList_File.csv",
                )
                uploadStudentList(uploadedStudentListFile)
                return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
    printFormErrors(uploadStudentListFormDetails)

    if "submitDeleteStudent" in request.form:
        if deleteStudentFormDetails.validate_on_submit():
            if deleteStudentFormDetails.confirmDeleteStudent.data == "DELETE":
                printLogEntry("Delete Student Form Submitted")
                # studentName returns chattStateANumber as its value
                chattStateANumber = deleteStudentFormDetails.studentName.data
                print("chattStateANumber =", chattStateANumber)
                deleteStudent(chattStateANumber)
                deleteStudentFormDetails.confirmDeleteStudent.data = ""
                # deleteClassScheduleFormDetails.process()
                return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
            else:
                deleteStudentFormDetails.confirmDeleteStudent.data = ""
                printLogEntry("Type DELETE in the text box to confirm delete")
    printFormErrors(deleteStudentFormDetails)

    if "submitParentsToEdit" in request.form:
        if selectParentsToEditFormDetails.validate_on_submit:
            printLogEntry("Parents to Edit Form Submitted")
            chattStateANumber = selectParentsToEditFormDetails.studentName.data
            print("chattStateANumber = ", chattStateANumber)
            return redirect(
                url_for("p2mtAdmin_bp.updateParents",
                        chattStateANumber=chattStateANumber))
    printFormErrors(selectParentsToEditFormDetails)

    if "submitDownloadParentsListForm" in request.form:
        if downloadParentsListFormDetails.validate_on_submit():
            printLogEntry("Download Parent List Form Submitted")
            return downloadParentsList()

    if "submitUploadParentsList" in request.form:
        if uploadParentsListFormDetails.validate_on_submit():
            printLogEntry("Upload Parents List Form Submitted")
            if uploadParentsListFormDetails.csvParentsListFile.data:
                uploadedParentsListFile = save_File(
                    uploadParentsListFormDetails.csvParentsListFile.data,
                    "Uploaded_ParentsList_File.csv",
                )
                uploadParentsList(uploadedParentsListFile)
                return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
    printFormErrors(uploadParentsListFormDetails)

    if "submitAddStaff" in request.form:
        if addStaffFormDetails.validate_on_submit():
            printLogEntry("Add Staff submitted")
            firstName = addStaffFormDetails.firstName.data
            lastName = addStaffFormDetails.lastName.data
            position = addStaffFormDetails.position.data
            email = addStaffFormDetails.email.data
            phoneNumber = addStaffFormDetails.phoneNumber.data
            chattStateANumber = addStaffFormDetails.chattStateANumber.data
            myersBriggs = addStaffFormDetails.myersBriggs.data
            house = addStaffFormDetails.house.data
            houseGrade = addStaffFormDetails.houseGrade.data
            twitterAccount = addStaffFormDetails.twitterAccount.data

            addStaffToDatabase(
                firstName,
                lastName,
                position,
                email,
                phoneNumber,
                chattStateANumber,
                myersBriggs,
                house,
                houseGrade,
                twitterAccount,
            )
            return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
    printFormErrors(addStaffFormDetails)

    if "submitDownloadStaffListForm" in request.form:
        if downloadStaffListFormDetails.validate_on_submit():
            printLogEntry("Download Staff List Form Submitted")
            return downloadStaffList()

    if "submitStaffToEdit" in request.form:
        if selectStaffToEditFormDetails.validate_on_submit:
            printLogEntry("Staff to Edit Form Submitted")
            staff_id = int(selectStaffToEditFormDetails.staffName.data)
            print("staff_id = ", staff_id)
            return redirect(
                url_for("p2mtAdmin_bp.updateStaff", staff_id=staff_id))
    printFormErrors(selectStaffToEditFormDetails)

    if "submitUploadStaffList" in request.form:
        if uploadStaffListFormDetails.validate_on_submit():
            printLogEntry("Upload Staff List Form Submitted")
            if uploadStaffListFormDetails.csvStaffListFile.data:
                uploadedStaffListFile = save_File(
                    uploadStaffListFormDetails.csvStaffListFile.data,
                    "Uploaded_StaffList_File.csv",
                )
                uploadStaffList(uploadedStaffListFile)
                return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
    printFormErrors(uploadStaffListFormDetails)

    if "submitDeleteStaff" in request.form:
        if deleteStaffFormDetails.validate_on_submit():
            if deleteStaffFormDetails.confirmDeleteStaff.data == "DELETE":
                printLogEntry("Delete Staff Form Submitted")
                # staffname returns log id as its value
                log_id = int(deleteStaffFormDetails.staffName.data)
                print("log_id =", log_id)
                deleteStaff(log_id)
                deleteStaffFormDetails.confirmDeleteStaff.data = ""
                # deleteClassScheduleFormDetails.process()
                return redirect(url_for("p2mtAdmin_bp.displayP2MTAdmin"))
            else:
                deleteStaffFormDetails.confirmDeleteStaff.data = ""
                printLogEntry("Type DELETE in the text box to confirm delete")
    printFormErrors(deleteStaffFormDetails)

    return render_template(
        "p2mtadmin.html",
        title="P2MT Admin",
        staffInfo=staffInfo,
        addStudentForm=addStudentFormDetails,
        selectStudentToEditForm=selectStudentToEditFormDetails,
        downloadStudentListForm=downloadStudentListFormDetails,
        uploadStudentListForm=uploadStudentListFormDetails,
        deleteStudentForm=deleteStudentFormDetails,
        selectParentsToEditForm=selectParentsToEditFormDetails,
        downloadParentsListForm=downloadParentsListFormDetails,
        uploadParentsListForm=uploadParentsListFormDetails,
        addStaffForm=addStaffFormDetails,
        selectStaffToEditForm=selectStaffToEditFormDetails,
        downloadStaffListForm=downloadStaffListFormDetails,
        uploadStaffListForm=uploadStaffListFormDetails,
        deleteStaffForm=deleteStaffFormDetails,
    )
Ejemplo n.º 3
0
def displayLearningLab():
    printLogEntry("Running displayLearningLab()")
    # Learning lab uses the same form as adding a single class schedule
    # This form includes several fields which can be pre-set rather
    # than including the fields on the form
    # Pre-setting the fields will avoid form validation errors later
    addLearningLabDetails = addLearningLabToSchedule()
    # Pre-set campus equal to STEM School
    addLearningLabDetails.campus.choices = getCampusChoices()
    addLearningLabDetails.campus.data = "STEM School"
    # Pre-set school year to current school year
    addLearningLabDetails.schoolYear.choices = getSchoolYear()
    addLearningLabDetails.schoolYear.data = getCurrentSchoolYear()
    # Pre-set semester to current semester
    addLearningLabDetails.semester.choices = getSemester()
    addLearningLabDetails.semester.data = getCurrentSemester()
    addLearningLabDetails.teacherName.choices = getTeachers(
        use_staff_list=True)
    addLearningLabDetails.studentName.choices = getStudents()
    addLearningLabDetails.className.choices = getClassNames(campus="All")
    addLearningLabDetails.classDays.choices = getClassDayChoices()
    addLearningLabDetails.classDays2.choices = getClassDayChoices()
    addLearningLabDetails.classDays3.choices = getClassDayChoices()
    addLearningLabDetails.classDays4.choices = getClassDayChoices()
    addLearningLabDetails.classDays5.choices = getClassDayChoices()
    addLearningLabDetails.submitAddSingleClassSchedule.label.text = (
        "Submit New Learning Lab")
    print(request.form)
    # Handle form submission for adding new learning lab
    if "submitAddSingleClassSchedule" in request.form:
        if addLearningLabDetails.validate_on_submit():
            printLogEntry("Add Learning Lab submitted")

            schoolYear = addLearningLabDetails.schoolYear.data
            semester = addLearningLabDetails.semester.data
            chattStateANumber = addLearningLabDetails.studentName.data
            teacherLastName = addLearningLabDetails.teacherName.data
            className = addLearningLabDetails.className.data
            startDate = addLearningLabDetails.startDate.data
            endDate = addLearningLabDetails.endDate.data
            online = addLearningLabDetails.online.data
            indStudy = addLearningLabDetails.indStudy.data
            comment = addLearningLabDetails.comment.data
            googleCalendarEventID = addLearningLabDetails.googleCalendarEventID.data
            campus = "STEM School"
            staffID = current_user.id
            learningLab = True

            print(
                schoolYear,
                semester,
                chattStateANumber,
                teacherLastName,
                className,
                online,
                indStudy,
                comment,
                googleCalendarEventID,
                learningLab,
            )

            printLogEntry("Adding intervention")
            interventionType = 2
            interventionLevel = 1
            interventionLog = add_InterventionLog(
                chattStateANumber,
                interventionType,
                interventionLevel,
                startDate,
                endDate,
                comment,
                parentNotification=datetime.utcnow(),
            )
            db.session.commit()
            print("new intervention log ID:", interventionLog.id)
            # Store all of the common fields in a single variable for later use
            learningLabCommonFields = [
                schoolYear,
                semester,
                chattStateANumber,
                campus,
                className,
                teacherLastName,
                staffID,
                online,
                indStudy,
                comment,
                googleCalendarEventID,
                interventionLog.id,
                learningLab,
                startDate,
                endDate,
            ]
            # Initialize a list to store details of learning labs for email notifications
            learningLabList = []
            # Process each of the five possible entries of learning lab days/time
            if addLearningLabDetails.addTimeAndDays.data:
                print("Adding learning lab time 1")
                # Format time values from string objects to time objects
                startTime = datetime.strptime(
                    addLearningLabDetails.startTime.data, "%H:%M").time()
                endTime = datetime.strptime(addLearningLabDetails.endTime.data,
                                            "%H:%M").time()
                learningLabClassSchedule = addLearningLabTimeAndDays(
                    learningLabCommonFields,
                    addLearningLabDetails.classDays.data,
                    startTime,
                    endTime,
                )
                propagateLearningLab(
                    learningLabClassSchedule.id,
                    startDate,
                    endDate,
                    schoolYear,
                    semester,
                )
                learningLabList = updatelearningLabList(
                    learningLabList,
                    addLearningLabDetails.classDays.data,
                    startTime,
                    endTime,
                )
            if addLearningLabDetails.addTimeAndDays2.data:
                print("Adding learning lab time 2")
                # Format time values from string objects to time objects
                startTime2 = datetime.strptime(
                    addLearningLabDetails.startTime2.data, "%H:%M").time()
                endTime2 = datetime.strptime(
                    addLearningLabDetails.endTime2.data, "%H:%M").time()

                learningLabClassSchedule = addLearningLabTimeAndDays(
                    learningLabCommonFields,
                    addLearningLabDetails.classDays2.data,
                    startTime2,
                    endTime2,
                )
                propagateLearningLab(
                    learningLabClassSchedule.id,
                    startDate,
                    endDate,
                    schoolYear,
                    semester,
                )
                learningLabList = updatelearningLabList(
                    learningLabList,
                    addLearningLabDetails.classDays2.data,
                    startTime2,
                    endTime2,
                )
            if addLearningLabDetails.addTimeAndDays3.data:
                print("Adding learning lab time 3")
                # Format time values from string objects to time objects
                startTime3 = datetime.strptime(
                    addLearningLabDetails.startTime3.data, "%H:%M").time()
                endTime3 = datetime.strptime(
                    addLearningLabDetails.endTime3.data, "%H:%M").time()
                learningLabClassSchedule = addLearningLabTimeAndDays(
                    learningLabCommonFields,
                    addLearningLabDetails.classDays3.data,
                    startTime3,
                    endTime3,
                )
                propagateLearningLab(
                    learningLabClassSchedule.id,
                    startDate,
                    endDate,
                    schoolYear,
                    semester,
                )
                learningLabList = updatelearningLabList(
                    learningLabList,
                    addLearningLabDetails.classDays3.data,
                    startTime3,
                    endTime3,
                )
            if addLearningLabDetails.addTimeAndDays4.data:
                print("Adding learning lab time 4")
                # Format time values from string objects to time objects
                startTime4 = datetime.strptime(
                    addLearningLabDetails.startTime4.data, "%H:%M").time()
                endTime4 = datetime.strptime(
                    addLearningLabDetails.endTime4.data, "%H:%M").time()
                learningLabClassSchedule = addLearningLabTimeAndDays(
                    learningLabCommonFields,
                    addLearningLabDetails.classDays4.data,
                    startTime4,
                    endTime4,
                )
                propagateLearningLab(
                    learningLabClassSchedule.id,
                    startDate,
                    endDate,
                    schoolYear,
                    semester,
                )
                learningLabList = updatelearningLabList(
                    learningLabList,
                    addLearningLabDetails.classDays4.data,
                    startTime4,
                    endTime4,
                )
            if addLearningLabDetails.addTimeAndDays5.data:
                print("Adding learning lab time 5")
                # Format time values from string objects to time objects
                startTime5 = datetime.strptime(
                    addLearningLabDetails.startTime5.data, "%H:%M").time()
                endTime5 = datetime.strptime(
                    addLearningLabDetails.endTime5.data, "%H:%M").time()
                learningLabClassSchedule = addLearningLabTimeAndDays(
                    learningLabCommonFields,
                    addLearningLabDetails.classDays5.data,
                    startTime5,
                    endTime5,
                )
                propagateLearningLab(
                    learningLabClassSchedule.id,
                    startDate,
                    endDate,
                    schoolYear,
                    semester,
                )
                learningLabList = updatelearningLabList(
                    learningLabList,
                    addLearningLabDetails.classDays5.data,
                    startTime5,
                    endTime5,
                )
            print("learningLabList =", learningLabList)
            # Define learning lab parameters for intervention email
            intervention_id = getInterventionId("Academic Behavior")
            interventionLevel = 1
            templateParams = {
                "learningLabList": learningLabList,
                "className": className,
                "teacherLastName": teacherLastName,
            }
            sendInterventionEmail(
                chattStateANumber,
                intervention_id,
                interventionLevel,
                startDate,
                endDate,
                comment,
                templateParams=templateParams,
            )
            return redirect(url_for("learningLab_bp.displayLearningLab"))
    print("addLearningLabDetails.errors: ", addLearningLabDetails.errors)

    # Get list of learning labs to display on learning lab manager
    start_of_current_school_year = get_start_of_current_school_year()
    end_of_current_school_year = get_end_of_current_school_year()
    LearningLabSchedules = (db.session.query(ClassSchedule).join(
        InterventionLog).join(Student).filter(
            ClassSchedule.learningLab == True,
            InterventionLog.endDate >= start_of_current_school_year,
            InterventionLog.endDate <= end_of_current_school_year,
        ).order_by(InterventionLog.endDate.desc(),
                   Student.lastName.asc())).all()

    return render_template(
        "learninglabmanager.html",
        title="Learning Lab",
        addSingleClassSchedule=addLearningLabDetails,
        ClassSchedules=LearningLabSchedules,
    )