diff --git a/quiz.html b/quiz.html
index 46d52071..a011045d 100644
--- a/quiz.html
+++ b/quiz.html
@@ -55,12 +55,6 @@
Loading...
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);
@@ -79,6 +73,10 @@ Loading...
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) {
@@ -101,14 +99,14 @@ Loading...
}
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)}`
}