-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquestion_submission_detail.php
144 lines (115 loc) · 5.17 KB
/
question_submission_detail.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
<?php
session_start();
require_once "assets/connect/pdo.php";
if (!isset($_SESSION['Name']) && !isset($_SESSION['Teacher_ID'])) {
header("Location: teacher_Login.php");
return;
}
$errors = array('score' => '');
$success = '';
//getting the data by query parameter
if (isset($_GET['Question_Description_ID']) && isset($_GET['Student_Id'])) {
$question_id = $_GET['Question_Description_ID'];
$student_id = $_GET['Student_Id'];
$_SESSION['question_id'] = $_GET['Question_Description_ID'];
$stmt = $pdo->query("SELECT * FROM student_answer INNER JOIN question_description on question_description.Question_Description_ID = student_answer.Question_Description_ID WHERE question_description.Question_Description_ID = '$question_id' AND student_answer.Student_ID = '$student_id'");
$infos = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
//putting score in database
if (isset($_POST['submit'])) {
$score = $_POST['score'];
try {
require_once "assets/connect/pdo.php";
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE student_answer SET Score = '$score' WHERE Student_ID = '$student_id' AND Question_Description_ID = '$question_id'";
// use exec() because no results are returned
$pdo->exec($sql);
$success = "<label class='alert alert-success'>Score has been updated! 
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button></label>";
} catch (PDOException $e) {
$err = $e->getMessage();
echo "Data insertion failed. Please try again. $err";
}
$question_id = $_SESSION['question_id'];
sleep(1);
header("Location: question_submission.php?Question_Description_ID=$question_id");
}
?>
<head>
<?php
//Head Links
require_once 'assets/connect/head.php';
?>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light sticky-top">
<div class="container justify-content-start">
<a class="navbar-brand" href="index.php"><img id="logo" src="assets/images/LuExamHiveLogo.png" height="30px"> LU EXAM HIVE</a>
<a type="button" href="javascript:history.back(1)" class="btn btn-sm btn-outline-dark ml-3"><i class="fas fa-arrow-left"></i> Go Back</a>
</div>
</nav>
</header>
<main>
<div class="container">
<div class="row mt-4">
<div class="col">
<h3 class="display-4">Submission Details</h3>
</div>
</div>
<?php echo $success; ?>
<div class="row">
<div class="col">
<p class="text-center mt-3">Individual student submission details.</p>
<?php foreach ($infos as $info) {?>
<p class="text-center">
<b><?php echo $info['Title']; ?>  </b>
<b>Course Code: </b><span class="text-primary"><?php echo $info['Course_Code']; ?></span>  
<b>Course Title: </b><span class="text-primary"><?php echo $info['Course_Name']; ?></span>  
</p>
</div>
</div>
<div class="row alert alert-light shadow-lg p-3 mb-5 bg-white rounded mt-3">
<div class="col"></div>
<div class="col-xl-9 col-lg-9 col-md-10 col-sm-9 col-xs-6 my-5">
<p class="text-center">
<b>Name: </b><span class="text-primary"><?php echo $info['Full_Name']; ?></span>  
<b>Student ID: </b><span class="text-primary"><?php echo $info['Student_ID']; ?></span>  
<b>Batch (Sec): </b><span class="text-primary"><?php echo htmlspecialchars($info['Batch']); ?>(<?php echo htmlspecialchars($info['Section']); ?>)</span>  
</p>
<p class="text-center">
<button class="btn btn-sm btn-warning" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">See The Question <i class="fas fa-chevron-circle-down"></i>
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
<p><?php echo $info['Content']; ?></p>
</div>
</div>
<h4 class="text-primary">Answer:</h4>
<p><?php echo $info['Answer']; ?></p>
<form method="POST" action="question_submission_detail.php?Question_Description_ID=<?php echo $info['Question_Description_ID']; ?>&Student_Id=<?php echo $info['Student_ID']; ?>" class="form-inline mt-5 pt-5 float-right">
<div class="form-group mb-2">
<label>Give a Score or Update Current Score: </label>
</div>
<div class="form-group mx-3 mb-2">
<input type="text" name="score" class="form-control form-control-sm" id="inputPassword2" value="<?php echo $info['Score']; ?>">
<label class="text-danger"><?php echo $errors['score']; ?></label>
</div>
<input type="submit" name="submit" value="Save" class="btn btn-sm btn-dark mb-2">
</form>
<?php }?>
</div>
<div class="col"></div>
</div>
</div>
</main>
<!--footer Start -->
<?php
require_once 'assets/connect/footer.php';
?>
<!--footer End -->
</body>
</html>