forked from rakesh-m-r/DBMS-MINI-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homestud.php
248 lines (231 loc) · 8.17 KB
/
homestud.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
<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>";
}
?>
<style>
li {
margin: 1.5vw;
font-size: 1.5vw !important;
}
ul {
list-style: none;
width: auto !important;
font-weight: 2vw !important;
}
.navbar {
background-color: white !important;
font-size: 1.5vw !important;
}
.navbar>ul>li:hover {
color: #042A38;
text-decoration: underline;
font-weight: bold;
cursor: default;
}
.navbar>ul>li>a:hover {
color: #042A38;
text-decoration: underline;
font-weight: bold !important;
}
a {
text-decoration: none;
color: #fff;
}
.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;
}
@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;
border: 3px solid #fff;
padding: 0.5vw;
border-radius: 10px;
}
#sc{
width: 100% !important;
margin: 0%;
color: #042A38;
}
#le{
margin-bottom: 2vw;
}
</style>
<body style="color: #fff !important;font-weight:bolder;margin: 0 !important;font-weight: bolder !important;font-family: 'Courier New', Courier, monospace;">
<div style="background-color: #042A38;height: auto;">
<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()">Score</li>
<li onclick="lo()">Sign Out</li>
</ul>
</div><br><br>
<?php
$type1 = $_SESSION["type"];
$username1 = $_SESSION["username"];
$sql = "select * from " . $type1 . " where mail='{$username1}'";
$res = mysqli_query($conn, $sql);
if ($res == true) {
global $dbmail, $dbpw;
while ($row = mysqli_fetch_array($res)) {
$dbmail = $row['mail'];
$dbname = $row['name'];
$dbusn = $row['usn'];
$dbphno = $row['phno'];
$dbgender = $row['gender'];
$dbdob = $row['DOB'];
$dbdept = $row['dept'];
}
}
?>
<center><section style="width:100vw;margin:0vw;margin-top:5vw;font-size:3vw;">Welcome to Online Examination System <?php echo $dbname ?></section></center>
<section style="color:#fff !important"><br><br><br><br><br>
<?php
$sql ="select * from quiz";
$res=mysqli_query($conn,$sql);
if($res)
{
echo "<center><h1 style=\"font-size:2vw;\">Take any Quiz</h1></center>";
echo "<center><table><thead><tr><td>Quiz Title</td><td>Created on</td><td>Created By</td><td> </td></tr></thead>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr><td>".$row["quizname"]."</td><td>".$row["date_created"]."</td><td>".$row["mail"]."</td><td><a id=\"tq\" href='takeq.php?qid=".$row['quizid']."'>Take Quiz</button></tr>";
}
echo "</table></center>";
}
?>
</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>USN : <?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 score,quiz where score.mail='{$username1}' and score.quizid=quiz.quizid";
$res=mysqli_query($conn,$sql);
if($res)
{
echo "<h1>Scoreboard</h1>";
echo "<table id=\"sc\"><thead><tr><td>Quiz Title</td><td>Score Obtained</td><td>Total Score</td><td>Remarks</td></tr></thead>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr><td>".$row["quizname"]."</td><td>".$row["score"]."</td><td>".$row["totalscore"]."</td><td>".$row["remark"]."</tr>";
}
echo "</table>";
}
else{
echo " ".mysqli_error($conn);
}
?><br><br><br>
</section>
<section style="color:#fff !important">
<?php
$sql="call leaderboard;";
$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>Score</td><td>Total Score</td><td>Student name</td><td>Student Mail ID</td></tr></thead>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr><td>".$row["quizname"]."</td><td>".$row["score"]."</td><td>".$row["totalscore"]."</td><td>".$row["name"]."</td><td>".$row["mail"]."</td></tr>";
}
echo "</table><br><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\");".
"}</script>";
?>
</html>