-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrade6score.php
240 lines (234 loc) · 11.6 KB
/
grade6score.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
session_start();
//check if user is logged in
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
require_once "config.php";
$filtervalues = "";
if(isset($_POST['exam-period'])){
$filtervalues = $_POST['exam-period'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SPIMA</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="myStyle.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<script src="https://use.fontawesome.com/releases/v6.1.0/js/all.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
</head>
<body id="welcome" data-spy="scroll" data-target=".navbar" data-offset="60">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="welcome.php">
<div style="display:inline-block;vertical-align:text-top;">
</div>
<div style="display: inline-block;vertical-align:top;">
SPIMA
</div>
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="student.php">STUDENTS</a></li>
<li><a href="exams.php">EXAMS</a></li>
<li><a href="logout.php">Sign Out</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid text-center">
<h2>Grade 6 Exam Result sheets</h2>
<div class="row">
</div>
</div>
<br>
<div class="container" id="classscore">
<h2>Term 1 Scores</h2>
<div class="col-md-7">
<form onsubmit="" method="post">
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="exam-type">Choose Examination Period </label>
</div>
<select name="exam-period" id="exam-type">
<option value="Select Exam period">Select Period...</option>
<option value="opener">Opener</option>
<option value="mid-term">Mid-term</option>
<option value="end-term">End-term</option>
</select>
<button type="submit" class="btn btn-primary"> Search</button>
</div>
</form>
</div>
<table class="table table-bordered table-hover" id="mytablescore">
<thead class="thead-dark">
<tr><th colspan="3"> Grade 6 Term 1 2022 <?php echo $filtervalues; ?></th></tr>
</thead>
<thead class="thead-light">
<tr>
<th scope="col">Student ID</th>
<th scope="col">Name</th>
<th scope="col">Maths</th>
<th scope="col">English</th>
<th scope="col">Swahili</th>
<th scope="col">Science</th>
<th scope="col">Social Studies</th>
<th scope="col">Religious Education</th>
<th scope="col">Total Score</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_POST['exam-period']))
{
$filtervalues = $_POST['exam-period'];
$query = "SELECT students.id, students.name, students.grade,
term1.exam_type, term1.maths, term1.english, term1.swahili,
term1.science, term1.social, term1.religious, term1.total from students INNER JOIN term1 ON students.id = term1.id WHERE students.grade = 6 AND term1.exam_type = '$filtervalues' ORDER BY term1.total DESC";
$query_run = mysqli_query($link, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $items)
{
?>
<tr>
<td><?= $items['id']; ?></td>
<td><?= $items['name']; ?></td>
<td><?= $items['maths']; ?></td>
<td><?= $items['english']; ?></td>
<td><?= $items['swahili']; ?></td>
<td><?= $items['science']; ?></td>
<td><?= $items['social']; ?></td>
<td><?= $items['religious']; ?></td>
<td><?= $items['total']; ?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="4">No Record Found</td>
</tr>
<?php
}
}?>
</tbody>
<thead class="thead-light">
<tr>
<th colspan="2">Class Average Score</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(maths) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(maths)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(english) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(english)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(swahili) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(swahili)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(science) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(science)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(social) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(social)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(religious) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(religious)'];
}
?>
</th>
<th scope="col">
<?php
$result = $link->query("SELECT AVG(total) FROM term1 INNER JOIN students ON students.id = term1.id WHERE term1.exam_type ='$filtervalues' AND students.grade=6");
//display data on web page
while($row = mysqli_fetch_array($result)){
echo $row['AVG(total)'];
}
?>
</th>
</tr>
</thead>
</table>
<div class="container text-center">
<button id="download" class="btn btn-success">Download/Print Score</button>
</div>
</div>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<script>
function downloadPDFWithjsPDF() {
var doc = new jspdf.jsPDF({orientation:'p', unit:'pt', format: 'a4'});
margin = 30; // narrow margin - 12.7 mm
let srcwidth = document.getElementById('mytablescore').scrollWidth;
let scale = (595.28 - margin * 2) / srcwidth; // a4 pageSize 595.28
doc.html(document.querySelector('#mytablescore'), {
html2canvas: {
scale: scale, // default is window.devicePixelRatio,
letterRendering:true
},
callback: function (doc) {
doc.save('Grade 6 <?php echo $filtervalues ?> 2022 Score Report.pdf');
},
x: margin,
y: margin,
});
}
document.querySelector('#download').addEventListener('click', downloadPDFWithjsPDF);
</script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>