Skip to content

Commit

Permalink
fix: exam attempts marked as ready to resume should remain resumable (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto authored Nov 1, 2021
1 parent f0eaf4f commit 739dd5e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const ExamStatus = Object.freeze({
VERIFIED: 'verified',
REJECTED: 'rejected',
ERROR: 'error',
READY_TO_RESUME: 'ready_to_resume',
ONBOARDING_MISSING: 'onboarding_missing',
ONBOARDING_PENDING: 'onboarding_pending',
ONBOARDING_FAILED: 'onboarding_failed',
Expand Down
5 changes: 3 additions & 2 deletions src/instructions/Instructions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe('SequenceExamWrapper', () => {
expect(screen.getByText('Error with proctored exam')).toBeInTheDocument();
});

it('Instructions for ready to resume status', () => {
it('Instructions for ready to resume state', () => {
store.getState = () => ({
examState: Factory.build('examState', {
timeIsOver: true,
Expand All @@ -257,7 +257,8 @@ describe('SequenceExamWrapper', () => {
exam: Factory.build('exam', {
type: ExamType.PROCTORED,
attempt: Factory.build('attempt', {
attempt_status: ExamStatus.READY_TO_RESUME,
attempt_status: ExamStatus.ERROR,
attempt_ready_to_resume: true,
}),
}),
}),
Expand Down
10 changes: 7 additions & 3 deletions src/instructions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const Instructions = ({ children }) => {
} = exam || {};
const prerequisitesPassed = prerequisitesData ? prerequisitesData.are_prerequisites_satisifed : true;
let verificationStatus = verification.status || '';
const { verification_url: verificationUrl, attempt_status: attemptStatus } = attempt || {};
const {
verification_url: verificationUrl,
attempt_status: attemptStatus,
attempt_ready_to_resume: attemptReadyToResume,
} = attempt || {};
const [skipProctoring, toggleSkipProctoring] = useState(false);
const toggleSkipProctoredExam = () => toggleSkipProctoring(!skipProctoring);
const expired = shouldRenderExpiredPage(exam);
Expand Down Expand Up @@ -66,6 +70,8 @@ const Instructions = ({ children }) => {
return <SkipProctoredExamInstruction cancelSkipProctoredExam={toggleSkipProctoredExam} />;
case isEmpty(attempt) || !attempt.attempt_id:
return renderEmptyAttemptInstructions();
case attemptReadyToResume:
return <EntranceExamInstructions examType={examType} skipProctoredExam={toggleSkipProctoredExam} />;
case attemptStatus === ExamStatus.CREATED:
return examType === ExamType.PROCTORED && verificationStatus !== VerificationStatus.APPROVED
? <VerificationProctoredExamInstructions status={verificationStatus} verificationUrl={verificationUrl} />
Expand All @@ -92,8 +98,6 @@ const Instructions = ({ children }) => {
return <RejectedInstructions examType={examType} />;
case attemptStatus === ExamStatus.ERROR:
return <ErrorExamInstructions examType={examType} />;
case attemptStatus === ExamStatus.READY_TO_RESUME:
return <EntranceExamInstructions examType={examType} skipProctoredExam={toggleSkipProctoredExam} />;
case examType === ExamType.PROCTORED && IS_ONBOARDING_ERROR(attemptStatus):
return <OnboardingErrorProctoredExamInstructions />;
case attemptStatus === ExamStatus.STARTED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Button } from '@edx/paragon';
import { ExamStatus } from '../../constants';
import ExamStateContext from '../../context';
import SkipProctoredExamButton from './SkipProctoredExamButton';

Expand All @@ -14,7 +13,7 @@ const EntranceProctoredExamInstructions = ({ skipProctoredExam }) => {

return (
<>
{ attempt.attempt_status === ExamStatus.READY_TO_RESUME ? (
{ attempt.attempt_ready_to_resume ? (
<div>
<div className="h3" data-testid="proctored-exam-instructions-title">
<FormattedMessage
Expand Down

0 comments on commit 739dd5e

Please sign in to comment.