-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattendexam.php
139 lines (119 loc) · 4.46 KB
/
attendexam.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
<?php
include("header.php");
unset($_SESSION[examid]);
$selexam = "SELECT exam.*, subjects.*, course.* FROM course INNER JOIN subjects ON course.courseid = subjects.courseid RIGHT OUTER JOIN exam ON subjects.subjectcode = exam.subjectcode where exam.regno=$_SESSION[regno] ";
$selresult = mysqli_query($con,$selexam);
?>
<script>
function countdowntimer(id, time,enddate)
{
// Set the date were counting down to
var countDownDate = new Date(time).getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("countdowntime"+id).innerHTML = "<b style=color: red;>Exam starts in </b> <br><b>" + days + "Days " + hours + "hrs " + minutes + "min " + seconds + "sec</b>";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
countdowntimer2(id, time,enddate);
//document.getElementById("countdowntime"+id).innerHTML = "<center><b style=color: red;>EXPIRED</b></center>";
}
}, 1000);
}
function countdowntimer2(id, time,enddate)
{
// Set the date were counting down to
var countDownDate = new Date(enddate).getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("countdowntime"+id).innerHTML = "<b style=color: red;>Attend Exam in</b> <br><b>" + hours + "hrs " + minutes + "min " + seconds + "sec</b><hr> <a href=examstart.php?examid=" + id + "><b>Attend Exam</b></a>";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("countdowntime"+id).innerHTML = "<center><b style=color: red;>EXPIRED</b></center>";
}
}, 1000);
}
</script>
<div class="slider_top2">
<h2>Attend exam</h2>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div >
<p >
<?php
while($rs = mysqli_fetch_array($selresult))
{
?>
<table class="tftable" width=100% border=1>
<tr>
<th width="125" > Subject</th>
<th width="300" scope=col> Exam rules</th>
<th width="110" scope=col> Exam Detail</th>
<th width="80" scope=col> Exam <br>Datetime</th>
<th width="150" scope=col> Attend Exam</th>
</tr>
<?php
echo "
<tr>
<td style=font-size: 15px;>$rs[subjectname]</td>
<td style=font-size: 15px;>$rs[rules]</td>
<td style=font-size: 15px;>
<b>Total Marks -</b> $rs[totalmarks] <br>
<b>Pass Mark -</b> $rs[passmarks] <br>
<b>Exam duration -</b> $rs[examduration]min<br>
</td>
<td style=font-size: 15px;>" . date("d-M-Y",strtotime($rs[datetime])) . "<br>" . date("h:i A",strtotime($rs[datetime])) . "</td>
<td style=font-size: 15px;> ";
$sqlq = "SELECT * FROM results where examid=$rs[examid] ";
$qquery = mysqli_query($con,$sqlq);
if(mysqli_num_rows($qquery) >= 1)
{
echo "Exam finished";
}
else
{
$minut = round($rs[examduration]/4);
$enddate = date("Y-m-d H:i:s", strtotime("+$minut minutes",strtotime($rs[datetime])));
?>
<p id="countdowntime<?php echo $rs[0]; ?>"></p>
<script type="application/javascript">countdowntimer(<?php echo $rs[0]; ?>, <?php echo date("M d, Y H:i:s",strtotime($rs[datetime])); ?>, <?php echo $enddate; ?>);</script>
<?php
}
echo "</td>
</tr>";
?>
</table>
<br><hr><br>
<?php
}
?>
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>