Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
initial commit
- Loading branch information
Tom Singleton
committed
Mar 24, 2017
0 parents
commit 4723055b66a5e2bd1939d877495fdb6b147e4fbe
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
21
grades.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"second_year": [ | ||
{"name": "203CR - Usability 2", "credits": 20, "grade": 40}, | ||
{"name": "205CDE - Modern Web", "credits": 20, "grade": 40}, | ||
{"name": "206CDE - Real-Word", "credits": 20, "grade": 50}, | ||
{"name": "210CT - Data Structures", "credits": 20, "grade": 40}, | ||
{"name": "220CT - Data information", "credits": 20, "grade": 40}, | ||
{"name": "290COM - Ethics", "credits": 10, "grade": 40}, | ||
{"name": "AdVantage", "credits": 10, "grade": 40}, | ||
|
||
{"name": "Placement", "credits": 40, "grade": 40} | ||
], | ||
"third_year": [ | ||
{"name": "301CEM - iOS Development", "credits": 20, "grade": 40}, | ||
{"name": "302CEM - Agile", "credits": 20, "grade": 40}, | ||
{"name": "303COM - Individual Project", "credits": 30, "grade": 50}, | ||
{"name": "304CEM - Web API", "credits": 20, "grade": 40}, | ||
{"name": "307CR - Pervasive Computing", "credits": 20, "grade": 40}, | ||
{"name": "AdVantage", "credits": 10, "grade": 40} | ||
] | ||
} |
66
index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use strict' | ||
|
||
const gradefile = require('./grades.json') | ||
|
||
console.log("Parsing grades file") | ||
|
||
const secondYear = gradefile.second_year | ||
const thirdYear = gradefile.third_year | ||
|
||
console.log("Checking gradefile correctness") | ||
|
||
const secondParseInfo = { | ||
noOf40: 0, | ||
noOf20: 0, | ||
noOf10: 0, | ||
noOfOther: 0, | ||
|
||
totalCredits: 0 | ||
} | ||
|
||
secondYear.forEach(module => { | ||
switch (module.credits) { | ||
case 40: | ||
secondParseInfo.noOf40 += 1 | ||
break | ||
case 20: | ||
secondParseInfo.noOf20 += 1 | ||
break | ||
case 10: | ||
secondParseInfo.noOf10 += 1 | ||
break | ||
default: | ||
secondParseInfo.noOfOther += 1 | ||
break | ||
} | ||
|
||
secondParseInfo.totalCredits += module.credits | ||
}) | ||
|
||
console.log(secondParseInfo) | ||
|
||
// third year avg with lowest 20 missing // | ||
// third year avg without lowest missing | ||
// | ||
// avg secondyear 120 without placement | ||
// avg secondyear 120 with placement (2 20s) | ||
// avg secondyear 120 with placement (1 20s 2 10s) | ||
|
||
const lowestThirdMod = thirdYear.reduce((before, item) => { | ||
if (before.name === 'none' && item.credits === 20) { | ||
return item | ||
} else if (item.credits === 20 && before.grade >= item.grade) { | ||
return item | ||
} else { | ||
return before | ||
} | ||
}, {name: 'none'}) | ||
|
||
const thirdLowRemoved = thirdYear.filter((item) => { | ||
return item !== lowestThirdMod | ||
}) | ||
|
||
// console.log(lowestThirdMod) | ||
// console.log(thirdLowRemoved) | ||
|
||
|
11
package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "gradecalc", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Tom Singleton", | ||
"license": "MIT" | ||
} |