-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinitializeQueue.py
More file actions
41 lines (26 loc) · 1.15 KB
/
initializeQueue.py
File metadata and controls
41 lines (26 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def initializeQueue(student):
#possible is a list of the possible courses
#a student could take next semester
possible = []
gd = GlobalDictionary()
for takenCourseID in student.taken:
takenCourse = gd.classes[takenCourseID]
for childID in takenCourse.children:
childCourse = gd.classes[childID]
possible.append(childCourse)
toReturn = PriorityQueue()
for possibleCourse in possible:
if possibleCourse not in toReturn.courses and possibleCourse.ID not in student.taken and checkPreReqs(possibleCourse.preReqs,student.taken):
toReturn.add(possibleCourse)
return toReturn
def checkPreReqs(preReqs, taken):
# preReqs is a list of lists and there needs to be something
# in taken for each of the lists inside
for list in preReqs:
found = False
for course in list:
if course in taken:
found = True
if not found:
return False
return True