Add grade calculation algorithm
This commit is contained in:
parent
bb9ec41cbd
commit
8bd6b16f71
3 changed files with 30 additions and 1 deletions
|
@ -124,12 +124,31 @@ function setUpStrings(){
|
|||
// Is it checked?
|
||||
if (currentEl.checked){
|
||||
// Get the ID
|
||||
//choices[x].push(mappedIds[x][y]);
|
||||
choices[x].push(mappedIds[x][y]);
|
||||
score += quiz.reports[mappedIds[x][y]].points;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the grade
|
||||
let grade;
|
||||
if (score > quiz.threshold['a.min'])
|
||||
grade = 's';
|
||||
else if (score > quiz.threshold['b.min'])
|
||||
grade = 'a'
|
||||
else if (score > quiz.threshold['c.min'])
|
||||
grade = 'b'
|
||||
else if (score > quiz.threshold['d.min'])
|
||||
grade = 'c'
|
||||
else if (score > quiz.threshold['e.min'])
|
||||
grade = 'd'
|
||||
else if (score > quiz.threshold['b.min'])
|
||||
grade = 'e';
|
||||
else grade = 'f';
|
||||
|
||||
// Display the grade X badge element (unset its 'none' display value)
|
||||
document.getElementById('badge-' + grade).style['display'] = 'unset';
|
||||
|
||||
// Hide quiz and then show the results.
|
||||
quizEl.style['display'] = 'none';
|
||||
document.getElementById('results').style['display'] = 'unset';
|
||||
|
|
Reference in a new issue