-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewquestions.php
265 lines (259 loc) · 6.23 KB
/
viewquestions.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
include("header.php");
if(isset($_GET[quedelid]))
{
$sql= "DELETE FROM questions WHERE queid=$_GET[quedelid]";
$qsql = mysqli_query($con,$sql);
if(mysqli_affected_rows($con) == 1)
{
echo "<script>alert(Question record deleted successfully..);</script>";
echo "<script>window.location=viewquestions.php?select=$_GET[select]&subjectid=$_GET[subjectid]&submit=$_GET[submit];</script>";
}
}
?>
<div class="slider_top2">
<h2>View questions</h2>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div class="full">
<p>
<script>
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajaxsubject.php?q="+str,true);
xmlhttp.send();
}
</script>
<form method="get" action="">
<?php
if($_SESSION[usertype] == "Administrator")
{
?>
<table width="541" border="1">
<tr>
<th scope="col"><select name="select" size="1" onchange="showUser(this.value)">
<option value="">Select</option>
<?php
$sql = "SELECT * FROM course where status=Enabled";
$qresult = mysqli_query($con,$sql);
while($rs = mysqli_fetch_array($qresult))
{
if($rs[courseid] == $_GET[select])
{
echo "<option value=$rs[courseid] selected>$rs[coursename]</option>";
}
else
{
echo "<option value=$rs[courseid]>$rs[coursename]</option>";
}
}
?>
</select></th>
<th scope="col"><div id="txtHint">
<select size=1 name="subjectid" >
<option value="">Select</option>
<?php
if(isset($_SESSION[courseid]))
{
$sql = "SELECT * FROM subjects where status=Enabled and courseid=$_SESSION[courseid]";
}
else
{
$sql = "SELECT * FROM subjects where status=Enabled";
}
$qresult = mysqli_query($con,$sql);
while($rs = mysqli_fetch_array($qresult))
{
if($rs[subjectcode] == $_GET[subjectid])
{
echo "<option value=$rs[subjectcode] selected>$rs[subjectname]</option>";
}
else
{
echo "<option value=$rs[subjectcode]>$rs[subjectname]</option>";
}
}
?>
</select>
</div></th>
<th scope="col"> <input type="submit" name="submit" id="submit" value="Submit" /> </th>
</tr>
</table>
</p>
<?php
}
?>
<?php
if($_SESSION[usertype] == "Examiner")
{
?>
<table width="541" border="1" class=tftable >
<tr>
<th scope="col"><div id="txtHint">
<select size=1 name="subjectid" >
<option value="">Select subject</option>
<?php
$sql = "SELECT * FROM subjects where status=Enabled and courseid=$_SESSION[courseid]";
$qresult = mysqli_query($con,$sql);
while($rs = mysqli_fetch_array($qresult))
{
if($rs[subjectcode] == $_GET[subjectid])
{
echo "<option value=$rs[subjectcode] selected>$rs[subjectname]</option>";
}
else
{
echo "<option value=$rs[subjectcode]>$rs[subjectname]</option>";
}
}
?>
</select>
</div></th>
<th scope="col"> <input type="submit" name="submit" id="submit" value="Submit" /> </th>
</tr>
</table>
</form>
</p>
<?php
}
?>
<?php
if(isset($_GET[submit]))
{
?>
<p>
<?php
$selquestions = "SELECT questions.*, subjects.*, course.* FROM course INNER JOIN subjects ON course.courseid = subjects.courseid RIGHT OUTER JOIN questions ON subjects.subjectcode = questions.subjectcode where questions.subjectcode=$_GET[subjectid]";
$selresult = mysqli_query($con,$selquestions);
echo "<h3>No of questions: ".mysqli_num_rows($selresult). "</h3>";
while($rs = mysqli_fetch_array($selresult))
{
echo "<table class=tftable width=595 border=1>
<tr>
<td width=28><strong>Course name: </strong></td>
<td width=291><strong> $rs[20]</strong></td>
</tr>
<tr>
<td width=28><strong>Subject</strong></td>
<td width=291><strong>$rs[13]</strong></td>
</tr>
<tr>
<td><strong>Question</strong></td>
<td> $rs[question]</td>
</tr>
<tr>
<td><strong>Image</strong></td>
<td> ";
if($rs[uploads] != "")
{
echo "<img src=uploads/$rs[uploads] width=100 height=100>";
}
echo "</td>
</tr>
<tr>
<td><strong>Option A:</strong> </td>
<td>$rs[option1]$rs[option2]</td>
</tr>
<tr>
<td><strong>Option B:</strong></td>
<td>$rs[option2]</td>
</tr>
<tr>
<td><strong>Option C:</strong></td>
<td>$rs[option3]</td>
</tr>
<tr>
<td><strong>Option D:</strong></td>
<td>$rs[option4]</td>
</tr>
<tr>
<td><strong>Correct answer : </strong> </td>
<td>";
if($rs[answer]==1)
{
echo $rs[option1];
}
else if($rs[answer]==2)
{
echo $rs[option2];
}
if($rs[answer]==3)
{
echo $rs[option3];
}
if($rs[answer]==4)
{
echo $rs[option4];
}
echo " </td>
</tr>
<tr>
<td><strong>Description:</strong><br /></td><td>";
echo $rs[9];
echo " </td>
</tr>
<tr>
<td><strong>Status</strong></td>
<td>$rs[status]</td>
</tr>
<tr>
<td colspan=2>
<center><a href=questions.php?queid=$rs[queid]>Edit</a> |
<a href=viewquestions.php?quedelid=$rs[queid]&select=$_GET[select]&subjectid=$_GET[subjectid]&submit=$_GET[submit] onclick=return confirm2delete()>Delete</a></center>
</td>
</tr>
</table>
<hr>";
}
?>
</p>
<?php
}
?>
</div>
<div class="right">
<?php
include("usersidebar.php");
?>
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>
<script>
function confirm2delete()
{
if(confirm("Are you sure want to delete this record?") == true)
{
return true;
}
else
{
return false;
}
}
</script>