-
Notifications
You must be signed in to change notification settings - Fork 0
/
join_quizz.php
318 lines (314 loc) · 10.4 KB
/
join_quizz.php
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<?php
session_start();
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if(isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'])
{
if(isset($_SESSION["userData"]))
{
$userData = json_decode($_SESSION["userData"]);
if($userData->is_teacher)
{
header("Location: /", true);
exit;
}
}
}
?>
<?php
if(isset($_POST['logout']))
{
unset($_SESSION["isLoggedIn"]);
unset($_SESSION["userData"]);
session_destroy();
header("Refresh:0");
exit;
}
$path = $_SERVER['DOCUMENT_ROOT'];
if(isset($_POST['joinQuizz']) && $_POST['joinQuizz']) {
if(isset($_POST['quizzCode']) && isset($_POST['quizzNickname'])) {
$quizzCode=$_POST['quizzCode'];
$quizzNickname=$_POST['quizzNickname'];
require_once $path . '/db_handler/web.php';
$db = new DbHandlerWeb();
$db->initializeAPI("xtoAkWqVGp4nDtW6tZL1AaJUCl9I3tYcqjfTBhSu", "PHZ7dh4vHtbJoF7kD2RtZQUxi3opTFeXvpa0Jp7R");
$joinQuizz = $db->joinQuizz($quizzCode, $quizzNickname);
if(!$joinQuizz["error"])
{
$_SESSION["questionRowsData"] = $joinQuizz["questionRowsData"];
$_SESSION["quizzSessionID"] = $joinQuizz["session_id"];
$_SESSION["quizzData"] = $joinQuizz["quizzData"];
$_SESSION["currentQuestion"] = 0;
header("Location: ../../quizz/wait");
exit;
}
exit;
} else {
exit;
}
}
?>
<?php
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo '<title>Join Quest</title>';
echo '<!-- Disable tap highlight on IE -->';
echo '<!-- Web Application Manifest -->';
echo '<link rel="manifest" href="manifest.json">';
echo '<!-- Add to homescreen for Chrome on Android -->';
echo '<meta name="mobile-web-app-capable" content="yes">';
echo '<meta name="application-name" content="Quest Mode">';
echo '<meta name="theme-color" content="#ffffff">';
echo '<link href="https://fonts.googleapis.com/css?family=PT+Sans&display=swap" rel="stylesheet">';
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>';
echo '<link rel="stylesheet" href="../../assets/style/cookieConsent.css" type="text/css">';
echo '<link rel="stylesheet" href="../../assets/style/material.css" type="text/css">';
echo '<link rel="stylesheet" href="../../assets/style/toolbar.css" type="text/css">';
echo '<script src="../../assets/script/cookieConsent.js" type="text/javascript"></script>';
echo '<style>';
echo 'img[alt="www.000webhost.com"] {';
echo 'display: none !important;';
echo '}';
echo '/* colors */';
echo ':root {';
echo '--pure-material-primary-rgb: 85, 8, 194;';
echo '--pure-material-onsurface-rgb: 0, 0, 0;';
echo '}';
echo '/* Body Style */';
echo 'body {';
echo 'margin: 0;';
echo 'background-color: #f5f5f5;';
echo '}';
echo '.unselectable {';
echo '-webkit-user-select: none; /* Safari */';
echo '-moz-user-select: none; /* Firefox */';
echo '-ms-user-select: none; /* IE10+/Edge */';
echo 'user-select: none; /* Standard */';
echo '}';
echo 'a {';
echo 'text-decoration:none';
echo '}';
echo '/* Prevent Resizing on Padding */';
echo '* {';
echo '-moz-box-sizing: border-box;';
echo '-webkit-box-sizing: border-box;';
echo 'box-sizing: border-box;';
echo '}';
echo '/* Website Content Holder */';
echo '.contentHolder {';
echo 'padding-top: 90px;';
echo 'padding-bottom: 30px;';
echo 'width: 100%;';
echo 'position: absolute;';
echo '}';
echo '/* Question Content Style */';
echo '.quizzCodeHolder {';
echo 'background-color: rgb(236, 236, 236);';
echo 'font-family: "PT Sans";';
echo 'color: rgb(0, 0, 0);';
echo 'padding: 30px;';
echo 'position: fixed;';
echo 'top: 50%;';
echo 'left: 50%;';
echo 'transform: translateY(-50%) translateX(-50%);';
echo 'border-radius: 20px;';
echo '-webkit-filter: drop-shadow(0px 0px 10px rgba(0,0,0,0.5));';
echo 'filter: drop-shadow(0px 0px 10px #222);';
echo '}';
echo '.quizzCodeTitle {';
echo 'text-align: center;';
echo 'font-weight: 900;';
echo 'font-size: 25px;';
echo 'font-family: "PT Sans";';
echo 'color: rgb(0, 0, 0);';
echo '}';
echo '.codeHolder {';
echo 'margin-top: 10px;';
echo 'text-align: center;';
echo 'font-weight: 900;';
echo 'font-size: 17px;';
echo 'color: rgb(0, 0, 0);';
echo '}';
echo '.nicknameHolder {';
echo 'margin-top: 10px;';
echo 'text-align: center;';
echo 'font-weight: 900;';
echo 'font-size: 17px;';
echo 'color: rgb(0, 0, 0);';
echo '}';
echo '.inputHolder {';
echo 'font-weight: 900;';
echo 'font-size: 18px;';
echo 'font-family: "PT Sans";';
echo '}';
echo '.quizzCodeBtn {';
echo 'width: fit-content;';
echo 'margin-top: 15px;';
echo 'padding-top: 6px;';
echo 'padding-bottom: 6px;';
echo 'font-weight: 900;';
echo 'font-size: 16px;';
echo 'padding-left: 24px;';
echo 'padding-right: 24px;';
echo 'font-family: "PT Sans";';
echo 'color: rgb(255, 255, 255);';
echo 'background-color: #2b00a0;';
echo 'border-radius: 5px;';
echo 'background-color: #2b00a0;';
echo '-webkit-filter: drop-shadow(0px 0px 4px #2b00a0c0);';
echo 'filter: drop-shadow(0px 0px 4px #2b00a0be);';
echo '-moz-box-shadow: inset 0 0 10px #00000083;';
echo '-webkit-box-shadow: inset 0 0 10px #00000083;';
echo 'box-shadow: inset 0 0 10px #00000083;';
echo 'margin-left: 50%;';
echo 'transform: translate(-50%, 0%);';
echo '}';
echo '.quizzCodeBtn:hover {';
echo 'transform: translate(-50%, 0%) scale(0.95);';
echo 'background-color: #3b00df;';
echo '-webkit-filter: drop-shadow(0px 0px 6px #1a008dc0);';
echo 'filter: drop-shadow(0px 0px 6px #1a008dbe);';
echo '-moz-box-shadow: inset 0 0 10px #00000083;';
echo '-webkit-box-shadow: inset 0 0 10px #00000083;';
echo 'cursor: pointer;';
echo '}';
echo '</style>';
echo '</head>';
?>
<?php
echo '<body>';
echo '<div class="toolbarHolder toolbarShadow unselectable" id="toolbar">';
echo '<div class="toolbarContent">';
echo '<div class="titleToolbar" onclick="goHome();">';
echo 'Quest Mode';
echo '</div>';
echo '<script type="text/javascript">';
echo 'function goHome() {';
echo 'window.location = "/";';
echo '}';
echo '</script>';
echo '</div>';
echo '<div class="userLoggedInHolder">';
echo '<img class="userLoggedInPicture" src="https://firebasestorage.googleapis.com/v0/b/zeo-flow.appspot.com/o/ProfilePicturesLowQ%2F6jk6xzpHdrwB4kqok4xFDy2HrfobqKJeWRgOE470158261189.jpeg?alt=media" />';
echo '</div>';
echo '</div>';
echo '<div class="userLoggedInDetails hideElement" id="userLoggedInDetails">';
echo '<div class="userLoggedInDetailsHolder unselectable">';
echo '<div class="userLoggedInCover">';
echo '<img class="userLoggedInPicture2" src="https://firebasestorage.googleapis.com/v0/b/zeo-flow.appspot.com/o/ProfilePicturesLowQ%2F6jk6xzpHdrwB4kqok4xFDy2HrfobqKJeWRgOE470158261189.jpeg?alt=media" />';
echo '<div class="userLoggedInProfileHolder">';
echo '<div class="userLoggedInArcShape"></div>';
echo '<div class="userLoggedInProfileDetails">';
echo '<div class="userLoggedInViewProfile">';
echo 'View Profile';
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="profileHolder">';
echo '<div class="userLoggedInOptions">';
echo '<div class="userLoggedInOptionsItem" onclick="goJoinQuizz();">';
echo 'Join Quizz';
echo '</div>';
echo '<script type="text/javascript">';
echo 'function goJoinQuizz() {';
echo 'window.location = "/quizz/join";';
echo '}';
echo '</script>';
echo '<div class="userLoggedInOptionsItem">';
echo 'Help & Support';
echo '</div>';
echo '<div class="userLoggedInOptionsItem" onclick="logout()">';
echo 'Log Out';
echo '</div>';
echo '<script>';
echo 'function logout() {';
echo '$.ajax({';
echo 'type: "post",';
echo 'data: {';
echo 'ajax: 1,';
echo 'logout: true';
echo '},';
echo 'success: function(response){';
echo 'location.reload(true);';
echo '}';
echo '});';
echo '}';
echo '</script>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="contentHolder unselectable">';
echo '<div class="quizzCodeHolder">';
echo '<div class="quizzCodeTitle">';
echo 'Enter Quizz Code';
echo '</div>';
echo '<div class="inputHolder">';
echo '<label class="pure-material-textfield-outlined codeHolder">';
echo '<input class="inputHolder" id="quizzCode" placeholder=" " type="text" required>';
echo '<span>Code</span>';
echo '</label>';
echo '</div>';
echo '<div class="inputHolder">';
echo '<label class="pure-material-textfield-outlined nicknameHolder">';
echo '<input class="inputHolder" id="quizzNickname" placeholder=" " type="text" required>';
echo '<span>Nickname</span>';
echo '</label>';
echo '</div>';
echo '<div class="quizzCodeBtn" onclick="checkData();">';
echo 'Join Quizz';
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div id="myCookieConsent">';
echo '<a id="cookieButton">Understood</a>';
echo '<div>To help personalise content and provide a safer experience, we use cookies. By clicking on or navigating the site, you agree to allow us to collect information on and off Quest Mode through cookies. Learn more, including about available controls: <a href="/">Cookie Policy</a>.</div>';
echo '</div>';
echo '</body>';
echo '<script>';
echo 'function checkData()';
echo '{';
echo 'if(document.getElementById("quizzCode").value.length != 0';
echo '&& document.getElementById("quizzNickname").value.length != 0)';
echo '{';
echo '$.ajax({';
echo 'type: "post",';
echo 'data: {';
echo 'joinQuizz: true,';
echo 'quizzCode: document.getElementById("quizzCode").value,';
echo 'quizzNickname: document.getElementById("quizzNickname").value';
echo '},';
echo 'success: function(response){';
echo 'document.getElementById("quizzCode").value = "";';
echo 'document.getElementById("quizzNickname").value = "";';
echo 'window.location = "/quizz/wait";';
echo '}';
echo '});';
echo '}';
echo '}';
echo '$("#quizzNickname").keyup(function (e) {';
echo 'if (e.keyCode === 13) {';
echo 'checkData();';
echo '}';
echo '});';
echo '</script>';
echo '<script>';
echo 'document.body.addEventListener("click", function (evt) {';
echo 'var userLoggedInDetails = document.getElementById("userLoggedInDetails");';
echo 'if(userLoggedInDetails != null)';
echo '{';
echo 'if(evt.target.classList.contains("userLoggedInPicture")) {';
echo 'if (userLoggedInDetails.classList.contains("hideElement")) {';
echo 'userLoggedInDetails.classList.remove("hideElement");';
echo '} else {';
echo 'userLoggedInDetails.classList.add("hideElement");';
echo '}';
echo '} else {';
echo 'userLoggedInDetails.classList.add("hideElement");';
echo '}';
echo '}';
echo '});';
echo '</script>';
?>