From e377149610aeafa08edb68c6c4b99bc1e1e6703a Mon Sep 17 00:00:00 2001 From: michelle <94196677+yijen-sun@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:38:18 -0400 Subject: [PATCH] User transfer courses when generating pre-req errors (#613) (#628) * Use transfer courses in getting req errors (#613) * Transfer courses add to only pre-req errors (#613) --- packages/frontend-v2/pages/home.tsx | 4 ++-- packages/frontend-v2/utils/plan/preAndCoReqCheck.ts | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/frontend-v2/pages/home.tsx b/packages/frontend-v2/pages/home.tsx index 9be1b6890..edfe71ec0 100644 --- a/packages/frontend-v2/pages/home.tsx +++ b/packages/frontend-v2/pages/home.tsx @@ -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)); } } @@ -170,7 +170,7 @@ const HomePage: NextPage = () => { return; } - setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule)); + setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule, student.coursesTransfered)); setCoReqWarnings(getCoReqWarnings(updatedPlan.schedule)); mutateStudentWithUpdatedPlan(updatedPlan); }; diff --git a/packages/frontend-v2/utils/plan/preAndCoReqCheck.ts b/packages/frontend-v2/utils/plan/preAndCoReqCheck.ts index 0318b60a9..bcbb7a0bf 100644 --- a/packages/frontend-v2/utils/plan/preAndCoReqCheck.ts +++ b/packages/frontend-v2/utils/plan/preAndCoReqCheck.ts @@ -8,12 +8,13 @@ import { INEUReqError, PreReqWarnings, Schedule2, + ScheduleCourse2, ScheduleTerm2, TermError, } from "@graduate/common"; export const getCoReqWarnings = ( - schedule: Schedule2 + schedule: Schedule2, ): CoReqWarnings => { const errors: CoReqWarnings = { type: "coreq", @@ -29,7 +30,7 @@ export const getCoReqWarnings = ( }; export const getCoReqWarningsSem = ( - term: ScheduleTerm2 + term: ScheduleTerm2, ): TermError => { const seen: Set = new Set(); const coReqErrors: TermError = {}; @@ -44,9 +45,15 @@ export const getCoReqWarningsSem = ( }; export const getPreReqWarnings = ( - schedule: Schedule2 + schedule: Schedule2, + coursesTransfered: ScheduleCourse2[] | undefined ): PreReqWarnings => { const seen: Set = new Set(); + if (coursesTransfered != undefined) { + for (const course of coursesTransfered) { + seen.add(courseToString(course)); + } + } const preReqErrors: PreReqWarnings = { type: "prereq", years: schedule.years.map((year) => ({