work on step 6
This commit is contained in:
1 parent
a2d365625e
commit
73590ccbf9
1 file changed
+45
-27
@@ -353,6 +353,7 @@ def generateScheduleV3(
|
|||||||
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
initialBlocks = [student["schedule"][block] for block in student["schedule"]]
|
||||||
conflicts = sum(1 for b in initialBlocks if len(b)>1)
|
conflicts = sum(1 for b in initialBlocks if len(b)>1)
|
||||||
hasConflicts = True if conflicts > 0 else False
|
hasConflicts = True if conflicts > 0 else False
|
||||||
|
|
||||||
# If there is no conflicts
|
# If there is no conflicts
|
||||||
# and classes inserted to is equal to expectedClasses
|
# and classes inserted to is equal to expectedClasses
|
||||||
# or classes the student is inserted do is missing
|
# or classes the student is inserted do is missing
|
||||||
@@ -364,6 +365,15 @@ def generateScheduleV3(
|
|||||||
(student["expectedClasses"]-2) <= student["classes"] < student["expectedClasses"]
|
(student["expectedClasses"]-2) <= student["classes"] < student["expectedClasses"]
|
||||||
)
|
)
|
||||||
): continue
|
): continue
|
||||||
|
|
||||||
|
studentData = {
|
||||||
|
"Pupil #": student["Pupil #"],
|
||||||
|
"index": student["studentIndex"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# If we are unable to solve, we add to exceptions
|
||||||
|
# and keep trying to resolve the rest of the schedule
|
||||||
|
exceptions = []
|
||||||
|
|
||||||
while hasConflicts:
|
while hasConflicts:
|
||||||
# Check if conflicts have been resolved
|
# Check if conflicts have been resolved
|
||||||
@@ -390,10 +400,6 @@ def generateScheduleV3(
|
|||||||
blockIn = list(running)[index]
|
blockIn = list(running)[index]
|
||||||
for cname in running[blockIn]:
|
for cname in running[blockIn]:
|
||||||
if cname[:-2] == classOut[:-2] and len(running[blockIn][cname]["students"]) < classCap:
|
if cname[:-2] == classOut[:-2] and len(running[blockIn][cname]["students"]) < classCap:
|
||||||
studentData = {
|
|
||||||
"Pupil #": student["Pupil #"],
|
|
||||||
"index": student["studentIndex"]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update records
|
# Update records
|
||||||
student["schedule"][blockOut].remove(classOut)
|
student["schedule"][blockOut].remove(classOut)
|
||||||
@@ -417,31 +423,43 @@ def generateScheduleV3(
|
|||||||
|
|
||||||
elif found: done = True
|
elif found: done = True
|
||||||
if advancedConflict:
|
if advancedConflict:
|
||||||
conflictLogs.append({
|
classIndex = 0
|
||||||
"Pupil #": student["Pupil #"],
|
solved, done = False, False
|
||||||
"Email": "",
|
classOut = blocks[clashIndex][classIndex]
|
||||||
"Type": "Critical",
|
while not done:
|
||||||
"Code": "C-CSS",
|
for blockIndex in range(len(running)):
|
||||||
"Conflict": "Couldn't solve schedule"
|
if solved: break
|
||||||
})
|
if blockIndex != clashIndex:
|
||||||
hasConflicts = False
|
for cname in running[list(running)[blockIndex]]:
|
||||||
# classOut = blocks[clashIndex][classIndex]
|
if cname[:-2] == classOut[:-2]:
|
||||||
# existsIn = []
|
blockIn = f"block{blockIndex+1}"
|
||||||
# for blockIndex in range(len(running)):
|
if blockIndex in freeBlocks:
|
||||||
# for cname in running[list(running)[blockIndex]]:
|
if len(running[blockIn][cname]["students"]) < classCap:
|
||||||
# if cname[:-2] == classOut[:-2]: existsIn.append(blockIndex)
|
# In the rare or impossible case a student was not inserted to a class
|
||||||
|
# And it weren't full, insert them into the class
|
||||||
|
student["schedule"][blockOut].remove(classOut)
|
||||||
|
student["schedule"][blockIn].append(cname)
|
||||||
|
|
||||||
# for blockIndex in existsIn:
|
running[blockOut][classOut]["students"].remove(studentData)
|
||||||
# if blockIndex in freeBlocks:
|
running[blockIn][cname]["students"].append(studentData)
|
||||||
# # If this was in a free block it should've been added
|
|
||||||
# # But just in case I'll do it again here
|
solved = True
|
||||||
# pass
|
break
|
||||||
# elif len(blocks[blockIndex]) == 1:
|
else:
|
||||||
|
|
||||||
# pass
|
|
||||||
# elif len(blocks[blockIndex]) > 1:
|
|
||||||
# print("How to solve")
|
|
||||||
|
|
||||||
|
# Resort to remaining alternates
|
||||||
|
if len(student["remainingAlts"]) > 0:
|
||||||
|
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Add to exceptions try to continue
|
||||||
|
print("Create exception and continue")
|
||||||
|
pass
|
||||||
|
elif len(blocks[blockIndex]) == 1:
|
||||||
|
pass
|
||||||
|
elif len(blocks[blockIndex]) > 1:
|
||||||
|
print("How to solve")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"Fatal error ({getLineNumber()}): Impossible error")
|
print(f"Fatal error ({getLineNumber()}): Impossible error")
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in new issue
Block a user