Skip to content

Commit 9c18203

Browse files
authored
Fix error when grading assessment where student has empty name (#3347)
1 parent aca89fb commit 9c18203

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/pages/academy/grading/subcomponents/GradingWorkspace.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ type Props = {
5353
questionId: number;
5454
};
5555

56+
const getDisplayName = (
57+
studentName?: string | null,
58+
team?: {
59+
username: any;
60+
name: string;
61+
id: number;
62+
}[]
63+
): string[] => {
64+
if (studentName) return [studentName];
65+
if (team != null) return team.map(member => member.name);
66+
67+
return [''];
68+
};
69+
5670
const GradingWorkspace: React.FC<Props> = props => {
5771
const navigate = useNavigate();
5872
const { selectedTab, setSelectedTab } = useSideContent(
@@ -294,11 +308,10 @@ const GradingWorkspace: React.FC<Props> = props => {
294308
initialXp={grading!.answers[questionId].grade.xp}
295309
xpAdjustment={grading!.answers[questionId].grade.xpAdjustment}
296310
maxXp={grading!.answers[questionId].question.maxXp}
297-
studentNames={
298-
grading!.answers[questionId].student.name
299-
? [grading!.answers[questionId].student.name]
300-
: grading!.answers[questionId].team!.map(member => member.name)
301-
}
311+
studentNames={getDisplayName(
312+
grading!.answers[questionId].student.name,
313+
grading!.answers[questionId].team
314+
)}
302315
studentUsernames={
303316
grading!.answers[questionId].student.username
304317
? [grading!.answers[questionId].student.username]

0 commit comments

Comments
 (0)