-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformance_report.html
453 lines (388 loc) · 23.3 KB
/
performance_report.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Report</title>
<link rel="stylesheet" href="performance_report.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="topBar">
<div id="Search" class="container"></div>
<div id="BINO" class="page-header">BINO</div>
<img src="img_avatar.png" alt="Avatar" id="avatar" style="width:60px">
<p id="avatar_text">Raphael Low<br>Student</p>
<div id = "sidenav">
<div id="overview_button">
<svg id="icon" width="25px" height="25px" viewBox="0 0 16 16" class="bi bi-chevron-left" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
</svg>
<div id="overview_text" x="50" y="35" fill="black">Overview</div>
</div>
<svg width = "300" height = "600">
<g>
<rect rx="25" ry="25" width = "250" height = "260" fill="white"></rect>
<text class="sidenavweek" x="40" y="35" fill="Orange">Week 0</text>
<line x1="50" y1="50" x2="50" y2="240" stroke-linecap="round" d="M5 40 l215 0" style="stroke:rgba(249, 220, 215, 1); stroke-width:3" />
<line x1="50" y1="50" x2="50" y2="200" stroke-linecap="round" d="M5 40 l215 0" style="stroke:orange; stroke-width:3" />
<text class="sidenavweek2" x="70" y="85">Lecture 1</text>
<text class="sidenavweek2" x="70" y="135">Lecture 2</text>
<text class="sidenavweek2" x="70" y="185">Lecture 3</text>
<text class="sidenavweek2" x="70" y="235">Quiz</text>
<text class="sidenavweek" x="40" y="300" fill = "Grey">Week 1</text>
<text class="sidenavweek" x="40" y="350" fill = "Grey">Week 2</text>
<text class="sidenavweek" x="40" y="400" fill = "Grey">Week 3</text>
</g>
</svg>
</div>
</div>
<div id="main_section" class="col-md-6 offset-md-3">
<div id="quiz_content">
<div id = "quiz_text">Alkanes (C1003)</div>
<div id = "quiz_text2">Performance Report</div>
<hr>
<div id = "quiz_options">
<h3>General Overview</h3>
<h4 id = "score">Score</h4>
<h4 id = "skillrating">Skill Rating</h4>
<h5 id = "goodjob">Great Job!</h5>
<hr>
<h3>Breakdown of Questions Attempted by Skillset</h3>
<div id="skillsetpiechart"></div>
<div id="skillset_table_div"></div>
<hr>
<h3>Breakdown of Questions Attempted by Difficulty</h3>
<div id="difficultypiechart"></div>
<div id="difficulty_table_div"></div>
<hr>
<h3>Breakdown of Individual Questions</h3>
<div id = "individual_questions"></div>
</div>
</div>
</div>
<!-- JAVASCRIPT CODE -->
<script type="text/javascript">
var array = [];
var input = [];
var skillrating = Number(localStorage.getItem("currentAverage"));
if (skillrating >= 4.0) {
document.getElementById("goodjob").innerHTML = "Great Job!"
} else if (skillrating >= 3.0 && skillrating < 4.0) {
document.getElementById("goodjob").innerHTML = "You did well!"
} else if (skillrating >= 2.25 && skillrating < 3.0) {
document.getElementById("goodjob").innerHTML = "You need to buck up!"
} else {
document.getElementById("goodjob").innerHTML = "Revise your fundamentals and try again!"
}
fetch('http://awsbino-env-2.eba-vh6jpy5i.us-east-1.elasticbeanstalk.com/report')
.then((response) => {
return response.json()
})
.then((data) => {
const jsonStr = JSON.stringify(data)
const obj = JSON.parse(jsonStr)
input = obj.data
console.log(input.length);
})
.catch(err => {
console.log('Fetch error:' + err);
});
fetch('http://awsbino-env-2.eba-vh6jpy5i.us-east-1.elasticbeanstalk.com/quiz')
.then((response) => {
return response.json()
})
.then((data) => {
const jsonStr = JSON.stringify(data)
const obj = JSON.parse(jsonStr)
const obj2 = JSON.parse(obj.data)
var array = obj2.Items
var n = input.length;
for (a = 1; a < (n + 1); a++) {
//Question
var qn = document.createElement("p");
qn.setAttribute("id", String("demo" + a));
qn.setAttribute("class", "question");
qn.innerHTML = "Question";
//Skillset
var skill = document.createElement("p");
skill.setAttribute("id", String("skillset" + a));
skill.setAttribute("class", "skillsetstyle");
skill.innerHTML = "Skillset";
//Difficulty
var difficultyrating = document.createElement("p");
difficultyrating.setAttribute("id", String("difficulty" + a));
difficultyrating.setAttribute("class", "difficultystyle");
difficultyrating.innerHTML = "Difficulty Rating";
//Option A
var option_A = document.createElement("div");
option_A.setAttribute("id", String("q" + a + "o1"));
option_A.innerHTML = "A";
//Option B
var option_B = document.createElement("div");
option_B.setAttribute("id", String("q" + a + "o2"));
option_B.innerHTML = "B";
//Option C
var option_C = document.createElement("div");
option_C.setAttribute("id", String("q" + a + "o3"));
option_C.innerHTML = "C";
//Option D
var option_D = document.createElement("div");
option_D.setAttribute("id", String("q" + a + "o4"));
option_D.setAttribute("class", "lastoption");
option_D.innerHTML = "D";
//Bootstrap div
var div = document.createElement("div");
div.setAttribute("class", "alert alert-danger");
div.setAttribute("role", "alert");
div.setAttribute("id", String("div" + a));
var heading = document.createElement("h4");
heading.setAttribute("class", "alert-heading");
heading.setAttribute("id", String("heading" + a));
heading.innerHTML = "Incorrect";
var answer = document.createElement("p");
answer.setAttribute("id", String("ans" + a));
answer.innerHTML = "Your Ans";
var correctanswer = document.createElement("p");
correctanswer.setAttribute("id", String("demoo" + a + "1"));
correctanswer.innerHTML = "Correct Ans";
var hr = document.createElement('hr');
var explanation = document.createElement("p");
explanation.setAttribute("id", String("explan" + a));
explanation.setAttribute("class", "mb-0");
explanation.innerHTML = "Explanation";
//Line Break
var hr_end = document.createElement('hr');
document.getElementById("individual_questions").appendChild(qn);
document.getElementById("individual_questions").appendChild(skill);
document.getElementById("individual_questions").appendChild(difficultyrating);
document.getElementById("individual_questions").appendChild(option_A);
document.getElementById("individual_questions").appendChild(option_B);
document.getElementById("individual_questions").appendChild(option_C);
document.getElementById("individual_questions").appendChild(option_D);
document.getElementById("individual_questions").appendChild(div);
div.appendChild(heading);
div.appendChild(answer);
div.appendChild(correctanswer);
div.appendChild(hr);
div.appendChild(explanation);
document.getElementById("individual_questions").appendChild(hr_end);
}
var recall, inference, evaluation, application, level1, level2, level3, level4, level5, recallcorrect, inferencecorrect, evaluationcorrect, applicationcorrect, level1correct, level2correct, level3correct, level4correct, level5correct;
recall = inference = evaluation = application = level1 = level2 = level3 = level4 = level5 = recallcorrect = inferencecorrect = evaluationcorrect = applicationcorrect = level1correct = level2correct = level3correct = level4correct = level5correct = 0;
for (i = 0; i < n; i++) {
for (j = 0; j < obj2.Items.length; j++) {
if (array[j]['Qns_ID']['S'] == input[i][0]) {
var a = i + 1;
var question = String("demo" + a);
var skillset = String("skillset" + a);
var difficulty = String("difficulty" + a);
var optionA = String("q" + a + "o1");
var optionB = String("q" + a + "o2");
var optionC = String("q" + a + "o3");
var optionD = String("q" + a + "o4");
var div = String("div" + a);
var heading = String("heading" + a);
var ans = String("ans" + a);
var correctans = String("demoo" + a + "1");
var explanation = String("explan" + a);
//Skillset, Difficulty, and Student's ans from /report
document.getElementById(difficulty).innerHTML = "Difficulty rating: " + String(input[i][1]);
document.getElementById(skillset).innerHTML = String(input[i][2]);
document.getElementById(ans).innerHTML = "You chose: " + input[i][4];
//Question, Ans Key, Options, Explanation from /quiz
document.getElementById(question).innerHTML = "Q" + a + ". " + array[j]['Question']['S'];
document.getElementById(correctans).innerHTML = "Correct answer is: " + array[j]['Answer']['S'];
document.getElementById(optionA).innerHTML = "A. " + array[j]['Option_A']['S'];
document.getElementById(optionB).innerHTML = "B. " + array[j]['Option_B']['S'];
document.getElementById(optionC).innerHTML = "C. " + array[j]['Option_C']['S'];
document.getElementById(optionD).innerHTML = "D. " + array[j]['Option_D']['S'];
document.getElementById(explanation).innerHTML = "Explanation: " + array[j]['Explanation']['S'];
if (input[i][2] == "Recall") {
recall += 1;
if (input[i][3] == 1) {
recallcorrect += 1;
document.getElementById(heading).innerHTML = "Correct";
document.getElementById(div).className = "alert alert-success";
}
} else if (input[i][2] == "Evaluation") {
evaluation += 1;
if (input[i][3] == 1) {
evaluationcorrect += 1;
document.getElementById(heading).innerHTML = "Correct";
document.getElementById(div).className = "alert alert-success";
}
} else if (input[i][2] == "Inference") {
inference += 1;
if (input[i][3] == 1) {
inferencecorrect += 1;
document.getElementById(heading).innerHTML = "Correct";
document.getElementById(div).className = "alert alert-success";
}
} else if (input[i][2] == "Application") {
application += 1;
if (input[i][3] == 1) {
applicationcorrect += 1;
document.getElementById(heading).innerHTML = "Correct";
document.getElementById(div).className = "alert alert-success";
}
}
if (input[i][1] >= 1 && input[i][1] < 2) {
level1 += 1;
if (input[i][3] == 1) {
score += 1;
level1correct += 1;
}
} else if (input[i][1] >= 2 && input[i][1] < 3) {
level2 += 1;
if (input[i][3] == 1) {
score += 1;
level2correct += 1;
}
} else if (input[i][1] >= 3 && input[i][1] < 4) {
level3 += 1;
if (input[i][3] == 1) {
score += 1;
level3correct += 1;
}
} else if (input[i][1] >= 4 && input[i][1] < 5) {
level4 += 1;
if (input[i][3] == 1) {
score += 1;
level4correct += 1;
}
} else if (input[i][1] == 5) {
level5 += 1;
if (input[i][3] == 1) {
score += 1;
level5correct += 1;
}
}
}
else {
continue;
}
}
}
var total = recall + inference + evaluation + application;
var totalcorrect = recallcorrect + inferencecorrect + evaluationcorrect + applicationcorrect;
var percentagecorrect = totalcorrect/total;
document.getElementById("score").innerHTML = "Score: " + totalcorrect + "/" + total;
document.getElementById("skillrating").innerHTML = "Skill Rating: " + localStorage.getItem("currentAverage") + "/5";
// Load google charts
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
// Draw the chart and set the chart values
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Skillset', 'Number of Questions'],
['Recall', recall],
['Evaluation', evaluation],
['Inference', inference],
['Application', application]
]);
var difficultydata = google.visualization.arrayToDataTable([
['Difficulty Level', 'Number of Questions'],
['Level 1+', level1],
['Level 2+', level2],
['Level 3+', level3],
['Level 4+', level4],
['Level 5', level5]
]);
// Optional; add a title and set the width and height of the chart
var options = {title: 'Question Distribution', 'width':550, 'height':400, is3D: true,};
var options2 = {title: 'Question Distribution', 'width':550, 'height':400, is3D: true,};
// Display the chart inside the <div> element with id="skillsetpiechart"
var skillsetchart = new google.visualization.PieChart(document.getElementById('skillsetpiechart'));
skillsetchart.draw(data, options);
// Display the chart inside the <div> element with id="difficultypiechart"
var difficultychart = new google.visualization.PieChart(document.getElementById('difficultypiechart'));
difficultychart.draw(difficultydata, options2);
}
google.charts.load('current', {'packages':['table']});
google.charts.setOnLoadCallback(drawTable);
function drawTable() {
var skillset_table_data = new google.visualization.DataTable();
skillset_table_data.addColumn('string', 'Skillset');
skillset_table_data.addColumn('number', 'No. of Questions Asked');
skillset_table_data.addColumn('number', 'No. of Questions Correct');
skillset_table_data.addColumn('number', '% of Questions Correct');
if (recall == 0) {
var recallcorrectstr = "-";
} else {
var recallcorrectstr = String((Math.round(((recallcorrect/recall) + Number.EPSILON) * 100)) + '%');
}
if (inference == 0) {
var inferencecorrectstr = "-";
} else {
var inferencecorrectstr = String((Math.round(((inferencecorrect/inference) + Number.EPSILON) * 100)) + '%');
}
if (evaluation == 0) {
var evaluationcorrectstr = "-";
} else {
var evaluationcorrectstr = String((Math.round(((evaluationcorrect/evaluation) + Number.EPSILON) * 100)) + '%');
}
if (application == 0) {
var applicationcorrectstr = "-";
} else {
var applicationcorrectstr = String((Math.round(((applicationcorrect/application) + Number.EPSILON) * 100)) + '%');
}
skillset_table_data.addRows([
['Recall', {v: recall, f: String(recall)}, {v: recallcorrect, f: String(recallcorrect)}, {v: (Math.round(((recallcorrect/recall) + Number.EPSILON) * 100)), f: recallcorrectstr}],
['Evaluation', {v: evaluation, f: String(evaluation)}, {v: evaluationcorrect, f: String(evaluationcorrect)}, {v: (Math.round(((evaluationcorrect/evaluation) + Number.EPSILON) * 100)), f: evaluationcorrectstr}],
['Inference', {v: inference, f: String(inference)}, {v: inferencecorrect, f: String(inferencecorrect)}, {v: (Math.round(((inferencecorrect/inference) + Number.EPSILON) * 100)), f: inferencecorrectstr}],
['Application', {v: application, f: String(application)}, {v: applicationcorrect, f: String(applicationcorrect)}, {v: (Math.round(((applicationcorrect/application) + Number.EPSILON) * 100)), f: applicationcorrectstr}],
['Total', {v: total, f: String(total)}, {v: totalcorrect, f: String(totalcorrect)}, {v: (Math.round(((totalcorrect/total) + Number.EPSILON) * 100)), f: String((Math.round(((totalcorrect/total) + Number.EPSILON) * 100)) + '%')}]
]);
var difficulty_table_data = new google.visualization.DataTable();
difficulty_table_data.addColumn('string', 'Difficulty');
difficulty_table_data.addColumn('number', 'No. of Questions Asked');
difficulty_table_data.addColumn('number', 'No. of Questions Correct');
difficulty_table_data.addColumn('number', '% of Questions Correct');
if (level1 == 0) {
var level1correctstr = "-";
} else {
var level1correctstr = String((Math.round(((level1correct/level1) + Number.EPSILON) * 100)) + '%');
}
if (level2 == 0) {
var level2correctstr = "-";
} else {
var level2correctstr = String((Math.round(((level2correct/level2) + Number.EPSILON) * 100)) + '%');
}
if (level3 == 0) {
var level3correctstr = "-";
} else {
var level3correctstr = String((Math.round(((level3correct/level3) + Number.EPSILON) * 100)) + '%');
}
if (level4 == 0) {
var level4correctstr = "-";
} else {
var level4correctstr = String((Math.round(((level4correct/level4) + Number.EPSILON) * 100)) + '%');
}
if (level5 == 0) {
var level5correctstr = "-";
} else {
var level5correctstr = String((Math.round(((level5correct/level5) + Number.EPSILON) * 100)) + '%');
}
difficulty_table_data.addRows([
['Level 1+', {v: level1, f: String(level1)}, {v: level1correct, f: String(level1correct)}, {v: (Math.round(((level1correct/level1) + Number.EPSILON) * 100)), f: level1correctstr}],
['Level 2+', {v: level2, f: String(level2)}, {v: level2correct, f: String(level2correct)}, {v: (Math.round(((level2correct/level2) + Number.EPSILON) * 100)), f: level2correctstr}],
['Level 3+', {v: level3, f: String(level3)}, {v: level3correct, f: String(level3correct)}, {v: (Math.round(((level3correct/level3) + Number.EPSILON) * 100)), f: level3correctstr}],
['Level 4+', {v: level4, f: String(level4)}, {v: level4correct, f: String(level4correct)}, {v: (Math.round(((level4correct/level4) + Number.EPSILON) * 100)), f: level4correctstr}],
['Level 5+', {v: level5, f: String(level5)}, {v: level5correct, f: String(level5correct)}, {v: (Math.round(((level5correct/level5) + Number.EPSILON) * 100)), f: level5correctstr}],
['Total', {v: total, f: String(total)}, {v: totalcorrect, f: String(totalcorrect)}, {v: (Math.round(((totalcorrect/total) + Number.EPSILON) * 100)), f: String((Math.round(((totalcorrect/total) + Number.EPSILON) * 100)) + '%')}],
]);
var skillset_table = new google.visualization.Table(document.getElementById('skillset_table_div'));
skillset_table.draw(skillset_table_data, {showRowNumber: false, width: '100%', height: '100%'});
var difficulty_table = new google.visualization.Table(document.getElementById('difficulty_table_div'));
difficulty_table.draw(difficulty_table_data, {showRowNumber: false, width: '100%', height: '100%'});
}
})
.catch((err) => {
console.error('There has been a problem with your fetch operation:' + err);
})
fetch('http://awsbino-env-2.eba-vh6jpy5i.us-east-1.elasticbeanstalk.com/clear');
</script>
</body>
</html>