-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfacultystatistics.php
More file actions
185 lines (158 loc) · 6.61 KB
/
facultystatistics.php
File metadata and controls
185 lines (158 loc) · 6.61 KB
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
<html>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Faculty Stats SummaryTask', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'Faculty Stats Summary'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
<head>
<title>Evaluation Start</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
</head>
<?php
session_start();
$mysqli = new mysqli("localhost", "cs340", "cs340_s19", "courseeval");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
echo "Please try again.";
}
?>
<div id="nav"><a href="http://34.73.123.138/"><button type="button" class="btn btn-default" >Home</button></a></div>
<div class="container">
<body>
<h2>Instructor ID: <?php echo $_SESSION["instructorID"]; ?>
<h2>Your class statistics for <?php echo $_POST["class_num"];?></h2>
<br>
<br>
<?php
$class_num = $_POST["class_num"];
//questions to get statistics for
$questions = $mysqli->query("select question.questionid, question.type, question.text, question.options
from class, question, class_question
where class.class_num='$class_num'
and class.class_num = class_question.class_num
and class_question.questionid = question.questionid
order by question.questionid;");
if ($questions){
if ($questions->num_rows == 0){
echo 'Error: no results found.';
} else {
$questions->data_seek(0);
while ($row = $questions->fetch_assoc()){
$questionid = $row["questionid"];
//get the total number of responses.
$num_responses = $mysqli->query("select count(*)
from answer, eval_answer, evaluation, class
where answer.questionid = '$questionid'
and answer.answerid = eval_answer.answerid
and eval_answer.evalid = evaluation.evalid
and evaluation.class_num = class.class_num
and class.class_num = '$class_num';");
$num_responses->data_seek(0);
$totcount = $num_responses->fetch_assoc();
$totcount = $totcount["count(*)"];
//get each of the responses
$responses = $mysqli->query("select answer.response
from answer, eval_answer, evaluation, class
where answer.questionid = '$questionid'
and answer.answerid = eval_answer.answerid
and eval_answer.evalid = evaluation.evalid
and evaluation.class_num = class.class_num
and class.class_num = '$class_num';");
$response_array = array();
$responses->data_seek(0);
while ($row2 = $responses->fetch_assoc()){
array_push($response_array, $row2["response"]);
}
switch ($row["type"]){
case "MC":
echo '<h2>' . $row["text"] . '</h2>';
echo '<h3>' . $totcount . ' responses total. Breakdown: </h3>';
$options = explode(',', $row["options"]);
//breakdown by each option
foreach ($options as $option){
echo $option . ': ';
$count = 0;
foreach ($response_array as $response){
if ($option == $response) {$count++;}
}
echo $count . ' responses. (' . ($count / $totcount)*100 . '%)';
echo '<br>';
}
echo '<br>';
break;
//selecting answers 1 to 10
case "110":
echo '<h2>' . $row["text"] . '</h2>';
echo '<h3>' . $totcount . ' responses total. Breakdown: </h3>';
$median_array = array();
for ($i = 1; $i <= 10; $i++){
echo $i . ': ';
$count=0;
foreach ($response_array as $response){
if ($i == $response) {
$count++;
array_push($median_array, $i);
}
}
echo $count . ' responses.';
echo '<br>';
}
sort($median_array);
echo 'Median of: ' . $median_array[sizeof($median_array)/2];
echo '<br>';
break;
//agree/disagree
case "AD":
echo '<h2>' . $row["text"] . '</h2>';
echo '<h3>' . $totcount . ' responses total. Breakdown: </h3>';
$options = array('Strongly Disagree', 'Disagree', 'Neutral', 'Agree', 'Strongly Agree');
foreach ($options as $option){
echo $option . ': ';
$count = 0;
foreach ($response_array as $response){
if ($option == $response) {$count++;}
}
echo $count . ' responses. (' . ($count / $totcount)*100 . '%)';
echo '<br>';
}
echo '<br>';
break;
//freetext answers
case "FT":
echo '<h2>' . $row["text"] . '</h2>';
echo '<h3>' . $totcount . ' responses total. Responses: </h3>';
echo '<ul class="list-group">';
foreach ($response_array as $response){
echo '<li class="list-group-item">' . $response . '</li>';
}
echo '</ul>';
echo '<br>';
break;
}
}
}
}
?>
<a href="facultyreport.php"><button type="button" class="btn btn-primary">Back</button></a>
<br><br><br>
<body>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</body>
</div>
</html>