Skip to content

Commit d9856a0

Browse files
author
Suhas Hariharan
authored
Merge pull request #222 from gary-kim/grade-calculation-fix
Grade calculation fix
2 parents 28f5440 + 1d394c7 commit d9856a0

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/js/components/CumulativeGPA.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ export default {
128128
}
129129
130130
this.currently = CURRENTLY.CALCULATING;
131-
const gpa = await this.calculate_cumulative_gpa(this.courses, this.currentTerm, this.secondSemester).catch(() => null);
131+
const gpa = await this.calculate_cumulative_gpa(this.courses, this.currentTerm, this.secondSemester).catch((err) => {
132+
console.log("Error in cumulative GPA calculation " + err);
133+
});
132134
if (gpa) {
133135
this.gpa = gpa.toFixed(2);
134136
this.currently = CURRENTLY.DONE;
@@ -149,7 +151,12 @@ export default {
149151
.then(data => {
150152
const el = document.createElement("html");
151153
el.innerHTML = data;
152-
const current_term_history = el.getElementsByClassName("selected")[0].textContent.split(" - ")[0];
154+
let current_term_history = el.getElementsByClassName("selected");
155+
if (current_term_history.length !== 0) {
156+
current_term_history = current_term_history[0].textContent.split(" - ")[0];
157+
} else {
158+
current_term_history = undefined;
159+
}
153160
const tabs = el.getElementsByClassName("tabs")[0].getElementsByTagName("li");
154161
// Iterate until the end of tabs or until no longer at a high school semester
155162
for (let i = 0; i < tabs.length && /HS$/.test(tabs[i].innerText); i++) {
@@ -190,7 +197,6 @@ export default {
190197
}));
191198
}
192199
// Calculates cumulative GPA based on credit hours per semester and gpa for each semester.
193-
194200
const cumulative_gpa = Promise.all(fetches).then(function () {
195201
let include_current_semester = false;
196202
if (current_courses.length !== 0) {

src/js/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async function getSavedGrades (username) {
187187
const courses = [];
188188
const course_list = (await browser.storage.local.get("USERDATA_" + username))["USERDATA_" + username] || [];
189189
course_list.forEach(course => {
190-
courses.push(new Course(course.name, course.link, course_list.grade, course_list.finalPercent, course_list.assignments));
190+
courses.push(new Course(course.name, course.link, course.grade, course.finalPercent, course.assignments));
191191
});
192192
return courses;
193193
}

src/js/saspowerschoolff.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ function main_page () {
9696
}
9797
curr += parseInt(e.getAttribute('colspan')) || 1;
9898
});
99+
second_semester = false;
100+
for (let t = 0; t < $grade_rows.length; t++) {
101+
if (gradeToGPA($grade_rows.eq(t).find('td').get(s2col)) !== -1) {
102+
second_semester = true;
103+
}
104+
}
99105
}
100106
for (let i = 0; i < $grade_rows.length; i++) {
101107
let $course;

0 commit comments

Comments
 (0)