From 12fffeacc51136b5841584fb94c0002e20af2c5b Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Mon, 27 May 2024 01:50:31 +0200 Subject: [PATCH] fix: increase subsection grades rounding precision We used two decimal digits to match the experience from the edx-platform. However, https://github.com/openedx/edx-platform/pull/27788 increased the precision to reduce the impact of double rounding. --- src/course-home/data/__snapshots__/redux.test.js.snap | 2 +- src/course-home/data/api.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/course-home/data/__snapshots__/redux.test.js.snap b/src/course-home/data/__snapshots__/redux.test.js.snap index 99605c5176..e2ef6ffdb1 100644 --- a/src/course-home/data/__snapshots__/redux.test.js.snap +++ b/src/course-home/data/__snapshots__/redux.test.js.snap @@ -782,7 +782,7 @@ Object { "gradingPolicy": Object { "assignmentPolicies": Array [ Object { - "averageGrade": "1.00", + "averageGrade": "1.0000", "numDroppable": 1, "shortLabel": "HW", "type": "Homework", diff --git a/src/course-home/data/api.js b/src/course-home/data/api.js index f963f715c8..22b6738df4 100644 --- a/src/course-home/data/api.js +++ b/src/course-home/data/api.js @@ -18,7 +18,7 @@ const calculateAssignmentTypeGrades = (points, assignmentWeight, numDroppable) = // Calculate the average grade for the assignment and round it. This rounding is not ideal and does not accurately // reflect what a learner's grade would be, however, we must have parity with the current grading behavior that // exists in edx-platform. - averageGrade = (points.reduce((a, b) => a + b, 0) / points.length).toFixed(2); + averageGrade = (points.reduce((a, b) => a + b, 0) / points.length).toFixed(4); weightedGrade = averageGrade * assignmentWeight; } return { averageGrade, weightedGrade };