This repository has been archived by the owner on Mar 14, 2022. It is now read-only.
forked from 9Axes/9axes.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullquiz.html
128 lines (116 loc) · 4.49 KB
/
fullquiz.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:400,700" rel="stylesheet">
<link href='style.css' rel='stylesheet' type='text/css'>
<title>PaganValues</title>
<link rel="icon" type="x-icon" href="icon.png">
<link rel="shortcut icon" type="x-icon" href="icon.png">
<meta charset="utf-8">
</head>
<body>
<script type="application/javascript"
src="questions.js">
</script>
<h1>9Axes</h1>
<hr>
<h2 style="text-align:center;" id="question-number">Loading...</h2>
<p class="question" id="question-text"></p>
<button class="button" onclick="next_question( 2)" style="background-color: #1b5e20;">Strongly Agree</button> <br>
<button class="button" onclick="next_question( 1)" style="background-color: #4caf50;">Agree</button> <br>
<button class="button" onclick="next_question(0.5)" style="background-color: #9bd99d;">Slightly Agree</button> <br>
<button class="button" onclick="next_question( 0)" style="background-color: #bbbbbb;">Neutral/Unsure</button> <br>
<button class="button" onclick="next_question(-0.5)" style="background-color: #ff948c;">Slightly Disagree</button> <br>
<button class="button" onclick="next_question(-1)" style="background-color: #f44336;">Disagree</button> <br>
<button class="button" onclick="next_question(-2)" style="background-color: #b71c1c;">Strongly Disagree</button> <br>
<button class="small_button" onclick="prev_question()" id="back_button">Previous</button>
<button class="small_button_off" id="back_button_off">Previous</button><br>
<script>
var scores = [0, 0, 0, 0, 0, 0, 0, 0, 0];//fed, dem, glo, mil, fre, equ, sec, pro, mul - User's scores
var qn = 0; // Question number
var answers = [];
var quests = [];
init_all_questions(quests);
init_question(quests);
function init_all_questions(qs) {
//1,2,3,-2,-4
for(var i = 0; i < 9; i++) //Number of Axes
{
for(var j = 0; j < questions[i].length; j++)
{
for(var k = 0; k < questions[i][j].length; k++)
{
var m = [i, j, k];
qs.push(m);
}
}
}
shuffle(qs);
}
function init_question() {
var ax = quests[qn][0];
var rate = quests[qn][1];
var num = quests[qn][2];
document.getElementById("question-text").innerHTML = questions[ax][rate][num];
document.getElementById("question-number").innerHTML = "Question " + (qn + 1) + " of " + (quests.length);
if (qn == 0) {
document.getElementById("back_button").style.display = 'none';
document.getElementById("back_button_off").style.display = 'block';
} else {
document.getElementById("back_button").style.display = 'block';
document.getElementById("back_button_off").style.display = 'none';
}
}
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function next_question(mult) {
var ax = quests[qn][0];
var rate = quests[qn][1];
var num = quests[qn][2];
scores[ax] += mult*(rate<4?1:-1);
answers[qn] = mult;
qn++;
if (qn < quests.length) {
init_question();
} else {
results();
}
}
function prev_question() {
if (qn == 0) {
return;
}
qn--;
var ax = quests[qn][0];
var rate = quests[qn][1];
var num = quests[qn][2];
scores[ax] -= answers[qn]*(rate<4?1:-1);
init_question();
}
function calc_score(score) {
return (50+score);
}
function results() {
location.href = `results.html`
+ `?a=${calc_score(scores[0])}`
+ `&b=${calc_score(scores[1])}`
+ `&c=${calc_score(scores[2])}`
+ `&d=${calc_score(scores[3])}`
+ `&e=${calc_score(scores[4])}`
+ `&f=${calc_score(scores[5])}`
+ `&g=${calc_score(scores[6])}`
+ `&h=${calc_score(scores[7])}`
+ `&i=${calc_score(scores[8])}`;
}
</script>
</body>