We got this
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<title>UT Grade Viewer</title>
|
||||
<link rel="icon" href="https://derec4.github.io/ut-grade-distribution-viewer/data/icon.png">
|
||||
<link rel="icon" href="https://github.com/DereC4/ut-grade-distribution-viewer/blob/master/data/icon.png?raw=true">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js">
|
||||
@@ -48,8 +48,10 @@
|
||||
<input type="text" id="courseField" name="fname" required><br><br>
|
||||
<label for="courseNum">Course Number (Ex: "307"):</label>
|
||||
<input type="text" id="courseNum" name="fname" required><br><br>
|
||||
<label for="courseName">Course Name (Optional, useful if classes have the same number like UGS 303):</label>
|
||||
<label for="courseName">Course Name (Optional, useful if classes have the same number Ex: UGS 303):</label>
|
||||
<input type="text" id="courseName" name="fname"><br><br>
|
||||
<label for="sectionNum">Section Number (Optional, can be used alone)</label>
|
||||
<input type="text" id="sectionNum" name="fname" required><br><br>
|
||||
<!-- <label for="courseInstructor">Instructor (Optional):</label>
|
||||
<input type="text" id="courseInstructor" name="fname"><br><br> -->
|
||||
<button type="button" id="subBut">Submit</button><br><br>
|
||||
|
||||
@@ -54,7 +54,7 @@ footer {
|
||||
border: 3px solid #f1f1f1;
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
font-weight: 600;
|
||||
font-weight: 400;
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
|
||||
62
docs/main.js
62
docs/main.js
@@ -14,34 +14,37 @@ const gradeLabels = ["A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-
|
||||
Parse the input form and class data
|
||||
*/
|
||||
async function parseName() {
|
||||
let fiveDigit = document.getElementById('sectionNum').value;
|
||||
let className = document.getElementById('courseName').value.toUpperCase();
|
||||
let classNum = document.getElementById('courseNum').value;
|
||||
let department = document.getElementById('courseField').value.trim().toUpperCase();
|
||||
let semester = document.getElementById('semester').value;
|
||||
let departments = '';
|
||||
await fetch('https://derec4.github.io/ut-grade-data/2022prefixes.json')
|
||||
.then(res => res.json())
|
||||
.then(data => { departments = data; });
|
||||
if(!className && !classNum && !department) {
|
||||
alert("At least fill out the form...");
|
||||
return;
|
||||
if(!fiveDigit) {
|
||||
await fetch('https://derec4.github.io/ut-grade-data/2022prefixes.json')
|
||||
.then(res => res.json())
|
||||
.then(data => { departments = data; });
|
||||
if(!className && !classNum && !department) {
|
||||
alert("At least fill out the form...");
|
||||
return;
|
||||
}
|
||||
if(!department || !classNum) {
|
||||
alert("Missing fields")
|
||||
return;
|
||||
}
|
||||
if(!departments.includes(department)) {
|
||||
alert("Invalid Department");
|
||||
return;
|
||||
}
|
||||
console.log(department, classNum.toString(), className.trim(), semester);
|
||||
}
|
||||
if(!department || !classNum) {
|
||||
alert("Missing fields")
|
||||
return;
|
||||
}
|
||||
if(!departments.includes(department)) {
|
||||
alert("Invalid Department");
|
||||
return;
|
||||
}
|
||||
console.log(department, classNum.toString(), className.trim(), semester);
|
||||
await PapaParse(department, classNum.toString(), className.trim(), semester);
|
||||
await PapaParse(department, classNum.toString(), className.trim(), semester, fiveDigit);
|
||||
}
|
||||
|
||||
/*
|
||||
Fetch the necessary database depending on semester and filter based on the input data
|
||||
*/
|
||||
async function PapaParse(department, num, name, sem) {
|
||||
async function PapaParse(department, num, name, sem, unique) {
|
||||
let cData = '';
|
||||
let url = '';
|
||||
switch (sem) {
|
||||
@@ -65,22 +68,25 @@ async function PapaParse(department, num, name, sem) {
|
||||
await fetch(url)
|
||||
.then(res => res.json())
|
||||
.then(data => { cData = data; });
|
||||
|
||||
let selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
||||
.filter(cData => cData["Course Number"] == num.toString().toUpperCase())
|
||||
.filter(cData => cData["Course Title"].includes(name));
|
||||
if(selectedClass.length == 0) {
|
||||
// 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");
|
||||
let selectedClass = '';
|
||||
if(unique) {
|
||||
selectedClass = cData.filter(cData => cData['Section Number'] == unique);
|
||||
} else {
|
||||
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));
|
||||
if(selectedClass.length == 0) {
|
||||
// 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");
|
||||
selectedClass = cData.filter(cData => cData["Course Prefix"].includes(department))
|
||||
.filter(cData => cData["Course Number"] == num.toString().toUpperCase());
|
||||
}
|
||||
}
|
||||
if(selectedClass.length == 0) {
|
||||
// Still can't find anything? Just exit without making a chart and alert that nothing could be found
|
||||
alert("No data found. Try again :(");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
console.log(selectedClass);
|
||||
|
||||
let gradeDist = {
|
||||
|
||||
Reference in New Issue
Block a user