diff --git a/src/exam/ExamWrapper.jsx b/src/exam/ExamWrapper.jsx index 1bd7c391..2e5f4133 100644 --- a/src/exam/ExamWrapper.jsx +++ b/src/exam/ExamWrapper.jsx @@ -10,7 +10,7 @@ import ExamStateContext from '../context'; const ExamWrapper = ({ children, ...props }) => { const state = useContext(ExamStateContext); const { authenticatedUser } = useContext(AppContext); - const { sequence, courseId } = props; + const { sequence, courseId, isStaff } = props; const { getExamAttemptsData, getAllowProctoringOptOut } = state; const loadInitialData = async () => { await getExamAttemptsData(courseId, sequence.id); @@ -18,8 +18,9 @@ const ExamWrapper = ({ children, ...props }) => { }; // if the user is browsing public content (not logged in) they cannot be in an exam + // if the user is staff they may view exam content without an exam attempt // any requests for exam state will 403 so just short circuit this component here - if (!authenticatedUser) { + if (!authenticatedUser || isStaff) { return children; } @@ -42,6 +43,11 @@ ExamWrapper.propTypes = { }).isRequired, courseId: PropTypes.string.isRequired, children: PropTypes.element.isRequired, + isStaff: PropTypes.bool, +}; + +ExamWrapper.defaultProps = { + isStaff: false, }; export default ExamWrapper; diff --git a/src/exam/ExamWrapper.test.jsx b/src/exam/ExamWrapper.test.jsx index 317c256d..fe26f1fa 100644 --- a/src/exam/ExamWrapper.test.jsx +++ b/src/exam/ExamWrapper.test.jsx @@ -24,7 +24,7 @@ describe('SequenceExamWrapper', () => { }; const courseId = 'course-v1:test+test+test'; - it('is successfully rendered and shows instructions', () => { + it('is successfully rendered and shows instructions if the user is not staff', () => { store.getState = () => ({ examState: Factory.build('examState'), }); @@ -121,4 +121,23 @@ describe('SequenceExamWrapper', () => { ); expect(getByTestId('sequence-content')).toHaveTextContent('children'); }); + + it('renders exam content without an active attempt if the user is staff', () => { + store.getState = () => ({ + examState: Factory.build('examState', { + exam: Factory.build('exam', { + type: ExamType.PROCTORED, + }), + }), + }); + const { queryByTestId } = render( + + +
children
+
+
, + { store }, + ); + expect(queryByTestId('sequence-content')).toHaveTextContent('children'); + }); });