Add grade calculation algorithm

This commit is contained in:
luca0N! 2021-05-30 16:31:16 -03:00
parent bb9ec41cbd
commit 8bd6b16f71
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
3 changed files with 30 additions and 1 deletions

View File

@ -18,6 +18,15 @@
"section.multiple.points.max": 10,
"section.multiple.points.min": -10
},
"threshold":{
"s.min": 10,
"a.min": 8,
"b.min": 4,
"c.min": 0,
"d.min": -3,
"e.min": -5,
"f.min": -8
},
"contents":[
{

View File

@ -42,6 +42,7 @@ body {
}
.badge {
display: none;
padding: 14px;
font-weight: bold;
font-size: 32pt;

View File

@ -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';