track error %
This commit is contained in:
2 files changed
+50
No files matched your search
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3.11
|
||||||
|
import json
|
||||||
|
import csv
|
||||||
|
|
||||||
|
# Calculate Errors and log to .csv file
|
||||||
|
def writeErrorsToCSV(
|
||||||
|
studentsLen: int,
|
||||||
|
conflictsDir: str = './output/raw/json/conflicts.json',
|
||||||
|
outputDir: str = './output/raw/csv/errors.csv'
|
||||||
|
) -> None:
|
||||||
|
# Error Table calulation / output
|
||||||
|
with open(conflictsDir) as file:
|
||||||
|
conflicts = json.load(file)
|
||||||
|
|
||||||
|
totalCritical = conflicts["Critical"]["Students"]
|
||||||
|
totalAcceptable = conflicts["Acceptable"]["Students"]
|
||||||
|
|
||||||
|
with open(outputDir, 'w') as file:
|
||||||
|
writer = csv.writer(file)
|
||||||
|
# Write header
|
||||||
|
data = (
|
||||||
|
"Error Type",
|
||||||
|
"Error %",
|
||||||
|
"Success %",
|
||||||
|
"Student Error Ratio"
|
||||||
|
)
|
||||||
|
writer.writerow(data)
|
||||||
|
|
||||||
|
errorsC = round(totalCritical / studentsLen * 100, 2)
|
||||||
|
errorsA = round(totalAcceptable / studentsLen * 100, 2)
|
||||||
|
successC = round(100 - errorsC, 2)
|
||||||
|
successA = round(100 - errorsA, 2)
|
||||||
|
|
||||||
|
criticalData = (
|
||||||
|
'Critical',
|
||||||
|
f'{errorsC} %',
|
||||||
|
f'{successC} %',
|
||||||
|
f'{totalCritical}/{studentsLen} Students'
|
||||||
|
)
|
||||||
|
writer.writerow(criticalData)
|
||||||
|
|
||||||
|
acceptableData = (
|
||||||
|
'Acceptable',
|
||||||
|
f'{errorsA} %',
|
||||||
|
f'{successA} %',
|
||||||
|
f'{totalAcceptable}/{studentsLen} Students'
|
||||||
|
)
|
||||||
|
writer.writerow(acceptableData)
|
||||||
@@ -8,6 +8,7 @@ from app.generator import generateScheduleV3
|
|||||||
from app.util.globals import Error
|
from app.util.globals import Error
|
||||||
from app.util.courses import getCourses, writeCoursesToCSV
|
from app.util.courses import getCourses, writeCoursesToCSV
|
||||||
from app.util.students import getStudents, writeStudentsToCSV
|
from app.util.students import getStudents, writeStudentsToCSV
|
||||||
|
from app.util.errorCalculator import writeErrorsToCSV
|
||||||
|
|
||||||
eel.init('template')
|
eel.init('template')
|
||||||
|
|
||||||
@@ -92,6 +93,7 @@ def start(
|
|||||||
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')
|
||||||
|
writeErrorsToCSV(len(students), conflictsDir='./output/raw/json/conflicts.json', outputDir='./output/raw/csv/error_tracker.csv')
|
||||||
|
|
||||||
eel.post_data('Writing master timetable to .xlsx file...')
|
eel.post_data('Writing master timetable to .xlsx file...')
|
||||||
putMasterTimetable(master_timetable, './output/final')
|
putMasterTimetable(master_timetable, './output/final')
|
||||||
|
|||||||
Reference in new issue
Block a user