Skip to content

Commit

Permalink
User transfer courses when generating pre-req errors (#613) (#628)
Browse files Browse the repository at this point in the history
* Use transfer courses in getting req errors (#613)

* Transfer courses add to only pre-req errors (#613)
  • Loading branch information
yijen-sun authored Oct 19, 2023
1 parent f584773 commit e377149
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/frontend-v2/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const HomePage: NextPage = () => {
if (student) {
const plan = student.plans.find((plan) => plan.id === selectedPlanId);
if (plan) {
setPreReqWarnings(getPreReqWarnings(plan.schedule));
setPreReqWarnings(getPreReqWarnings(plan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(plan.schedule));
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ const HomePage: NextPage = () => {
return;
}

setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule));
setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(updatedPlan.schedule));
mutateStudentWithUpdatedPlan(updatedPlan);
};
Expand Down
13 changes: 10 additions & 3 deletions packages/frontend-v2/utils/plan/preAndCoReqCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
INEUReqError,
PreReqWarnings,
Schedule2,
ScheduleCourse2,
ScheduleTerm2,
TermError,
} from "@graduate/common";

export const getCoReqWarnings = (
schedule: Schedule2<unknown>
schedule: Schedule2<unknown>,
): CoReqWarnings => {
const errors: CoReqWarnings = {
type: "coreq",
Expand All @@ -29,7 +30,7 @@ export const getCoReqWarnings = (
};

export const getCoReqWarningsSem = (
term: ScheduleTerm2<unknown>
term: ScheduleTerm2<unknown>,
): TermError => {
const seen: Set<string> = new Set();
const coReqErrors: TermError = {};
Expand All @@ -44,9 +45,15 @@ export const getCoReqWarningsSem = (
};

export const getPreReqWarnings = (
schedule: Schedule2<unknown>
schedule: Schedule2<unknown>,
coursesTransfered: ScheduleCourse2<null>[] | undefined
): PreReqWarnings => {
const seen: Set<string> = new Set();
if (coursesTransfered != undefined) {
for (const course of coursesTransfered) {
seen.add(courseToString(course));
}
}
const preReqErrors: PreReqWarnings = {
type: "prereq",
years: schedule.years.map((year) => ({
Expand Down

0 comments on commit e377149

Please sign in to comment.