basic course reorganization
This commit is contained in:
1 file changed
+42
-8
@@ -37,6 +37,8 @@ from util.generateCourses import getSampleCourses
|
||||
}
|
||||
'''
|
||||
|
||||
def exists(n): return True if n not in ('', None) else False
|
||||
|
||||
def getLineNumber(): return currentframe().f_back.f_lineno
|
||||
|
||||
# Takes in information to create or add a new conflict
|
||||
@@ -416,17 +418,45 @@ def generateScheduleV3(
|
||||
found = True
|
||||
break
|
||||
|
||||
# Remove class after inserted or failed to insert
|
||||
classes.remove(classes[index])
|
||||
runCounts.remove(runCounts[index])
|
||||
|
||||
if not found:
|
||||
# Try alternate
|
||||
alternates = [alt["CrsNo"] for alt in students[student["studentIndex"]]["remainingAlts"] if alt["CrsNo"] not in flex and alt["CrsNo"] in courseRunInfoCopy]
|
||||
if len(alternates) == 0: # If not alternates, create critical error
|
||||
c_cr_count += 1
|
||||
criticalCount += 1
|
||||
if not newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs): studentsCritical += 1
|
||||
# Determine all places class exists
|
||||
existsIn, existingClassNames = [], []
|
||||
for block in running:
|
||||
for cname in running[block]:
|
||||
if cname[:-2] == classes[index] and len(running[block][cname]["students"]) < classCap:
|
||||
existsIn.append(block)
|
||||
existingClassNames.append(cname)
|
||||
|
||||
# Attempt to fix
|
||||
solution = False
|
||||
if len(existsIn) > 0:
|
||||
for i, existing in enumerate(existsIn):
|
||||
if solution: break
|
||||
classOut = student["schedule"][existing][0]
|
||||
for block in running:
|
||||
if solution: break
|
||||
if block == existing or block not in availableBlocks: continue
|
||||
for cname in running[block]:
|
||||
if cname[:-2] == classOut[:-2] and len(running[block][cname]["students"]) < classCap:
|
||||
# Move to existing class elsewhere
|
||||
student["schedule"][block].append(cname)
|
||||
running[block][cname]["students"].append(studentData)
|
||||
|
||||
# Overwrite old class
|
||||
running[existing][student["schedule"][existing][0]]["students"].remove(studentData)
|
||||
student["schedule"][existing][0] = existingClassNames[i]
|
||||
running[existing][existingClassNames[i]]["students"].append(studentData)
|
||||
|
||||
solution = True
|
||||
break
|
||||
|
||||
if not solution:
|
||||
c_cr_count += 1
|
||||
criticalCount += 1
|
||||
if not newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs): studentsCritical += 1
|
||||
|
||||
else:
|
||||
# Get alternate least run
|
||||
@@ -441,7 +471,11 @@ def generateScheduleV3(
|
||||
for remaining in students[student["studentIndex"]]["remainingAlts"]:
|
||||
if remaining["CrsNo"] == alternates[altIndex]:
|
||||
students[student["studentIndex"]]["remainingAlts"].remove(remaining)
|
||||
|
||||
|
||||
# Remove class after inserted or failed to insert
|
||||
classes.remove(classes[index])
|
||||
runCounts.remove(runCounts[index])
|
||||
|
||||
metSelfRequirements = True if student["classes"] == student["expectedClasses"] else False
|
||||
while not metSelfRequirements:
|
||||
|
||||
|
||||
Reference in new issue
Block a user