fix conflict data collection
This commit is contained in:
1 file changed
+28
-18
@@ -53,13 +53,19 @@ def newConflict(pupilNum: str, email: str, conflictType: str, code: str, descrip
|
|||||||
"Email": email,
|
"Email": email,
|
||||||
"Type": conflictType,
|
"Type": conflictType,
|
||||||
"Code": code,
|
"Code": code,
|
||||||
"Conflict": description,
|
"Conflict": description
|
||||||
**({"Data": courseData} if courseData is not None else {})
|
|
||||||
}
|
}
|
||||||
if exists: logs[pupilNum].append(log)
|
if exists: logs[pupilNum].append(log)
|
||||||
else: logs[pupilNum] = [log]
|
else: logs[pupilNum] = [log]
|
||||||
return exists if conflictType == "Critical" else False
|
return exists if conflictType == "Critical" else False
|
||||||
|
|
||||||
|
def insertConflictSolutions(pupilNum: str, logs: dict, data: dict) -> None:
|
||||||
|
log = logs[pupilNum]
|
||||||
|
for conflict in log:
|
||||||
|
if conflict["Type"] == "Critical":
|
||||||
|
conflict["Missing"] = data
|
||||||
|
break
|
||||||
|
|
||||||
minReq, median, classCap = 18, 24, 30
|
minReq, median, classCap = 18, 24, 30
|
||||||
running = {
|
running = {
|
||||||
"block1": {},
|
"block1": {},
|
||||||
@@ -387,9 +393,7 @@ def generateScheduleV3(
|
|||||||
|
|
||||||
if hasConflicts:
|
if hasConflicts:
|
||||||
student["classes"] = 0
|
student["classes"] = 0
|
||||||
couldnt_resolve = False
|
|
||||||
missing = []
|
missing = []
|
||||||
missingSolutions = []
|
|
||||||
# Clear student schedule to restructure
|
# Clear student schedule to restructure
|
||||||
for block in student["schedule"]:
|
for block in student["schedule"]:
|
||||||
[running[block][cname]["students"].remove(studentData) for cname in student["schedule"][block]]
|
[running[block][cname]["students"].remove(studentData) for cname in student["schedule"][block]]
|
||||||
@@ -461,7 +465,10 @@ def generateScheduleV3(
|
|||||||
c_cr_count += 1
|
c_cr_count += 1
|
||||||
criticalCount += 1
|
criticalCount += 1
|
||||||
|
|
||||||
missing.append(classes[index])
|
missing.append({
|
||||||
|
"block": f'block{index + 1}',
|
||||||
|
"CrsNo": classes[index]
|
||||||
|
})
|
||||||
|
|
||||||
if not newConflict(
|
if not newConflict(
|
||||||
student["Pupil #"],
|
student["Pupil #"],
|
||||||
@@ -492,31 +499,34 @@ def generateScheduleV3(
|
|||||||
|
|
||||||
# Collect missing course data and solutions
|
# Collect missing course data and solutions
|
||||||
|
|
||||||
data = { "missing": [] }
|
if len(missing) > 0:
|
||||||
|
data = []
|
||||||
|
|
||||||
if student["gradelevel"] is None:
|
if student["gradelevel"] is None:
|
||||||
for mCname in missing:
|
for obj in missing:
|
||||||
data["missing"].append({
|
data["missing"].append({
|
||||||
"missing": mCname,
|
"CrsNo": obj["CrsNo"],
|
||||||
|
"block": obj['block'],
|
||||||
"solutions": None,
|
"solutions": None,
|
||||||
"error": "Unable to find solutions, err no grade" })
|
"error": "Unable to find solutions, err no grade"
|
||||||
|
})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for block in student["schedule"]:
|
for obj in missing:
|
||||||
print(student["schedule"][block])
|
blockSolution = { "CrsNo": obj["CrsNo"], "block": obj['block'], "solutions": [] }
|
||||||
if len(student["schedule"][block]) == 0:
|
for cname in running[obj['block']]:
|
||||||
blockSolution = { "block": block, "courseSolutions": [] }
|
|
||||||
for cname in running[block]:
|
|
||||||
courseGrade = getGradeFromCourseCode(cname[:-2])
|
courseGrade = getGradeFromCourseCode(cname[:-2])
|
||||||
if courseGrade is None: continue
|
if courseGrade is None: continue
|
||||||
if (student["gradelevel"] == courseGrade) or (student["gradelevel"] == 12 and courseGrade == 11):
|
if (student["gradelevel"] == courseGrade) or (student["gradelevel"] == 12 and courseGrade == 11):
|
||||||
if len(running[block][cname]["students"]) < classCap:
|
if len(running[obj['block']][cname]["students"]) < classCap:
|
||||||
blockSolution["courseSolutions"].append({
|
blockSolution["solutions"].append({
|
||||||
"CrsNo": cname,
|
"CrsNo": cname,
|
||||||
"Description": running[block][cname]["Description"]
|
"Description": running[obj['block']][cname]["Description"]
|
||||||
})
|
})
|
||||||
|
|
||||||
data["solutions"].append(blockSolution)
|
data.append(blockSolution)
|
||||||
|
|
||||||
|
insertConflictSolutions(student["Pupil #"], conflictLogs, data)
|
||||||
|
|
||||||
metSelfRequirements = True if student["classes"] == student["expectedClasses"] else False
|
metSelfRequirements = True if student["classes"] == student["expectedClasses"] else False
|
||||||
if not metSelfRequirements:
|
if not metSelfRequirements:
|
||||||
|
|||||||
Reference in new issue
Block a user