[F] Fix term 1 displaying term 2 grades issue

This commit is contained in:
Hykilpikonna
2019-11-07 22:00:08 -05:00
parent 2f30e67671
commit adfebc8c44
+10 -2
View File
@@ -130,14 +130,18 @@ export default class Course
return this.computed.termAssignments[timeCode]; return this.computed.termAssignments[timeCode];
} }
// TODO: Optimize this
private letterGradeComputed = false;
/** /**
* Get letter grade * Get letter grade
*/ */
get letterGrade(): string get letterGrade(): string
{ {
// Cached // Cached
if (this.rawLetterGrade != undefined) if (this.rawLetterGrade != undefined && this.letterGradeComputed)
return this.rawLetterGrade; return this.rawLetterGrade;
this.letterGradeComputed = true;
// Get scale // Get scale
let scale = GPAUtils.findScale(this.numericGrade); let scale = GPAUtils.findScale(this.numericGrade);
@@ -149,14 +153,17 @@ export default class Course
return this.rawLetterGrade = scale.letter; return this.rawLetterGrade = scale.letter;
} }
private numericGradeComputed = false;
/** /**
* Get numeric grade * Get numeric grade
*/ */
get numericGrade(): number get numericGrade(): number
{ {
// Cached // Cached
if (this.rawNumericGrade != undefined) if (this.rawNumericGrade != undefined && this.numericGradeComputed)
return this.rawNumericGrade; return this.rawNumericGrade;
this.numericGradeComputed = true;
// Calculate // Calculate
if (this.grading.method == 'PERCENT_TYPE') if (this.grading.method == 'PERCENT_TYPE')
@@ -168,6 +175,7 @@ export default class Course
return this.rawNumericGrade = GPAUtils.getTotalMeanAverage(this.assignments); return this.rawNumericGrade = GPAUtils.getTotalMeanAverage(this.assignments);
} }
// Error
return -1; return -1;
} }
} }