From a22759aea4caf39601b681749fdd734587bf69fc Mon Sep 17 00:00:00 2001 From: Piotr Surowiec Date: Mon, 23 Sep 2024 20:39:15 +0200 Subject: [PATCH] fix: increase subsection grades rounding precision (#1397) 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. (cherry picked from commit e4a010504251b318593faf380b6c3cc73da7dfdb) --- 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 };