-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamstop.php
105 lines (95 loc) · 2.62 KB
/
examstop.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
<?php
include("header.php");
//The exam ID should come from session
$sqlqexam ="SELECT * FROM exam where examid=$_SESSION[examid]";
$quexam = mysqli_query($con,$sqlqexam);
$tqexam= mysqli_fetch_array($quexam);
$sqlqcertificate ="SELECT * FROM certificate where examid=$_SESSION[examid] AND regno=$tqexam[regno]";
$qcertificate = mysqli_query($con,$sqlqcertificate);
if(mysqli_num_rows($qcertificate) == 0)
{
$sqlinscertificate = "INSERT INTO certificate(examid,regno,scoredmarks,result,datetime,status) VALUES($_SESSION[examid],$tqexam[regno],0,0,$tqexam[datetime],Active)";
$qsqlcerificateins = mysqli_query($con,$sqlinscertificate);
}
?>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div class="left">
<p align="center">
<?php
$timestamp = time();
$diff = 1122;
//<-Time of countdown in seconds. ie. 3600 = 1 hr. or 86400 = 1 day.
//MODIFICATION BELOW THIS LINE IS NOT REQUIRED.
$hld_diff = $diff;
if(isset($_SESSION[ts])) {
$slice = ($timestamp - $_SESSION[ts]);
$diff = $diff - $slice;
}
if(!isset($_SESSION[ts]) || $diff > $hld_diff || $diff < 0) {
$diff = $hld_diff;
$_SESSION[ts] = $timestamp;
}
//Below is demonstration of output. Seconds could be passed to Javascript.
$diff; //$diff holds seconds less than 3600 (1 hour);
$hours = floor($diff / 3600) . : ;
$diff = $diff % 3600;
$minutes = floor($diff / 60) . : ;
$diff = $diff % 60;
$seconds = $diff;
?>
<div id="strclock">Clock Here!</div>
<script type="text/javascript">
var hour = <?php echo floor($hours); ?>;
var min = <?php echo floor($minutes); ?>;
var sec = <?php echo floor($seconds); ?>;
var timer = <?php echo floor($timer); ?>;
function countdown()
{
timer = "start";
if(sec <= 0 && min > 0)
{
sec = 59;
min -= 1;
}
else if(min <= 0 && sec <= 0)
{
min = 0;
sec = 0;
}
else
{
sec -= 1;
}
if(min <= 0 && hour > 0)
{
min = 59;
hour -= 1;
}
var pat = /^[0-9]{1}$/;
sec = (pat.test(sec) == true) ? 0+sec : sec;
min = (pat.test(min) == true) ? 0+min : min;
hour = (pat.test(hour) == true) ? 0+hour : hour;
if(sec == 0)
{
self.location="result.php?examid=<?php echo $_SESSION[examid]; ?>";
}
else
{
document.getElementById(strclock).innerHTML = "<h1>Calculating Examination result </h1> <h2>Please wait "+sec+" seconds</h2>";
}
setTimeout("countdown()",1000);
}
countdown();
</script>
</p>
</div>
<div class="right">
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>