oops
This commit is contained in:
39
main.js
39
main.js
@@ -7,7 +7,7 @@ if(chartDiv.getAttribute('value') == 'invisible'){
|
|||||||
}
|
}
|
||||||
var gradeChart;
|
var gradeChart;
|
||||||
const ctx = document.getElementById("gradeBar");
|
const ctx = document.getElementById("gradeBar");
|
||||||
|
const labels = ['A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D', 'D-', 'F'];
|
||||||
/*
|
/*
|
||||||
Parse the input form and class data
|
Parse the input form and class data
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ async function parseName() {
|
|||||||
alert("Invalid Department");
|
alert("Invalid Department");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(department, classNum.toString(), className.trim(), sem);
|
console.log(department, classNum.toString(), className.trim(), semester);
|
||||||
await PapaParse(department, classNum.toString(), className.trim(), semester);
|
await PapaParse(department, classNum.toString(), className.trim(), semester);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,6 @@ async function PapaParse(department, num, name, sem) {
|
|||||||
url = 'https://derec4.github.io/ut-grade-data/2022%20Summer.json';
|
url = 'https://derec4.github.io/ut-grade-data/2022%20Summer.json';
|
||||||
break;
|
break;
|
||||||
case 'sp2022':
|
case 'sp2022':
|
||||||
// Temp, change when other data sets are added
|
|
||||||
url = 'https://derec4.github.io/ut-grade-data/2022%20Spring.json';
|
url = 'https://derec4.github.io/ut-grade-data/2022%20Spring.json';
|
||||||
break;
|
break;
|
||||||
case 'f2021':
|
case 'f2021':
|
||||||
@@ -64,12 +63,16 @@ async function PapaParse(department, num, name, sem) {
|
|||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => { cData = data; });
|
.then(data => { cData = data; });
|
||||||
|
|
||||||
|
if(sem.includes("sum")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
let selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
let selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
||||||
.filter(cData => cData["Course Number"] == num.toString().toUpperCase())
|
.filter(cData => cData["Course Number"] == num.toString().toUpperCase())
|
||||||
.filter(cData => cData["Course Title"].includes(name));
|
.filter(cData => cData["Course Title"].includes(name));
|
||||||
if(selectedClass.length == 0) {
|
if(selectedClass.length == 0) {
|
||||||
// Possible that the class name was typed wrong; try again with just the course number
|
// Possible that the class name was typed wrong; try again with just the course number
|
||||||
console.log("Invalid name; trying again with just the course number");
|
console.log("Invalid name; trying again with just course number and prefix");
|
||||||
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
||||||
.filter(cData => cData["Course Number"] == num.toString().toUpperCase());
|
.filter(cData => cData["Course Number"] == num.toString().toUpperCase());
|
||||||
}
|
}
|
||||||
@@ -105,19 +108,7 @@ async function PapaParse(department, num, name, sem) {
|
|||||||
console.log(gradeDist);
|
console.log(gradeDist);
|
||||||
if(gradeChart) {
|
if(gradeChart) {
|
||||||
gradeChart.config.data = {
|
gradeChart.config.data = {
|
||||||
labels: [
|
labels: labels,
|
||||||
'A',
|
|
||||||
'A-',
|
|
||||||
'B+',
|
|
||||||
'B',
|
|
||||||
'B-',
|
|
||||||
'C+',
|
|
||||||
'C',
|
|
||||||
'C-',
|
|
||||||
'D+',
|
|
||||||
'D',
|
|
||||||
'D-',
|
|
||||||
'F'],
|
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Grade distribution for \"' + selectedClass[0]["Course Title"] +"\"",
|
label: 'Grade distribution for \"' + selectedClass[0]["Course Title"] +"\"",
|
||||||
data: Object.values(gradeDist),
|
data: Object.values(gradeDist),
|
||||||
@@ -138,19 +129,7 @@ function loadChart(gradeDist, courseName) {
|
|||||||
gradeChart = new Chart(ctx, {
|
gradeChart = new Chart(ctx, {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
labels: [
|
labels: labels,
|
||||||
'A',
|
|
||||||
'A-',
|
|
||||||
'B+',
|
|
||||||
'B',
|
|
||||||
'B-',
|
|
||||||
'C+',
|
|
||||||
'C',
|
|
||||||
'C-',
|
|
||||||
'D+',
|
|
||||||
'D',
|
|
||||||
'D-',
|
|
||||||
'F'],
|
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Grade distribution for \"' + courseName + "\"",
|
label: 'Grade distribution for \"' + courseName + "\"",
|
||||||
data: Object.values(gradeDist),
|
data: Object.values(gradeDist),
|
||||||
|
|||||||
Reference in New Issue
Block a user