Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-26][EDUCATOR-5798] fix: don't do polling when exam is in 'ready_to_submit' status #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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