forked from Puja0708/Online-Examination-Software
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresumetest.php
More file actions
195 lines (164 loc) · 8.58 KB
/
resumetest.php
File metadata and controls
195 lines (164 loc) · 8.58 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
/*
***************************************************
*** Online Examination System ***
*** Title: Resume Test ***
***************************************************
*/
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['dashboard'])) {
//redirect to dashboard
header('Location: studentwelcome.php');
}
else if(isset($_REQUEST['resume'])) {
//test code preparation
if($r=mysql_fetch_array($result=executeQuery("select testname from test where testid=".$_REQUEST['resume'].";"))) {
$_SESSION['testname']=htmlspecialchars_decode($r['testname'],ENT_QUOTES);
$_SESSION['testid']=$_REQUEST['resume'];
}
}
else if(isset($_REQUEST['resumetest'])) {
//Prepare the parameters needed for Test Conducter and redirect to test conducter
if(!empty($_REQUEST['tc'])) {
$result=executeQuery("select DECODE(testcode,'oespass') as tcode from test where testid=".$_SESSION['testid'].";");
if($r=mysql_fetch_array($result)) {
if(strcmp(htmlspecialchars_decode($r['tcode'],ENT_QUOTES),htmlspecialchars($_REQUEST['tc'],ENT_QUOTES))!=0) {
$display=true;
$_GLOBALS['message']="You have entered an Invalid Test Code.Try again.";
}
else {
//now prepare parameters for Test Conducter and redirect to it.
$result=executeQuery("select totalquestions,duration from test where testid=".$_SESSION['testid'].";");
$r=mysql_fetch_array($result);
$_SESSION['tqn']=htmlspecialchars_decode($r['totalquestions'],ENT_QUOTES);
$_SESSION['duration']=htmlspecialchars_decode($r['duration'],ENT_QUOTES);
$result=executeQuery("select DATE_FORMAT(starttime,'%Y-%m-%d %H:%i:%s') as startt,DATE_FORMAT(endtime,'%Y-%m-%d %H:%i:%s') as endt from studenttest where testid=".$_SESSION['testid']." and stdid=".$_SESSION['stdid'].";");
$r=mysql_fetch_array($result);
$_SESSION['starttime']=$r['startt'];
$_SESSION['endtime']=$r['endt'];
$_SESSION['qn']=1;
header('Location: testconducter.php');
}
}
else {
$display=true;
$_GLOBALS['message']="You have entered an Invalid Test Code.Try again.";
}
}
else {
$display=true;
$_GLOBALS['message']="Enter the Test Code First!";
}
}
?>
<html>
<head>
<title>OES-Resume Test</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="resumetest.php" method="post">
<div class="menubar">
<ul id="menu">
<?php if(isset($_SESSION['stdname'])) {
// Navigations
?>
<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>
</ul>
</div>
<div class="page">
<?php
if(isset($_REQUEST['resume'])) {
echo "<div class=\"pmsg\" style=\"text-align:center;\">What is the Code of ".$_SESSION['testname']." ? </div>";
}
else {
echo "<div class=\"pmsg\" style=\"text-align:center;\">Tests to be Resumed</div>";
}
?>
<?php
if(isset($_REQUEST['resume'])|| $display==true) {
?>
<table cellpadding="30" cellspacing="10">
<tr>
<td>Enter Test Code</td>
<td><input type="text" tabindex="1" name="tc" value="" size="16" /></td>
<td><div class="help"><b>Note:</b><br/>Quickly enter Test Code and<br/> press Resume button to utilize<br/> Remaining time.</div></td>
</tr>
<tr>
<td colspan="3">
<input type="submit" tabindex="3" value="Resume Test" name="resumetest" class="subbtn" />
</td>
</tr>
</table>
<?php
}
else {
$result=executeQuery("select t.testid,t.testname,DATE_FORMAT(st.starttime,'%d %M %Y %H:%i:%s') as startt,sub.subname as sname,TIMEDIFF(st.endtime,CURRENT_TIMESTAMP) as remainingtime from subject as sub,studenttest as st,test as t where sub.subid=t.subid and t.testid=st.testid and st.stdid=".$_SESSION['stdid']." and st.status='inprogress' order by st.starttime desc;");
if(mysql_num_rows($result)==0) {
echo"<h3 style=\"color:#0000cc;text-align:center;\">There are no incomplete exams, that needs to be resumed! Please Try Again..!</h3>";
}
else {
//editing components
?>
<table cellpadding="30" cellspacing="10" class="datatable">
<tr>
<th>Date and Time</th>
<th>Test</th>
<th>Subject</th>
<th>Remaining Time</th>
<th>Resume</th>
</tr>
<?php
while($r=mysql_fetch_array($result)) {
$i=$i+1;
if($r['remainingtime']<0) {
//IF Suppose MySQL Event fails for some reasons to change status this condtion becomes true.
// executeQuery("update studenttest set status='over' where stdid=".$_SESSION['stdid']." and testid=".$r['testid'].";");
// continue ;
}
if($i%2==0) {
echo "<tr class=\"alt\">";
}
else { echo "<tr>";}
echo "<td>".$r['startt']."</td><td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)."</td><td>".htmlspecialchars_decode($r['sname'],ENT_QUOTES)."</td><td>".$r['remainingtime']."</td>";
echo"<td class=\"tddata\"><a title=\"Resume\" href=\"resumetest.php?resume=".$r['testid']."\"><img src=\"images/resume.png\" height=\"30\" width=\"60\" alt=\"Resume\" /></a></td></tr>";
}
?>
</table>
<?php
}
}
closedb();
}
?>
</div>
</form>
</div>
</body>
</html>