remove deprecated code
This commit is contained in:
6 files changed
+3
-703
No files matched your search
File renamed without changes.
@@ -1,197 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
from util.courses import mockCourses, activeCourses # Fake courses
|
|
||||||
from util.mockStudents import generateMockStudents # Generate fake students
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
Block 1-4 is first semester while
|
|
||||||
block 5-8 is second semester
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''
|
|
||||||
schedule example:
|
|
||||||
schedule: {
|
|
||||||
"block1": "className",
|
|
||||||
"block2": "className",
|
|
||||||
"block3": "className",
|
|
||||||
"block4": "className"
|
|
||||||
"block5": "className",
|
|
||||||
"block6": "className",
|
|
||||||
"block7": "className",
|
|
||||||
"block8": "className"
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''
|
|
||||||
running example:
|
|
||||||
running: {
|
|
||||||
"block1": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block2": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block3": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block4": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block5": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block6": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block7": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block8": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
# Error 1: No classes in schedule can fit this student
|
|
||||||
# Error 2: No more room in schedule for another class
|
|
||||||
|
|
||||||
minReq, median, classCap, blockClassLimit = 18, 24, 30, 12
|
|
||||||
activeCourses = {}
|
|
||||||
running = {
|
|
||||||
"block1": {},
|
|
||||||
"block2": {},
|
|
||||||
"block3": {},
|
|
||||||
"block4": {},
|
|
||||||
"block5": {},
|
|
||||||
"block6": {},
|
|
||||||
"block7": {},
|
|
||||||
"block8": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Currently V1 has an average of 9.4% success rate, with an avverage of 90.6% error rate
|
|
||||||
def generateScheduleV1(mockStudents, mockCourses):
|
|
||||||
# Collect data and calculate schedules
|
|
||||||
for student in mockStudents:
|
|
||||||
# Tally class request
|
|
||||||
for request in student["requests"]:
|
|
||||||
mockCourses[request]["totalrequests"] += 1
|
|
||||||
mockCourses[request]["studentindexes"].append(mockStudents.index(student))
|
|
||||||
# Add course to active list if enough requests
|
|
||||||
if mockCourses[request]["totalrequests"] > minReq and mockCourses[request]["code"] not in activeCourses: activeCourses[mockCourses[request]["code"]] = mockCourses[request]
|
|
||||||
|
|
||||||
for student in mockStudents:
|
|
||||||
alternateOffset = len(student["requests"])-8
|
|
||||||
alternateIndex = 8
|
|
||||||
for i in range(len(student["requests"])-alternateOffset): # Subtract x classes as they are alternatives
|
|
||||||
currentCourse = student["requests"][i]
|
|
||||||
generate = True
|
|
||||||
while generate:
|
|
||||||
# If class is allowed to run
|
|
||||||
if currentCourse in activeCourses:
|
|
||||||
blockIndex = 1
|
|
||||||
courseNum = 1
|
|
||||||
getFreeBlock = True
|
|
||||||
while getFreeBlock:
|
|
||||||
block = f"block{blockIndex}"
|
|
||||||
cname = f"{mockCourses[currentCourse]['name']}-{courseNum}"
|
|
||||||
if cname in running[block]:
|
|
||||||
if student["schedule"][block] == "": # Add student to class
|
|
||||||
if len(running[block][cname]["students"]) < classCap:
|
|
||||||
running[block][cname]["students"].append(student["name"])
|
|
||||||
student["schedule"][block] = cname
|
|
||||||
getFreeBlock = False
|
|
||||||
else: # Find next available class or create new one
|
|
||||||
if blockIndex == 8: # No available classes
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # No more alterantive
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
getFreeBlock = False
|
|
||||||
else:
|
|
||||||
if (mockCourses[currentCourse]["teachers"] - courseNum) > 0:
|
|
||||||
courseNum += 1
|
|
||||||
else:
|
|
||||||
blockIndex += 1
|
|
||||||
courseNum = 1
|
|
||||||
else:
|
|
||||||
if blockIndex == 8: # No available classes
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
err1 += 1
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # No more alternatives
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
getFreeBlock = False
|
|
||||||
else:
|
|
||||||
blockIndex += 1
|
|
||||||
courseNum = 1
|
|
||||||
else:
|
|
||||||
if blockIndex == 8:
|
|
||||||
# Class does not exists
|
|
||||||
# Create new class in first available slot
|
|
||||||
blockNum = 1
|
|
||||||
while True:
|
|
||||||
newBlock = f"block{blockNum}"
|
|
||||||
if cname not in running[newBlock] and len(running[newBlock]) < blockClassLimit:
|
|
||||||
if student["schedule"][newBlock] == "": # Add student to class
|
|
||||||
running[newBlock][cname] = {
|
|
||||||
"name": mockCourses[currentCourse]["name"],
|
|
||||||
"students": [student["name"]]
|
|
||||||
}
|
|
||||||
student["schedule"][newBlock] = cname
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
if blockNum == 8:
|
|
||||||
# All student classes have been filled
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
blockNum += 1
|
|
||||||
courseNum = 1
|
|
||||||
else:
|
|
||||||
if blockNum == 8:
|
|
||||||
# No room in school for more classes
|
|
||||||
# print(f"\nError 2: No more room in school for another class")
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
if (mockCourses[currentCourse]["teachers"] - courseNum) > 0:
|
|
||||||
courseNum += 1
|
|
||||||
else:
|
|
||||||
blockNum += 1
|
|
||||||
courseNum = 1
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
blockIndex += 1
|
|
||||||
courseNum = 1
|
|
||||||
break
|
|
||||||
elif currentCourse not in activeCourses:
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # Out of alternatives
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
|
|
||||||
return running
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print("Processing...")
|
|
||||||
|
|
||||||
mockStudents = generateMockStudents(400)
|
|
||||||
timetable = {}
|
|
||||||
timetable["Version"] = 1
|
|
||||||
timetable["timetable"] = generateScheduleV1(mockStudents, mockCourses)
|
|
||||||
|
|
||||||
with open("../output/timetable.json", "w") as outfile:
|
|
||||||
json.dump(timetable, outfile, indent=2)
|
|
||||||
|
|
||||||
print("Done")
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
from util.courses import mockCourses, activeCourses # Fake courses
|
|
||||||
from util.mockStudents import generateMockStudents # Generate fake students
|
|
||||||
import math
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
Block 1-4 is first semester while
|
|
||||||
block 5-8 is second semester
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''
|
|
||||||
schedule example:
|
|
||||||
schedule: {
|
|
||||||
"block1": "className",
|
|
||||||
"block2": "className",
|
|
||||||
"block3": "className",
|
|
||||||
"block4": "className"
|
|
||||||
"block5": "className",
|
|
||||||
"block6": "className",
|
|
||||||
"block7": "className",
|
|
||||||
"block8": "className"
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''
|
|
||||||
running example:
|
|
||||||
running: {
|
|
||||||
"block1": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block2": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block3": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block4": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block5": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block6": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block7": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}},
|
|
||||||
"block8": {classCode:{"className":name,"students":[student Name]},classCode:{"className":name,"students":[student Name]}}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
minReq, median, classCap, blockClassLimit = 18, 24, 30, 12
|
|
||||||
mockStudents = []
|
|
||||||
activeCourses = {}
|
|
||||||
running = {
|
|
||||||
"block1": {},
|
|
||||||
"block2": {},
|
|
||||||
"block3": {},
|
|
||||||
"block4": {},
|
|
||||||
"block5": {},
|
|
||||||
"block6": {},
|
|
||||||
"block7": {},
|
|
||||||
"block8": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Currently V2 has an average of 0.35% success rate, with an avverage of 99.65% error rate
|
|
||||||
def generateScheduleV2(mockStudents, mockCourses):
|
|
||||||
# Collect data and calculate schedules
|
|
||||||
for student in mockStudents:
|
|
||||||
# Tally class request
|
|
||||||
for request in student["requests"]:
|
|
||||||
mockCourses[request]["totalrequests"] += 1
|
|
||||||
mockCourses[request]["studentindexes"].append(mockStudents.index(student))
|
|
||||||
# Add course to active list if enough requests
|
|
||||||
if mockCourses[request]["totalrequests"] > minReq and mockCourses[request]["code"] not in activeCourses: activeCourses[mockCourses[request]["code"]] = mockCourses[request]
|
|
||||||
|
|
||||||
# calculate # of times to run class
|
|
||||||
for i in range(len(activeCourses)):
|
|
||||||
index = list(activeCourses)[i]
|
|
||||||
classRunCount = math.floor(activeCourses[index]["totalrequests"] / classCap)
|
|
||||||
# If there is minReq+ requests left, 1 more class could be run
|
|
||||||
if (activeCourses[index]["totalrequests"] % classCap) > minReq: classRunCount += 1
|
|
||||||
activeCourses[index]["classRunCount"] = classRunCount
|
|
||||||
|
|
||||||
newBlockIndex = 1
|
|
||||||
newCourseNum = 1
|
|
||||||
while classRunCount > 0:
|
|
||||||
block = f"block{newBlockIndex}"
|
|
||||||
cname = f"{activeCourses[index]['name']}-{newCourseNum}"
|
|
||||||
if cname not in running[block] and len(running[block]) < blockClassLimit:
|
|
||||||
# Generate class and sub 1 from classRunCount
|
|
||||||
running[block][cname] = {
|
|
||||||
"name": activeCourses[index]["name"],
|
|
||||||
"students": []
|
|
||||||
}
|
|
||||||
classRunCount -= 1
|
|
||||||
else:
|
|
||||||
if newBlockIndex == 8:
|
|
||||||
if (activeCourses[index]["teachers"] - newCourseNum) > 0:
|
|
||||||
newCourseNum += 1
|
|
||||||
newBlockIndex = 1
|
|
||||||
else:
|
|
||||||
# No room in school for more classes
|
|
||||||
# print(f"\nError 2: No more room in school for another class")
|
|
||||||
classRunCount = 0
|
|
||||||
else: newBlockIndex += 1
|
|
||||||
|
|
||||||
for student in mockStudents:
|
|
||||||
alternateOffset = len(student["requests"])-8
|
|
||||||
alternateIndex = 8
|
|
||||||
for i in range(len(student["requests"])-alternateOffset): # Subtract x classes as they are alternatives
|
|
||||||
currentCourse = student["requests"][i]
|
|
||||||
generate = True
|
|
||||||
courseNum = 1
|
|
||||||
while generate:
|
|
||||||
# If class is allowed to run
|
|
||||||
if currentCourse in activeCourses:
|
|
||||||
blockIndex = 1
|
|
||||||
getFreeBlock = True
|
|
||||||
cname = f"{mockCourses[currentCourse]['name']}-{courseNum}"
|
|
||||||
while getFreeBlock:
|
|
||||||
block = f"block{blockIndex}"
|
|
||||||
if cname in running[block]:
|
|
||||||
if student["schedule"][block] == "": # Add student to class
|
|
||||||
if len(running[block][cname]["students"]) < classCap:
|
|
||||||
running[block][cname]["students"].append(student["name"])
|
|
||||||
student["schedule"][block] = cname
|
|
||||||
getFreeBlock = False
|
|
||||||
else: # Find next available class or create new one
|
|
||||||
if blockIndex == 8: # No available classes
|
|
||||||
if (activeCourses[index]["teachers"] - newCourseNum) > 0:
|
|
||||||
newCourseNum += 1
|
|
||||||
newBlockIndex = 1
|
|
||||||
else:
|
|
||||||
# No room in school for more classes
|
|
||||||
# print(f"\nError 2: No more room in school for another class")
|
|
||||||
classRunCount = 0
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # No more alterantive
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
getFreeBlock = False
|
|
||||||
else: blockIndex += 1
|
|
||||||
else:
|
|
||||||
if blockIndex == 8: # No available classes
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # No more alternatives
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
getFreeBlock = False
|
|
||||||
else:
|
|
||||||
if (mockCourses[currentCourse]["teachers"] - courseNum) > 0:
|
|
||||||
courseNum += 1
|
|
||||||
else:
|
|
||||||
blockIndex += 1
|
|
||||||
courseNum = 1
|
|
||||||
else:
|
|
||||||
if blockIndex == 8:
|
|
||||||
# Class does not exists
|
|
||||||
# Resort to alternative
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # Out of alternatives
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
if (mockCourses[currentCourse]["teachers"] - courseNum) > 0:
|
|
||||||
courseNum += 1
|
|
||||||
else:
|
|
||||||
blockIndex += 1
|
|
||||||
courseNum = 1
|
|
||||||
break
|
|
||||||
elif currentCourse not in activeCourses:
|
|
||||||
if len(student["requests"]) == 8:
|
|
||||||
# This student never had any alternatives
|
|
||||||
# How to solve?
|
|
||||||
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
else:
|
|
||||||
if alternateIndex <= (len(student["requests"]) - 1):
|
|
||||||
currentCourse = student["requests"][alternateIndex]
|
|
||||||
alternateIndex += 1
|
|
||||||
else: # Out of alternatives
|
|
||||||
# print(f"\nError 1: No more available classes for student {student['name']}")
|
|
||||||
generate = False
|
|
||||||
|
|
||||||
return running
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print("Processing...")
|
|
||||||
|
|
||||||
mockStudents = generateMockStudents(400)
|
|
||||||
timetable = {}
|
|
||||||
timetable["Version"] = 2
|
|
||||||
timetable["timetable"] = generateScheduleV2(mockStudents, mockCourses)
|
|
||||||
|
|
||||||
with open("../output/timetable.json", "w") as outfile:
|
|
||||||
json.dump(timetable, outfile, indent=2)
|
|
||||||
|
|
||||||
print("Done")
|
|
||||||
@@ -5,14 +5,11 @@ import json
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Import required utilities
|
# Import required utilities
|
||||||
from util.mockStudents import generateMockStudents, getSampleStudents
|
from util.mockStudents import getSampleStudents
|
||||||
from util.generateCourses import getSampleCourses
|
from util.generateCourses import getSampleCourses
|
||||||
from util.courses import mockCourses
|
|
||||||
|
|
||||||
# Import Algorithms
|
# Import Algorithm
|
||||||
from scheduleGenerator.generator_v1 import generateScheduleV1
|
from scheduleGenerator.generator import generateScheduleV3
|
||||||
from scheduleGenerator.generator_v2 import generateScheduleV2
|
|
||||||
from scheduleGenerator.generator_v3 import generateScheduleV3
|
|
||||||
|
|
||||||
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
||||||
# Error Table calulation / output
|
# Error Table calulation / output
|
||||||
@@ -37,28 +34,6 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print("Missing argument")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
if sys.argv[1].upper() == 'V1':
|
|
||||||
print("Processing...")
|
|
||||||
|
|
||||||
mockStudents = generateMockStudents(400)
|
|
||||||
timetable = {}
|
|
||||||
timetable["Version"] = 1
|
|
||||||
timetable["timetable"] = generateScheduleV1(mockStudents, mockCourses)
|
|
||||||
|
|
||||||
elif sys.argv[1].upper() == 'V2':
|
|
||||||
print("Processing...")
|
|
||||||
|
|
||||||
mockStudents = generateMockStudents(400)
|
|
||||||
timetable = {}
|
|
||||||
timetable["Version"] = 2
|
|
||||||
timetable["timetable"] = generateScheduleV2(mockStudents, mockCourses)
|
|
||||||
|
|
||||||
|
|
||||||
elif sys.argv[1].upper() == 'V3':
|
|
||||||
|
|
||||||
print("Processing...\n")
|
print("Processing...\n")
|
||||||
|
|
||||||
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
||||||
|
|||||||
-222
@@ -1,222 +0,0 @@
|
|||||||
# Fake sample data
|
|
||||||
|
|
||||||
mockCourses = {
|
|
||||||
"P-CL": {
|
|
||||||
"name": "Pre-Calculus",
|
|
||||||
"code": "P-CL",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"CL": {
|
|
||||||
"name": "Calculus",
|
|
||||||
"code": "CL",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"EN-CW": {
|
|
||||||
"name": "English: Creative Writing",
|
|
||||||
"code": "EN-CW",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"EN-LS": {
|
|
||||||
"name": "English: Literary Studies",
|
|
||||||
"code": "EN-LS",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"EN-C": {
|
|
||||||
"name": "English: Compisition",
|
|
||||||
"code": "EN-C",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"S-J": {
|
|
||||||
"name": "Social Justice",
|
|
||||||
"code": "S-J",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"S-H": {
|
|
||||||
"name": "History",
|
|
||||||
"code": "S-H",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"S-P": {
|
|
||||||
"name": "Psychology",
|
|
||||||
"code": "S-P",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"SC-P": {
|
|
||||||
"name": "Physics",
|
|
||||||
"code": "SC-P",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"SC-B": {
|
|
||||||
"name": "Biology",
|
|
||||||
"code": "SC-B",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"SC-C": {
|
|
||||||
"name": "Chemistry",
|
|
||||||
"code": "SC-C",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"SC-ES": {
|
|
||||||
"name": "Earth Science",
|
|
||||||
"code": "SC-ES",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"M": {
|
|
||||||
"name": "Music",
|
|
||||||
"code": "M",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"CH": {
|
|
||||||
"name": "Choir",
|
|
||||||
"code": "CH",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"DN": {
|
|
||||||
"name": "Dance",
|
|
||||||
"code": "DN",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"CS": {
|
|
||||||
"name": "Computer Science",
|
|
||||||
"code": "CS",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"GD": {
|
|
||||||
"name": "Game Development",
|
|
||||||
"code": "GD",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"WW": {
|
|
||||||
"name": "Woodwork",
|
|
||||||
"code": "WW",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"MW": {
|
|
||||||
"name": "MetwalWork",
|
|
||||||
"code": "MW",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"M-WP": {
|
|
||||||
"name": "Math: Workplace",
|
|
||||||
"code": "M-WP",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"M-F": {
|
|
||||||
"name": "Math: Foundations",
|
|
||||||
"code": "M-F",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"BN": {
|
|
||||||
"name": "Band",
|
|
||||||
"code": "BN",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"TH": {
|
|
||||||
"name": "Theatre",
|
|
||||||
"code": "TH",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
},
|
|
||||||
"VD-P": {
|
|
||||||
"name": "Video Production",
|
|
||||||
"code": "VD-P",
|
|
||||||
"credits": 4,
|
|
||||||
"gradelevel": 11,
|
|
||||||
"totalrequests": 0,
|
|
||||||
"studentindexes": [],
|
|
||||||
"teachers": 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activeCourses = {}
|
|
||||||
@@ -1,42 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import random
|
|
||||||
import names
|
|
||||||
import json
|
import json
|
||||||
import csv
|
import csv
|
||||||
import sys
|
|
||||||
from util.courses import mockCourses
|
|
||||||
|
|
||||||
flex= ["XAT--12A-S", "XAT--12B-S"]
|
flex= ["XAT--12A-S", "XAT--12B-S"]
|
||||||
|
|
||||||
mockStudents: list[dict] = []
|
mockStudents: list[dict] = []
|
||||||
|
|
||||||
# Generate n students for mock data
|
|
||||||
def generateMockStudents(n: int) -> list[dict]:
|
|
||||||
for _ in range(n):
|
|
||||||
newStudent = {
|
|
||||||
"name": names.get_full_name(),
|
|
||||||
"requests": [], # list of class codes
|
|
||||||
"schedule": {
|
|
||||||
"block1": "",
|
|
||||||
"block2": "",
|
|
||||||
"block3": "",
|
|
||||||
"block4": "",
|
|
||||||
"block5": "",
|
|
||||||
"block6": "",
|
|
||||||
"block7": "",
|
|
||||||
"block8": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Get list of random class choices with no repeats
|
|
||||||
# 8 primary choices, 2 secondary choices
|
|
||||||
courseSelection = random.sample(range(0, len(mockCourses)), 10)
|
|
||||||
for courseNum in courseSelection:
|
|
||||||
newStudent["requests"].append(list(mockCourses)[courseNum])
|
|
||||||
mockStudents.append(newStudent)
|
|
||||||
|
|
||||||
return mockStudents
|
|
||||||
|
|
||||||
|
|
||||||
# sort real sample data into usable dictionary
|
# sort real sample data into usable dictionary
|
||||||
def getSampleStudents(data_dir: str, log: bool = False) -> list[dict]:
|
def getSampleStudents(data_dir: str, log: bool = False) -> list[dict]:
|
||||||
with open(data_dir, newline='') as csvfile:
|
with open(data_dir, newline='') as csvfile:
|
||||||
@@ -91,21 +60,9 @@ def getSampleStudents(data_dir: str, log: bool = False) -> list[dict]:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) == 1:
|
|
||||||
print("Missing argument")
|
|
||||||
exit()
|
|
||||||
if sys.argv[1].lower() == 'sample':
|
|
||||||
studentRequests: list[dict] = getSampleStudents("../sample_data/course_selection_data.csv")
|
studentRequests: list[dict] = getSampleStudents("../sample_data/course_selection_data.csv")
|
||||||
|
|
||||||
with open("../output/students.json", "w") as outfile:
|
with open("../output/students.json", "w") as outfile:
|
||||||
json.dump(studentRequests, outfile, indent=2)
|
json.dump(studentRequests, outfile, indent=2)
|
||||||
elif sys.argv[1].lower() == 'mock':
|
|
||||||
studentRequests: list[dict] = generateMockStudents(400)
|
|
||||||
|
|
||||||
with open("../output/students.json", "w") as outfile:
|
|
||||||
json.dump(studentRequests, outfile, indent=2)
|
|
||||||
else:
|
|
||||||
print("Invalid argument")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
print("done")
|
print("done")
|
||||||
Reference in new issue
Block a user