-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaySessionSummary.php
executable file
·153 lines (133 loc) · 4.92 KB
/
aySessionSummary.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
<?php
include('control/connectionVars.php');
include_once('control/functions.php');
include('classes/InstructionSession.php');
include('classes/User.php');
require_once('control/startSession.php');
// Insert the page header
$page_title = 'Academic Year Session Summary';
include('includes/header.php');
(isset($_GET['semester']) && $_GET['semester'] != "") ? $semester = $_GET['semester'] : $semester = "any";
(isset($_GET['year']) && $_GET['year'] != "") ? $year = $_GET['year'] : $year = "any";
echo '<h2>Academic Year - Session Summary for <span id="daterange">'.$semester.' semester, AY '.$year.'</span></h2>';
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Failed to connect to the database: '.mysqli_error($dbc));
echo '<h3>Sessions by level</h3>';
// This will be reused in several queries
$dateFragment = ' where '.inSemester($semester, 'sesdDate').' and '.inAcademicYear($year, 'sesdDate');
$query = 'select (select count(sesdID) from lowerlevel '.$dateFragment.') as lcount, (select count(sesdID) from upperlevel '.$dateFragment.') as ucount';
$result = mysqli_query($dbc, $query) or die('Failed to query database: ' . mysqli_error($dbc));
$row = mysqli_fetch_assoc($result);
$totalsessions = $row['lcount'] + $row['ucount'];
echo '<table id="ulsession">
<thead>
<tr>
<th>Description</th>
<th>Count</th>
<th>Percent</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lower level</td>
<td id="llcount">'.$row['lcount'].'</td>
<td>'.round($row['lcount']/$totalsessions*100, 2).'</td>
</tr>
<tr>
<td>Upper level</td>
<td id="ulcount">'.$row['ucount'].'</td>
<td>'.round($row['ucount']/$totalsessions*100, 2).'</td>
</tr>
</tbody>
</table>';
echo '<h3>Sessions by course</h3>';
$query = 'select (select count(sesdID) from itw '.$dateFragment.') as count, "ITW" as description
union select (select count(sesdID) from iql '.$dateFragment.'), "IQL"
union select (select count(sesdID) from hlsc '.$dateFragment.'), "HLSC"
union select (select count(sesdID) from ihcomm171 '.$dateFragment.'), "IHCOMM-171"';
$result = mysqli_query($dbc, $query) or die('Failed to query database: ' . mysqli_error($dbc));
$stotal = 0;
echo '<table id="subjectsession">
<thead>
<tr>
<th>Description</th>
<th>Count</th>
<th>Percent</th>
</tr>
</thead>
<tbody>';
while ($row = mysqli_fetch_assoc($result)) {
$stotal += $row['count'];
echo '<tr>
<td>'.$row['description'].'</td>
<td>'.$row['count'].'</td>
<td>'.round($row['count']/$totalsessions*100, 2).'</td>
</tr>';
}
echo '<tr>
<td>Other</td>
<td>'.($totalsessions-$stotal).'</td>
<td>'.round(($totalsessions-$stotal)/$totalsessions*100, 2).'</td>
</tr>';
echo '</tbody>
</table>';
?>
<div id="chartContainer" style="clear: both; margin-top: 40px;">
<div style="width:50%; float:left;" id="upperLowerChart"></div>
<div style="width:50%; float:left;" id="ITWetcChart"></div>
</div>
<?php
$jsOutput .= '
var oTable = $("#ulsession").dataTable({
"sDom": "T<\'clear\'>lrtp",
"bSort": false,
"bPaginate": false,
"oTableTools": { "sSwfPath":"swf/copy_csv_xls_pdf.swf" }
});
var oTable = $("#subjectsession").dataTable({
"sDom": "T<\'clear\'>lrtp",
"bSort": false,
"bPaginate": false,
"oTableTools": { "sSwfPath":"swf/copy_csv_xls_pdf.swf" }
});
var uldata = tableToArray("ulsession", 0, 2);
ulchart = new Highcharts.Chart({
title: { text: "Sessions by level ("+$("#daterange").text()+")" },
chart: { renderTo: "upperLowerChart" },
tooltip: { enabled: false },
series: [{
type: "pie",
data: uldata,
animation: false
}],
plotOptions: {
pie: {
enableMouseTracking: false,
dataLabels:{
formatter: function(){ return "<b>"+this.point.name+"</b><br>"+this.y+" ("+Highcharts.numberFormat(this.percentage, 2)+"%)"; }
}
}
}
});
var sdata = tableToArray("subjectsession", 0, 2);
schart = new Highcharts.Chart({
title: { text: "Sessions by course ("+$("#daterange").text()+")" },
chart: { renderTo: "ITWetcChart" },
tooltip: { enabled: false },
series: [{
type: "pie",
data: sdata,
animation: false
}],
plotOptions: {
pie: {
enableMouseTracking: false,
dataLabels:{
formatter: function(){ return "<b>"+this.point.name+"</b><br>"+this.y+" ("+Highcharts.numberFormat(this.percentage, 2)+"%)"; }
}
}
}
});
';
include('includes/footer.php');
?>