cleaner
This commit is contained in:
2 files changed
+32
-20
No files matched your search
@@ -21,7 +21,6 @@ from util.generateCourses import getSampleCourses
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
running example:
|
running example:
|
||||||
running: {
|
running: {
|
||||||
"block1": {
|
"block1": {
|
||||||
@@ -44,21 +43,15 @@ def getLineNumber(): return currentframe().f_back.f_lineno
|
|||||||
# Returns if the particular student has a previous error
|
# Returns if the particular student has a previous error
|
||||||
def newConflict(pupilNum: str, email: str, conflictType: str, code: str, description: str, logs: dict) -> bool:
|
def newConflict(pupilNum: str, email: str, conflictType: str, code: str, description: str, logs: dict) -> bool:
|
||||||
exists = True if pupilNum in logs else False
|
exists = True if pupilNum in logs else False
|
||||||
if exists: logs[pupilNum].append({
|
log = {
|
||||||
"Pupil #": pupilNum,
|
"Pupil #": pupilNum,
|
||||||
"Email": email,
|
"Email": email,
|
||||||
"Type": conflictType,
|
"Type": conflictType,
|
||||||
"Code": code,
|
"Code": code,
|
||||||
"Conflict": description
|
"Conflict": description
|
||||||
})
|
}
|
||||||
else:
|
if exists: logs[pupilNum].append(log)
|
||||||
logs[pupilNum] = [{
|
else: logs[pupilNum] = [log]
|
||||||
"Pupil #": pupilNum,
|
|
||||||
"Email": email,
|
|
||||||
"Type": conflictType,
|
|
||||||
"Code": code,
|
|
||||||
"Conflict": description
|
|
||||||
}]
|
|
||||||
return exists
|
return exists
|
||||||
|
|
||||||
minReq, median, classCap = 18, 24, 30
|
minReq, median, classCap = 18, 24, 30
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#! python
|
#! python
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
from time import time, sleep
|
||||||
|
import itertools
|
||||||
|
import threading
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -11,6 +14,15 @@ from util.generateCourses import getSampleCourses
|
|||||||
# Import Algorithm
|
# Import Algorithm
|
||||||
from scheduleGenerator.generator import generateScheduleV3
|
from scheduleGenerator.generator import generateScheduleV3
|
||||||
|
|
||||||
|
done = False
|
||||||
|
|
||||||
|
def processing():
|
||||||
|
for c in itertools.cycle(['|', '/', '-', '\\']):
|
||||||
|
if done: break
|
||||||
|
sys.stdout.write(f'\rProcessing {c}')
|
||||||
|
sys.stdout.flush()
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
||||||
# Error Table calulation / output
|
# Error Table calulation / output
|
||||||
f = open('./output/conflicts.json')
|
f = open('./output/conflicts.json')
|
||||||
@@ -34,14 +46,23 @@ def errorOutput(students) -> Tuple[PrettyTable, dict, dict]:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print("Processing...\n")
|
print()
|
||||||
|
|
||||||
|
st = time() # Start time
|
||||||
|
t = threading.Thread(target=processing)
|
||||||
|
t.start() # Start animation
|
||||||
|
|
||||||
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
sampleStudents = getSampleStudents("./sample_data/course_selection_data.csv", True)
|
||||||
samplemockCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
|
samplemockCourses = getSampleCourses("./sample_data/course_selection_data.csv", True)
|
||||||
timetable = {}
|
timetable = {}
|
||||||
timetable["Version"] = 3
|
timetable["Version"] = 3
|
||||||
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
|
timetable["timetable"] = generateScheduleV3(sampleStudents, samplemockCourses, 40, "./output/students.json", "./output/conflicts.json")
|
||||||
|
|
||||||
|
done = True # End Animation
|
||||||
|
et = time() # End time
|
||||||
|
elapsed_time = round((et - st), 3) # Execution time
|
||||||
|
print(f'\n\nDone - Finished in {elapsed_time} seconds\n')
|
||||||
|
|
||||||
errors, _, _ = errorOutput(sampleStudents)
|
errors, _, _ = errorOutput(sampleStudents)
|
||||||
print(errors)
|
print(errors)
|
||||||
|
|
||||||
@@ -69,5 +90,3 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
with open("./output/timetable.json", "w") as outfile:
|
with open("./output/timetable.json", "w") as outfile:
|
||||||
json.dump(timetable, outfile, indent=2)
|
json.dump(timetable, outfile, indent=2)
|
||||||
|
|
||||||
print("\nDone")
|
|
||||||
Reference in new issue
Block a user