Skip to content

Commit ad9166f

Browse files
committed
feat: inform learners about hidden scores
1 parent f01d40b commit ad9166f

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

src/course-home/progress-tab/grades/detailed-grades/DetailedGradesTable.jsx

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const DetailedGradesTable = ({ intl }) => {
2020
sectionScores,
2121
} = useModel('progress', courseId);
2222

23+
const { course, isMasquerading } = useModel('courseHomeMeta', courseId);
24+
const isStaff = course?.isStaff;
25+
2326
const isLocaleRtl = isRtl(getLocale());
2427
const showUngradedAssignments = (
2528
getConfig().SHOW_UNGRADED_ASSIGNMENT_PROGRESS === 'true'
@@ -30,7 +33,6 @@ const DetailedGradesTable = ({ intl }) => {
3033
const subsectionScores = chapter.subsections.filter(
3134
(subsection) => !!(
3235
(showUngradedAssignments || subsection.hasGradedAssignment)
33-
&& subsection.showGrades
3436
&& (subsection.numPointsPossible > 0 || subsection.numPointsEarned > 0)
3537
),
3638
);
@@ -39,10 +41,34 @@ const DetailedGradesTable = ({ intl }) => {
3941
return null;
4042
}
4143

42-
const detailedGradesData = subsectionScores.map((subsection) => ({
43-
subsectionTitle: <SubsectionTitleCell subsection={subsection} />,
44-
score: <span className={subsection.learnerHasAccess ? '' : 'greyed-out'}>{subsection.numPointsEarned}{isLocaleRtl ? '\\' : '/'}{subsection.numPointsPossible}</span>,
45-
}));
44+
const detailedGradesData = subsectionScores.map((subsection) => {
45+
let scoreDisplay;
46+
47+
if (subsection.showCorrectness === 'never') {
48+
scoreDisplay = 'This score is hidden.';
49+
} else if (
50+
!isStaff && !isMasquerading
51+
&& (subsection.showCorrectness === 'past_due' || subsection.showCorrectness === 'never_but_include_grade')
52+
&& Date.parse(subsection.due) > Date.now()
53+
) {
54+
const formattedDate = intl.formatDate(new Date(subsection.due), {
55+
year: 'numeric',
56+
month: 'short',
57+
day: 'numeric',
58+
hour: 'numeric',
59+
minute: 'numeric',
60+
timeZoneName: 'short',
61+
});
62+
scoreDisplay = `Score will appear at ${formattedDate}`;
63+
} else {
64+
scoreDisplay = `${subsection.numPointsEarned}${isLocaleRtl ? '\\' : '/'}${subsection.numPointsPossible}`;
65+
}
66+
67+
return {
68+
subsectionTitle: <SubsectionTitleCell subsection={subsection} />,
69+
score: <span className={subsection.learnerHasAccess ? '' : 'greyed-out'}>{scoreDisplay}</span>,
70+
};
71+
});
4672

4773
return (
4874
<div className="my-3" key={`${chapter.displayName}-grades-table`}>

src/course-home/progress-tab/grades/detailed-grades/SubsectionTitleCell.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ const SubsectionTitleCell = ({ intl, subsection }) => {
4545
return (
4646
<Collapsible.Advanced>
4747
<Row className="w-100 m-0">
48-
<Collapsible.Trigger
49-
className="mr-1 position-absolute"
50-
aria-label={intl.formatMessage(messages.problemScoreToggleAltText, { subsectionTitle: displayName })}
51-
tabIndex={gradesFeatureIsFullyLocked ? '-1' : '0'}
52-
>
53-
<Collapsible.Visible whenClosed><Icon src={ArrowDropDown} /></Collapsible.Visible>
54-
<Collapsible.Visible whenOpen><Icon src={ArrowDropUp} /></Collapsible.Visible>
55-
</Collapsible.Trigger>
48+
{problemScores && problemScores.length > 0 && (
49+
<Collapsible.Trigger
50+
className="mr-1 position-absolute"
51+
aria-label={intl.formatMessage(messages.problemScoreToggleAltText, { subsectionTitle: displayName })}
52+
tabIndex={gradesFeatureIsFullyLocked ? '-1' : '0'}
53+
>
54+
<Collapsible.Visible whenClosed><Icon src={ArrowDropDown} /></Collapsible.Visible>
55+
<Collapsible.Visible whenOpen><Icon src={ArrowDropUp} /></Collapsible.Visible>
56+
</Collapsible.Trigger>
57+
)}
5658
<span className="small d-inline ml-4 pl-1">
5759
{gradesFeatureIsFullyLocked || subsection.learnerHasAccess ? ''
5860
: (

0 commit comments

Comments
 (0)