I have developed a method called setRemark which displays a message indicating whether the grade passed or failed
According to the method: Elementary grade = 75 is considered as "passed" College grade = 3 is also considered as "passed"
private getFinalGrade(studentId: number, gradingSections: IGradingSection[], transmutation: ITransmutation) {
let finalGrade: number = 0;
let grades: number[] = [];
let gradingSectionNumber = gradingSections.length;
for (let gradingSection of gradingSections) {
let weightedPercentageGrade = (new StudentGradeComputerService(studentId))
.setAssessment(gradingSection.assessments)
.setTransmutation(transmutation)
.generate()
.getTotalWeightedScore();
grades.push(weightedPercentageGrade);
finalGrade += weightedPercentageGrade;
}
return {grades, finalGrade: finalGrade / gradingSectionNumber};
}
private setRemark(grades: number, removalGrade: number) {
if(removalGrade) {
grades = removalGrade;
}
let passingGrade = (grades < 6) ? 3 : 75;
let condition = (passingGrade == 3) ? (grades <= 3) : (grades >= passingGrade);
console.log(condition)
return (condition && grades != 0) ? "Passed" : "Failed";
}
UPDATED Here is where the setRemark method is being called
private getStudentScheduleBySession(studentRecord): void {
let studentReportData: object[] = [];
let maxGradingSections: number = 1;
studentRecord.forEach((subject) => {
let newData = subject;
let grades = this.getFinalGrade(subject.student_id, subject.schedule.class_record.sections, subject.schedule.class_record.transmutation);
newData["finalGrade"] = grades.finalGrade;
newData["grades"] = grades.grades;
newData["remark"] = this.setRemark(newData["final_grade"], newData["removal_grade"]);
studentReportData.push(newData);
maxGradingSections = (grades.grades.length > maxGradingSections) ? grades.grades.length : maxGradingSections;
})
this.maxGradingSections = maxGradingSections;
this.studentReportData = studentReportData;
}
Even when the grade is 70, it still shows as "passed". There seems to be an issue with my logic that needs fixing.