-
Notifications
You must be signed in to change notification settings - Fork 0
/
exams.php
364 lines (320 loc) · 12.6 KB
/
exams.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
<?php
session_start();
require_once('includes/dbh.inc.php');
if(!isset($_SESSION['student']) && !isset($_COOKIE['student'])){
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Exams | IAS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/profile.css">
<link rel="stylesheet" type="text/css" href="css/profile_new.css">
<link rel="stylesheet" type="text/css" href="css/exams.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" type="image/jpg"
href="images/logo.jpg" />
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.php" class="pull-left hidden-xs"><img src="images/logo.jpg " height="35" width="45" style="margin:8px;"></a>
<a class="navbar-brand" href="index.php"><span class="brand"><span>I</span>NSTITUTE OF <span>A</span>PPLIED <span>S</span>CIENCE</span></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
<form class="navbar-form" action="includes/logout.inc.php" method="POST">
<button type="submit" name="logout"><span class="fa fa-sign-out"></span>Log Out</button>
</form>
</li>
</ul>
</div>
</div>
</nav>
<?php
if(isset($_SESSION['student'])){
$email = $_SESSION['student'];
$query = "select * from students INNER JOIN students_courses ON student_id=stu_id INNER JOIN courses ON courses.course_id=students_courses.course_id INNER JOIN centers ON centers.center_id=students_courses.center_id where stu_email='$email'";
}
elseif(isset($_COOKIE['student'])){
$email = $_COOKIE['student'];
$query = "select * from students INNER JOIN students_courses ON student_id=stu_id INNER JOIN courses ON courses.course_id=students_courses.course_id INNER JOIN centers ON centers.center_id=students_courses.center_id where stu_email='$email'";
}
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_array($result);
$query="select * from students_courses natural join courses natural join centers where student_id=".$row['stu_id'];
$course_res=mysqli_query($conn,$query);
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="cover_wrap">
<div class="cover">
</div>
<div class="data">
<div class="row">
<div class="col-sm-3 text-center">
<img class="img" <?php echo 'src="'.$row['stu_imageLocation'].'"'; ?> />
</div>
<div class="col-sm-3 text-center">
<p class="res"><?php echo $row['stu_name']; ?></p>
<p class="query">Full Name</p>
</div>
<div class="col-sm-3 text-center">
<p class="res"><?php echo $row['stu_roll']; ?></p>
<p class="query">Roll Number</p>
</div>
<div class="col-sm-3 text-center">
<p class="res"><?php echo $row['center_name']; ?></p>
<p class="query">Center</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row row2">
<div class="col-sm-3">
<div class="courses">
<p class="chead">My Courses</p>
<ul>
<?php
while($r=mysqli_fetch_array($course_res)){
echo '
<li><span class="cname">'.$r['course_name'].'</span><br>
<span class="reg">'.$r['registration_no'].' </span><br>
<span class="cen">'.$r['center_name'].' </span></li>
';
}
?>
</ul>
</div>
<div class="nav-menu shadow">
<ul>
<li class="link">
<a href="#">
<i class="fa fa-home" aria-hidden="true"></i>PROFILE HOME</span>
</a>
</li>
<li class="link">
<a href="account_settings.php">
<i class="fa fa-cogs" aria-hidden="true"></i>ACCOUNT SETTINGS</span>
</a>
</li>
<li class="link">
<a href="change_course.php">
<i class="fa fa-book" aria-hidden="true"></i>CHANGE COURSE / CENTER</span>
</a>
</li>
<li class="link ">
<a href="add_course.php">
<i class="fa fa-plus-square-o" aria-hidden="true"></i>APPLY FOR ANOTHER COURSE</span>
</a>
</li>
<li class="link">
<a href="pending_updates.php">
<i class="fa fa-spinner" aria-hidden="true"></i>VIEW PENDING UPDATES</span>
</a>
</li>
<li class="link">
<a href="downloads.php">
<i class="fa fa-download" aria-hidden="true"></i>DOWNLOADS</span>
</a>
</li>
<li class="link active" id="exam">
<a href="505.php" id="exam_link">
<i class="fa fa-pencil" aria-hidden="true"></i>EXAMS</span>
<?php
$sql = "select * from exams natural join exam_course where exam_status=1 and course_id in (select course_id from students_courses where student_id=".$row['stu_id'].");";
$resultset = mysqli_query($conn,$sql);
$i=0;
while($r = mysqli_fetch_array($resultset)){
$query = "select * from results where exam_id = '".$r['exam_id']."' and student_id = ".$row['stu_id'];
$res = mysqli_query($conn,$query);
$num_res = mysqli_num_rows($res);
if($num_res == 0){
$i++;
}
}
if($i!=0){
echo '<span class="notification">'.$i.'</span>';
}
?>
</a>
</li>
<li class="link" id="result">
<a href="results.php">
<i class="fa fa-list-alt" aria-hidden="true"></i>RESULTS</span>
<?php
$sql = "select * from results where student_id =".$row['stu_id']." and publish_status=1";;
$res = mysqli_query($conn,$sql);
$rescount = mysqli_num_rows($res);
if($rescount > 0)
echo '<span class="res_no">'.$rescount.'</span>';
?>
</a>
</li>
<li class="link logout">
<form action="includes/logout.inc.php" method="POST">
<button type="submit" name="logout"><span class="fa fa-sign-out"></span>LOG OUT</button>
</form>
</li>
</ul>
</div>
</div>
<div class="col-sm-9">
<div class="main">
<div class="exam_heading">Active Exams</div>
<div class="exam_content">
<table class="table table-bordered">
<thead>
<tr>
<th>Exam Id</th>
<th>Title</th>
<th>Course</th>
<th>Standard</th>
<th>Full Marks</th>
<th>Time (mins)</th>
<th>Will Close on</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$sql = "select * from exam_course natural join exams natural join courses where exam_status=1 and course_id in (select course_id from students_courses where student_id = ".$row['stu_id'].")";
$res = mysqli_query($conn, $sql);
$i=1;
while($r=mysqli_fetch_array($res)){
$sql = "select * from results where student_id = ".$row['stu_id']." and exam_id = '".$r['exam_id']."'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if($count >= 1){
continue;
}
$query = "select qp_fullmarks from papers where qpid = '".$r['paper_id']."'";
$rs = mysqli_query($conn, $query);
$full_marks=mysqli_fetch_array($rs);
$date = strtotime($r['exam_end']);
echo '
<tr>
<td>'.$r['exam_id'].'</td>
<td>'.$r['exam_title'].'</td>
<td>'.$r['course_name'].'</td>
<td>'.$r['exam_standard'].'</td>
<td>'.$full_marks['qp_fullmarks'].'</td>
<td>'.$r['exam_time'].'</td>
<td>'.date('d/m/Y h:i:sa', $date).'</td>
<td><button class="btn btn-success btn-xs begin_btn" id="bt'.$i.'">Begin</button></td>
</tr>
<div class="modal fade" id="exam_confirm'.$i.'" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<div class="modal-body">
<h1>Sure to begin?</h1>
<p>Once you click on start you won\'t be able to revert back.</p>
</div>
<div class="modal-foot">
<center><button type="button" class="btn btn-success btn-sm" onclick="window.open(\'exam.php?eid='.$r['exam_id'].'&sid='.$row['stu_id'].'&course='.$r['course_name'].'\', \'_blank\', \'toolbar=yes,scrollbars=yes,resizable=no,fullscreen=yes\')" data-dismiss="modal">START</button></center>
</div>
</div>
</div>
</div>
';
$i++;
}
?>
</tbody>
</table>
</div>
</div>
<div class="main" style="margin-top: 10px;">
<div class="exam_heading">Completed Exams</div>
<div class="exam_content">
<table class="table table-bordered">
<thead>
<tr>
<th>Exam Id</th>
<th>Title</th>
<th>Course</th>
<th>Standard</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$sql = "select * from exam_course natural join exams natural join courses where exam_status=1 and course_id in (select course_id from students_courses where student_id = ".$row['stu_id'].")";
$res = mysqli_query($conn, $sql);
$i=1;
while($r=mysqli_fetch_array($res)){
$sql = "select * from results where student_id = ".$row['stu_id']." and exam_id = '".$r['exam_id']."' and submission != 0";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if($count < 1){
continue;
}
$date = strtotime($r['exam_end']);
echo '
<tr>
<td>'.$r['exam_id'].'</td>
<td>'.$r['exam_title'].'</td>
<td>'.$r['course_name'].'</td>
<td>'.$r['exam_standard'].'</td>
<td><button class="btn btn-success btn-xs begin_btn" onclick="location.href=\'results.php\'">View Result</button></td>
</tr>
';
$i++;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!------CONFIRMATION MODAL----->
<footer>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="text-center">
Copyright © Institute of Applied Science 2017
</div>
</div>
</div>
</div>
</footer>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="js/bootstrap.js"></script>
<script>
window.onload = function () {
document.getElementById('button').onclick = function () {
document.getElementById('success-modal').style.display = "none"
window.location.replace('exams.php');
};
};
$(".begin_btn").click(function(e) {
var id = this.id.substring(2);
$('#exam_confirm'+id).modal('show');
});
/*<button type="button" class="btn btn-success btn-sm" onclick="window.open(\'exam.php?eid='.$r['exam_id'].'&sid='.$row['stu_id'].'&course='.$r['course_name'].'\', \'_blank\', \'toolbar=yes,scrollbars=yes,resizable=no,fullscreen=yes\')" data-dismiss="modal">START</button>
<button type="button" class="btn btn-success btn-sm" onclick="location.href=\'exam.php?eid='.$r['exam_id'].'&sid='.$row['stu_id'].'&course='.$r['course_name'].'\'" data-dismiss="modal">START</button>
*/
</script>
</body>
</html>