Skip to content

Commit

Permalink
feat: take control over exam instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladas Tamoshaitis authored and TamoshaytisV committed Apr 21, 2021
1 parent 33fcab9 commit e352d7a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/Unit/Unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useState } from 'react';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';

const ExamSequence = (props) => (
<div>
<button onClick={props.startExam}>Start exam</button>
</div>
);

const SequenceExamWrapper = ({children, ...props}) => {
const [examStarted, setExamStarted] = useState(false);
const { sequence } = props;

const startExam = async () => {
const { data } = await getAuthenticatedHttpClient().post(
'http://localhost:18000/api/edx_proctoring/v1/proctored_exam/attempt',
{
exam_id: 1,
start_clock: 'true',
},
);
if (data && data.exam_attempt_id) {
setExamStarted(true);
}
};

return sequence.isTimeLimited && !examStarted
? <ExamSequence startExam={startExam} />
: children;
};

export { SequenceExamWrapper, ExamSequence };
1 change: 1 addition & 0 deletions src/components/Unit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Unit';
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Unit';
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components';
Empty file removed src/index.jsx
Empty file.

0 comments on commit e352d7a

Please sign in to comment.