Skip to content

Commit

Permalink
fix: don't do pulling when exam is in 'ready_to_submit' status (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorrusakov authored May 25, 2021
1 parent fab224f commit 9c946bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ export function startExam() {
export function pollAttempt(url) {
return async (dispatch, getState) => {
const currentAttempt = getState().examState.activeAttempt;

// If the learner is in a state where they've finished the exam
// and the attempt can be submitted (i.e. they are "ready_to_submit"),
// don't ping the proctoring app (which action could move
// the attempt into an error state).
if (currentAttempt && currentAttempt.attempt_status === ExamStatus.READY_TO_SUBMIT) {
return;
}

const data = await pollExamAttempt(url).catch(
err => logError(err),
);
Expand Down
12 changes: 0 additions & 12 deletions src/timer/TimerProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
TIMER_IS_LOW,
TIMER_LIMIT_REACHED,
} from './events';
import { ExamStatus } from '../constants';
import { withExamStore } from '../hocs';

/* give an extra 5 seconds where the timer holds at 00:00 before page refreshes */
Expand Down Expand Up @@ -47,18 +46,7 @@ const TimerServiceProvider = ({ children, attempt, pollHandler }) => {
},
).join(':');

// AED 2020-02-21:
// If the learner is in a state where they've finished the exam
// and the attempt can be submitted (i.e. they are "ready_to_submit"),
// don't ping the proctoring app (which action could move
// the attempt into an error state).
const pollExam = () => {
// Fixme: this condition has no effect because attempt status is always 'started'.
// This happens because pollExam becomes a closure
// and uses attempt_status value from when component was first rendered.
if (attempt.attempt_status === ExamStatus.READY_TO_SUBMIT) {
return;
}
const url = attempt.exam_started_poll_url;
const queryString = `?sourceid=in_exam&proctored=${attempt.taking_as_proctored}`;
pollHandler(url + queryString);
Expand Down

0 comments on commit 9c946bf

Please sign in to comment.