-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathviewresult.php
More file actions
279 lines (247 loc) · 14.8 KB
/
viewresult.php
File metadata and controls
279 lines (247 loc) · 14.8 KB
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
<?php
/*
***************************************************
*** Online Examination System ***
*** Title: View Results ***
***************************************************
*/
error_reporting(0);
session_start();
include_once 'oesdb.php';
if(!isset($_SESSION['stdname'])) {
$_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Re-LogIn</a>";
}
else if(isset($_REQUEST['logout'])) {
//Log out and redirect login page
unset($_SESSION['stdname']);
header('Location: index.php');
}
else if(isset($_REQUEST['back'])) {
//redirect to View Result
header('Location: viewresult.php');
}
else if(isset($_REQUEST['dashboard'])) {
//redirect to dashboard
header('Location: studentwelcome.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>OES-View Result</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/>
<meta http-equiv="PRAGMA" content="NO-CACHE"/>
<meta name="ROBOTS" content="NONE"/>
<link rel="stylesheet" type="text/css" href="oes.css"/>
<script type="text/javascript" src="validate.js" ></script>
</head>
<body >
<?php
if($_GLOBALS['message']) {
echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
}
?>
<div id="container">
<div class="header"><h3 class="headtext"> Online Examination System </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;">
</div>
<form id="summary" action="viewresult.php" method="post">
<div class="menubar">
<ul id="menu">
<?php if(isset($_SESSION['stdname'])) {
// Navigations
if(isset($_REQUEST['details'])) {
?>
<li><input type="submit" value="LogOut" name="logout" class="subbtn" title="Log Out"/></li>
<li><input type="submit" value="Back" name="back" class="subbtn" title="View Results"/></li>
<?php
}
else
{
?>
<li><input type="submit" value="LogOut" name="logout" class="subbtn" title="Log Out"/></li>
<li><input type="submit" value="DashBoard" name="dashboard" class="subbtn" title="Dash Board"/></li>
<?php
}
?>
</ul>
</div>
<div class="page">
<?php
if(isset($_REQUEST['details'])) {
$result=executeQuery("select s.stdname,t.testname,sub.subname,DATE_FORMAT(st.starttime,'%d %M %Y %H:%i:%s') as stime,TIMEDIFF(st.endtime,st.starttime) as dur,(select sum(marks) from question where testid=".$_REQUEST['details'].") as tm,IFNULL((select sum(q.marks) from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=".$_SESSION['stdid']." and sq.testid=".$_REQUEST['details']."),0) as om from student as s,test as t, subject as sub,studenttest as st where s.stdid=st.stdid and st.testid=t.testid and t.subid=sub.subid and st.stdid=".$_SESSION['stdid']." and st.testid=".$_REQUEST['details'].";") ;
if(mysql_num_rows($result)!=0) {
$r=mysql_fetch_array($result);
?>
<table cellpadding="20" cellspacing="30" border="0" style="background:#ffffff url(images/page.gif);text-align:left;line-height:20px;">
<tr>
<td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Summary</h3></td>
</tr>
<tr>
<td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td>
</tr>
<tr>
<td>Student Name</td>
<td><?php echo htmlspecialchars_decode($r['stdname'],ENT_QUOTES); ?></td>
</tr>
<tr>
<td>Test</td>
<td><?php echo htmlspecialchars_decode($r['testname'],ENT_QUOTES); ?></td>
</tr>
<tr>
<td>Subject</td>
<td><?php echo htmlspecialchars_decode($r['subname'],ENT_QUOTES); ?></td>
</tr>
<tr>
<td>Date and Time</td>
<td><?php echo $r['stime']; ?></td>
</tr>
<tr>
<td>Test Duration</td>
<td><?php echo $r['dur']; ?></td>
</tr>
<tr>
<td>Max. Marks</td>
<td><?php echo $r['tm']; ?></td>
</tr>
<tr>
<td>Obtained Marks</td>
<td><?php echo $r['om']; ?></td>
</tr>
<tr>
<td>Percentage</td>
<td><?php echo (($r['om']/$r['tm'])*100)." %"; ?></td>
</tr>
<tr>
<td colspan="2" ><hr style="color:#ff0000;border-width:2px;"/></td>
</tr>
<tr>
<td colspan="2"><h3 style="color:#0000cc;text-align:center;">Test Information in Detail</h3></td>
</tr>
<tr>
<td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td>
</tr>
</table>
<?php
$result1=executeQuery("select q.qnid as questionid,q.question as quest,q.correctanswer as ca,sq.answered as status,sq.stdanswer as sa from studentquestion as sq,question as q where q.qnid=sq.qnid and sq.testid=q.testid and sq.testid=".$_REQUEST['details']." and sq.stdid=".$_SESSION['stdid']." order by q.qnid;" );
if(mysql_num_rows($result1)==0) {
echo"<h3 style=\"color:#0000cc;text-align:center;\">1.Sorry because of some problems Individual questions Cannot be displayed.</h3>";
}
else {
?>
<table cellpadding="30" cellspacing="10" class="datatable">
<tr>
<th>Q. No</th>
<th>Question</th>
<th>Correct Answer</th>
<th>Your Answer</th>
<th>Score</th>
<th> </th>
</tr>
<?php
while($r1=mysql_fetch_array($result1)) {
if(is_null($r1['sa']))
$r1['sa']="question"; //any valid field of question
$result2=executeQuery("select ".$r1['ca']." as corans,IF('".$r1['status']."'='answered',(select ".$r1['sa']." from question where qnid=".$r1['questionid']." and testid=".$_REQUEST['details']."),'unanswered') as stdans, IF('".$r1['status']."'='answered',IFNULL((select q.marks from question as q, studentquestion as sq where q.qnid=sq.qnid and q.testid=sq.testid and q.correctanswer=sq.stdanswer and sq.stdid=".$_SESSION['stdid']." and q.qnid=".$r1['questionid']." and q.testid=".$_REQUEST['details']."),0),0) as stdmarks from question where qnid=".$r1['questionid']." and testid=".$_REQUEST['details'].";");
if($r2=mysql_fetch_array($result2)) {
?>
<tr>
<td><?php echo $r1['questionid']; ?></td>
<td><?php echo htmlspecialchars_decode($r1['quest'],ENT_QUOTES); ?></td>
<td><?php echo htmlspecialchars_decode($r2['corans'],ENT_QUOTES); ?></td>
<td><?php echo htmlspecialchars_decode($r2['stdans'],ENT_QUOTES); ?></td>
<td><?php echo $r2['stdmarks']; ?></td>
<?php
if($r2['stdmarks']==0) {
echo"<td class=\"tddata\"><img src=\"images/wrong.png\" title=\"Wrong Answer\" height=\"30\" width=\"40\" alt=\"Wrong Answer\" /></td>";
}
else {
echo"<td class=\"tddata\"><img src=\"images/correct.png\" title=\"Correct Answer\" height=\"30\" width=\"40\" alt=\"Correct Answer\" /></td>";
}
?>
</tr>
<?php
}
else {
echo"<h3 style=\"color:#0000cc;text-align:center;\">Sorry because of some problems Individual questions Cannot be displayed.</h3>".mysql_error();
}
}
}
}
else {
echo"<h3 style=\"color:#0000cc;text-align:center;\">Something went wrong. Please logout and Try again.</h3>".mysql_error();
}
?>
</table>
<?php
}
else {
$result=executeQuery("select st.*,t.testname,t.testdesc,DATE_FORMAT(st.starttime,'%d %M %Y %H:%i:%s') as startt from studenttest as st,test as t where t.testid=st.testid and st.stdid=".$_SESSION['stdid']." and st.status='over' order by st.testid;");
if(mysql_num_rows($result)==0) {
echo"<h3 style=\"color:#0000cc;text-align:center;\">I Think You Haven't Attempted Any Exams Yet..! Please Try Again After Your Attempt.</h3>";
}
else {
//editing components
?>
<table cellpadding="30" cellspacing="10" class="datatable">
<tr>
<th>Date and Time</th>
<th>Test Name</th>
<th>Max. Marks</th>
<th>Obtained Marks</th>
<th>Percentage</th>
<th>Details</th>
</tr>
<?php
while($r=mysql_fetch_array($result)) {
$i=$i+1;
$om=0;
$tm=0;
$result1=executeQuery("select sum(q.marks) as om from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=".$_SESSION['stdid']." and sq.testid=".$r['testid']." order by sq.testid;");
$r1=mysql_fetch_array($result1);
$result2=executeQuery("select sum(marks) as tm from question where testid=".$r['testid'].";");
$r2=mysql_fetch_array($result2);
if($i%2==0) {
echo "<tr class=\"alt\">";
}
else { echo "<tr>";}
echo "<td>".$r['startt']."</td><td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)." : ".htmlspecialchars_decode($r['testdesc'],ENT_QUOTES)."</td>";
if(is_null($r2['tm'])) {
$tm=0;
echo "<td>$tm</td>";
}
else {
$tm=$r2['tm'];
echo "<td>$tm</td>";
}
if(is_null($r1['om'])) {
$om=0;
echo "<td>$om</td>";
}
else {
$om=$r1['om'];
echo "<td>$om</td>";
}
if($tm==0) {
echo "<td>0</td>";
}
else {
echo "<td>".(($om/$tm)*100)." %</td>";
}
echo"<td class=\"tddata\"><a title=\"Details\" href=\"viewresult.php?details=".$r['testid']."\"><img src=\"images/detail.png\" height=\"30\" width=\"40\" alt=\"Details\" /></a></td></tr>";
}
?>
</table>
<?php
}
}
closedb();
}
?>
</div>
</form>
</div>
</body>
</html>
ss