Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User transfer courses when generating pre-req errors (#613) #628

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was prettier run before the PR?

): 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