Created
October 7, 2021 17:10
-
-
Save 000407/d1a319a8cf23c9e522c042920d16c307 to your computer and use it in GitHub Desktop.
Grading function for ANC schemas
This file contains hidden or 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
| function GRADE(los, plos = null, prevGrade = null) { | |
| if (prevGrade && prevGrade == 'P') { | |
| return 'P'; | |
| } | |
| if (los.length > 1) { | |
| throw 'Invalid range for LOs' | |
| } | |
| los = los[0]; | |
| if (plos != null) { | |
| if (plos.length > 1) { | |
| throw 'Invalid range for previous LOs' | |
| } | |
| plos = plos[0]; | |
| } | |
| passResult = Array(los.length).fill('A'); | |
| actualResult = passResult.map((e,i) => e === los[i] ? 1 : 0); | |
| secondAttempt = false; | |
| if (Array.isArray(plos)) { | |
| secondAttempt = true; | |
| actualResult = actualResult.map((e,i) => { | |
| if (e == 1) { | |
| return 1; | |
| } | |
| return passResult[i] === plos[i] ? 1 : 0; | |
| }); | |
| } | |
| aggregatedResult = actualResult.reduce((a, c) => a & c); | |
| if (aggregatedResult === 1) { | |
| return 'P'; | |
| } | |
| if (secondAttempt) { | |
| return 'F/R'; | |
| } | |
| return 'R'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment