basic course reorganization

This commit is contained in:
SowinskiBraeden committed 2022-06-29 20:33:47 -07:00
1 parent a95d839a1c
commit 8f5e2c600c
1 file changed
+38 -4
+38 -4
View File
@@ -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 def getLineNumber(): return currentframe().f_back.f_lineno
# Takes in information to create or add a new conflict # Takes in information to create or add a new conflict
@@ -416,14 +418,42 @@ def generateScheduleV3(
found = True found = True
break break
# Remove class after inserted or failed to insert
classes.remove(classes[index])
runCounts.remove(runCounts[index])
if not found: if not found:
# Try alternate # Try alternate
alternates = [alt["CrsNo"] for alt in students[student["studentIndex"]]["remainingAlts"] if alt["CrsNo"] not in flex and alt["CrsNo"] in courseRunInfoCopy] 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 if len(alternates) == 0: # If not alternates, create critical error
# 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 c_cr_count += 1
criticalCount += 1 criticalCount += 1
if not newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs): studentsCritical += 1 if not newConflict(student["Pupil #"], "", "Critical", "C-CR", "Couldn't Resolve", conflictLogs): studentsCritical += 1
@@ -442,6 +472,10 @@ def generateScheduleV3(
if remaining["CrsNo"] == alternates[altIndex]: if remaining["CrsNo"] == alternates[altIndex]:
students[student["studentIndex"]]["remainingAlts"].remove(remaining) 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 metSelfRequirements = True if student["classes"] == student["expectedClasses"] else False
while not metSelfRequirements: while not metSelfRequirements: