forked from raja-theking/SE_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_questions.php
52 lines (43 loc) · 1.14 KB
/
add_questions.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
<?php
include("connect.php");
if (!$_GET['quiz_id']) {
header("Location: teacher.php");
}
else {
$question = $_GET['ques'];
$opt1 = $_GET['opt1'];
$opt2 = $_GET['opt2'];
$opt3 = $_GET['opt3'];
$opt4 = $_GET['opt4'];
$answer = $_GET['ans'];
$quiz_id = $_GET['quiz_id'];
$ans1 = 0;
$ans2 = 0;
$ans3 = 0;
$ans4 = 0;
$ansd = array("0","0","0","0");
doDB();
$N = count($answer);
$multi = 'yes';
for($i=0; $i < $N; $i++)
{
$ansd[$answer[$i]-1] = $answer[$i];
}
if($ansd[0]==0 and $ansd[1]==0 and $ansd[2]==0){
$multi = 'no';
}
if($ansd[0]==0 and $ansd[1]==0 and $ansd[3]==0){
$multi = 'no';
}
if($ansd[0]==0 and $ansd[2]==0 and $ansd[3]==0){
$multi = 'no';
}
if($ansd[1]==0 and $ansd[2]==0 and $ansd[3]==0){
$multi = 'no';
}
$sql = "INSERT INTO quiz_questions values (NULL, '".$quiz_id."','".$question."','".$opt1."','".$opt2."','".$opt3."','".$opt4."',
'".$ansd[0]."','".$ansd[1]."','".$ansd[2]."','".$ansd[3]."','".$multi."')";
mysqli_query($con, $sql) or die(mysqli_error($con));
header("Location: add_quiz.php?quiz_id=".$quiz_id."");
}
?>