Skip to content

Commit

Permalink
Transfer courses add to only pre-req errors (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
yijen-sun committed Oct 1, 2023
1 parent 879572a commit 067ccf3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 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 @@ -102,7 +102,7 @@ const HomePage: NextPage = () => {
const plan = student.plans.find((plan) => plan.id === selectedPlanId);
if (plan) {
setPreReqWarnings(getPreReqWarnings(plan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(plan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(plan.schedule));
}
}
}, [student, selectedPlanId, setSelectedPlanId]);
Expand Down Expand Up @@ -171,7 +171,7 @@ const HomePage: NextPage = () => {
}

setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(updatedPlan.schedule, student.coursesTransfered));
setCoReqWarnings(getCoReqWarnings(updatedPlan.schedule));
mutateStudentWithUpdatedPlan(updatedPlan);
};

Expand Down
15 changes: 4 additions & 11 deletions packages/frontend-v2/utils/plan/preAndCoReqCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,28 @@ import {

export const getCoReqWarnings = (
schedule: Schedule2<unknown>,
coursesTransfered: ScheduleCourse2<null>[] | undefined
): CoReqWarnings => {
const errors: CoReqWarnings = {
type: "coreq",
years: schedule.years.map((year) => ({
year: year.year,
fall: getCoReqWarningsSem(year.fall, coursesTransfered),
spring: getCoReqWarningsSem(year.spring, coursesTransfered),
summer1: getCoReqWarningsSem(year.summer1, coursesTransfered),
summer2: getCoReqWarningsSem(year.summer2, coursesTransfered),
fall: getCoReqWarningsSem(year.fall),
spring: getCoReqWarningsSem(year.spring),
summer1: getCoReqWarningsSem(year.summer1),
summer2: getCoReqWarningsSem(year.summer2),
})),
};
return errors;
};

export const getCoReqWarningsSem = (
term: ScheduleTerm2<unknown>,
coursesTransfered: ScheduleCourse2<null>[] | undefined
): TermError => {
const seen: Set<string> = new Set();
const coReqErrors: TermError = {};
for (const course of term.classes) {
seen.add(courseToString(course));
}
if (coursesTransfered != undefined) {
for (const course of coursesTransfered) {
seen.add(courseToString(course));
}
}
for (const course of term.classes) {
if (course.coreqs && course.coreqs.values.length !== 0)
coReqErrors[courseToString(course)] = getReqErrors(course.coreqs, seen);
Expand Down

0 comments on commit 067ccf3

Please sign in to comment.