-
Notifications
You must be signed in to change notification settings - Fork 2
/
addqs.php
336 lines (294 loc) · 10.2 KB
/
addqs.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
<html>
<?php require ("header.php");?>
<?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 {
$staffid = $_SESSION["staffid"];
$sql = "select * from staff where staffid='{$staffid}'";
$res = mysqli_query($conn, $sql);
if ($res == true) {
global $dbstaffid, $dbpw;
while ($row = mysqli_fetch_array($res)) {
$dbstaffid = $row['staffid'];
$dbname = $row['name'];
$dbmail = $row['mail'];
$dbphno = $row['phno'];
$dbgender = $row['gender'];
$dbdob = $row['DOB'];
$dbdept = $row['dept'];
}
}
$qname = $_SESSION['qname'];
$sql = "select quizid from quiz where quizname='{$qname}'";
$res = mysqli_query($conn, $sql);
if ($res == true) {
global $qid;
while ($row = mysqli_fetch_array($res)) {
$qid = $row['quizid'];
}
}
if (isset($_POST['submit'])) {
$qs = $_POST["qs"];
$op1 = $_POST["op1"];
$op2 = $_POST["op2"];
$op3 = $_POST["op3"];
$ans = $_POST["ans"];
$sql = "insert into questions(qs,op1,op2,op3,answer,quizid) values('$qs','$op1','$op2','$op3','$ans','$qid');";
$res = mysqli_query($conn, $sql);
if ($res == true) {
echo '<script>history.pushState({}, "", "");</script>';
} elseif ($res != true) {
echo '<script>alert("Question already exsits");</script>';
}
}
if (isset($_POST['submit1'])) {
$qs = $_POST["qs"];
$op1 = $_POST["op1"];
$op2 = $_POST["op2"];
$op3 = $_POST["op3"];
$ans = $_POST["ans"];
$sql = "insert into questions(qs,op1,op2,op3,answer,quizid) values('$qs','$op1','$op2','$op3','$ans','$qid');";
$res = mysqli_query($conn, $sql);
if ($res == true) {
header("Location: homestaff.php");
} elseif ($res != true) {
echo '<script>alert("Question already exsits");</script>';
}
}
}
?>
<body class="bg-white" id="top">
<!-- Navbar -->
<nav
id="navbar-main"
class="
navbar navbar-main navbar-expand-lg
bg-default
navbar-light
position-sticky
top-0
shadow
py-0
"
>
<div class="container">
<ul class="navbar-nav navbar-nav-hover align-items-lg-center">
<li class="nav-item dropdown">
<a href="index.php" class="navbar-brand mr-lg-5 text-white">
<img src="assets/img/navbar.png" />
</a>
</li>
</ul>
<button
class="navbar-toggler bg-white"
type="button"
data-toggle="collapse"
data-target="#navbar_global"
aria-controls="navbar_global"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon text-white"></span>
</button>
<div class="navbar-collapse collapse bg-default" id="navbar_global">
<div class="navbar-collapse-header">
<div class="row">
<div class="col-10 collapse-brand">
<a href="index.html">
<img src="assets/img/navbar.png" />
</a>
</div>
<div class="col-2 collapse-close bg-danger">
<button
type="button"
class="navbar-toggler"
data-toggle="collapse"
data-target="#navbar_global"
aria-controls="navbar_global"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span></span>
<span></span>
</button>
</div>
</div>
</div>
<ul class="navbar-nav align-items-lg-center ml-auto">
<li class="nav-item">
<a href="homestaff.php" class="nav-link">
<span class="text-success nav-link-inner--text font-weight-bold"
><i class="text-success fad fa-home"></i> DashBoard</span
>
</a>
</li>
<li class="nav-item">
<a href="quizlist.php" class="nav-link">
<span class="text-white nav-link-inner--text font-weight-bold"
><i class="text-white fad fa-poll"></i> QuizList</span
>
</a>
</li>
<li class="nav-item">
<a href="staffleaderboard.php" class="nav-link">
<span class="text-white nav-link-inner--text font-weight-bold"
><i class="text-white fad fa-award"></i> LeaderBoard</span
>
</a>
</li>
<li class="nav-item">
<a href="staffprofile.php" class="nav-link">
<span class="text-white nav-link-inner--text font-weight-bold"
><i class="text-white fas fa-user-circle"></i> <?php echo $dbname ?></span
>
</a>
</li>
<li class="nav-item">
<a href="logout.php" class="nav-link">
<span class="text-white nav-link-inner--text font-weight-bold"
><i class="text-danger fas fa-power-off"></i> Logout</span
>
</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<section class="section section-shaped section-lg">
<div class="shape shape-style-1 shape-primary">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 mb-3">
<div class="card card-body bg-gradient-default text-white mt-3">
<div class="col-12 mx-auto text-center">
<span class="badge badge-warning badge-pill mb-3">Add questions</span>
</div>
<section id="ans">
<form method="post">
<div id="QS">
<div class="form-group row">
<label for="qs" class="col-md-2 col-form-label"
><h6 class="text-white font-weight-bold">Question</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="quizid"
name="qs"
placeholder="Enter Question"
required"
/>
</div>
</div>
<div class="form-group row">
<label for="op1" class="col-md-2 col-form-label"
><h6 class="text-white font-weight-bold">Option 1</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="quizid"
name="op1"
placeholder="Option 1"
required"
/>
</div>
</div>
<div class="form-group row">
<label for="op2" class="col-md-2 col-form-label"
><h6 class="text-white font-weight-bold">Option 2</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="quizid"
name="op2"
placeholder="Option 2"
required"
/>
</div>
</div>
<div class="form-group row">
<label for="op3" class="col-md-2 col-form-label"
><h6 class="text-white font-weight-bold">Option 3</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="quizid"
name="op3"
placeholder="Option 3"
required"
/>
</div>
</div>
<div class="form-group row">
<label for="ans" class="col-md-2 col-form-label"
><h6 class="text-white font-weight-bold">Option 4</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="quizid"
name="ans"
placeholder="Option 4"
required"
/>
</div>
</div>
</div>
<div class="form-group row">
<div class="offset-md-2 col-md-2">
<button
type="submit"
class="btn btn-info text-dark"
name="submit" id="submit" value="Add 1 More Question"
>
Add 1 More Question
</button>
</div>
<div class="offset-md-7 col-md-">
<button
type="submit"
class="btn btn-success text-white"
name="submit1" id="submit1" value="Done"
>
Submit
</button>
</div>
</div>
</form>
</section>
</div>
</div>
</div>
</div>
</section>
<?php require("footer.php");?>
</body>
</html>