-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
174 lines (127 loc) · 5.43 KB
/
check.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
<?php require_once("backend/config.php"); ?>
<?php include("header.php"); ?>
<?php include ("left-sidebar.php");?>
<div class="wrapper">
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark"></h1>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3>Add question</h3>
</div>
<div class="card-body">
<?php
if (isset($_POST['send']))
{
if(!empty($_POST['option'])){
$count=count($_POST['option']);
echo "out of 5,You have selected".$count;
$result=0;
$wrong_result=0;
$i=0;
$selected=$_POST['option'];
//select course
$select_course=query("SELECT * FROM `course`");
$fetch_course=fetch_array($select_course);
$course_id=$fetch_course['id'];
// course select end
// exam start
$query_exam=query("SELECT * FROM `exam` WHERE action='SHOW' AND examStatus='Temporary' AND courseID='$course_id' AND StartingAction=1 ");
$row_exam=fetch_array($query_exam);
$exam_id=$row_exam['id'];
$exam_status=$row_exam['examStatus'];
$courseID=$row_exam['courseID'];
// exam end
$correctAnswers = 0;
$wrongAnswers = 0;
//question start
$q=query("select * from questions where examID='$exam_id' ");
while($row=fetch_array($q)){
$sl = $row['id'];
// $correct=$row['rightAns'];
// if ($correct == $_POST['option']['1']) {
// $correctAnswers +=1;
// }
// else {
// $wrongAnswers +=1;
// }
if($row['rightAns']==1){
$ck = $row['firstOptn'];
if($ck == $selected[$sl]){
$result++;
}
}
if($row['rightAns']==2){
$ck = $row['secondOptn'];
if($ck == $selected[$sl]){
$result++;
}
}
if($row['rightAns']==3){
$ck = $row['thirdOptn'];
if($ck == $selected[$sl]){
$result++;
}
}
if($row['rightAns']==4){
$ck = $row['fourthOptn'];
if($ck == $selected[$sl]){
$result++;
}
}
}
//for incorrect
echo "<br>".$result."<br>";
echo $wrong_result;
}
$_SESSION['email'] = $username;
$select_student=query("SELECT * FROM `students` where email='$username' ");
$fetch_student=fetch_array($select_student);
$std_row=$fetch_student['id'];
// course id start
$exam_id=escape_string($_POST['exam_id']);
$courseID=escape_string($_POST['courseID']);
// course id end
$query=query("INSERT INTO `result`(studentID,courseID,examID) VALUES ('$std_row','$courseID','$exam_id') ");
}
?>
</div>
</div>
</div>
</div>
<!-- /.row -->
<!-- Main row -->
<div class="row">
<?php
$numberOfQs = $correctAnswers + $wrongAnswers;
$score = round(($correctAnswers / $numberOfQs) * 100);
?>
Correct Answers: <?php echo $correctAnswers; ?> <br>
Wrong Answers: <?php echo $wrongAnswers; ?> <br>
Score: <?php echo $score;
?>
</div>
<!-- /.row (main row) -->
</div><!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<!-- footer Start -->
<?php include("footer.php"); ?>
<!-- footer End -->