Skip to content

Commit

Permalink
Added whitelist for courses
Browse files Browse the repository at this point in the history
  • Loading branch information
el-agua committed Nov 10, 2023
1 parent 396db6a commit f145626
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions backend/courses/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ def find_possible_schedules(
"""

day_to_num = {"M": 0, "T": 1, "W": 2, "R": 3, "F": 4}
whitelist = ["CIS-7000"]

class Scheduler:
def __init__(self):
Expand Down Expand Up @@ -744,10 +745,14 @@ def find_optimal_schedule(self, unwanted_intervals=[]):
for interval in optimal_schedule:
class_name = interval[2]
sections = [i for i in optimal_schedule if i[2] == class_name]
section = random.choice(sections)
if class_name not in selected_classes:
if class_name not in whitelist:
section = random.choice(sections)
if class_name not in selected_classes:
selected_classes.add(class_name)
final_schedule.append(section)
else:
selected_classes.add(class_name)
final_schedule.append(section)
final_schedule += sections
return final_schedule

def find_sections(courses):
Expand Down Expand Up @@ -855,7 +860,10 @@ def choose_class_hash(given_l):
hash[class_name].append(node)
for key in hash.keys():
# Chooses a random lecture for each class
courses.append(random.choice(hash[key]))
if key not in whitelist:
courses.append(random.choice(hash[key]))
else:
courses += hash[key]
return courses

def credit_count(sections):
Expand Down

0 comments on commit f145626

Please sign in to comment.