camille-readbean / ezConnect

0 stars 1 forks source link

Study Plan Validator #19

Closed camille-readbean closed 1 year ago

camille-readbean commented 1 year ago

Create a validator for study plans to check if courses met their prerequisites (i.e. courses in study plans have their prerequisites met and before them in the plan)

Find a way to parse / evaluate NUSMod's prerequisiteRule:
Ideally what it should look like is something similar to the list of dicts below

"CS2030S"
prerequisite = "if undertaking an Undergraduate Degree then ( must have completed 1 of CS1010/CS1010E/CS1010J/CS1010S/CS1010X/CS1101S at a grade of at least D)"
prerequisiteRule = "PROGRAM_TYPES IF_IN Undergraduate Degree THEN ((COURSES (1) CS2020:D, CS1020:D, CS1020E:D) OR (COURSES (1) CS2030S:D, CS2030:D AND COURSES (1) CS2040S:D, CS2040:D, CS2040C:D))"
[
    {
        "OR 1" : [
            {"OR 1" : ["CS2020", "CS1020", "CS1020E"]},
            {"AND" : 
                [
                    [{"OR 1" : ["CS2030S", "CS2030"]}],
                    [{"OR 1" : ["CS2040S", "CS2040", "CS2040C"]}]
                ]
            }
        ]
    }
]

"ST2132"
prerequisite = "If undertaking an Undergraduate Degree THEN ( must have completed ST2334 at a grade of at least D OR must have completed ST2131 at a grade of at least D OR must have completed MA2116 at a grade of at least D OR must have completed MA2216 at a grade of at least D)"
prerequisiteRule = "PROGRAM_TYPES IF_IN Undergraduate Degree THEN (COURSES ST2334:D OR COURSES ST2131:D OR COURSES MA2116:D OR COURSES MA2216:D)"
[
    {"OR" : ["ST2334", "ST2131", "MA2116", "MA2216"]}
]

"CS4225"
prerequisite = "If undertaking an Undergraduate Degree THEN ( must have completed 1 of CS2102/IT2002 at a grade of at least D)"
prerequisiteRule = "PROGRAM_TYPES IF_IN Undergraduate Degree THEN (COURSES (1) CS2102:D, IT2002:D)"

[
    {"OR 1" : ["CS2102", "IT2002"]}
]

"CS4248"
prerequisite = "If undertaking an Undergraduate Degree THEN (( must have completed 1 of CS2109S/CS3243 at a grade of at least D AND must have completed 1 of EE2012/EE2012A/MA2116/MA2216/ST2131/ST2334/YSC2243 at a grade of at least D) AND ( must have completed 1 of MA1102R/MA1505/MA1507/MA1521/MA2002/YSC1216 at a grade of at least D OR must have completed all of MA1511/MA1512 at a grade of at least D))"
prerequisiteRule = "PROGRAM_TYPES IF_IN Undergraduate Degree THEN ((COURSES (1) CS3243:D, CS2109S:D AND COURSES (1) EE2012A:D, EE2012:D, ST2131:D, MA2216:D, MA2116:D, ST2334:D, YSC2243:D) AND (COURSES (1) MA1505:D, MA1507:D, MA1521:D, MA1102R:D, YSC1216:D, MA2002:D OR COURSES (2) MA1511:D, MA1512:D))"
[
    {
        "AND" : [
        [
            {"AND" : [
                {"OR 1" : ["CS3243", "CS2109S"]},
                {"OR 1" : ["EE2012A", "EE2012", "ST2131", "MA2216", "MA2116", "ST2334", "YSC2243"]}
            ]}
        ],
        [
            {"OR" :   [
                {"OR 1" : ["MA1505", "MA1507", "MA1521", "MA1102R", "YSC1216", "MA2002"]},
                {"OR 2" : ["MA1511", "MA1512"]}
            ]}
        ]

        ]
    }
]

Todo:

camille-readbean commented 1 year ago

539ccc0