Skip to content

Commit 2ee2564

Browse files
author
Suhas Hariharan
committed
fixed cumulative gpa calculation and regular gpa calculation
Signed-off-by: Suhas Hariharan <[email protected]>
1 parent d17698b commit 2ee2564

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/js/components/CumulativeGPA.vue

Lines changed: 12 additions & 4 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,13 @@ 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+
}
158+
else {
159+
current_term_history=undefined;
160+
}
153161
const tabs = el.getElementsByClassName("tabs")[0].getElementsByTagName("li");
154162
// Iterate until the end of tabs or until no longer at a high school semester
155163
for (let i = 0; i < tabs.length && /HS$/.test(tabs[i].innerText); i++) {
@@ -190,7 +198,7 @@ export default {
190198
}));
191199
}
192200
// Calculates cumulative GPA based on credit hours per semester and gpa for each semester.
193-
201+
console.log("got this far in calculation");
194202
const cumulative_gpa = Promise.all(fetches).then(function () {
195203
let include_current_semester = false;
196204
if (current_courses.length !== 0) {
@@ -206,7 +214,7 @@ export default {
206214
} else if (current_term_history === current_term && include_current_semester && current_term_grades.length === 1 && current_semester === false) {
207215
all_courses.splice(all_courses.indexOf(current_term_grades[0]), 1);
208216
}
209-
217+
210218
if (include_current_semester) {
211219
all_courses.push(current_courses);
212220
}

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)