more course data collection

This commit is contained in:
SowinskiBraeden committed 2022-11-15 17:27:32 -08:00
1 parent 3f1c4dff16
commit 8920104c86
3 files changed
+28 -8

No files matched your search

+5
View File
@@ -541,6 +541,11 @@ def generateScheduleV3(
for course in running[block]:
sem = "Sem1" if int(block[5:]) <= blockPerSem else "Sem2"
courses[running[block][course]["CrsNo"]][sem] += 1
courses[running[block][course]["CrsNo"]]["Occupied"] += len(running[block][course]["students"])
for course in courses:
courses[course]["Total"] = courses[course]["Sem1"] + courses[course]["Sem2"]
courses[course]["Seats"] = courses[course]["Total"] * classCap
# Update/log new student records
with open(studentsDir, "w") as outfile:
+22 -7
View File
@@ -23,11 +23,14 @@ def getCourses(
grade = getGrade(row["CrsNo"], row["Description"])
courses[row["CrsNo"]] = {
"CrsNo": row["CrsNo"],
"Requests": 0,
"Description": row["Description"],
"Sem1": 0,
"Sem2":0,
"Grade": grade
"Grade": grade,
"Requests": 0,
"Sem1": 0, # number of classes running in sem1
"Sem2": 0, # number of classes running in sem2
"Total": 0, # total number of classes running
"Seats": 0, # total number of seats
"Occupied": 0, # number of occupied seats
}
if log:
@@ -37,11 +40,21 @@ def getCourses(
return courses
# Writes all course data to csv file
def writeCoursesToCSV(courses: dict, output_dir: str='./output/raw/csv/courses.csv') -> None:
def writeCoursesToCSV(courses: dict, output_dir: str='./output/raw/csv/courses.csv', classCap: int=30) -> None:
with open(output_dir, 'w') as file:
writer = csv.writer(file)
# Write header
data = ("CrsNo", "Description", "Grade", "Requests", "First sem. # of Classes", "Second sem. # of Classes", "Total # of Classes")
data = (
"CrsNo",
"Description",
"Grade",
"Requests",
"First sem. # of Classes",
"Second sem. # of Classes",
"Total # of Classes",
"Total # of Seats",
"# of Seats Occupied"
)
writer.writerow(data)
for course in courses:
@@ -52,6 +65,8 @@ def writeCoursesToCSV(courses: dict, output_dir: str='./output/raw/csv/courses.c
courses[course]["Requests"],
courses[course]["Sem1"],
courses[course]["Sem2"],
(courses[course]["Sem1"] + courses[course]["Sem2"])
courses[course]["Total"],
courses[course]["Seats"],
courses[course]["Occupied"]
)
writer.writerow(courseData)
+1 -1
View File
@@ -90,7 +90,7 @@ def start(
with open(f'{raw_json_dir}/students.json', 'r') as sFile: students = json.load(sFile)
with open(f'{raw_json_dir}/courses.json', 'r') as cFile: courses = json.load(cFile)
writeStudentsToCSV(students, output_dir='./output/raw/csv/students.csv')
writeCoursesToCSV(courses, output_dir='./output/raw/csv/courses.csv')
writeCoursesToCSV(courses, output_dir='./output/raw/csv/courses.csv', classCap=class_cap)
eel.post_data('Writing timetables to .docx files...')
if save_student_schedules: