This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
quiz.html
158 lines (143 loc) · 7.25 KB
/
quiz.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en-US">
<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'>
<link rel="icon" type="x-icon" href="icon.png">
<link rel="shortcut icon" type="x-icon" href="icon.png">
<title>PolcompballValues</title>
<meta property="og:ttl" content="600">
<meta property="og:site_name" content="polcompballvalues.github.io">
<meta property="og:title" content="PolcompballValues">
<meta property="og:type" content="website">
<meta property="og:description"
content="PolcompballValues a quiz aimed at members of the Polcompball community, specially the official Discord server">
<meta property="og:url" content="https://polcompballvalues.github.io/legacy/">
<meta property="og:image" content="https://polcompballvalues.github.io/legacy/previcon.png">
<meta property="og:image:width" content="1024">
<meta property="og:image:height" content="1024">
<meta name="theme-color" content="#000000" data-react-helmet="true">
<meta charset="utf-8">
</head>
<body>
<script type="application/javascript" src="longquestions.js">
</script>
<script type="application/javascript" src="shortquestions.js">
</script>
<h1>PolcompballValues (legacy)</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( 1.0)" style="background-color: #1b5e20;">Strongly Agree</button> <br>
<button class="button" onclick="next_question( 0.67)" style="background-color: #4caf50;">Agree</button> <br>
<button class="button" onclick="next_question( 0.33)" style="background-color: #7de381;">Partially Agree</button>
<br>
<button class="button" onclick="next_question( 0.0)" style="background-color: #bbbbbb;">Neutral/Unsure</button> <br>
<button class="button" onclick="next_question(-0.33)" style="background-color: #eb847c;">Partially Disagree</button>
<br>
<button class="button" onclick="next_question(-0.67)" style="background-color: #f44336;">Disagree</button> <br>
<button class="button" onclick="next_question(-1.0)" style="background-color: #b71c1c;">Strongly Disagree</button>
<br>
<button class="small_button" onclick="prev_question()" id="back_button">Back</button>
<button class="small_button_off" id="back_button_off">Back</button><br>
<!-- JavaScript for the test itself -->
<script>
let questions = []
let length = ""
if (window.location.search.substring(1) == "s") {
questions = shortquestions
length = "s"
} else {
questions = longquestions
}
var max_spos, max_alle, max_serv, max_pers, max_horn, max_fame, max_show, max_sani, max_rela, max_fedp, max_acti // Max possible scores
max_spos = max_alle = max_serv = max_pers = max_horn = max_fame = max_show = max_sani = max_rela = max_fedp = max_acti = 0;
var spos, alle, serv, pers, horn, fame, show, sani, rela, fedp, acti // User's scores
spos = alle = serv = pers = horn = fame = show = sani = rela = fedp = acti = 0;
var qn = 0; // Question number
var prev_answer = null;
init_question();
for (let i = 0; i < questions.length; i++) {
max_spos += Math.abs(questions[i].effect.spos)
max_alle += Math.abs(questions[i].effect.alle)
max_serv += Math.abs(questions[i].effect.serv)
max_pers += Math.abs(questions[i].effect.pers)
max_horn += Math.abs(questions[i].effect.horn)
max_fame += Math.abs(questions[i].effect.fame)
max_show += Math.abs(questions[i].effect.show)
max_sani += Math.abs(questions[i].effect.sani)
max_rela += Math.abs(questions[i].effect.rela)
max_fedp += Math.abs(questions[i].effect.fedp)
max_acti += Math.abs(questions[i].effect.acti)
}
function init_question() {
document.getElementById("question-text").innerHTML = questions[qn].question;
document.getElementById("question-number").innerHTML = "Question " + (qn + 1) + " of " + (questions.length);
if (prev_answer == null) {
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 next_question(mult) {
spos += mult * questions[qn].effect.spos
alle += mult * questions[qn].effect.alle
serv += mult * questions[qn].effect.serv
pers += mult * questions[qn].effect.pers
horn += mult * questions[qn].effect.horn
fame += mult * questions[qn].effect.fame
show += mult * questions[qn].effect.show
sani += mult * questions[qn].effect.sani
rela += mult * questions[qn].effect.rela
fedp += mult * questions[qn].effect.fedp
acti += mult * questions[qn].effect.acti
qn++;
prev_answer = mult;
if (qn < questions.length) {
init_question();
} else {
results();
}
}
function prev_question() {
if (prev_answer == null) {
return;
}
qn--;
spos -= prev_answer * questions[qn].effect.spos;
alle -= prev_answer * questions[qn].effect.alle;
serv -= prev_answer * questions[qn].effect.serv;
pers -= prev_answer * questions[qn].effect.pers;
horn -= prev_answer * questions[qn].effect.horn;
fame -= prev_answer * questions[qn].effect.fame;
show -= prev_answer * questions[qn].effect.show;
sani -= prev_answer * questions[qn].effect.sani;
rela -= prev_answer * questions[qn].effect.rela;
fedp -= prev_answer * questions[qn].effect.fedp;
acti -= prev_answer * questions[qn].effect.acti;
prev_answer = null;
init_question();
}
function calc_score(score, max) {
return (100 * (max + score) / (2 * max)).toFixed(1)
}
function results() {
location.href = `results.html`
+ `?s=${calc_score(spos, max_spos)}`
+ `&j=${calc_score(alle, max_alle)}`
+ `&c=${calc_score(serv, max_serv)}`
+ `&w=${calc_score(pers, max_pers)}`
+ `&h=${calc_score(horn, max_horn)}`
+ `&a=${calc_score(fame, max_fame)}`
+ `&t=${calc_score(show, max_show)}`
+ `&n=${calc_score(sani, max_sani)}`
+ `&l=${calc_score(rela, max_rela)}`
+ `&i=${calc_score(fedp, max_fedp)}`
+ `&b=${calc_score(acti, max_acti)}`
+ `&d=${length}`
}
</script>
</body>
</html>