-
Notifications
You must be signed in to change notification settings - Fork 0
/
duquesne_quiz_3.html
257 lines (245 loc) · 9.7 KB
/
duquesne_quiz_3.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quiz Game</title>
<style>
body {
font-family: Arial, sans-serif;
}
.app-container {
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
border-style: solid;
border-width: medium;
border-color: #854abe;
border-radius: 30px;
padding: 10px;
background-color: white;
}
.question-container {
margin: 0px 50px 0px 50px;
}
.instructions {
text-align: center;
font-size: 28px;
margin-bottom: 20px;
}
.question {
text-align: center;
font-size: 24px;
margin-bottom: 20px;
}
.answer {
text-align: center;
font-size: 22px;
background-color: #f0f0f0;
border: 1px solid #ccc;
padding: 10px;
margin: 5px;
cursor: pointer;
margin-left: 25vw;
margin-right: 25vw;
margin-top: 10px;
border-radius: 50px;
}
.answer:hover {
background-color: #854abe;
color: #fff;
}
.intro-container {
}
.intro-text {
text-align: center;
font-size: 28px;
margin-bottom: 20px;
}
.game-container {
display: none;
}
.end-container {
display: none;
}
.start-button {
text-align: center;
font-size: 22px;
background-color: #854abe;
color: #fff;
/* background-color: #f0f0f0; */
border: 1px solid #ccc;
padding: 10px;
margin: 5px;
cursor: pointer;
margin-left: 35vw;
margin-right: 35vw;
margin-top: 10px;
border-radius: 50px;
}
.start-button:hover {
background-color: #e0e0e0;
color: #000000;
}
.center-img {
/* display: block;
margin-left: auto;
margin-right: auto; */
}
</style>
</head>
<body>
<div class="app-container">
<div class="intro-container">
<div class="intro-text">
<!-- <h1> Intro...(Temp) </h1> -->
<!-- <h3> Welcome to the C4R Quiz Game! </h3> -->
<h3> You will be presented with a list of research questions and asked to identify which component is missing. Later into the lesson, you can repeat the quiz and see how your score improved. </h2>
<h4> Click the button below to start the quiz! </h3>
<div class="start-button" onclick="startGame()" id="start">Start</div>
</div>
</div>
<div class="game-container">
<div class="instructions">
In the following research question, which component is missing?
</div>
<div class="question-container">
<div class="question" id="question"></div>
<div class="answer" onclick="checkAnswer(0)" id="answer0"></div>
<div class="answer" onclick="checkAnswer(1)" id="answer1"></div>
<div class="answer" onclick="checkAnswer(2)" id="answer2"></div>
<div class="answer" onclick="checkAnswer(3)" id="answer3"></div>
<div class="answer" onclick="checkAnswer(4)" id="answer4"></div>
</div>
</div>
<div class="end-container">
<div class="intro-text">
<h2> Quiz finished! </h2>
<h3> Your score is: <span id="currentScore"></span> </h3>
<h3 id="previousScoreMsg"> Your previous score is: <span id="previousScore"></span> </h3>
<!-- <h4> Click the button below to restart the quiz! </h4> -->
<img src="correct.png" class="center-img" width="150" height="150" />
<div class="start-button" onclick="restartGame()">Restart</div>
</div>
</div>
<a href="https://c4r.io/" target="_blank">
<img src="raven-head-smallest2.png" width="50" height="50" />
</a>
</div>
<script>
let score = 0;
var questions = [];
var currentQuestionIndex = 0;
questions = [
{
question:
"Is apixaban superior to aspirin in preventing ischemic lesions?",
answers: [
"Population",
"Intervention",
"Comparison",
"Outcome",
"None of the above",
],
correctAnswer: 0,
},
{
question:
"In post-operative pediatric patients, does physical therapy improve mobility recovery?",
answers: [
"Population",
"Intervention",
"Comparison",
"Outcome",
"None of the above",
],
correctAnswer: 2,
},
{
question:
"What could reduce seizures in children with medically resistant focal epilepsy receiving standard care?",
answers: [
"Population",
"Intervention",
"Comparison",
"Outcome",
"None of the above",
],
correctAnswer: 1,
},
{
question:
"Does cognitive behavioral therapy reduce self-reported anxiety symptoms more effectively than selective serotonin-reuptake inhibitors in adolescents?",
answers: [
"Population",
"Intervention",
"Comparison",
"Outcome",
"None of the above",
],
correctAnswer: 4,
},
{
question:
"In adult smokers, how does nicotine replacement therapy compare to behavioral therapy?",
answers: [
"Population",
"Intervention",
"Comparison",
"Outcome",
"None of the above",
],
correctAnswer: 3,
},
];
displayQuestion(currentQuestionIndex);
function displayQuestion(index) {
var question = questions[index];
document.getElementById("question").innerText =
question.question;
for (var i = 0; i < 5; i++) {
document.getElementById("answer" + i).innerText =
question.answers[i];
}
}
function checkAnswer(selectedAnswer) {
// Check correct answer
var correctAnswer = questions[currentQuestionIndex].correctAnswer;
if (selectedAnswer === correctAnswer) {
score += 25;
// } else {
// alert('Wrong! Try again.');
}
// Go to next question - exit if no more questions
currentQuestionIndex++;
if (currentQuestionIndex < questions.length) {
displayQuestion(currentQuestionIndex);
} else {
// End of quiz
// Set current score element on results page
document.getElementById("currentScore").innerText = score;
// Fetch previous score from session storage
var previousScoreToken = sessionStorage.getItem("score1");
if (previousScoreToken) {
document.getElementById("previousScore").innerText = previousScoreToken;
}
else {
document.getElementById("previousScoreMsg").innerText = "There was an error retrieving your previous score.";
}
// Display results page
document.getElementsByClassName("game-container")[0].style.display =
"none";
document.getElementsByClassName("end-container")[0].style.display =
"block";
}
}
function startGame() {
document.getElementsByClassName("intro-container")[0].style.display =
"none";
document.getElementsByClassName("game-container")[0].style.display =
"block";
}
function restartGame() {
location.reload();
}
</script>
</body>
</html>