Skip to content

Commit

Permalink
Ignore course rules with 0 requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Clue88 committed Nov 10, 2023
1 parent 4072c93 commit 3a90f3e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions backend/degree/utils/parse_degreeworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ def parse_rulearray(
if num_courses is None and credits is None:
raise ValueError("No classesBegin or creditsBegin in Course requirement")

this_rule.q = repr(parse_coursearray(rule_req["courseArray"]))
this_rule.credits = credits
this_rule.num_courses = num_courses
# a rule with 0 required cus/credits is not a rule
if num_courses == 0 or credits == 0:
rules.pop()
else:
this_rule.q = repr(parse_coursearray(rule_req["courseArray"]))
this_rule.credits = credits
this_rule.num_courses = num_courses
case "IfStmt":
assert "rightCondition" not in rule_req
try:
Expand Down Expand Up @@ -227,8 +231,7 @@ def parse_rulearray(
parse_rulearray(rule_json["ruleArray"], degree_plan, rules, parent=parent)
else:
print("WARNING: subset has no ruleArray")
case "Group": # TODO: this is nested

case "Group": # this is nested
parse_rulearray(rule_json["ruleArray"], degree_plan, rules, parent=this_rule)
this_rule.num_courses = int(rule_req["numberOfGroups"])
case "Complete" | "Incomplete":
Expand Down

0 comments on commit 3a90f3e

Please sign in to comment.