-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_marks.php
113 lines (96 loc) · 3.34 KB
/
add_marks.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
<?php
include("connect.php");
doDB();
session_start();
if (!isset($_SESSION['id'])) {
header("Location: student.php");
exit();
}
else {
if($_GET){
$quiz_id_sql = "SELECT marks from marks where quiz_id = '".$_GET['quiz_id']."' and id = '".$_SESSION['id']."'";
$login_res = mysqli_query($con, $quiz_id_sql) or die(mysqli_error($con));
while ($quiz = mysqli_fetch_array($login_res)) {
$total_marks = $quiz["marks"];
}
$_SESSION['quiz_start'] = 'stop';
// echo "Total marks are ".$total_marks;
}
else {
if (isset($_POST['opt'])) {
if ($_POST['ans']!=0) {
$chkans = $_POST['ans'];
}
if ($_POST['ans2']!=0) {
$chkans = $_POST['ans2'];
}
if ($_POST['ans3']!=0) {
$chkans = $_POST['ans3'];
}
if ($_POST['ans4']!=0) {
$chkans = $_POST['ans4'];
}
if($_POST['opt'] == $chkans){
$quiz_id_sql = "SELECT marks, index_a from marks where quiz_id = '".$_POST['quiz_id']."' and id =
'".$_SESSION['id']."' ORDER BY index_a DESC LIMIT 1;";
$login_res = mysqli_query($con, $quiz_id_sql) or die(mysqli_error($con));
while ($quiz = mysqli_fetch_array($login_res)) {
$total_marks = $quiz["marks"];
$index_a = $quiz["index_a"];
}
$total_marks++;
$quiz_id_sql = "UPDATE marks SET marks='".$total_marks."' where quiz_id='".$_POST['quiz_id']."' and id = '".$_SESSION['id']."' and index_a='".$index_a."';";
$login_res = mysqli_query($con, $quiz_id_sql) or die(mysqli_error($con));
}
}
else {
$opt1 = (isset($_POST['opt1'])) ? $_POST['opt1'] : 0;
$opt2 = (isset($_POST['opt2'])) ? $_POST['opt2'] : 0;
$opt3 = (isset($_POST['opt3'])) ? $_POST['opt3'] : 0;
$opt4 = (isset($_POST['opt4'])) ? $_POST['opt4'] : 0;
if ($opt1 == $_POST['ans1'] and $opt2 == $_POST['ans2'] and $opt3 == $_POST['ans3'] and $opt4 == $_POST['ans4'] ) {
$quiz_id_sql = "SELECT marks, index_a from marks where quiz_id = '".$_POST['quiz_id']."' and id =
'".$_SESSION['id']."' ORDER BY index_a DESC LIMIT 1;";
$login_res = mysqli_query($con, $quiz_id_sql) or die(mysqli_error($con));
while ($quiz = mysqli_fetch_array($login_res)) {
$total_marks = $quiz["marks"];
$index_a = $quiz["index_a"];
}
$total_marks++;
$quiz_id_sql = "UPDATE marks SET marks='".$total_marks."' where quiz_id='".$_POST['quiz_id']."' and id = '".$_SESSION['id']."' and index_a='".$index_a."';";
$login_res = mysqli_query($con, $quiz_id_sql) or die(mysqli_error($con));
}
}
$quiz_id = $_POST['quiz_id'];
$ques_no = $_POST['ques_no'];
$ques_no++;
header("Location: attempt_quiz.php?ques_no=$ques_no&quiz_id=$quiz_id");
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Marks</title>
<link rel="stylesheet" href="mark.css">
<link href='https://fonts.googleapis.com/css?family=Alegreya Sans SC' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Merienda' rel='stylesheet'>
</head>
<body>
</br>
<div class="qq">
<h1> Your Marks ! </h1>
</div>
<div class="ab">
<?php
echo "Total marks are ".$total_marks;?>
</div>
<div class="wrapper-inner-tab">
<div class="wrapper-inner-tab-backgrounds">
<div class="wrapper-inner-tab-backgrounds-first"><a href="student.php" style="text-decoration:none;"><div class="sim-button button28"><span>Go Back</span></div></div>
<div class="wrapper-inner-tab-backgrounds-second"><a href="logout.php" style="text-decoration:none;"><div class="sim-button button28"><span>Logout</span></div></div>
</div>
</div>
</body>
</html>