more course data collection
This commit is contained in:
3 files changed
+29
-9
No files matched your search
@@ -541,6 +541,11 @@ def generateScheduleV3(
|
|||||||
for course in running[block]:
|
for course in running[block]:
|
||||||
sem = "Sem1" if int(block[5:]) <= blockPerSem else "Sem2"
|
sem = "Sem1" if int(block[5:]) <= blockPerSem else "Sem2"
|
||||||
courses[running[block][course]["CrsNo"]][sem] += 1
|
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
|
# Update/log new student records
|
||||||
with open(studentsDir, "w") as outfile:
|
with open(studentsDir, "w") as outfile:
|
||||||
|
|||||||
+23
-8
@@ -22,12 +22,15 @@ def getCourses(
|
|||||||
if not exists:
|
if not exists:
|
||||||
grade = getGrade(row["CrsNo"], row["Description"])
|
grade = getGrade(row["CrsNo"], row["Description"])
|
||||||
courses[row["CrsNo"]] = {
|
courses[row["CrsNo"]] = {
|
||||||
"CrsNo": row["CrsNo"],
|
"CrsNo": row["CrsNo"],
|
||||||
"Requests": 0,
|
|
||||||
"Description": row["Description"],
|
"Description": row["Description"],
|
||||||
"Sem1": 0,
|
"Grade": grade,
|
||||||
"Sem2":0,
|
"Requests": 0,
|
||||||
"Grade": grade
|
"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:
|
if log:
|
||||||
@@ -37,11 +40,21 @@ def getCourses(
|
|||||||
return courses
|
return courses
|
||||||
|
|
||||||
# Writes all course data to csv file
|
# 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:
|
with open(output_dir, 'w') as file:
|
||||||
writer = csv.writer(file)
|
writer = csv.writer(file)
|
||||||
# Write header
|
# 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)
|
writer.writerow(data)
|
||||||
|
|
||||||
for course in courses:
|
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]["Requests"],
|
||||||
courses[course]["Sem1"],
|
courses[course]["Sem1"],
|
||||||
courses[course]["Sem2"],
|
courses[course]["Sem2"],
|
||||||
(courses[course]["Sem1"] + courses[course]["Sem2"])
|
courses[course]["Total"],
|
||||||
|
courses[course]["Seats"],
|
||||||
|
courses[course]["Occupied"]
|
||||||
)
|
)
|
||||||
writer.writerow(courseData)
|
writer.writerow(courseData)
|
||||||
@@ -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}/students.json', 'r') as sFile: students = json.load(sFile)
|
||||||
with open(f'{raw_json_dir}/courses.json', 'r') as cFile: courses = json.load(cFile)
|
with open(f'{raw_json_dir}/courses.json', 'r') as cFile: courses = json.load(cFile)
|
||||||
writeStudentsToCSV(students, output_dir='./output/raw/csv/students.csv')
|
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...')
|
eel.post_data('Writing timetables to .docx files...')
|
||||||
if save_student_schedules:
|
if save_student_schedules:
|
||||||
|
|||||||
Reference in new issue
Block a user