Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions quiz.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
var qn = 0; // Question number
var prev_answer = null;
init_question();
for (var i = 0; i < questions.length; i++) {
max_econ += Math.abs(questions[i].effect.econ)
max_dipl += Math.abs(questions[i].effect.dipl)
max_govt += Math.abs(questions[i].effect.govt)
max_scty += Math.abs(questions[i].effect.scty)
}
function init_question() {
document.getElementById("question-text").innerHTML = questions[qn].question;
document.getElementById("question-number").innerHTML = "Question " + (qn + 1) + " of " + (questions.length);
Expand All @@ -79,6 +73,10 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
dipl += mult*questions[qn].effect.dipl
govt += mult*questions[qn].effect.govt
scty += mult*questions[qn].effect.scty
max_econ += Math.abs(mult*questions[qn].effect.econ)
max_dipl += Math.abs(mult*questions[qn].effect.dipl)
max_govt += Math.abs(mult*questions[qn].effect.govt)
max_scty += Math.abs(mult*questions[qn].effect.scty)
qn++;
prev_answer = mult;
if (qn < questions.length) {
Expand All @@ -101,14 +99,14 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>

}
function calc_score(score,max) {
return (100*(max+score)/(2*max)).toFixed(1)
return (100*((score+max)/max/2)).toFixed(1)
}
function results() {
location.href = `results.html`
+ `?e=${calc_score(econ,max_econ)}`
+ `&d=${calc_score(dipl,max_dipl)}`
+ `&g=${calc_score(govt,max_govt)}`
+ `&s=${calc_score(scty,max_scty)}`
+ `?e=${calc_score(econ,max_econ+0.000001)}`
+ `&d=${calc_score(dipl,max_dipl+0.000001)}`
+ `&g=${calc_score(govt,max_govt+0.000001)}`
+ `&s=${calc_score(scty,max_scty+0.000001)}`
}
</script>
</body>