-
Notifications
You must be signed in to change notification settings - Fork 1
/
chartPageStudent.html
213 lines (167 loc) · 7.62 KB
/
chartPageStudent.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="expires" content="-1">
<title>Student Assessment Page</title>
<link rel="stylesheet" href="teacherAssessmentPage.css">
<link rel="stylesheet" href="studentAssessmentPage.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<script>
let grades =[
75.44,
75.46,
75.15,
74.57,
75.07,
88,
90
];
//below are the functions associated with displaying specific data
function average(array){
let average = array.reduce((a, b) => a + b, 0) / array.length;
return average;
}
function standardDeviation(array) {
const n = array.length
const mean = array.reduce((a, b) => a + b) / n
return Math.sqrt(array.map(x => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n)
}
function median(array){
array.sort(function(a,b){
return a-b;
});
let half = Math.floor(array.length / 2);
if (array.length % 2)
return array[half];
return (array[half - 1] + array[half]) / 2.0;
}
function round(number){
return Math.round(number*100)/100;
}
</script>
<header>
<nav id="mainNav">
<div id="subSection">
<img src="book-stack.png" alt="Image of a book stack">
<p>Student Management System</p>
</div>
<div id="subSection">
<p id="teacherName">Student ID: studentID</p>
<a href="studentLogin.html">
<div id="power">
<img src="power.png" alt="Image of a power on/off button">
<p>Logout</p>
</div>
</a>
</div>
</nav>
</header>
<nav id="sideNav">
<h3>Navigation</h3>
<form action="studentAssessmentPage.html">
<button>Assignment 1</button>
</form>
<form action="studentAssessmentPage.html">
<button>Assignment 2</button>
</form>
<form action="studentAssessmentPage.html">
<button>Assignment 3</button>
</form>
<form action="studentAssessmentPage.html">
<button>Midterm</button>
</form>
</nav>
<div class="mainbody">
<div class="maintitle"><p>Assignment 1</p></div>
<div class="NotifBorder1">
<h3 class="NotifTitle">Grade</h3>
<div class="NotifContent">
<div class="Divider1">
<h4>Your Grade: </h4>
</div>
<div class="Divider2">
<h4>80%</h4>
</div>
</div>
</div>
<div class="NotifBorder2">
<h3 class="NotifTitle">Statistics</h3>
<div class="NotifContent">
<div class="Divider1">
<h4>Class Mean:</h4>
<h4>Class Median:</h4>
<h4>Class Mode:</h4>
<h4>Standard Deviation:</h4>
</div>
<div class="Divider2">
<h4><script>document.write(round(average(grades)))</script></h4>
<h4><script>document.write(round(median(grades)))</script></h4>
<h4><script>document.write(round(mode(grades)))</script></h4>
<h4><script>document.write(round(standardDeviation(grades)))</script></h4>
</div>
<div>
<canvas id = "myChart" height="50px" width="100px" Your browser does not support this canvas>
<script>
const labels = [
'Assignment 1',
'Assignment 2',
'Assignment 3',
'Assignment 4',
'Labs',
'Midterm',
'Exam',
];
const data = {
labels: labels,
datasets: [{
label: 'Your Overall Grades',
//backgroundColor: 'rgba(141, 153, 174,0.7)',
//backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(240,248,255))',
//borderColor: 'rgb(255, 99, 132)',
color: 'rgb(240,248,255)',//font color
tesnion: 0.4,
data: grades,
}]
};
const config = {
type: 'line',
data: data,
options: {
y: {
min: 0,
max: 100
}
}
};
const myChart = new Chart(
document.getElementById('myChart'),config);
function addData(label, data) {
myChart.data.labels.push(label);
myChart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
myChart.update();
}
function removeData(label,data) {
myChart.data.labels.pop(label);
myChart.data.datasets.forEach((dataset) => {
dataset.data.pop(data);
});
myChart.update();
}
</script>
</canvas>
</div>
</div>
</div>
</div>
</div>
</body>
</html>