-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add to the 120 credits on repeated courses #280
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
import { CollegeOrMajorRequirement } from '../../types'; | ||
import { courseIsAllEligible } from '../checkers-common'; | ||
|
||
const businessRequirements: readonly CollegeOrMajorRequirement[] = [ | ||
{ | ||
name: 'Total Academic Credits', | ||
description: | ||
'120 academic credits are required' + | ||
'PE courses and courses numbered 1000-1099 do not count towards the 120 credits', | ||
source: 'http://courses.cornell.edu/content.php?catoid=41&navoid=11715', | ||
checker: courseIsAllEligible, | ||
subRequirementProgress: 'any-can-count', | ||
fulfilledBy: 'credits', | ||
minCount: 120, | ||
}, | ||
]; | ||
const businessRequirements: readonly CollegeOrMajorRequirement[] = []; | ||
|
||
export default businessRequirements; |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import store from '../store'; | ||
import { CREDITS_COURSE_ID, FWS_COURSE_ID } from './data/constants'; | ||
import buildRequirementFulfillmentGraphFromUserData from './requirement-graph-builder-from-user-data'; | ||
import { | ||
CourseTaken, | ||
|
@@ -8,6 +9,121 @@ import { | |
GroupedRequirementFulfillmentReport, | ||
} from './types'; | ||
|
||
type FulfillmentStatistics = { | ||
readonly id: string; | ||
readonly requirement: RequirementWithIDSourceType; | ||
readonly courses: readonly (readonly CourseTaken[])[]; | ||
} & RequirementFulfillmentStatistics; | ||
|
||
/** | ||
* @param course course object with useful information retrived from Cornell courses API. | ||
* @returns true if the course is AP/IB equivalent course or credit | ||
*/ | ||
const courseIsAPIB = (course: CourseTaken): boolean => | ||
[CREDITS_COURSE_ID, FWS_COURSE_ID].includes(course.courseId) || | ||
['AP', 'IB', 'CREDITS'].includes(course.subject); | ||
|
||
/** | ||
* Used for total academic credit requirements for all colleges except EN and AR | ||
* @param course course object with useful information retrived from Cornell courses API. | ||
* @returns true if the course is not PE or 10** level | ||
*/ | ||
const courseIsAllEligible = (course: CourseTaken): boolean => | ||
course.courseId === CREDITS_COURSE_ID || | ||
(!courseIsAPIB(course) && course.subject !== 'PE' && !course.number.startsWith('10')); | ||
|
||
const getTotalCreditsFulfillmentStatistics = ( | ||
college: string, | ||
courses: readonly CourseTaken[] | ||
): FulfillmentStatistics | null => { | ||
const requirementCommon = { | ||
sourceType: 'College', | ||
sourceSpecificName: college, | ||
name: 'Total Academic Credits', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's handled by completely remove them from the requirement json, and inject it as the first college requirement in the requirement menu. |
||
courses: [], | ||
subRequirementProgress: 'any-can-count', | ||
fulfilledBy: 'credits', | ||
minCount: 120, | ||
} as const; | ||
let requirement: RequirementWithIDSourceType; | ||
switch (college) { | ||
case 'AG': | ||
requirement = { | ||
...requirementCommon, | ||
id: 'College-AG-total-credits', | ||
description: | ||
'120 academic credits are required for graduation. ' + | ||
'A minimum of 100 credits must be in courses for which a letter grade was recieved. ' + | ||
'PE courses do not count.', | ||
source: 'http://courses.cornell.edu/content.php?catoid=41&navoid=11561', | ||
}; | ||
break; | ||
case 'AS': | ||
requirement = { | ||
...requirementCommon, | ||
id: 'College-AS-total-credits', | ||
description: | ||
'120 academic credits are required. ' + | ||
'PE courses and courses numbered 1000-1099 do not count towards the 120 credits.', | ||
source: 'http://courses.cornell.edu/content.php?catoid=41&navoid=11570#credit-req', | ||
}; | ||
break; | ||
case 'HE': | ||
requirement = { | ||
...requirementCommon, | ||
id: 'College-HE-total-credits', | ||
description: | ||
'120 academic credits are required. ' + | ||
'PE courses and courses numbered 1000-1099 do not count towards the 120 credits.', | ||
source: | ||
'http://courses.cornell.edu/content.php?catoid=41&navoid=11600#Cornell_Credit_Requirements', | ||
}; | ||
break; | ||
case 'IL': | ||
requirement = { | ||
...requirementCommon, | ||
id: 'College-IL-total-credits', | ||
description: | ||
'120 academic credits are required. ' + | ||
'PE courses and courses numbered 1000-1099 do not count towards the 120 credits.', | ||
source: 'http://courses.cornell.edu/content.php?catoid=41&navoid=11587', | ||
}; | ||
break; | ||
case 'BU': | ||
requirement = { | ||
...requirementCommon, | ||
id: 'College-BU-total-credits', | ||
description: | ||
'120 academic credits are required. ' + | ||
'PE courses and courses numbered 1000-1099 do not count towards the 120 credits.', | ||
source: 'http://courses.cornell.edu/content.php?catoid=41&navoid=11715', | ||
}; | ||
break; | ||
default: | ||
return null; | ||
} | ||
|
||
let minCountFulfilled = 0; | ||
if (college === 'AG') { | ||
courses.forEach(course => { | ||
if (course.subject !== 'PE') minCountFulfilled += course.credits; | ||
}); | ||
} else { | ||
courses.forEach(course => { | ||
if (courseIsAllEligible(course)) minCountFulfilled += course.credits; | ||
}); | ||
} | ||
|
||
return { | ||
id: requirement.id, | ||
requirement, | ||
courses: [], | ||
fulfilledBy: 'credits', | ||
minCountFulfilled, | ||
minCountRequired: 120, | ||
}; | ||
}; | ||
|
||
function computeFulfillmentStatisticsFromCourses( | ||
coursesThatFulfilledRequirement: readonly (readonly CourseTaken[])[], | ||
counting: 'courses' | 'credits', | ||
|
@@ -163,12 +279,14 @@ export default function computeRequirements( | |
minors | ||
); | ||
|
||
type FulfillmentStatistics = { | ||
readonly id: string; | ||
readonly requirement: RequirementWithIDSourceType; | ||
readonly courses: readonly (readonly CourseTaken[])[]; | ||
} & RequirementFulfillmentStatistics; | ||
const collegeFulfillmentStatistics: FulfillmentStatistics[] = []; | ||
const totalCreditsFulfillmentStatistics = getTotalCreditsFulfillmentStatistics( | ||
college, | ||
coursesTaken | ||
); | ||
if (totalCreditsFulfillmentStatistics != null) { | ||
collegeFulfillmentStatistics.push(totalCreditsFulfillmentStatistics); | ||
} | ||
const majorFulfillmentStatisticsMap = new Map<string, FulfillmentStatistics[]>(); | ||
const minorFulfillmentStatisticsMap = new Map<string, FulfillmentStatistics[]>(); | ||
requirementFulfillmentGraph.getAllRequirements().forEach(requirement => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snapshot is updated as expected, since there are no longer part of the requirement json any more. Since it's before launch, no migration is necessary. For more background, see #222