Skip to content

Commit 4e609e0

Browse files
authored
feat: improve error message for proctored exam settings (openedx#1300)
1 parent 8d49f2e commit 4e609e0

File tree

3 files changed

+67
-15
lines changed

3 files changed

+67
-15
lines changed

plugins/course-apps/proctoring/Settings.jsx

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ const ProctoringSettings = ({ intl, onClose }) => {
148148
setSaveSuccess(true);
149149
setSaveError(false);
150150
setSubmissionInProgress(false);
151-
}).catch(() => {
151+
}).catch((error) => {
152152
setSaveSuccess(false);
153-
setSaveError(true);
153+
setSaveError(error);
154154
setSubmissionInProgress(false);
155155
});
156156
}
@@ -460,21 +460,32 @@ const ProctoringSettings = ({ intl, onClose }) => {
460460
}
461461

462462
function renderSaveError() {
463-
return (
464-
<Alert
465-
variant="danger"
466-
data-testid="saveError"
467-
tabIndex="-1"
468-
ref={saveStatusAlertRef}
469-
onClose={() => setSaveError(false)}
470-
dismissible
471-
>
463+
let errorMessage = (
464+
<FormattedMessage
465+
id="authoring.proctoring.alert.error"
466+
defaultMessage={`
467+
We encountered a technical error while trying to save proctored exam settings.
468+
This might be a temporary issue, so please try again in a few minutes.
469+
If the problem persists, please go to the {support_link} for help.
470+
`}
471+
values={{
472+
support_link: (
473+
<Alert.Link href={getConfig().SUPPORT_URL}>
474+
{intl.formatMessage(messages['authoring.proctoring.support.text'])}
475+
</Alert.Link>
476+
),
477+
}}
478+
/>
479+
);
480+
481+
if (saveError?.response.status === 403) {
482+
errorMessage = (
472483
<FormattedMessage
473-
id="authoring.examsettings.alert.error"
484+
id="authoring.proctoring.alert.error.forbidden"
474485
defaultMessage={`
475-
We encountered a technical error while trying to save proctored exam settings.
476-
This might be a temporary issue, so please try again in a few minutes.
477-
If the problem persists, please go to the {support_link} for help.
486+
You do not have permission to edit proctored exam settings for this course.
487+
If you are a course team member and this problem persists,
488+
please go to the {support_link} for help.
478489
`}
479490
values={{
480491
support_link: (
@@ -484,6 +495,19 @@ const ProctoringSettings = ({ intl, onClose }) => {
484495
),
485496
}}
486497
/>
498+
);
499+
}
500+
501+
return (
502+
<Alert
503+
variant="danger"
504+
data-testid="saveError"
505+
tabIndex="-1"
506+
ref={saveStatusAlertRef}
507+
onClose={() => setSaveError(false)}
508+
dismissible
509+
>
510+
{errorMessage}
487511
</Alert>
488512
);
489513
}

plugins/course-apps/proctoring/Settings.test.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,24 @@ describe('ProctoredExamSettings', () => {
814814
});
815815
});
816816

817+
test('Exams API permission error', async () => {
818+
axiosMock.onPatch(
819+
`${ExamsApiService.getExamsBaseUrl()}/api/v1/configs/course_id/${defaultProps.courseId}`,
820+
).reply(403, 'error');
821+
822+
await act(async () => render(intlWrapper(<IntlProctoredExamSettings {...defaultProps} />)));
823+
const submitButton = screen.getByTestId('submissionButton');
824+
fireEvent.click(submitButton);
825+
expect(axiosMock.history.post.length).toBe(1);
826+
await waitFor(() => {
827+
const errorAlert = screen.getByTestId('saveError');
828+
expect(errorAlert.textContent).toEqual(
829+
expect.stringContaining('You do not have permission to edit proctored exam settings for this course'),
830+
);
831+
expect(document.activeElement).toEqual(errorAlert);
832+
});
833+
});
834+
817835
it('Manages focus correctly after different save statuses', async () => {
818836
// first make a call that will cause a save error
819837
axiosMock.onPost(

plugins/course-apps/proctoring/messages.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { defineMessages } from '@edx/frontend-platform/i18n';
22

33
const messages = defineMessages({
4+
'authoring.proctoring.alert.error': {
5+
id: 'authoring.proctoring.alert.error',
6+
defaultMessage: 'We encountered a technical error while trying to save proctored exam settings. This might be a temporary issue, so please try again in a few minutes. If the problem persists, please go to the {support_link} for help.',
7+
description: 'Alert message for proctoring settings save error.',
8+
},
9+
'authoring.proctoring.alert.forbidden': {
10+
id: 'authoring.proctoring.alert.forbidden',
11+
defaultMessage: 'You do not have permission to edit proctored exam settings for this course. If you are a course team member and this problem persists, please go to the {support_link} for help.',
12+
description: 'Alert message for proctoring settings permission error.',
13+
},
414
'authoring.proctoring.no': {
515
id: 'authoring.proctoring.no',
616
defaultMessage: 'No',

0 commit comments

Comments
 (0)