-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtake_assignment.php
93 lines (88 loc) · 5.3 KB
/
take_assignment.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
<?php include('./components/header.php') ?>
<?php include('./includes/global.php'); ?>
<title>Profile || Glowedu</title>
<div class="app-main__outer">
<div class="app-main__inner">
<div class="row">
<div class="col-md-12">
<div class="card-body">
<?php
$assignment_code = $_GET['id'];
$answer = @$_GET['answer'];
$submit_answer = @$_GET['submit_answer'];
$main = @$_GET['main'];
$student_email = $_SESSION['email'];
$created_at = date('Y-m-d');
if ($submit_answer) {
$insert_select_question = "INSERT INTO `assignment_answer`(`answer_id`, `student_email`, `assignment_code`, `answer`, `student_answer`, `created_at`) VALUES
(NULL,'$student_email','$assignment_code','$main','$answer','$created_at')";
$insert_select_query = mysqli_query($conn, $insert_select_question);
if ($insert_select_query) {
echo "<meta http-equiv=\"refresh\" content=\"5; url=take_assignment.php?id=$assignment_code\">";
}
}
$query_select_1 = "SELECT * FROM `assignment_serial_number` WHERE assignment_question_code = '$assignment_code'";
$query_select = mysqli_query($conn, $query_select_1);
$numberofrows = mysqli_num_rows($query_select);
$query_select_question = "SELECT * FROM assignment_serial_number WHERE assignment_question_code = '$assignment_code'";
$result_select_question = mysqli_query($conn, $query_select_question);
while ($row = mysqli_fetch_array($result_select_question)) {
$assignment_question_id = $row['assignment_question_id'];
$assignment_question_number = $row['assignment_question_number'];
$query_select_question = "SELECT * FROM mcq WHERE question_id = '$assignment_question_id'";
$result_select_question = mysqli_query($conn, $query_select_question);
while ($row = mysqli_fetch_array($result_select_question)) {
$question = $row['question'];
$first = $row['first'];
$second = $row['second'];
$third = $row['third'];
$fourth = $row['fourth'];
$answer = $row['answer'];
McqWidget($question, $first, $second, $third, $fourth, $answer, $assignment_code, $assignment_question_id);
}
}
?>
</div>
</div>
</div>
<?php
function McqWidget($question, $first, $second, $third, $fourth, $answer, $assignment_code)
{
echo "
<div class='mb-3 card bg-white border'>
<div class='card-header text-black font-size-lg'>$question</div>
<div class='card-body'>
<form method='GET' action='./take_assignment.php'>
<div class='form-check form-check'>
<input class='form-check-input' type='radio' name='answer' id='inlineRadio1' value='$first'>
<label class='form-check-label font-size-lg' for='inlineRadio1'>$first</label>
</div>
<div class='form-check form-check'>
<input class='form-check-input' type='radio' name='answer' id='inlineRadio2' value='$second'>
<label class='form-check-label font-size-lg' for='inlineRadio2'>$second</label>
</div>
<div class='form-check form-check'>
<input class='form-check-input' type='radio' name='answer' id='inlineRadio3' value='$third'>
<label class='form-check-label font-size-lg' for='inlineRadio3'>$third</label>
</div>
<div class='form-check form-check'>
<input class='form-check-input' type='radio' name='answer' id='inlineRadio4' value='$fourth'>
<label class='form-check-label font-size-lg' for='inlineRadio4'>$fourth</label>
</div>
<input type='hidden' name='id' value='$assignment_code'>
<input type='hidden' name='id' value='$assignment_code'>
<input type='hidden' name='main' value='$answer'>
<div class='row mt-3'>
<div class='col-md-10'></div>
<div class='col-md-2'>
<input type='submit' value='Submit Answer' name='submit_answer' class='col-md-12 btn btn-outline-primary'>
</div>
</div>
</form>
</div>
</div>
";
}
?>
<?php include('./components/footer.php'); ?>
<?php include('./components/scripts.php'); ?>