Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grade calculation fix #222

Merged
merged 4 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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