Skip to content

Commit

Permalink
Add excludes feature in requirements and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
handotdev committed Feb 24, 2020
1 parent 4b8e36a commit 2906d66
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 38 deletions.
32 changes: 25 additions & 7 deletions src/components/Requirements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export default {
for (const code of codes) {
const courseInfo = coursesTakenWithInfo[code];
const indexIsFulfilled = checkIfCourseFulfilled(courseInfo, requirement.search, requirement.includes);
const indexIsFulfilled = checkIfCourseFulfilled(courseInfo, requirement.search, requirement.includes, requirement.excludes);
if (indexIsFulfilled) {
// depending on what it is fulfilled by, either increase the count or credits you took
Expand Down Expand Up @@ -508,25 +508,43 @@ export default {
* @param {*} search : the scope of search for the requirement (e.g all-eligible, code, catalogDistr)
* @param {*} includes : the query for the search (e.g (MQR-AS), CS 2***)
*/
function checkIfCourseFulfilled(courseInfo, search, includes) {
function checkIfCourseFulfilled(courseInfo, search, includes, excludes) {
// Check if search exists. False if not
if (search !== undefined) {
// Special search: if search code is all or self-check. Anything would work
if (search.includes('all') || search.includes('self-check')) return true;
// Special search: if search code is not PE or 10XX course
if (search.includes('all-eligible')) return ifAllEligible(courseInfo.subject, courseInfo.catalogNbr.toString());
// Excludes is optional. If it exists, a match returns false
if (excludes) {
for (const exclude of excludes) {
for (const excludeOption of exclude) {
// Special search: if course code matches code
if (search.includes('code')) {
if (ifCodeMatch(`${courseInfo.subject} ${courseInfo.catalogNbr}`, excludeOption)) return false
// Make sure courseInfo[search] is not null
} else {
// Loop through search (for search commands with multiple options)
for (let singleSearch of search) {
if (courseInfo[singleSearch] && courseInfo[singleSearch].includes(excludeOption)) return false;
}
}
}
}
}
// Includes is mandatory. Function will check for include match with search command
for (const include of includes) {
for (const option of include) {
for (const includeOption of include) {
// Special search: if course code matches code
if (search.includes('code')) {
if (ifCodeMatch(`${courseInfo.subject} ${courseInfo.catalogNbr}`, option)) {
return true;
}
if (ifCodeMatch(`${courseInfo.subject} ${courseInfo.catalogNbr}`, includeOption)) return true
// Make sure courseInfo[search] is not null
} else {
// Loop through search (for search commands with multiple options)
for (let singleSearch of search) {
if (courseInfo[singleSearch] && courseInfo[singleSearch].includes(option)) return true;
if (courseInfo[singleSearch] && courseInfo[singleSearch].includes(includeOption)) return true;
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/requirements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ The requirements data and its interpreting algorithm is uniquely developed by an
"name": "Mathematics",
"description": "MATH 1910, 1920, 2930 or 2940, and a mathematics course chosen by the Major.",
"source": "https://www.engineering.cornell.edu/students/undergraduate-students/curriculum/undergraduate-requirements",
"search": "code",
"search": ["code"],
"includes": [["MATH 1910"], ["MATH 1920"], ["MATH 2930", "MATH 2940"]],
"excludes": [["CS 1810"]],
"fulfilledBy": "credits",
"minCount": 14
},
{
"name": "Freshman Writing Seminars",
"description": "All students are required to take two first-year writing seminars",
"source": "https://www.engineering.cornell.edu/students/undergraduate-students/curriculum/undergraduate-requirements",
"search": "catalogSatisfiesReq",
"search": ["catalogSatisfiesReq", "catalogComments"],
"includes": [["First-Year Writing Seminar."]],
"fulfilledBy": "credits",
"minCount": 6
Expand All @@ -32,10 +33,11 @@ The requirements data and its interpreting algorithm is uniquely developed by an
| name | full name of the requirement | any string |
| description | description of the requirement | string copied from source |
| source | the soure with more information on the requirement | a URL string |
| search | the command used to determine whether courses satisfy the requirement | (special search: all, all-elidgible, code) or any attribute in course object |
| includes | the query that uses the search command | a string that is an value in course data (e.g CS 2110, MQR-AS) |
| search | (optional if fulfilledBy exists) the command(s) used to determine whether courses satisfy the requirement | (special search: all, all-elidgible, code) or any attribute in course object |
| includes | the query that uses the search command to find courses that fulfills requirement | a string that is an value in course data (e.g CS 2110, MQR-AS) |
| excludes | (optional) the query that uses the search command to find courses that does not fulfill requirement | a string that is an value in course data (e.g CS 2110, MQR-AS) |
| fulfilledBy | the metric that tracks the requirement completion progress | credits, courses, or self-check |
| minCount | the minimum number of fulfilledBy count | any positive integer |
| progressBar | whether this requirement should be the one requirement displayed in the progress bar | boolean |
| progressBar | (optional) whether this requirement should be the one requirement displayed in the progress bar | boolean |

The `includes` attribute has its own logic that uses nested arrays. The outer array lists all possible requirement queries, and the nested array allows for options. For example `[["CS 1110"], ["CS 2110", "CS 2112"]]` means that satisfying the requirement means both having CS 1110 and CS 2110 or CS 2112 on the board.
The `includes` and `excludes` attribute has its own logic that uses nested arrays. The outer array lists all possible requirement queries, and the nested array allows for options. For example `[["CS 1110"], ["CS 2110", "CS 2112"]]` means that satisfying the requirement means both having CS 1110 and CS 2110 or CS 2112 on the board.
53 changes: 28 additions & 25 deletions src/requirements/reqs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,34 @@
"AS"
],
"requirements": [
{
"name": "Total Credits",
"description": "To graduate with a major in English, a student must complete with a grade of C or better 40 credit hours approved for the English major. All 2000-level ENGL courses (with the exception of 2800-2810 and 2880-2890) count for the major, as do all 3000-and 4000-level courses.",
"source": "https://english.cornell.edu/majoring-and-minoring-english-cornell#requirements-for-the-major",
"search": [
"code"
],
"includes": [
[
"ENGL 2***",
"ENGL 3***",
"ENGL 4***",
"ENGL 5***",
"ENGL 6***"
]
],
"excludes": [
[
"ENGL 2800",
"ENGL 2810",
"ENGL 2880",
"ENGL 2890"
]
],
"fulfilledBy": "credits",
"minCount": 40,
"progressBar": true
},
{
"name": "Pre-1800",
"description": "12 credits (normally 3 courses) must be from courses in which 50% or more of the material consists of literature originally written in English before 1800 (such courses are indicated in the English course listings)",
Expand Down Expand Up @@ -1215,31 +1243,6 @@
"includes": [],
"fulfilledBy": "self-check",
"minCount": 12
},
{
"name": "Total Credits",
"description": "To graduate with a major in English, a student must complete with a grade of C or better 40 credit hours approved for the English major. All 2000-level ENGL courses (with the exception of 2800-2810 and 2880-2890) count for the major, as do all 3000-and 4000-level courses.",
"source": "https://english.cornell.edu/majoring-and-minoring-english-cornell#requirements-for-the-major",
"search": ["code"],
"includes": [
[
"ENGL 2***",
"ENGL 3***",
"ENGL 4***",
"ENGL 5***",
"ENGL 6***"
]
],
"excludes": [
[
"ENGL 2800",
"ENGL 2810",
"ENGL 2880",
"ENGL 2890"
]
],
"fulfilledBy": "credits",
"minCount": 40
}
]
},
Expand Down

0 comments on commit 2906d66

Please sign in to comment.