step 6 work
This commit is contained in:
1 parent
eec6c57e15
commit
f0d0f4cd7e
1 file changed
+20
-3
@@ -343,7 +343,7 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
while conflicts:
|
while conflicts:
|
||||||
count = sum(1 for b in blocks if len(b)==1)
|
count = sum(1 for b in blocks if len(b)==1)
|
||||||
|
|
||||||
print(blocks)
|
print(blocks, "\n")
|
||||||
|
|
||||||
if count < student["expectedClasses"]:
|
if count < student["expectedClasses"]:
|
||||||
# Attempt to fix
|
# Attempt to fix
|
||||||
@@ -360,14 +360,28 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
if list(running).index(block) != index and list(running).index(block) in freeBlocks:
|
if list(running).index(block) != index and list(running).index(block) in freeBlocks:
|
||||||
for cname in running[block]:
|
for cname in running[block]:
|
||||||
if cname[:-2] == blocks[index][moveIndex][:-2] and len(running[block][cname]["students"]) < classCap:
|
if cname[:-2] == blocks[index][moveIndex][:-2] and len(running[block][cname]["students"]) < classCap:
|
||||||
|
|
||||||
|
print("index: ", index)
|
||||||
|
print("blockOut: ", blockOut)
|
||||||
|
print("classOut: ", classOut)
|
||||||
|
print("blockIn: ", block)
|
||||||
|
print("classIn: ", cname)
|
||||||
|
|
||||||
studentData = {
|
studentData = {
|
||||||
"Pupil #": student["Pupil #"],
|
"Pupil #": student["Pupil #"],
|
||||||
"index": student["studentIndex"]
|
"index": student["studentIndex"]
|
||||||
}
|
}
|
||||||
print(running[blockOut][classOut]["students"])
|
|
||||||
studentIndex = running[blockOut][classOut]["students"].index(studentData)
|
studentIndex = running[blockOut][classOut]["students"].index(studentData)
|
||||||
del running[blockOut][classOut]["students"][studentIndex]
|
|
||||||
|
# Update current blocks to work with
|
||||||
|
blocks[index].remove(classOut)
|
||||||
|
blocks[list(running).index(block)].append(cname)
|
||||||
|
|
||||||
|
# Update Final Records
|
||||||
|
del running[blockOut][classOut]["students"][studentIndex] # Remove final
|
||||||
running[block][cname]["students"].append(studentData)
|
running[block][cname]["students"].append(studentData)
|
||||||
|
|
||||||
|
print(blocks)
|
||||||
found, done = True, True
|
found, done = True, True
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -376,8 +390,11 @@ def generateScheduleV3(students: list, courses: dict, blockClassLimit: int=40, s
|
|||||||
moveIndex += 1
|
moveIndex += 1
|
||||||
elif moveIndex == len(blocks[index])-1:
|
elif moveIndex == len(blocks[index])-1:
|
||||||
print("Failed")
|
print("Failed")
|
||||||
|
done = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
print("=========================\n")
|
||||||
|
|
||||||
elif count == student["expectedClasses"]:
|
elif count == student["expectedClasses"]:
|
||||||
conflicts = False
|
conflicts = False
|
||||||
elif count > student["expectedClasses"]:
|
elif count > student["expectedClasses"]:
|
||||||
|
|||||||
Reference in new issue
Block a user