forked from rakesh-m-r/DBMS-MINI-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewq.php
249 lines (233 loc) · 8.13 KB
/
viewq.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
<html>
<head>
<title>
Onine examination System
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<?php
session_start();
error_reporting(E_ERROR | E_PARSE);
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;
}
ul {
list-style: none;
width: auto !important;
}
.navbar {
background-color:#fff !important;
font-size: 1.5vw;
}
.navbar>ul>li:hover {
color: #042A38;
text-decoration: underline;
font-weight: bold;
}
.navbar>ul>li>a:hover {
color: #042A38;
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;
}
input{
margin: 1vw;
}
@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;
}
}
#btn{
height: 3vw;width: 10vw;font-family: 'Courier New', Courier, monospace;font-weight: bolder;border-radius: 10px;border: 2px solid black;background-color: lightblue;
}
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;
}
</style>
<body style="margin: 0 !important;font-weight: bolder !important;font-family: 'Courier New', Courier, monospace;color: #fff;height:auto;">
<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()">Quiz's</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'];
}
}
?>
<section style="margin-top: 4vw;width:80vw;margin-left:10vw;margin-right:10vw">
<?php
if(isset($_GET["qid"])){
$qid=$_GET["qid"];
$sql ="select * from questions where quizid='{$qid}'";
$res=mysqli_query($conn,$sql);
if($res)
{
$count=mysqli_num_rows($res);
if(mysqli_num_rows($res)==0)
{
echo "No questions found under this quiz please come later";
echo "<form method=\"POST\">";
echo "<input id=\"btn\" type=\"submit\" name=\"submit\" value=\"Add Questions\"><br><br><br>";
}else{
$i=1;
$j=0;
echo "<form method=\"POST\">";
echo "<input id=\"btn\" type=\"submit\" name=\"submit\" value=\"Add Questions\"><br><br><br>";
echo "</form><br><br>";
while ($row = mysqli_fetch_assoc($res)) {
echo $i.". ".$row["qs"]."<br>";
echo "<input type=\"radio\" value=\"".$j."\" name=\"ans".$i.$j."\">".$row["op1"]."<br>";
echo "<input type=\"radio\" value=\"".($j+1)."\" name=\"ans".$i.$j."\">".$row["op2"]."<br>";
echo "<input type=\"radio\" value=\"".($j+2)."\"name=\"ans".$i.$j."\">".$row["op3"]."<br>";
echo "<input type=\"radio\"value=\"".($j+3)."\" name=\"ans".$i.$j."\">".$row["answer"]."<br><br>";
$i++;
}
echo "</form><br><br>";
}
}
else
{
echo "error".mysqli_error($conn).".";
}
if(isset($_POST["submit"])){
echo "<script>window.location.replace(\"addq.php?qid=".$qid."\")</script>";
}
} ?>
</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 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>
</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>