Skip to content

Commit

Permalink
fix: tooltip message
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki committed Dec 18, 2024
1 parent ae99478 commit 46da7f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -42,7 +56,10 @@ const GradeSummaryTableFooter = () => {
placement="bottom"
overlay={(
<Tooltip>
{intl.formatMessage(messages.weightedGradeSummaryTooltip)}
{intl.formatMessage(
messages.weightedGradeSummaryTooltip,
{ roundedGrade: totalGrade, rawGrade },
)}
</Tooltip>
)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/course-home/progress-tab/grades/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
});
Expand Down

0 comments on commit 46da7f8

Please sign in to comment.