-
Notifications
You must be signed in to change notification settings - Fork 0
/
welcome.php
292 lines (250 loc) · 15.4 KB
/
welcome.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
<?php
include_once 'header.php';
// Check if the user is logged in, if not then redirect him to login page
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("location: index.php");
exit;
}
?>
<div class="container-fluid">
<div class="jumbotron bg-info">
<?php
if (@$_GET['page'] == 1 || !(@$_GET['page'])) {
echo '
<div class="container-fluid text-center">
<h1>Hi, <b>' . $_SESSION["username"] . '</b>!</h1>
</div>
<br>
</div>
</div>
';
echo '
<div class="row">
<div class="col-sm-1">
</div>
<div class="col-sm-3">
<div class="card text-white bg-info border-dark mb-4">
<div class="card-body">
<h5 class="card-title text-center">Let\'s get started!</h5>
<p class="card-text text-center">What would you like to do?</p>
<p class="card-text text-center"><a class="text-white" href="welcome.php?page=2"><u>Create a Quiz</u></a></p>
<p class="card-text text-center"><a class="text-white" href="welcome.php?page=3"><u>Take/Share/Delete your Quizzes</u></a></p>
<p class="card-text text-center"><a class="text-white" href="#" data-toggle="popover" data-trigger="focus" title="Feature Unavailable" data-content="Our engineers are still working on this feature; it will be available in the near future."><u>Search for a Quiz</u></a></p>
<p class="card-text text-center"><a class="text-white" href="#" data-toggle="popover" data-trigger="focus" title="Feature Unavailable" data-content="Our engineers are still working on this feature; it will be available in the near future."><u>Create a Group</u></a></p>
<p class="card-text text-center"><a class="text-white" href="#" data-toggle="popover" data-trigger="focus" title="Feature Unavailable" data-content="Our engineers are still working on this feature; it will be available in the near future."><u>Join a Group</u></a></p>
';
$userQ = mysqli_query($link, "SELECT * FROM users WHERE username='$_SESSION[username]' ") or die();
$user = mysqli_fetch_array($userQ);
$userType = $user['type'];
if ($userType == 'admin') {
echo '
<br>
<p class="card-text text-center">Admin Options</p>
<p class="card-text text-center"><a class="text-white" href="welcome.php?page=admin"><u>Admin Quiz Tool</u></a></p>
';
}
echo '
</div>
</div>
</div>
<div class="col-sm-1">
</div>
<div class="col-sm-5">
<div class="container border-dark">
<img src="img/DashImg.png" class="img-fluid rounded mx-auto d-block" alt="Dashboard Image">
</div>
</div>
<div class="col-sm-1">
</div>
</div>
';
}
if (@$_GET['page'] == 2 && !(@$_GET['step'])) {
echo '
<div class="row">
<span class="title1" style="margin-left:40%;font-size:30px;"><b>Enter Quiz Details</b></span><br><br>
<div class="col-md-3"></div><div class="col-md-6">
<form class="form-horizontal title1" name="form" action="update.php?page=addquiz" method="POST">
<fieldset>
<div class="form-group">
<label class="col-md-12 control-label" for="name"></label>
<div class="col-md-12">
<input id="name" name="name" placeholder="Enter quiz title" class="form-control input-md" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="description"></label>
<div class="col-md-12">
<input id="description" name="description" placeholder="Description for quiz" class="form-control input-md" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="total"></label>
<div class="col-md-12">
<input id="total" name="total" placeholder="Enter total number of questions" class="form-control input-md" type="number" max="50" min="1" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="time"></label>
<div class="col-md-12">
<input id="time" name="time" placeholder="Enter a time limit in minutes" class="form-control input-md" max="60" min="1" type="number" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for=""></label>
<div class="col-md-12">
<input type="submit" style="margin-left:45%" class="btn btn-success btn-outline-dark" value="Next">
</div>
</div>
</fieldset>
</form>
</div>
';
}
if (@$_GET['page'] == 2 && (@$_GET['step']) == 2) {
echo '
<div class="row">
<span class="title1" style="margin-left:40%;font-size:30px;"><b>Enter Question Details</b></span><br /><br />
<div class="col-md-3"></div>
<div class="col-md-6">
<form class="form-horizontal title1" name="form" action="update.php?page=addqns&n=' . @$_GET['n'] . '&eid=' . @$_GET['eid'] . '&ch=4" method="POST">
<fieldset>
';
for ($i = 1; $i <= @$_GET['n']; $i++) {
echo '
<b>Question number ' . $i . ' :</><br />
<!-- Text input-->
<div class="form-group">
<label class="col-md-12 control-label" for="qns' . $i . ' "></label>
<div class="col-md-12">
<textarea rows="3" cols="5" name="qns' . $i . '" class="form-control" placeholder="Write question number ' . $i . ' here..." required></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '1"></label>
<div class="col-md-12">
Option A - <input id="' . $i . '1" name="' . $i . '1" placeholder="Enter option a" class="form-control input-md" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '2"></label>
<div class="col-md-12">
Option B - <input id="' . $i . '2" name="' . $i . '2" placeholder="Enter option b" class="form-control input-md" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '3"></label>
<div class="col-md-12">
Option C - <input id="' . $i . '3" name="' . $i . '3" placeholder="Enter option c" class="form-control input-md" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '4"></label>
<div class="col-md-12">
Option D - <input id="' . $i . '4" name="' . $i . '4" placeholder="Enter option d" class="form-control input-md" type="text" required>
</div>
</div>
<br /><b>Correct answer</b>:<br />
<select id="ans' . $i . '" name="ans' . $i . '" placeholder="Choose correct answer " class="form-control input-md" >
<option value="a">option a</option>
<option value="b">option b</option>
<option value="c">option c</option>
<option value="d">option d</option>
</select><br /><br />
';
}
echo '
<div class="form-group">
<label class="col-md-12 control-label" for=""></label>
<div class="col-md-12">
<input type="submit" style="margin-left:45%" class="btn btn-primary" value="Submit" class="btn btn-primary"/>
</div>
</div>
</fieldset>
</form>
</div>
';
}
if (@$_GET['page'] == 3) {
$result = mysqli_query($link, "SELECT * FROM quiz WHERE owner='$_SESSION[username]' ORDER BY date DESC") or die('Error');
echo '
<div class="panel"><table class="table table-striped title1" style="vertical-align:middle">
<tr>
<td style="vertical-align:middle"><b>Name</b></td>
<td style="vertical-align:middle"><b>Created By</b></td>
<td style="vertical-align:middle"><b>Total Questions</b></td>
<td style="vertical-align:middle"><b>Time limit</b></td>
<td style="vertical-align:middle"><b>Action</b></td>
</tr>
';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$owner = $row['owner'];
$total = $row['total'];
$time = $row['time'];
$eid = $row['eid'];
$actual_link = 'http://'.$_SERVER['HTTP_HOST'];
echo '
<tr>
<td style="vertical-align:middle">' . $title . '</td>
<td style="vertical-align:middle">' . $owner . '</td>
<td style="vertical-align:middle">' . $total . '</td>
<td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle">
<a href="quiz.php?page=quiz&eid=' . $eid . '" class="btn btn btn-success btn-sm btn-outline-dark">Take Quiz</a>
<button type="button" class="btn btn-primary btn-sm btn-outline-dark" data-container="body" data-toggle="popover" data-placement="right" title="Send this link to a friend: " data-content=" '. $actual_link .'/quiz.php?page=quiz&eid=' . $eid . ' ">
Share Quiz
</button>
<button type="button" class="btn btn-danger btn-sm btn-outline-dark" data-container="body" data-toggle="popover" data-placement="right" title="Are You Sure?" data-content="<a href='. $actual_link .'/update.php?page=deletequiz&eid=' . $eid . '>Yes</a> <a href=welcome.php?page=3>No</a>" data-html="true">
Delete Quiz
</button>
</td>
</tr>
';
}
}
if (@$_GET['page'] == 'admin') {
$result = mysqli_query($link, "SELECT * FROM quiz ORDER BY date DESC") or die('Error');
echo '
<div class="panel"><table class="table table-striped title1" style="vertical-align:middle">
<tr>
<td style="vertical-align:middle"><b>Name</b></td>
<td style="vertical-align:middle"><b>Created By</b></td>
<td style="vertical-align:middle"><b>Total Questions</b></td>
<td style="vertical-align:middle"><b>Time limit</b></td>
<td style="vertical-align:middle"><b>Action</b></td>
</tr>
';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$owner = $row['owner'];
$total = $row['total'];
$time = $row['time'];
$eid = $row['eid'];
$actual_link = 'http://'.$_SERVER['HTTP_HOST'];
echo '
<tr>
<td style="vertical-align:middle">' . $title . '</td>
<td style="vertical-align:middle">' . $owner . '</td>
<td style="vertical-align:middle">' . $total . '</td>
<td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle">
<a href="quiz.php?page=quiz&eid=' . $eid . '" class="btn btn btn-success btn-sm btn-outline-dark">Take Quiz</a>
<button type="button" class="btn btn-primary btn-sm btn-outline-dark" data-container="body" data-toggle="popover" data-placement="right" title="Send this link to a friend: " data-content=" '. $actual_link .'/quiz.php?page=quiz&eid=' . $eid . ' ">
Share Quiz
</button>
<button type="button" class="btn btn-danger btn-sm btn-outline-dark" data-container="body" data-toggle="popover" data-placement="right" title="Are You Sure?" data-content="<a href='. $actual_link .'/update.php?page=admindeletequiz&eid=' . $eid . '>Yes</a> <a href=welcome.php?page=admin>No</a>" data-html="true">
Delete Quiz
</button>
</td>
</tr>
';
}
}
?>
</div>
</div>
</body>
</html>