Skip to content

Commit

Permalink
feat: don't show IDV interstitial if IDV is turned off for the course (
Browse files Browse the repository at this point in the history
  • Loading branch information
bseverino authored Nov 8, 2021
1 parent 739dd5e commit 0a4d286
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@edx/frontend-lib-special-exams",
"version": "1.13.0",
"version": "1.14.0",
"description": "Special exams lib",
"main": "dist/index.js",
"release": {
Expand Down
9 changes: 7 additions & 2 deletions src/exam/Exam.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ExamStatus, ExamType } from '../constants';
* @constructor
*/
const Exam = ({
isGated, isTimeLimited, originalUserIsStaff, children,
isGated, isTimeLimited, originalUserIsStaff, isIntegritySignatureEnabled, children,
}) => {
const state = useContext(ExamStateContext);
const {
Expand Down Expand Up @@ -98,7 +98,7 @@ const Exam = ({
isTimeLimited && apiErrorMsg && <ExamAPIError />
}
{isTimeLimited && !originalUserIsStaff && !isGated
? <Instructions>{sequenceContent}</Instructions>
? <Instructions isIntegritySignatureEnabled={isIntegritySignatureEnabled}>{sequenceContent}</Instructions>
: sequenceContent}
</div>
);
Expand All @@ -108,7 +108,12 @@ Exam.propTypes = {
isTimeLimited: PropTypes.bool.isRequired,
isGated: PropTypes.bool.isRequired,
originalUserIsStaff: PropTypes.bool.isRequired,
isIntegritySignatureEnabled: PropTypes.bool,
children: PropTypes.element.isRequired,
};

Exam.defaultProps = {
isIntegritySignatureEnabled: false,
};

export default Exam;
10 changes: 9 additions & 1 deletion src/exam/ExamWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ExamWrapper = ({ children, ...props }) => {
courseId,
isStaff,
originalUserIsStaff,
isIntegritySignatureEnabled,
} = props;
const { getExamAttemptsData, getAllowProctoringOptOut } = state;
const loadInitialData = async () => {
Expand All @@ -36,7 +37,12 @@ const ExamWrapper = ({ children, ...props }) => {
}, []);

return (
<Exam isGated={isGated} isTimeLimited={sequence.isTimeLimited} originalUserIsStaff={originalUserIsStaff}>
<Exam
isGated={isGated}
isTimeLimited={sequence.isTimeLimited}
originalUserIsStaff={originalUserIsStaff}
isIntegritySignatureEnabled={isIntegritySignatureEnabled}
>
{children}
</Exam>
);
Expand All @@ -55,11 +61,13 @@ ExamWrapper.propTypes = {
children: PropTypes.element.isRequired,
isStaff: PropTypes.bool,
originalUserIsStaff: PropTypes.bool,
isIntegritySignatureEnabled: PropTypes.bool,
};

ExamWrapper.defaultProps = {
isStaff: false,
originalUserIsStaff: false,
isIntegritySignatureEnabled: false,
};

export default ExamWrapper;
50 changes: 50 additions & 0 deletions src/instructions/Instructions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,56 @@ describe('SequenceExamWrapper', () => {
});
});

it('Shows download software proctored exam instructions verification is not approved, but integrity signature flag is turned on', () => {
const instructions = [
'instruction 1',
'instruction 2',
'instruction 3',
];
store.getState = () => ({
examState: Factory.build('examState', {
activeAttempt: {},
proctoringSettings: Factory.build('proctoringSettings', {
provider_name: 'Provider Name',
provider_tech_support_email: '[email protected]',
provider_tech_support_phone: '+123456789',
exam_proctoring_backend: {
instructions,
},
}),
verification: {
status: VerificationStatus.NONE,
can_verify: true,
},
exam: Factory.build('exam', {
is_proctored: true,
type: ExamType.PROCTORED,
attempt: Factory.build('attempt', {
attempt_status: ExamStatus.CREATED,
}),
}),
}),
});

render(
<ExamStateProvider>
<Instructions isIntegritySignatureEnabled>
<div>Sequence</div>
</Instructions>
</ExamStateProvider>,
{ store },
);

expect(screen.getByText(
'If you have issues relating to proctoring, you can contact '
+ 'Provider Name technical support by emailing [email protected] or by calling +123456789.',
)).toBeInTheDocument();
expect(screen.getByText('Set up and start your proctored exam.')).toBeInTheDocument();
instructions.forEach((instruction) => {
expect(screen.getByText(instruction)).toBeInTheDocument();
});
});

it('Shows error message if receives unknown attempt status', () => {
store.getState = () => ({
examState: Factory.build('examState', {
Expand Down
11 changes: 9 additions & 2 deletions src/instructions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import VerifiedExamInstructions from './VerifiedInstructions';
import ExpiredInstructions from './ExpiredInstructions';
import UnknownAttemptStatusError from './UnknownAttemptStatusError';

const Instructions = ({ children }) => {
const Instructions = ({ isIntegritySignatureEnabled, children }) => {
const state = useContext(ExamStateContext);
const { exam, verification } = state;
const {
Expand Down Expand Up @@ -58,6 +58,8 @@ const Instructions = ({ children }) => {
return component;
};

const blockedByIdv = () => !isIntegritySignatureEnabled && verificationStatus !== VerificationStatus.APPROVED;

// The API does not explicitly return 'expired' status, so we have to check manually.
// expires attribute is returned only for approved status, so it is safe to do this
// (meaning we won't override 'must_reverify' status for example)
Expand All @@ -73,7 +75,7 @@ const Instructions = ({ children }) => {
case attemptReadyToResume:
return <EntranceExamInstructions examType={examType} skipProctoredExam={toggleSkipProctoredExam} />;
case attemptStatus === ExamStatus.CREATED:
return examType === ExamType.PROCTORED && verificationStatus !== VerificationStatus.APPROVED
return examType === ExamType.PROCTORED && blockedByIdv()
? <VerificationProctoredExamInstructions status={verificationStatus} verificationUrl={verificationUrl} />
: <DownloadSoftwareProctoredExamInstructions skipProctoredExam={toggleSkipProctoredExam} />;
case attemptStatus === ExamStatus.DOWNLOAD_SOFTWARE_CLICKED:
Expand Down Expand Up @@ -109,6 +111,11 @@ const Instructions = ({ children }) => {

Instructions.propTypes = {
children: PropTypes.element.isRequired,
isIntegritySignatureEnabled: PropTypes.bool,
};

Instructions.defaultProps = {
isIntegritySignatureEnabled: false,
};

export default Instructions;

0 comments on commit 0a4d286

Please sign in to comment.