-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewanswers.php
243 lines (228 loc) · 6.28 KB
/
viewanswers.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
<?php
include("header.php");
$sqlstudentprofile = "SELECT * FROM students where regno=$_SESSION[regno]";
$querystudentprofile = mysqli_query($con,$sqlstudentprofile);
$rsstudentprofile = mysqli_fetch_array($querystudentprofile);
$sqlcourse = "SELECT * FROM course where courseid=$rsstudentprofile[courseid]";
$qcourse = mysqli_query($con,$sqlcourse);
$rscourse = mysqli_fetch_array($qcourse);
$sqlsubjects = "SELECT * FROM subjects where courseid=$rscourse[courseid]";
$qsubjects = mysqli_query($con,$sqlsubjects);
$rssubjects = mysqli_fetch_array($qsubjects);
$sqlsubject = "SELECT * FROM exam INNER JOIN subjects ON subjects.subjectcode=exam.subjectcode where exam.examid=$_GET[examid]";
$qsubject = mysqli_query($con,$sqlsubject);
$rssubject = mysqli_fetch_array($qsubject);
$sqlexamresult = "SELECT * FROM results where examid=$_GET[examid]";
$qexamresult = mysqli_query($con,$sqlexamresult);
$rsexamresult = mysqli_fetch_array($qexamresult);
//unanswered questions
$sqlunanswered = "SELECT * FROM results where examid=$_GET[examid] AND answerid=0";
$qunanswered = mysqli_query($con,$sqlunanswered);
$rsunanswered = mysqli_fetch_array($qunanswered);
//answered questions
$sqlanswered = "SELECT * FROM results where examid=$_GET[examid] AND answerid<>0";
$qanswered = mysqli_query($con,$sqlanswered);
$rsanswered = mysqli_fetch_array($qanswered);
//Correct answers
$sqlexamresult = "SELECT * FROM results INNER JOIN questions ON questions.queid = results.queid where examid=$_GET[examid]";
$qexamresult = mysqli_query($con,$sqlexamresult);
while($rsexamresult = mysqli_fetch_array($qexamresult))
{
if($rsexamresult[answerid] == $rsexamresult[answer])
{
$canswer = $canswer + 1;
}
else
{
$wanswer = $wanswer + 1;
}
}
?>
<div class="slider_top2">
<h2>Examination result</h2>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div class="full">
<p>
<form method=post action="">
<input type="hidden" name="setid" value="<?php echo $_SESSION[setid]; ?>" />
<table width="610" border="1" class="tftable">
<tr>
<th colspan="2" scope="col"><center>Candidate details</center></th>
</tr>
<tr>
<th scope="col">Roll No</th>
<td scope="col"> <?php echo $rsstudentprofile[regno]; ?></td>
</tr>
<tr>
<th width="183" scope="col">Student Name</th>
<td width="249" scope="col"> <?php echo $rsstudentprofile[name]; ?></td>
</tr>
<tr>
<th colspan="2" scope="row"><center>Result details</center></th>
</tr>
<tr>
<th scope="row">Total questions</th>
<td>
<?php
$sqlexamresult = "SELECT * FROM results where examid=$_GET[examid]";
$qexamresult = mysqli_query($con,$sqlexamresult);
$rsexamresult = mysqli_fetch_array($qexamresult);
echo $totalquestions = mysqli_num_rows($qexamresult);
?></td>
</tr>
<tr>
<th scope="row">Maximum Marks</th>
<td>
<?php echo $totalmarks = $rssubject[totalmarks]; ?>
</td>
</tr>
<tr>
<th scope="row">Pass marks</th>
<td> <?php echo $passmarks = $rssubject[passmarks]; ?> %</td>
</tr>
<tr>
<th colspan="2" scope="row">
<?php
$sqlexamresult = "SELECT * FROM results where examid=$_GET[examid]";
$qexamresult = mysqli_query($con,$sqlexamresult);
$qno=1;
while($rsexamresult = mysqli_fetch_array($qexamresult))
{
$sqlexamresult1 = "SELECT * FROM questions where queid=$rsexamresult[queid]";
$qexamresult1 = mysqli_query($con,$sqlexamresult1);
$rsexamresult1 = mysqli_fetch_array($qexamresult1);
?>
<table border="1" width="75%">
<tr>
<th width="32%" scope="col"> Question No. </th>
<th width="68%" scope="col"> <?php echo $qno; ?></th>
</tr>
<tr>
<th scope="col"> Question. </th>
<th scope="col"> <?php echo $rsexamresult1[question]; ?></th>
</tr>
<tr>
<th scope="row"> Option 1</th>
<td> <?php echo $rsexamresult1[option1]; ?></td>
</tr>
<tr>
<th scope="row"> Option 2</th>
<td> <?php echo $rsexamresult1[option2]; ?></td>
</tr>
<tr>
<th scope="row"> Option 3</th>
<td> <?php echo $rsexamresult1[option3]; ?></td>
</tr>
<tr>
<th scope="row"> Option 4</th>
<td> <?php echo $rsexamresult1[option4]; ?></td>
</tr>
<tr>
<th scope="row"> Correct answer</th>
<td>
<?php
echo "Option ". $rsexamresult1[answer];
?></td>
</tr>
<tr>
<th scope="row"> Your answer</th>
<td> <?php
echo "Option ". $rsexamresult[answerid];
?></td>
</tr>
</table>
<hr />
<?php
$qno++;
}
?>
</th>
</tr>
<tr>
<th colspan="2" scope="row" align="center"><center>Exam result</center></th>
</tr>
<tr>
<th scope="row">Answered questions</th>
<td> <?php echo mysqli_num_rows($qanswered); ?></td>
</tr>
<tr>
<th scope="row">Unanswered questions</th>
<td> <?php echo mysqli_num_rows($qunanswered); ?></td>
</tr>
<tr>
<th scope="row">Correct answers</th>
<td> <?php echo $canswer; ?></td>
</tr>
<tr>
<th scope="row">Incorrect answers</th>
<td> <?php echo $wanswer; ?></td>
</tr>
<tr>
<th scope="row">Marks obtained (In percentage %)</th>
<td> <?php
$totpercentagemarks = 0;
if($canswer > 0 )
{
$totpercentagemarks = number_format((($canswer*100) /$totalquestions), 2);
}
echo $totpercentagemarks;
?> %
</td>
</tr>
<tr>
<th scope="row">Exam result</th>
<td> <?php
if($totpercentagemarks < $passmarks)
{
echo "Fail";
}
else if($totpercentagemarks > 70)
{
echo "Distinction";
}
else if($totpercentagemarks > 60)
{
echo "First class";
}
else if($totpercentagemarks > 45)
{
echo "Second Class";
}
else if($totpercentagemarks > 35)
{
echo "Pass Class";
}
?></td>
</tr>
<tr>
<th scope="row"> </th>
<td><label for="answer"></label></td>
</tr>
</table>
</form>
<br />
<table border="2" width=612 align="center">
<tr>
<td align="center">
<button onclick="myFunction()">Print this page</button>
<script>
function myFunction()
{
window.print();
}
</script>
</td>
</tr>
</table>
</p>
</div>
<div class="clr"></div>
</div>
</div>
<?php
unset($_GET[examid]);
include("footer.php");
?>