-
Notifications
You must be signed in to change notification settings - Fork 1
/
cbt.php
191 lines (159 loc) · 7.1 KB
/
cbt.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
<?php require "main-header.php"; ?>
<?php
if(isset($_POST['cbt-btn'])){
$amount = trim($_POST['amount']);
$amount = stripslashes($amount);
$class = trim($_POST['class']);
$class = stripslashes($class);
$course = trim($_POST['course']);
$course = stripslashes($course);
$time = trim($_POST['time']);
$time = stripslashes($time);
$cbt_id = rand(1111, 9999);
if(empty($amount) || empty($class) || empty($course) || empty($time)){
echo "<script>alert('No field should be empty');</script>";
} elseif(!empty($amount) || !empty($class) || !empty($course) || !empty($time)) {
//create a random id for the cbt to check if students have written the exam before
$_SESSION['amount'] = $amount;
$_SESSION['course'] = $course;
$_SESSION['class'] = $class;
$_SESSION['time'] = $time;
$_SESSION['cbt_id'] = $cbt_id;
echo "<script>location.href = 'insert-cbt.php';</script>";
}
}
?>
<section class="section mt-5 pt-5">
<div class="row justify-content-center">
<div class="col-lg-4">
<div class="card">
<div class="card-body">
<h5 class="card-title text-center">Select how many Questions</h5>
<!-- Floating Labels Form -->
<form class="row g-3" action="<?= htmlspecialchars($_SERVER['PHP_SELF']); ?>"method="POST" >
<div class="col-12">
<div class="form-floating">
<select name="amount" id="" class="form-control">
<option value="2">1</option>
<option value="3">2</option>
<option value="4">3</option>
<option value="5">4</option>
<option value="6">5</option>
<option value="7">6</option>
<option value="8">7</option>
<option value="9">8</option>
<option value="10">9</option>
<option value="11">10</option>
</select>
<label for="floatingTextarea">How many questions?</label>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<select name="course" id="course" class="form-select" aria-label="Default select example">
<option value="">Select Course</option>
<?php
$sql_course = "SELECT courses FROM course";
$course_stmt = $conn->prepare($sql_course);
$course_stmt->execute();
$course_result = $course_stmt->get_result();
if($course_result->num_rows > 0){
while($course_row = $course_result->fetch_assoc()){
echo '
<option value='.$course_row['courses'].'>'.$course_row['courses'].'</option>
';
}
}
?>
</select>
<label for="floatingTextarea">How many questions?</label>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<select name="class" id="" class="form-control form_data">
<option value="">Select Student Class<option>
<?php
$sql = "SELECT class FROM class";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0){
while($row = $result->fetch_assoc()){
echo '
<option value='.$row['class'].'>'.$row['class'].'</option>
';
}
}
?>
</select>
</div>
</div>
<div class="form-floating">
<input class="form-control" name="time" placeholder="Address" type="text" id="floatingTextarea" />
<label for="floatingTextarea">Enter time - hour / minute / second</label>
</div>
<div class="text-center">
<button type="submit" name="cbt-btn" class="btn btn-success form-control" style=
"border-radius: 15px;">Continue</button>
</div>
</form><!-- End floating Labels Form -->
</div>
</div>
<?php
/*
for($i=0; $i<=10; $i++){
echo '
<div class="card">
<div class="card-body">
<h5 class="card-title text-center">Question One</h5>
<!-- Floating Labels Form -->
<form class="row g-3">
<div class="col-12">
<div class="form-floating">
<textarea class="form-control" placeholder="Address" id="floatingTextarea" style="height: 100px;"></textarea>
<label for="floatingTextarea">Enter Question Here</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="email" class="form-control" id="floatingEmail" placeholder="Your Email">
<label for="floatingEmail">Option one</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Option Two</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="email" class="form-control" id="floatingEmail" placeholder="Your Email">
<label for="floatingEmail">Option Three</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Option Four</label>
</div>
</div>
<div class="form-floating">
<input class="form-control" placeholder="Address" type="text" id="floatingTextarea" />
<label for="floatingTextarea">Enter Answer Here</label>
</div>
<div class="text-center">
<button type="submit" class="btn btn-success form-control" style=
"border-radius: 15px;">Continue</button>
</div>
</form><!-- End floating Labels Form -->
</div>
</div>
';
} */
?>
</div>
</div>
</section>
<?php require "main-footer.php"; ?>