forked from rakesh-m-r/DBMS-MINI-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homestaff.php
400 lines (364 loc) · 14.3 KB
/
homestaff.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
<html>
<head>
<title>
Onine examination System
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<?php
session_start();
require_once 'sql.php';
$conn = mysqli_connect($host, $user, $ps, $project);if (!$conn) {
echo "<script>alert(\"Database error retry after some time !\")</script>";
} else {
$type1 = $_SESSION["type"];
$username1 = $_SESSION["username"];
$sql = "select * from " . $type1 . " where mail='{$username1}'";
$res = mysqli_query($conn, $sql);
if ($res == true) {
global $dbmail, $dbpw, $dbusn;
while ($row = mysqli_fetch_array($res)) {
$dbmail = $row['mail'];
$dbname = $row['name'];
$dbusn = $row['staffid'];
$dbphno = $row['phno'];
$dbgender = $row['gender'];
$dbdob = $row['DOB'];
$dbdept = $row['dept'];
}
}
if (isset($_POST['submit'])) {
$qname = strtolower($_POST['quizname']);
$_SESSION["qname"]=$qname;
$sql1 = "insert into quiz(quizname,mail) values('$qname','$username1')";
$res1 = mysqli_query($conn, $sql1);
if ($res1 == true) {
$sql = "select quizid from quiz where quizname='" . $qname . "';";
$res = mysqli_query($conn, $sql);
if ($res == true) {
header("location: addqs.php");
} else {
echo "<script>alert(\"some error occured\");</script>";
}
} else {
echo "<script>alert(\"Already name exists\");</script>";
}
}
if (isset($_POST['submit1'])) {
$qid1 = strtolower($_POST['quizid']);
$sql1 = "delete from quiz where quizid='{$qid1}'";
$res1 = mysqli_query($conn, $sql1);
if ($res1 == true) {
echo "<script>alert(\"Quiz successfully deleted\");</script>";
} else {
echo "<script>alert(\"Unknown error occured during deletion of quiz\");</script>";
}
}
if (isset($_POST['submit2'])) {
$qid1 =$_POST['quizid'];
$sql1 = "select quizid from quiz where quizid='{$qid1}'";
$res1 = mysqli_query($conn, $sql1);
if ($res1 == true) {
echo "<script>window.location.replace(\"viewq.php?qid=".$qid1."\");</script>";
} else {
echo "<script>alert(\"Unknown error occured during viweing of quiz\");</script>";
}
}
}
?>
<style>
#main{
min-height: 100% !important;
}
table{
border: 1px solid black;
width: 100% !important;
font-weight: bolder;
font-size: 2vw;
color: #042A38;
}
td{
border: 1px solid black;
width: 20%;
font-weight: bolder;
font-size: 2vw;
}
li {
margin: 1.5vw;
}
ul {
list-style: none;
width: auto !important;
}
.navbar {
background-color: #fff!important;
font-size: 1.5vw;
}
.navbar>ul>li:hover {
color: black;
text-decoration: underline;
font-weight: bold;
}
.navbar>ul>li>a:hover {
color: black;
text-decoration: underline;
font-weight: bold !important;
}
a {
text-decoration: none;
color: #042A38;
}
.prof,
#score {
top: 3vw;
position: fixed;
width: 50vw !important;
margin-left: 25vw !important;
margin-right: 25vw !important;
background-color: #fff!important;
display: none !important;
border-radius: 10px;
margin-top: 2vw;
z-index: 1;
padding: 1vw;
padding-left: 2vw;
color: #042A38;
}
button {
height: 5vh;
width: 10vw;
background-color: lightgoldenrodyellow;
color: black;
outline: none;
border: none;
border-radius: 10px;
margin: 1vw;
}
input {
width: 30vw;
height: 3vw;
border-radius: 10px;
border: 2px solid black;
padding-left: 2vw;
font-weight: bolder;
outline: none;
}
::placeholder {
font-weight: bold;
font-family: 'Courier New', Courier, monospace;
}
label {
font-weight: bolder;
}
button:hover {
background-color: blueviolet !important;
}
.bg {
background-size: 100%;
}
@media screen and (max-width: 450px) {
.navbar {
display: initial !important;
}
.navbar>ul {
display: initial !important;
left: 25vw !important;
text-align: center;
right: 25vw !important;
}
.navbar>ul>li {
background-color: orange !important;
}
section {
text-align: center;
margin-top: 0 !important;
background-color: orange !important;
width: 100vw;
margin: 0 !important;
}
p {
color: #042A38 !important;
}
}
table{
width: 90vw;
margin-left: 5vw;
margin-right: 5vw;
align-content: center;
border: 1px solid black;
}
thead{
font-weight:900;
font-size: 1.5vw;
}
td{
width: auto;
border: 1px solid black;
text-align: center;
height: 4vw;
font-weight: bold;
}
#tq{
text-decoration: underline;
}
#sc{
width: 100% !important;
margin: 0%;
color: #042A38;
}
#le{
width: 90vw;
margin: 0;
color: #fff;
}
#delq,#addq{
width: 90vw;
margin-left: 5vw;
margin-right: 5vw;
justify-content: center;
}
form{
display: contents;
}
</style>
<body style="margin: 0 !important;font-weight: bolder !important;font-family: 'Courier New', Courier, monospace;height:auto;color:#fff">
<div id="main" style="background-color: #042A38;height: auto;color:#fff !important">
<div class="navbar" style="display: inline-flex;width: 100%;color:#042A38;position:fixed;">
<section style="margin: 1.5vw;">ONLINE EXAMINATION SYSTEM</section>
<ul style="display: inline-flex;padding: 0 !important;margin: 0;float: right;right: 0;position: fixed;width: 50vw;">
<li onclick="dash()">Dashbord</li>
<li onclick="prof()">profile</li>
<li onclick="score()">Quiz's</li>
<li onclick="lo()">Sign Out</li>
</ul>
</div><br><br>
<center><section style="width:100vw;margin:0vw;margin-top:4vw;font-size:2vw;">Welcome to Online Examination System <?php echo $dbname ?></section></center>
<section class="dash" style="margin: 5vw;width: 90vw;">
<center><h1 style="font-weight:bolder;font-size:3vw">Dashbord</h1></center>
<center> <button onclick="addquiz()">Add Quiz</button> <button onclick="delquiz()">Delete Quiz</button> <button onclick="viewq()">View Quiz</button></center>
<center>
<section id="addq" style="display:none;">
<form style="width: 30vw" method="post">
<h1>Add quiz</h1>
<label for="quizname">Quiz name</label>
<input type="text" name="quizname" placeholder="enter quiz name" required><br><br>
<input type="submit" name="submit" value="submit" style="height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color: lightblue;">
</form>
</section> </center><center>
<section id="delq" style="display:none;">
<form style="margin: 1vw;width: 30vw" method="post">
<h1>Delete Quiz</h1>
<label for="quizid">Quiz Id</label>
<input type="number" name="quizid" placeholder="enter quiz id" required><h7 onclick="score()" style="padding:0;color: #fff;font-size:1vw;text-decoration:underline">get Quiz ID</h7><br><br>
<input type="submit" name="submit1" value="submit" style="height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color: lightblue;">
</form>
</section></center>
<center>
<section id="viewq" style="display:none;">
<form style="margin: 1vw;width: 30vw" method="post">
<h1>View Quiz</h1>
<label for="quizid">Quiz Id</label>
<input type="number" name="quizid" placeholder="enter quiz id" required><h7 onclick="score()" style="padding:0;color: #fff;font-size:1vw;text-decoration:underline">get Quiz ID</h7><br><br>
<input type="submit" name="submit2" value="submit" style="height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color: lightblue;">
</form>
</section></center>
<!-- <section id="ans" style="display: none;">
<form style="margin: 5vw;width: 30vw" method="post">
<center>
<label for="quizname">Questions</label><br><br>
<div id="QS">
<input type="text" name="qs" placeholder="enter question " required><br><br>
<input type="text" name="op1" placeholder="option1" required><br><br>
<input type="text" name="op2" placeholder="option2" required><br><br>
<input type="text" name="op3" placeholder="option3" required><br><br>
<input type="text" name="ans" placeholder="answer" required><br><br>
</div>
<input type="submit" name="submit" value="submit" style="height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color: lightblue;">
</center>
</form>
</section> -->
</section>
<section class="prof" id="prof" style="display: none;color:#042A38;">
<p><b>Type of User : <?php echo $type1 ?></b></p>
<p><b>NAME : <?php echo $dbname ?></b></p>
<p><b>EMAIL : <?php echo $dbmail ?></b></p>
<p><b>Ph No. : <?php echo $dbphno ?></b></p>
<p><b>STAFF ID. : <?php echo $dbusn ?></b></p>
<p><b>GENDER : <?php echo $dbgender ?></b></p>
<p><b>DOB : <?php echo $dbdob ?></b></p>
<p><b>Dept. : <?php echo $dbdept ?></b></p>
</section>
<section id="score" style="display:none;">
<?php
$sql ="select * from quiz where mail='{$username1}'";
$res=mysqli_query($conn,$sql);
if($res)
{
echo "<h1>List of Quiz added by U</h1>";
echo "<table id=\"sc\"><thead><tr><td>Quiz id</td> <td>Quiz Title</td><td>Created on</td></tr></thead>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr><td>".$row["quizid"]."</td><td>".$row["quizname"]."</td><td>".$row["date_created"]."</td></tr>";
}
echo "</table>";
}
?>
</section>
<section style="color:#fff !important">
<?php
$sql="select quizname,s.name,score,totalscore from student s,staff st,score sc,quiz q where q.quizid=sc.quizid and s.mail=sc.mail and q.mail=st.mail and q.mail='{$username1}' ORDER BY score DESC";
$res=mysqli_query($conn,$sql);
if($res)
{
echo "<center><h1 style=\"font-size: 3vw\">Leaderboard</h1></center>";
echo "<table id=\"le\"><thead><tr><td>Quiz Title</td> <td>Student name</td><td>score obtained</td><td>Max Score</td></tr></thead>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr><td>".$row["quizname"]."</td><td>".$row["name"]."</td><td>".$row["score"]."</td><td>".$row["totalscore"]."</td></tr>";
}
echo "</table><br><br>";
}
else{
echo mysqli_error($conn);
}
?>
</section>
</div>
<?php require("footer.php");?>
</body>
<?php
echo '<script>' .
"function prof(){" .
"document.getElementById(\"prof\").style=\"display: block !important;\";" .
"document.getElementById(\"score\").style=\"display: none !important;\";" .
"}" .
"function score(){" .
"document.getElementById(\"prof\").style=\"display: none !important;\";" .
"document.getElementById(\"score\").style=\"display: block !important;\";" .
"}" .
"function dash(){" .
"document.getElementById(\"prof\").style=\"display: none !important;\";" .
"document.getElementById(\"score\").style=\"display: none !important;\";" .
"}" .
"function lo(){" .
"alert(\"Thank You for Using our Online Examination System\");";
//session_unset();
//session_destroy();
echo "window.location.replace(\"index.php\");" .
"}" .
"function addquiz(){" .
"document.getElementById(\"addq\").style=\"display: initial;\";" .
"document.getElementById(\"delq\").style=\"display: none;\";" .
"document.getElementById(\"viewq\").style=\"display: none;\";" .
"}" .
"function delquiz(){" .
"document.getElementById(\"delq\").style=\"display: initial;\";" .
"document.getElementById(\"addq\").style=\"display: none;\";" .
"document.getElementById(\"viewq\").style=\"display: none;\";" .
"}" .
"function viewq(){" .
"document.getElementById(\"viewq\").style=\"display: initial;\";" .
"document.getElementById(\"delq\").style=\"display: none;\";" .
"document.getElementById(\"addq\").style=\"display: none;\";" .
"}" .
"</script>";
?>
</html>