continue part 4

This commit is contained in:
SowinskiBraeden committed 2022-04-26 12:01:39 -07:00
1 parent b206a2b22a
commit dfdb6bf35a
6 files changed
+66 -23

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
from util.courses import mockCourses, activeCourses # Fake courses from util.courses import mockCourses, activeCourses # Fake courses
from util.mockStudents import generateMockStudents # Generate fake students from util.mockStudents import generateMockStudents # Generate fake students
import json import json
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
from util.courses import mockCourses, activeCourses # Fake courses from util.courses import mockCourses, activeCourses # Fake courses
from util.mockStudents import generateMockStudents # Generate fake students from util.mockStudents import generateMockStudents # Generate fake students
import math import math
+61 -18
View File
@@ -1,7 +1,9 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import json import json
import math import math
import random import random
from numpy import empty
from util.mockStudents import getSampleStudents from util.mockStudents import getSampleStudents
from util.generateCourses import getSampleCourses from util.generateCourses import getSampleCourses
@@ -225,24 +227,65 @@ def generateScheduleV3(students: list, courses: dict) -> dict[str, dict]:
index = allClassRunCounts.index(min(allClassRunCounts)) index = allClassRunCounts.index(min(allClassRunCounts))
course = list(courseRunInfo)[index] course = list(courseRunInfo)[index]
# Spread classes throughout both semesters # If there is more than one class Running
blockIndex = 0 if allClassRunCounts[index] > 1:
offset = 0 # Spread classes throughout both semesters
for i in range(courseRunInfo[course]["Total"]): blockIndex = 0
cname = f"{course}-{i}" offset = 0
blockIndex += offset for i in range(courseRunInfo[course]["Total"]):
running[list(running)[blockIndex]][cname] = { cname = f"{course}-{i}"
"CrsNo": cname[:len(cname)-2], blockIndex += offset
"Description": course, running[list(running)[blockIndex]][cname] = {
"students": selectedCourses[cname]["students"] "CrsNo": course,
} "Description": emptyClasses[course][cname]["Description"],
if offset == 0 or offset == -4: offset = 5 "students": selectedCourses[cname]["students"]
else: offset = -4 }
allClassRunCounts[index] -= 1 if offset == 0 or offset == -4: offset = 5
else: offset = -4
allClassRunCounts[index] -= 1
if blockIndex >= 9: if blockIndex >= 9:
blockIndex = 0 blockIndex = 0
offset = 0 offset = 0
# If the class only runs once, place in semester with least classes
elif allClassRunCounts[index] == 1:
# Tally first and second semester
sem1, sem2 = 0, 0
sem1List, sem2List = {}, {}
for i in range(1, 6):
sem1 += len(running[f"block{i}"])
sem1List[f"block{i}"] = running[f"block{i}"]
for i in range(5, 11):
sem2 += len(running[f"block{i}"])
sem2List[f"block{i}"] = running[f"block{i}"]
# Equally disperse into semesters classes
semBlocks = []
offset = 1
# If sem1 is less than or equal to sem2, add to sem1
if sem1 <= sem2:
for block in sem1List:
semBlocks.append(len(block))
# If sem2 is less than sem1, add to sem2
elif sem1 > sem2:
offset = 5
for block in sem2List:
semBlocks.append(len(block))
# Get block with least classes
leastBlock = semBlocks.index(min(semBlocks))
cname = f"{course}-0"
running[f"block{leastBlock+offset}"][course] = {
"CrsNo": course,
"Description": emptyClasses[course][cname]["Description"],
"Students": selectedCourses[cname]["students"],
}
allClassRunCounts[index] -= 1
# Remove course when fully inserted # Remove course when fully inserted
if allClassRunCounts[index] == 0: if allClassRunCounts[index] == 0:
+1 -1
View File
@@ -1 +1 @@
#!/usr/bin/python3 #!/usr/bin/env python3
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import json import json
import csv import csv
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import random import random
import names import names
import json import json