Skip to content

Commit

Permalink
Handle canvas_submission_max_attempts error in frontend
Browse files Browse the repository at this point in the history
Add a custom error message for this scenario.

See https://hypothes-is.slack.com/archives/C1MA4E9B9/p1719220175035739 for
discussion around the message.
  • Loading branch information
robertknight committed Jun 25, 2024
1 parent 4c58c04 commit 04f4434
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function canDismissError(e: ErrorState) {
return [
'error-reporting-submission',
'canvas_submission_course_not_available',
'canvas_submission_max_attempts',
].includes(e);
}

Expand Down
22 changes: 22 additions & 0 deletions lms/static/scripts/frontend_apps/components/LaunchErrorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,28 @@ export default function LaunchErrorDialog({
</ErrorModal>
);

case 'canvas_submission_max_attempts':
return (
<ErrorModal
{...defaultProps}
onRetry={undefined}
title="Grading submission failed"
>
<p>
Your annotation was saved, but Hypothesis could not record a new
submission for grading. Hypothesis has already recorded the maximum
number of allowed submissions for this assignment.
</p>
<p>
See{' '}
<ExternalLink href="https://web.hypothes.is/help/grading-student-annotations-in-canvas/#when-does-canvas-report-a-student-hypothesis-submission-for-grading">
this article
</ExternalLink>{' '}
for an explanation of when Hypothesis creates submissions.
</p>
</ErrorModal>
);

case 'error-reporting-submission':
return (
<ErrorModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ describe('LaunchErrorDialog', () => {
expectedText: 'This may be because the course has ended',
expectedTitle: 'Grading submission failed',
},
{
errorState: 'canvas_submission_max_attempts',
expectedText: 'maximum number of allowed submissions',
expectedTitle: 'Grading submission failed',
},
].forEach(
({
errorState,
Expand Down
2 changes: 2 additions & 0 deletions lms/static/scripts/frontend_apps/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type LTILaunchServerErrorCode =
| 'canvas_studio_media_not_found'
| 'canvas_studio_admin_token_refresh_failed'
| 'canvas_submission_course_not_available'
| 'canvas_submission_max_attempts'
| 'd2l_file_not_found_in_course_instructor'
| 'd2l_file_not_found_in_course_student'
| 'd2l_group_set_empty'
Expand Down Expand Up @@ -173,6 +174,7 @@ export function isLTILaunchServerError(error: ErrorLike): error is APIError {
'canvas_studio_media_not_found',
'canvas_studio_admin_token_refresh_failed',
'canvas_submission_course_not_available',
'canvas_submission_max_attempts',
'vitalsource_user_not_found',
'vitalsource_no_book_license',
'moodle_page_not_found_in_course',
Expand Down

0 comments on commit 04f4434

Please sign in to comment.