-
Notifications
You must be signed in to change notification settings - Fork 34
/
dash.php
406 lines (368 loc) · 19.7 KB
/
dash.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="favicon.ico" type="image/icon" sizes="16x16">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Admin || Quizzer</title>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/font.css">
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<script>
$(function () {
$(document).on( 'scroll', function(){
console.log('scroll top : ' + $(window).scrollTop());
if($(window).scrollTop()>=$(".logo").height())
{
$(".navbar").addClass("navbar-fixed-top");
}
if($(window).scrollTop()<$(".logo").height())
{
$(".navbar").removeClass("navbar-fixed-top");
}
});
});</script>
</head>
<body style="background:#eee;">
<body style="background:#eee;">
<div class="header">
<div class="row">
<div class="col-lg-6">
<span class="logo">Quizzer</span></div>
<?php
include_once 'dbConnection.php';
session_start();
if (!(isset($_SESSION['username'])) || ($_SESSION['key']) != '54585c506829293a2d4c3b68543b316e2e7a2d277858545a36362e5f39') {
session_destroy();
header("location:index.php");
} else {
$name = $_SESSION['name'];
$username = $_SESSION['username'];
include_once 'dbConnection.php';
echo '<span class="pull-right top title1" ><span style="color:white"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Hello,</span> <span class="log log1" style="color:lightyellow">' . $name . ' | <a href="logout.php?q=account.php" style="color:lightyellow"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Logout</button></a></span>';
}
?>
</div></div>
<nav class="navbar navbar-default title1">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="dash.php?q=0"><b>Dashboard</b></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li <?php
if (@$_GET['q'] == 0)
echo 'class="active"';
?>><a href="dash.php?q=0">Home<span class="sr-only">(current)</span></a></li>
<li <?php
if (@$_GET['q'] == 1)
echo 'class="active"';
?>><a href="dash.php?q=1">Users</a></li>
<li <?php
if (@$_GET['q'] == 2)
echo 'class="active"';
?>><a href="dash.php?q=2">Leaderboard</a></li>
<li <?php
if (@$_GET['q'] == 3)
echo 'class="active"';
?>><a href="dash.php?q=3">Feedback</a></li>
<li <?php
if (@$_GET['q'] == 4)
echo 'class="active"';
?>><a href="dash.php?q=4">Add Quiz</a></li>
<li <?php
if (@$_GET['q'] == 5)
echo 'class="active"';
?>><a href="dash.php?q=5">Remove Quiz</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-12">
<?php
if (@$_GET['q'] == 0) {
$result = mysqli_query($con, "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>S.N.</b></td><td style="vertical-align:middle"><b>Name</b></td><td style="vertical-align:middle"><b>Total question</b></td><td style="vertical-align:middle"><b>Marks</b></td><td style="vertical-align:middle"><b>Time limit</b></td><td style="vertical-align:middle"><b>Status</b></td><td style="vertical-align:middle"><b>Action</b></td></tr>';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$total = $row['total'];
$correct = $row['correct'];
$time = $row['time'];
$eid = $row['eid'];
$status = $row['status'];
if ($status == "enabled") {
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . '</td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td><td style="vertical-align:middle">Enabled</td>
<td style="vertical-align:middle"><b><a href="update.php?deidquiz=' . $eid . '" class="btn logb" style="color:#FFFFFF;background:#ff0000;font-size:12px;padding:5px;"> <span><b>Disable</b></span></a></b></td></tr>';
} else {
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . '</td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td><td style="vertical-align:middle">Disabled</td>
<td style="vertical-align:middle"><b><a href="update.php?eeidquiz=' . $eid . '" class="btn logb" style="color:#FFFFFF;background:darkgreen;font-size:12px;padding:5px;"> <span><b>Enable</b></span></a></b></td></tr>';
}
}
}
if (@$_GET['q'] == 2) {
if(isset($_GET['show'])){
$show = $_GET['show'];
$showfrom = (($show-1)*10) + 1;
$showtill = $showfrom + 9;
}
else{
$show = 1;
$showfrom = 1;
$showtill = 10;
}
$q = mysqli_query($con, "SELECT * FROM rank") or die('Error223');
echo '<div class="panel title">
<table class="table table-striped title1" >
<tr><td style="vertical-align:middle"><b>Rank</b></td><td style="vertical-align:middle"><b>Name</b></td><td style="vertical-align:middle"><b>Branch</b></td><td style="vertical-align:middle"><b>Username</b></td><td style="vertical-align:middle"><b>Roll number</b></td><td style="vertical-align:middle"><b>Gender</b></td><td style="vertical-align:middle"><b>Score</b></td></tr>';
$c = $showfrom-1;
$total = mysqli_num_rows($q);
if($total >= $showfrom){
$q = mysqli_query($con, "SELECT * FROM rank ORDER BY score DESC, time ASC LIMIT ".($showfrom-1).",10") or die('Error223');
while ($row = mysqli_fetch_array($q)) {
$e = $row['username'];
$s = $row['score'];
$q12 = mysqli_query($con, "SELECT * FROM user WHERE username='$e' ") or die('Error231');
while ($row = mysqli_fetch_array($q12)) {
$name = $row['name'];
$branch = $row['branch'];
$username = $row['username'];
$rollno = $row['rollno'];
$gender = $row['gender'];
}
$c++;
echo '<tr><td style="color:#99cc32"><b>' . $c . '</b></td><td style="vertical-align:middle">' . $name . '</td><td style="vertical-align:middle">' . $branch . '</td><td style="vertical-align:middle">' . $username . '</td><td style="vertical-align:middle">' . $rollno . '</td><td style="vertical-align:middle">' . $gender . '</td><td style="vertical-align:middle">' . $s . '</td><td style="vertical-align:middle">';
}
}
else{
}
echo '</table></div>';
echo '<div class="panel title"><table class="table table-striped title1" ><tr>';
$total = round($total/10) + 1;
if(isset($_GET['show'])){
$show = $_GET['show'];
}
else{
$show = 1;
}
if($show == 1 && $total==1){
}
else if($show == 1 && $total!=1){
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.($show+1).'"> >> </a></td>';
}
else if($show != 1 && $show==$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.($show-1).'"> << </a></td>';
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
}
else{
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.($show-1).'"> << </a></td>';
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="dash.php?q=2&show='.($show+1).'"> >> </a></td>';
}
echo '</tr></table></div>';
}
if (@$_GET['q'] == 1) {
$result = mysqli_query($con, "SELECT * FROM user") or die('Error');
echo '<div class="panel"><table class="table table-striped title1">
<tr><td style="vertical-align:middle"><b>S.N.</b></td><td style="vertical-align:middle"><b>Name</b></td><td style="vertical-align:middle"><b>Gender</b></td><td style="vertical-align:middle"><b>Rollno</b></td><td style="vertical-align:middle"><b>Branch</b></td><td style="vertical-align:middle"><b>Username</b></td><td style="vertical-align:middle"><b>Phno</b></td><td style="vertical-align:middle"></td></tr>';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$name = $row['name'];
$phno = $row['phno'];
$gender = $row['gender'];
$rollno = $row['rollno'];
$branch = $row['branch'];
$username1 = $row['username'];
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $name . '</td><td style="vertical-align:middle">' . $gender . '</td><td style="vertical-align:middle">' . $rollno . '</td><td style="vertical-align:middle">' . $branch . '</td><td style="vertical-align:middle">' . $username1 . '</td><td style="vertical-align:middle">' . $phno . '</td>
<td style="vertical-align:middle"><a title="Delete User" href="update.php?dusername=' . $username1 . '"><b><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></b></a></td></tr>';
}
$c = 0;
echo '</table></div>';
}
if (@$_GET['q'] == 3) {
$result = mysqli_query($con, "SELECT * FROM `feedback` ORDER BY `feedback`.`date` DESC") or die('Error');
echo '<div class="panel"><table class="table table-striped title1">
<tr><td style="vertical-align:middle"><b>S.N.</b></td><td style="vertical-align:middle"><b>Subject</b></td><td style="vertical-align:middle"><b>Username</b></td><td style="vertical-align:middle"><b>Date</b></td><td style="vertical-align:middle"><b>Time</b></td><td style="vertical-align:middle"><b>By</b></td><td style="vertical-align:middle"></td><td style="vertical-align:middle"><b>Action</b></td></tr>';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$date = $row['date'];
$date = date("d-m-Y", strtotime($date));
$time = $row['time'];
$subject = $row['subject'];
$name = $row['name'];
$username1 = $row['username'];
$id = $row['id'];
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td>';
echo '<td style="vertical-align:middle"><a title="Click to open feedback" href="dash.php?q=3&fid=' . $id . '">' . $subject . '</a></td><td style="vertical-align:middle">' . $username1 . '</td><td style="vertical-align:middle">' . $date . '</td><td style="vertical-align:middle">' . $time . '</td><td style="vertical-align:middle">' . $name . '</td>
<td style="vertical-align:middle"><a title="Open Feedback" href="dash.php?q=3&fid=' . $id . '"><b><span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span></b></a></td>';
echo '<td style="vertical-align:middle"><a title="Delete Feedback" href="update.php?fdid=' . $id . '"><b><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></b></a></td>
</tr>';
}
echo '</table></div>';
}
if (@$_GET['fid']) {
echo '<br />';
$id = @$_GET['fid'];
$result = mysqli_query($con, "SELECT * FROM feedback WHERE id='$id' ") or die('Error');
while ($row = mysqli_fetch_array($result)) {
$name = $row['name'];
$subject = $row['subject'];
$date = $row['date'];
$date = date("d-m-Y", strtotime($date));
$time = $row['time'];
$feedback = $row['feedback'];
echo '<div class="panel"<a title="Back to Archive" href="update.php?q1=2"><b><span class="glyphicon glyphicon-level-up" aria-hidden="true"></span></b></a><h2 style="text-align:center; margin-top:-15px;font-family: "Ubuntu", sans-serif;"><b>' . $subject . '</b></h1>';
echo '<div class="mCustomScrollbar" data-mcs-theme="dark" style="margin-left:10px;margin-right:10px; max-height:450px; line-height:35px;padding:5px;"><span style="line-height:35px;padding:5px;">- <b>DATE:</b> ' . $date . '</span>
<span style="line-height:35px;padding:5px;"> <b>Time:</b> ' . $time . '</span><span style="line-height:35px;padding:5px;"> <b>By:</b> ' . $name . '</span><br />' . $feedback . '</div></div>';
}
}
if (@$_GET['q'] == 4 && !(@$_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?q=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">
</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">
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="right"></label>
<div class="col-md-12">
<input id="right" name="right" placeholder="Enter marks on right answer" class="form-control input-md" min="0" type="number">
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="wrong"></label>
<div class="col-md-12">
<input id="wrong" name="wrong" placeholder="Enter minus marks on wrong answer without sign" class="form-control input-md" min="0" type="number">
</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 time limit for test in minute" class="form-control input-md" min="1" type="number">
</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-primary" value="Submit" class="btn btn-primary"/>
</div>
</div>
</fieldset>
</form></div>';
}
if (@$_GET['q'] == 4 && (@$_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?q=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..."></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '1"></label>
<div class="col-md-12">
<input id="' . $i . '1" name="' . $i . '1" placeholder="Enter option a" class="form-control input-md" type="text">
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '2"></label>
<div class="col-md-12">
<input id="' . $i . '2" name="' . $i . '2" placeholder="Enter option b" class="form-control input-md" type="text">
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '3"></label>
<div class="col-md-12">
<input id="' . $i . '3" name="' . $i . '3" placeholder="Enter option c" class="form-control input-md" type="text">
</div>
</div>
<div class="form-group">
<label class="col-md-12 control-label" for="' . $i . '4"></label>
<div class="col-md-12">
<input id="' . $i . '4" name="' . $i . '4" placeholder="Enter option d" class="form-control input-md" type="text">
</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">Select answer for question ' . $i . '</option>
<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['q'] == 5) {
$result = mysqli_query($con, "SELECT * FROM quiz ORDER BY date DESC") or die('Error');
echo '<div class="panel"><table class="table table-striped title1">
<tr><td style="vertical-align:middle"><b>S.N.</b></td><td style="vertical-align:middle"><b>Topic</b></td><td style="vertical-align:middle"><b>Total question</b></td><td style="vertical-align:middle"><b>Marks</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'];
$total = $row['total'];
$correct = $row['correct'];
$time = $row['time'];
$eid = $row['eid'];
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . '</td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle"><b><a href="update.php?q=rmquiz&eid=' . $eid . '" class="btn" style="margin:0px;background:red;color:white"> <span class="title1"><b>Remove</b></span></a></b></td></tr>';
}
$c = 0;
echo '</table></div>';
}
?>
</div>
</div></div>
</body>
</html>