diff --git a/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx b/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx index 4169bdcd93..1b9e710b44 100644 --- a/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx +++ b/lms/static/scripts/frontend_apps/components/dashboard/AssignmentActivity.tsx @@ -95,15 +95,29 @@ export default function AssignmentActivity() { ]} defaultOrderField="display_name" renderItem={(stats, field) => { - if (['annotations', 'replies'].includes(field)) { - return
{stats[field]}
; - } else if (field === 'last_activity') { - return stats.last_activity - ? formatDateTime(new Date(stats.last_activity)) - : ''; + switch (field) { + case 'annotations': + case 'replies': + return
{stats[field]}
; + case 'last_activity': + return stats.last_activity + ? formatDateTime(new Date(stats.last_activity)) + : ''; + case 'display_name': + return ( + stats.display_name ?? ( + + Unknown + + This student launched the assignment but didn{"'"}t + annotate yet + + + ) + ); + default: + return ''; } - - return stats[field] ?? `Student ${stats.id.substring(0, 10)}`; }} /> diff --git a/lms/static/scripts/frontend_apps/components/dashboard/test/AssignmentActivity-test.js b/lms/static/scripts/frontend_apps/components/dashboard/test/AssignmentActivity-test.js index 68f40301df..df132ed526 100644 --- a/lms/static/scripts/frontend_apps/components/dashboard/test/AssignmentActivity-test.js +++ b/lms/static/scripts/frontend_apps/components/dashboard/test/AssignmentActivity-test.js @@ -128,6 +128,8 @@ describe('AssignmentActivity', () => { fieldName: 'last_activity', expectedValue: formatDateTime(new Date('2024-01-01T10:35:18')), }, + // Render "unknown" field name + { fieldName: 'id', expectedValue: '' }, // Render last_activity when it's null { fieldName: 'last_activity', @@ -137,7 +139,8 @@ describe('AssignmentActivity', () => { // Render display_name when it's null { fieldName: 'display_name', - expectedValue: 'Student e4ca30ee27', + expectedValue: + "UnknownThis student launched the assignment but didn't annotate yet", studentStats: { id: 'e4ca30ee27eda1169d00b83f2a86e3494ffd9b12', display_name: null,