|
1 |
| -<head> |
2 |
| -<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:400,700" rel="stylesheet"> |
3 |
| -<link href='style.css' rel='stylesheet' type='text/css'> |
4 |
| -<title>8values Quiz</title> |
5 |
| -<link rel="icon" type="x-icon" href="icon.png"> |
6 |
| -<link rel="shortcut icon" type="x-icon" href="icon.png"> |
7 |
| -<meta charset="utf-8"> |
8 |
| -</head> |
9 |
| -<body> |
10 |
| -<script type="application/javascript" |
11 |
| - src="questions.js"> |
12 |
| -</script> |
13 |
| -<h1>8values</h1> |
14 |
| -<hr> |
15 |
| -<h2 style="text-align:center;" id="question-number">Loading...</h2> |
16 |
| -<p class="question" id="question-text"></p> |
17 |
| -<button class="button" onclick="next_question( 1.0)" style="background-color: #1b5e20;">Strongly Agree</button> <br> |
18 |
| -<button class="button" onclick="next_question( 0.5)" style="background-color: #4caf50;">Agree</button> <br> |
19 |
| -<button class="button" onclick="next_question( 0.0)" style="background-color: #bbbbbb;">Neutral/Unsure</button> <br> |
20 |
| -<button class="button" onclick="next_question(-0.5)" style="background-color: #f44336;">Disagree</button> <br> |
21 |
| -<button class="button" onclick="next_question(-1.0)" style="background-color: #b71c1c;">Strongly Disagree</button> <br> |
22 |
| - |
23 |
| -<script> |
24 |
| - var max_econ, max_dipl, max_govt, max_scty; // Max possible scores |
25 |
| - max_econ = max_dipl = max_govt = max_scty = 0 |
26 |
| - var econ, dipl, govt, scty; // User's scores |
27 |
| - econ = dipl = govt = scty = 0 |
28 |
| - var qn = 0; // Question number |
29 |
| - document.getElementById("question-text").innerHTML=questions[qn].question |
30 |
| - document.getElementById("question-number").innerHTML="Question " + (qn + 1) + " of " + (questions.length) |
31 |
| - for (var i = 0; i < questions.length; i++) { |
32 |
| - max_econ += Math.abs(questions[i].effect.econ) |
33 |
| - max_dipl += Math.abs(questions[i].effect.dipl) |
34 |
| - max_govt += Math.abs(questions[i].effect.govt) |
35 |
| - max_scty += Math.abs(questions[i].effect.scty) |
36 |
| - } |
37 |
| - function next_question(mult) { |
38 |
| - econ += mult*questions[qn].effect.econ |
39 |
| - dipl += mult*questions[qn].effect.dipl |
40 |
| - govt += mult*questions[qn].effect.govt |
41 |
| - scty += mult*questions[qn].effect.scty |
42 |
| - qn++ |
43 |
| - if (qn < questions.length) { |
44 |
| - document.getElementById("question-text").innerHTML=questions[qn].question |
45 |
| - document.getElementById("question-number").innerHTML="Question " + (qn + 1) + " of " + (questions.length) |
46 |
| - } else { |
47 |
| - results() |
48 |
| - } |
49 |
| - } |
50 |
| - function calc_score(score,max) { |
51 |
| - return (100*(max+score)/(2*max)).toFixed(1) |
52 |
| - } |
53 |
| - function results() { |
54 |
| - location.href = `results.html` |
55 |
| - + `?e=${calc_score(econ,max_econ)}` |
56 |
| - + `&d=${calc_score(dipl,max_dipl)}` |
57 |
| - + `&g=${calc_score(govt,max_govt)}` |
58 |
| - + `&s=${calc_score(scty,max_scty)}` |
59 |
| - } |
60 |
| -</script> |
61 |
| -</body> |
| 1 | +<head> |
| 2 | +<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:400,700" rel="stylesheet"> |
| 3 | +<link href='style.css' rel='stylesheet' type='text/css'> |
| 4 | +<title>8values Quiz</title> |
| 5 | +<link rel="icon" type="x-icon" href="icon.png"> |
| 6 | +<link rel="shortcut icon" type="x-icon" href="icon.png"> |
| 7 | +<meta charset="utf-8"> |
| 8 | +</head> |
| 9 | +<body> |
| 10 | +<script type="application/javascript" |
| 11 | + src="questions.js"> |
| 12 | +</script> |
| 13 | +<h1>8values</h1> |
| 14 | +<hr> |
| 15 | +<h2 style="text-align:center;" id="question-number">Loading...</h2> |
| 16 | +<p class="question" id="question-text"></p> |
| 17 | +<button class="button" onclick="next_question( 1.0)" style="background-color: #1b5e20;">Strongly Agree</button> <br> |
| 18 | +<button class="button" onclick="next_question( 0.5)" style="background-color: #4caf50;">Agree</button> <br> |
| 19 | +<button class="button" onclick="next_question( 0.0)" style="background-color: #bbbbbb;">Neutral/Unsure</button> <br> |
| 20 | +<button class="button" onclick="next_question(-0.5)" style="background-color: #f44336;">Disagree</button> <br> |
| 21 | +<button class="button" onclick="next_question(-1.0)" style="background-color: #b71c1c;">Strongly Disagree</button> <br> |
| 22 | +<button class="small_button" onclick="prev_question()" id="back_button">Back</button> |
| 23 | +<button class="small_button_off" id="back_button_off">Back</button><br> |
| 24 | + |
| 25 | +<script> |
| 26 | + var max_econ, max_dipl, max_govt, max_scty; // Max possible scores |
| 27 | + max_econ = max_dipl = max_govt = max_scty = 0; |
| 28 | + var econ, dipl, govt, scty; // User's scores |
| 29 | + econ = dipl = govt = scty = 0; |
| 30 | + var qn = 0; // Question number |
| 31 | + var prev_answer = null; |
| 32 | + init_question(); |
| 33 | + for (var i = 0; i < questions.length; i++) { |
| 34 | + max_econ += Math.abs(questions[i].effect.econ) |
| 35 | + max_dipl += Math.abs(questions[i].effect.dipl) |
| 36 | + max_govt += Math.abs(questions[i].effect.govt) |
| 37 | + max_scty += Math.abs(questions[i].effect.scty) |
| 38 | + } |
| 39 | + function init_question() { |
| 40 | + document.getElementById("question-text").innerHTML = questions[qn].question; |
| 41 | + document.getElementById("question-number").innerHTML = "Question " + (qn + 1) + " of " + (questions.length); |
| 42 | + if (prev_answer == null) { |
| 43 | + document.getElementById("back_button").style.display = 'none'; |
| 44 | + document.getElementById("back_button_off").style.display = 'block'; |
| 45 | + } else { |
| 46 | + document.getElementById("back_button").style.display = 'block'; |
| 47 | + document.getElementById("back_button_off").style.display = 'none'; |
| 48 | + } |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + function next_question(mult) { |
| 53 | + econ += mult*questions[qn].effect.econ |
| 54 | + dipl += mult*questions[qn].effect.dipl |
| 55 | + govt += mult*questions[qn].effect.govt |
| 56 | + scty += mult*questions[qn].effect.scty |
| 57 | + qn++; |
| 58 | + prev_answer = mult; |
| 59 | + if (qn < questions.length) { |
| 60 | + init_question(); |
| 61 | + } else { |
| 62 | + results(); |
| 63 | + } |
| 64 | + } |
| 65 | + function prev_question() { |
| 66 | + if (prev_answer == null) { |
| 67 | + return; |
| 68 | + } |
| 69 | + qn--; |
| 70 | + econ -= prev_answer * questions[qn].effect.econ; |
| 71 | + dipl -= prev_answer * questions[qn].effect.dipl; |
| 72 | + govt -= prev_answer * questions[qn].effect.govt; |
| 73 | + scty -= prev_answer * questions[qn].effect.scty; |
| 74 | + prev_answer = null; |
| 75 | + init_question(); |
| 76 | + |
| 77 | + } |
| 78 | + function calc_score(score,max) { |
| 79 | + return (100*(max+score)/(2*max)).toFixed(1) |
| 80 | + } |
| 81 | + function results() { |
| 82 | + location.href = `results.html` |
| 83 | + + `?e=${calc_score(econ,max_econ)}` |
| 84 | + + `&d=${calc_score(dipl,max_dipl)}` |
| 85 | + + `&g=${calc_score(govt,max_govt)}` |
| 86 | + + `&s=${calc_score(scty,max_scty)}` |
| 87 | + } |
| 88 | +</script> |
| 89 | +</body> |
0 commit comments