Skip to content

Commit 21efb43

Browse files
author
Suhas Hariharan
authored
Merge pull request #242 from sas-fossdev/cumulative-fix
Cumulative gpa fix
2 parents e90879d + 707370a commit 21efb43

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/js/components/CumulativeGPA.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default {
138138
this.currently = CURRENTLY.ERROR;
139139
}
140140
},
141-
calculate_cumulative_gpa (current_courses, current_term, current_semester) {
141+
calculate_cumulative_gpa (current_courses, current_term, is_second_semester) {
142142
const list_of_gpas = [];
143143
const all_courses = [];
144144
const credit_hour_list = [];
@@ -198,20 +198,27 @@ export default {
198198
}
199199
// Calculates cumulative GPA based on credit hours per semester and gpa for each semester.
200200
const cumulative_gpa = Promise.all(fetches).then(function () {
201-
let include_current_semester = false;
202-
if (current_courses.length !== 0) {
203-
for (let i = 0; i < current_courses.length; i++) {
204-
if (new URL(current_courses[i].link).searchParams.get("begdate")) {
205-
include_current_semester = true;
206-
}
207-
}
201+
let include_current_semester;
202+
let current_semester;
203+
if (is_second_semester) {
204+
current_semester = "S2";
205+
} else {
206+
current_semester = "S1";
207+
}
208+
if (current_term === current_semester) {
209+
include_current_semester = false;
210+
} else {
211+
include_current_semester = true;
208212
}
209213
// Handles edge case where grade history page is updated before semester end, removes the old value and counts the latest version of the current semester.
214+
// Removed as it seems to be causing other issues with calculating cumulative GPA, this can be reworked if necessary, but it is a rare case as it only occured when SAS implemented a grade freeze due to COVID resulting in grade history being updated prematurely.
215+
/* temporarily
210216
if (current_term_history === current_term && include_current_semester && current_term_grades.length === 2 && current_semester) {
211217
all_courses.splice(all_courses.indexOf(current_term_grades[1]), 1);
212218
} else if (current_term_history === current_term && include_current_semester && current_term_grades.length === 1 && current_semester === false) {
213219
all_courses.splice(all_courses.indexOf(current_term_grades[0]), 1);
214220
}
221+
*/
215222
216223
if (include_current_semester) {
217224
all_courses.push(current_courses);

0 commit comments

Comments
 (0)