Skip to content

Commit

Permalink
fix: accurate gpa calculations
Browse files Browse the repository at this point in the history
moved rounding the gpa to frontend instead of backend
  • Loading branch information
rithask committed May 16, 2024
1 parent 7940a9b commit 3fa0136
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const calculateSgpa = (result, credits) => {
sgpa += getGradePoint(course.grade) * course.credit
})
sgpa = (sgpa / credits)
sgpa = Math.round((sgpa + Number.EPSILON) * 100) / 100
// sgpa = Math.round((sgpa + Number.EPSILON) * 100) / 100

return sgpa
}
Expand All @@ -144,7 +144,7 @@ const calculateCgpa = (semesters) => {
cgpa += sem.sgpa * sem.allotedCredits
})
cgpa = (cgpa / total_credits)
cgpa = Math.round((cgpa + Number.EPSILON) * 100) / 100
// cgpa = Math.round((cgpa + Number.EPSILON) * 100) / 100

return cgpa
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ResultTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ResultTable = ({ result, updateSemester }) => {
<h1>{result.semester}</h1>
{!result.completed && <button onClick={() => updateSemester(result.semester, result.lastExamDefId || result.examDefId)}>Update</button>}
</div>
<p>SGPA: {result.sgpa}</p>
<p>SGPA: {result.sgpa.toFixed(2)}</p>
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Table = ({ data, updateSemester }) => {
</tr>
<tr>
<td>CGPA</td>
<td style={{ color: personalDetails.cgpa >= 7.5 ? "green" : "red" }}>{personalDetails.cgpa}</td>
<td style={{ color: personalDetails.cgpa >= 7.5 ? "green" : "red" }}>{personalDetails.cgpa.toFixed(2)}</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 3fa0136

Please sign in to comment.