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

Unbreak AP/IB requirement computation #411

Merged
merged 1 commit into from
Mar 31, 2021
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
19 changes: 19 additions & 0 deletions src/requirements/__test__/requirement-graph-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,22 @@ it('buildRequirementFulfillmentGraph phase 3 test 4', () => {
expect(graph.getConnectedCoursesFromRequirement('Probability')).toEqual([MATH4710]);
expect(graph.getConnectedCoursesFromRequirement('Elective')).toEqual([CS3420, MATH4710]);
});

// Normally, we will remove all edges when there is no user choice associated with a unique ID.
// However, there is the case when all the AP/IB equivalent courses all have the same unique ID -1.
// If we do the same for AP/IB courses, then all these courses will never be able to fulfill anything.
// The following test ensures that we don't regress again.
it('AP/IB course edge is not removed in step 3', () => {
const graph = buildRequirementFulfillmentGraph({
requirements,
userCourses: [{ courseId: CS3410.courseId, uniqueId: -1 }], // mock an AP/IB course
userChoiceOnFulfillmentStrategy: { 'CS3410/CS3420': [CS3410.courseId] },
userChoiceOnDoubleCountingElimination: {},
getAllCoursesThatCanPotentiallySatisfyRequirement,
allowDoubleCounting: r => r === 'Probability',
});

expect(graph.getConnectedCoursesFromRequirement('CS3410/CS3420')).toEqual([
{ courseId: CS3410.courseId, uniqueId: -1 },
]);
});
4 changes: 4 additions & 0 deletions src/requirements/requirement-graph-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ const buildRequirementFulfillmentGraph = <

// Phase 3: Respect user's choices on double-counted courses.
userCourses.forEach(({ uniqueId }) => {
// uniqueId === -1 means it's AP/IB course.
// User never gets to make a choice about these courses, so it will never appear in the choices.
// Therefore, removing those edges will nullify all these credits.
if (uniqueId === -1) return;
const chosenRequirement = userChoiceOnDoubleCountingElimination[uniqueId];
graph.getConnectedRequirementsFromCourse({ uniqueId }).forEach(connectedRequirement => {
if (allowDoubleCounting(connectedRequirement)) return;
Expand Down