From 9c946bff652cc1afac7fe45a404fcc9e6065181a Mon Sep 17 00:00:00 2001 From: Viktor Rusakov <52399399+ViktorRusakov@users.noreply.github.com> Date: Tue, 25 May 2021 16:56:33 +0300 Subject: [PATCH] fix: don't do pulling when exam is in 'ready_to_submit' status (#6) --- src/data/thunks.js | 9 +++++++++ src/timer/TimerProvider.jsx | 12 ------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/data/thunks.js b/src/data/thunks.js index 3ca674f2..cfb61bac 100644 --- a/src/data/thunks.js +++ b/src/data/thunks.js @@ -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), ); diff --git a/src/timer/TimerProvider.jsx b/src/timer/TimerProvider.jsx index 98c74c1a..8407e5de 100644 --- a/src/timer/TimerProvider.jsx +++ b/src/timer/TimerProvider.jsx @@ -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 */ @@ -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);