Skip to content

Commit

Permalink
Merge pull request #222 from gary-kim/grade-calculation-fix
Browse files Browse the repository at this point in the history
Grade calculation fix
  • Loading branch information
Suhas Hariharan authored Sep 3, 2020
2 parents 28f5440 + 1d394c7 commit d9856a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/js/components/CumulativeGPA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export default {
}
this.currently = CURRENTLY.CALCULATING;
const gpa = await this.calculate_cumulative_gpa(this.courses, this.currentTerm, this.secondSemester).catch(() => null);
const gpa = await this.calculate_cumulative_gpa(this.courses, this.currentTerm, this.secondSemester).catch((err) => {
console.log("Error in cumulative GPA calculation " + err);
});
if (gpa) {
this.gpa = gpa.toFixed(2);
this.currently = CURRENTLY.DONE;
Expand All @@ -149,7 +151,12 @@ export default {
.then(data => {
const el = document.createElement("html");
el.innerHTML = data;
const current_term_history = el.getElementsByClassName("selected")[0].textContent.split(" - ")[0];
let current_term_history = el.getElementsByClassName("selected");
if (current_term_history.length !== 0) {
current_term_history = current_term_history[0].textContent.split(" - ")[0];
} else {
current_term_history = undefined;
}
const tabs = el.getElementsByClassName("tabs")[0].getElementsByTagName("li");
// Iterate until the end of tabs or until no longer at a high school semester
for (let i = 0; i < tabs.length && /HS$/.test(tabs[i].innerText); i++) {
Expand Down Expand Up @@ -190,7 +197,6 @@ export default {
}));
}
// Calculates cumulative GPA based on credit hours per semester and gpa for each semester.
const cumulative_gpa = Promise.all(fetches).then(function () {
let include_current_semester = false;
if (current_courses.length !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function getSavedGrades (username) {
const courses = [];
const course_list = (await browser.storage.local.get("USERDATA_" + username))["USERDATA_" + username] || [];
course_list.forEach(course => {
courses.push(new Course(course.name, course.link, course_list.grade, course_list.finalPercent, course_list.assignments));
courses.push(new Course(course.name, course.link, course.grade, course.finalPercent, course.assignments));
});
return courses;
}
Expand Down
6 changes: 6 additions & 0 deletions src/js/saspowerschoolff.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ function main_page () {
}
curr += parseInt(e.getAttribute('colspan')) || 1;
});
second_semester = false;
for (let t = 0; t < $grade_rows.length; t++) {
if (gradeToGPA($grade_rows.eq(t).find('td').get(s2col)) !== -1) {
second_semester = true;
}
}
}
for (let i = 0; i < $grade_rows.length; i++) {
let $course;
Expand Down

0 comments on commit d9856a0

Please sign in to comment.