Skip to content

Commit

Permalink
feat: [BD-26][EDUCATOR-5808] Part-2 Add additional pages for onboardi…
Browse files Browse the repository at this point in the history
…ng / practice exams (#17)

* feat: check for verification only for proctored exams (previously were checkin for practice and onboarding also)

* feat: add Error, Submitted and Verified instruction pages

* test: add tests for Error, Submitted and Verified instructions

* feat: add allowProctoringOptOut to examState and use getSequenceMetadata API

* feat: Use sequence from the learning app instead of hitting the endpoint

Co-authored-by: Viktor Rusakov <[email protected]>
  • Loading branch information
UvgenGen and viktorrusakov authored Jun 14, 2021
1 parent e44e38e commit 5ea7bec
Show file tree
Hide file tree
Showing 25 changed files with 689 additions and 121 deletions.
1 change: 1 addition & 0 deletions src/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
getExamReviewPolicy,
pingAttempt,
resetExam,
getAllowProctoringOptOut,
} from './thunks';

export { default as store } from './store';
Expand Down
6 changes: 5 additions & 1 deletion src/data/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ export const examSlice = createSlice({
isLoading: true,
timeIsOver: false,
activeAttempt: null,
allowProctoringOptOut: false,
proctoringSettings: {},
exam: {},
verification: {},
apiErrorMsg: '',
},
reducers: {
setAllowProctoringOptOut: (state, { payload }) => {
state.allowProctoringOptOut = payload.allowProctoringOptOut;
},
setIsLoading: (state, { payload }) => {
state.isLoading = payload.isLoading;
},
Expand Down Expand Up @@ -46,7 +50,7 @@ export const examSlice = createSlice({
export const {
setIsLoading, setExamState, getExamId, expireExamAttempt,
setActiveAttempt, setProctoringSettings, setVerificationData,
setReviewPolicy, setApiError,
setReviewPolicy, setApiError, setAllowProctoringOptOut,
} = examSlice.actions;

export default examSlice.reducer;
7 changes: 7 additions & 0 deletions src/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
setVerificationData,
setReviewPolicy,
setApiError,
setAllowProctoringOptOut,
} from './slice';
import { ExamStatus } from '../constants';
import { workerPromiseForEventNames, pingApplication } from './messages/handlers';
Expand Down Expand Up @@ -359,3 +360,9 @@ export function getExamReviewPolicy() {
dispatch(setReviewPolicy({ policy: data.review_policy }));
};
}

export function getAllowProctoringOptOut(allowProctoringOptOut) {
return (dispatch) => {
dispatch(setAllowProctoringOptOut({ allowProctoringOptOut }));
};
}
3 changes: 2 additions & 1 deletion src/exam/ExamWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const ExamWrapper = ({ children, ...props }) => {

const loadInitialData = async () => {
await state.getExamAttemptsData(courseId, sequence.id);
await state.getAllowProctoringOptOut(sequence.allowProctoringOptOut);
state.getProctoringSettings();
state.getVerificationData();
};

useEffect(() => {
Expand All @@ -31,6 +31,7 @@ ExamWrapper.propTypes = {
sequence: PropTypes.shape({
id: PropTypes.string.isRequired,
isTimeLimited: PropTypes.bool,
allowProctoringOptOut: PropTypes.bool,
}).isRequired,
courseId: PropTypes.string.isRequired,
children: PropTypes.element.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/instructions/EntranceInstructions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Container } from '@edx/paragon';
import { ExamType } from '../constants';
import { EntranceProctoredExamInstructions } from './proctored_exam';
import { EntranceOnboardingExamInstructions } from './onboarding_exam';
import EntrancePracticeExamInstructions from './practice_exam';
import { EntrancePracticeExamInstructions } from './practice_exam';
import { StartTimedExamInstructions, TimedExamFooter } from './timed_exam';
import Footer from './proctored_exam/Footer';

Expand Down
38 changes: 38 additions & 0 deletions src/instructions/ErrorInstructions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Container } from '@edx/paragon';
import { ExamType } from '../constants';
import { ErrorPracticeExamInstructions } from './practice_exam';
import { ErrorOnboardingExamInstructions } from './onboarding_exam';
import { ErrorProctoredExamInstructions } from './proctored_exam';
import Footer from './proctored_exam/Footer';

const ErrorExamInstructions = ({ examType }) => {
const renderInstructions = () => {
switch (examType) {
case ExamType.ONBOARDING:
return <ErrorOnboardingExamInstructions />;
case ExamType.PRACTICE:
return <ErrorPracticeExamInstructions />;
case ExamType.PROCTORED:
return <ErrorProctoredExamInstructions />;
default:
return null;
}
};

return (
<div>
<Container className="border py-5 mb-4">
{renderInstructions()}
</Container>
{examType !== ExamType.TIMED && <Footer />}
</div>
);
};

ErrorExamInstructions.propTypes = {
examType: PropTypes.string.isRequired,
};

export default ErrorExamInstructions;
Loading

0 comments on commit 5ea7bec

Please sign in to comment.