From 46da7f8472c74c346277bba74f3612bcba09f197 Mon Sep 17 00:00:00 2001 From: KristinAoki Date: Wed, 18 Dec 2024 16:17:28 -0500 Subject: [PATCH] fix: tooltip message --- .../grade-summary/GradeSummaryTableFooter.jsx | 19 ++++++++++++++++++- .../progress-tab/grades/messages.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/course-home/progress-tab/grades/grade-summary/GradeSummaryTableFooter.jsx b/src/course-home/progress-tab/grades/grade-summary/GradeSummaryTableFooter.jsx index a99c278aa9..19299a4ef8 100644 --- a/src/course-home/progress-tab/grades/grade-summary/GradeSummaryTableFooter.jsx +++ b/src/course-home/progress-tab/grades/grade-summary/GradeSummaryTableFooter.jsx @@ -1,8 +1,10 @@ +import { useContext } from 'react'; import { useSelector } from 'react-redux'; import { getLocale, isRtl, useIntl } from '@edx/frontend-platform/i18n'; import { DataTable, + DataTableContext, Icon, OverlayTrigger, Stack, @@ -15,6 +17,18 @@ import messages from '../messages'; const GradeSummaryTableFooter = () => { const intl = useIntl(); + + const { data } = useContext(DataTableContext); + + const rawGrade = data.reduce( + (grade, currentValue) => { + const { weightedGrade } = currentValue.weightedGrade; + const percent = weightedGrade.replace(/%/g, '').trim(); + return grade + parseFloat(percent); + }, + 0, + ).toFixed(2); + const { courseId, } = useSelector(state => state.courseHome); @@ -42,7 +56,10 @@ const GradeSummaryTableFooter = () => { placement="bottom" overlay={( - {intl.formatMessage(messages.weightedGradeSummaryTooltip)} + {intl.formatMessage( + messages.weightedGradeSummaryTooltip, + { roundedGrade: totalGrade, rawGrade }, + )} )} > diff --git a/src/course-home/progress-tab/grades/messages.ts b/src/course-home/progress-tab/grades/messages.ts index 5b19e0b41c..24475b98fd 100644 --- a/src/course-home/progress-tab/grades/messages.ts +++ b/src/course-home/progress-tab/grades/messages.ts @@ -205,7 +205,7 @@ const messages = defineMessages({ }, weightedGradeSummaryTooltip: { id: 'progress.weightedGradeSummary', - defaultMessage: 'The weighted grade for individual assignment types is raw and the weighted grade summary is rounded.', + defaultMessage: 'Your raw weighted grade summary is {rawGrade} and rounds to {roundedGrade}.', description: 'Tooltip content that explains the rounding of the summary versus individual assignments', }, });