improved error collection
This commit is contained in:
1 parent
5c0d6d8279
commit
0a06f425ff
2 files changed
+15
-9
No files matched your search
@@ -43,21 +43,24 @@ from util.generateCourses import getSampleCourses
|
|||||||
|
|
||||||
def getLineNumber(): return currentframe().f_back.f_lineno
|
def getLineNumber(): return currentframe().f_back.f_lineno
|
||||||
|
|
||||||
def newConflict(pupilNum, email, type, code, description, logs):
|
def newConflict(pupilNum: str, email: str, type: str, code: str, description: str, logs: dict):
|
||||||
if pupilNum in logs: logs[pupilNum].append({
|
exists = True if pupilNum in logs else False
|
||||||
|
if exists: logs[pupilNum].append({
|
||||||
"Pupil #": pupilNum,
|
"Pupil #": pupilNum,
|
||||||
"Email": email,
|
"Email": email,
|
||||||
"Type": type,
|
"Type": type,
|
||||||
"Code": code,
|
"Code": code,
|
||||||
"Conflict": description
|
"Conflict": description
|
||||||
})
|
})
|
||||||
else: logs[pupilNum] = [{
|
else:
|
||||||
|
logs[pupilNum] = [{
|
||||||
"Pupil #": pupilNum,
|
"Pupil #": pupilNum,
|
||||||
"Email": email,
|
"Email": email,
|
||||||
"Type": type,
|
"Type": type,
|
||||||
"Code": code,
|
"Code": code,
|
||||||
"Conflict": description
|
"Conflict": description
|
||||||
}]
|
}]
|
||||||
|
return exists
|
||||||
|
|
||||||
minReq, median, classCap = 18, 24, 30
|
minReq, median, classCap = 18, 24, 30
|
||||||
mockStudents = []
|
mockStudents = []
|
||||||
@@ -90,7 +93,7 @@ def generateScheduleV3(
|
|||||||
conflictsDir: str="../output/conflicts.json"
|
conflictsDir: str="../output/conflicts.json"
|
||||||
) -> dict[str, dict]:
|
) -> dict[str, dict]:
|
||||||
|
|
||||||
def equal(l): # Used to equalize list of numbers
|
def equal(l: list) -> list: # Used to equalize list of numbers
|
||||||
q,r = divmod(sum(l),len(l))
|
q,r = divmod(sum(l),len(l))
|
||||||
return [q+1]*r + [q]*(len(l)-r)
|
return [q+1]*r + [q]*(len(l)-r)
|
||||||
|
|
||||||
@@ -367,6 +370,7 @@ def generateScheduleV3(
|
|||||||
conflictLogs = {}
|
conflictLogs = {}
|
||||||
criticalCount, acceptableCount = 0, 0
|
criticalCount, acceptableCount = 0, 0
|
||||||
c_mc_count, c_cr_count, a_mc_count = 0, 0, 0
|
c_mc_count, c_cr_count, a_mc_count = 0, 0, 0
|
||||||
|
studentsCritical, studentsAcceptable = 0, 0
|
||||||
|
|
||||||
for student in students:
|
for student in students:
|
||||||
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
||||||
@@ -514,7 +518,7 @@ def generateScheduleV3(
|
|||||||
exceptions.append(clashIndex)
|
exceptions.append(clashIndex)
|
||||||
criticalCount += 1
|
criticalCount += 1
|
||||||
c_cr_count += 1
|
c_cr_count += 1
|
||||||
newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs)
|
if not newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs): studentsCritical += 1
|
||||||
|
|
||||||
attemptResolve = False
|
attemptResolve = False
|
||||||
else: print("Impossible - Thanos")
|
else: print("Impossible - Thanos")
|
||||||
@@ -531,7 +535,7 @@ def generateScheduleV3(
|
|||||||
if (student["expectedClasses"] - 2) <= student["classes"] < student["expectedClasses"]:
|
if (student["expectedClasses"] - 2) <= student["classes"] < student["expectedClasses"]:
|
||||||
a_mc_count += 1
|
a_mc_count += 1
|
||||||
acceptableCount += 1
|
acceptableCount += 1
|
||||||
newConflict(student["Pupil #"], "", "Acceptable", "A-MC", "Missing 1-2 Classses", conflictLogs)
|
if not newConflict(student["Pupil #"], "", "Acceptable", "A-MC", "Missing 1-2 Classses", conflictLogs): studentsAcceptable += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
elif student["classes"] < (student["expectedClasses"] - 2):
|
elif student["classes"] < (student["expectedClasses"] - 2):
|
||||||
@@ -540,7 +544,7 @@ def generateScheduleV3(
|
|||||||
if student["Pupil #"] in conflictLogs:
|
if student["Pupil #"] in conflictLogs:
|
||||||
c_mc_count += 1
|
c_mc_count += 1
|
||||||
criticalCount += 1
|
criticalCount += 1
|
||||||
newConflict(student["Pupil #"], "", "Critical", "C-MC", "Missing too many Classses", conflictLogs)
|
if not newConflict(student["Pupil #"], "", "Critical", "C-MC", "Missing too many Classses", conflictLogs): studentsCritical += 1
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -559,6 +563,7 @@ def generateScheduleV3(
|
|||||||
"Conflicts": conflictLogs,
|
"Conflicts": conflictLogs,
|
||||||
"Critical": {
|
"Critical": {
|
||||||
"Total": criticalCount,
|
"Total": criticalCount,
|
||||||
|
"Students": studentsCritical,
|
||||||
"Errors": [{
|
"Errors": [{
|
||||||
"Total": c_mc_count,
|
"Total": c_mc_count,
|
||||||
"Description": "Missing too many Classes",
|
"Description": "Missing too many Classes",
|
||||||
@@ -571,6 +576,7 @@ def generateScheduleV3(
|
|||||||
},
|
},
|
||||||
"Acceptable": {
|
"Acceptable": {
|
||||||
"Total": acceptableCount,
|
"Total": acceptableCount,
|
||||||
|
"Students": studentsAcceptable,
|
||||||
"Errors": [{
|
"Errors": [{
|
||||||
"Total": a_mc_count,
|
"Total": a_mc_count,
|
||||||
"Description": "Missing 1-2 Classes",
|
"Description": "Missing 1-2 Classes",
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
|||||||
f = open('./output/conflicts.json')
|
f = open('./output/conflicts.json')
|
||||||
conflicts = json.load(f)
|
conflicts = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
totalCritical = conflicts["Critical"]["Total"]
|
totalCritical = conflicts["Critical"]["Students"]
|
||||||
totalAcceptable = conflicts["Acceptable"]["Total"]
|
totalAcceptable = conflicts["Acceptable"]["Students"]
|
||||||
|
|
||||||
t = PrettyTable(['Type', 'Error %', 'Success %', 'Error Ratio'])
|
t = PrettyTable(['Type', 'Error %', 'Success %', 'Error Ratio'])
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user