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

fix(programming): tweak live feedback presentation, fix evaluate polling issue #7409

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,27 @@ export const updateClientVersion = (answerId, clientVersion) => (dispatch) =>
payload: { answer: { id: answerId, clientVersion } },
});

const pollAutogradingJob =
(jobUrl, submissionId, questionId, answerId) => (dispatch) => {
pollJob(
jobUrl,
() => dispatch(getEvaluationResult(submissionId, answerId, questionId)),
(errorData) => {
dispatch({
type: actionTypes.AUTOGRADE_FAILURE,
questionId,
payload: errorData,
});
dispatch(setNotification(translations.requestFailure));
},
JOB_POLL_DELAY_MS,
);
};

export function submitAnswer(submissionId, answerId, rawAnswer, resetField) {
// const pollAutogradingJob =
// (jobUrl, submissionId, questionId, answerId) => (dispatch) => {
// pollJob(
// jobUrl,
// () => dispatch(getEvaluationResult(submissionId, answerId, questionId)),
// (errorData) => {
// dispatch({
// type: actionTypes.AUTOGRADE_FAILURE,
// questionId,
// payload: errorData,
// });
// dispatch(setNotification(translations.requestFailure));
// },
// JOB_POLL_DELAY_MS,
// );
// };
Comment on lines +36 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we removing commented out code?


export function submitAnswer(questionId, answerId, rawAnswer, resetField) {
const currentTime = Date.now();
const answer = formatAnswer(rawAnswer, currentTime);
const payload = { answer };
const questionId = answer.questionId;

return (dispatch) => {
dispatch(updateClientVersion(answerId, currentTime));
Expand All @@ -73,16 +72,14 @@ export function submitAnswer(submissionId, answerId, rawAnswer, resetField) {
if (data.newSessionUrl) {
window.location = data.newSessionUrl;
} else if (data.jobUrl) {
pollAutogradingJob(
data.jobUrl,
submissionId,
questionId,
answerId,
)(dispatch);
dispatch({
type: actionTypes.AUTOGRADE_SUBMITTED,
payload: { questionId, jobUrl: data.jobUrl },
});
} else {
dispatch({
type: actionTypes.AUTOGRADE_SUCCESS,
payload: data,
payload: { ...data, answerId },
});
// When an answer is submitted, the value of that field needs to be updated.
resetField(`${answerId}`, {
Expand Down Expand Up @@ -267,7 +264,6 @@ export function generateLiveFeedback(submissionId, answerId, questionId) {
});
}

// TODO should each answer/question store its own feedback array?
export function fetchLiveFeedback(
answerId,
questionId,
Expand Down
33 changes: 7 additions & 26 deletions client/app/bundles/course/assessment/submission/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import GlobalAPI from 'api';
import CourseAPI from 'api/course';
import { setNotification } from 'lib/actions';
import pollJob from 'lib/helpers/jobHelpers';
Expand All @@ -12,7 +13,6 @@ import translations from '../translations';
import { buildErrorMessage, formatAnswers } from './utils';

const JOB_POLL_DELAY_MS = 500;
const JOB_STAGGER_DELAY_MS = 400;

export function getEvaluationResult(submissionId, answerId, questionId) {
return (dispatch) => {
Expand All @@ -22,16 +22,20 @@ export function getEvaluationResult(submissionId, answerId, questionId) {
.then((data) => {
dispatch({
type: actionTypes.AUTOGRADE_SUCCESS,
payload: data,
payload: { ...data, answerId },
});
})
.catch(() => {
dispatch(setNotification(translations.requestFailure));
dispatch({ type: actionTypes.AUTOGRADE_FAILURE, questionId });
dispatch({ type: actionTypes.AUTOGRADE_FAILURE, questionId, answerId });
});
};
}

export function getJobStatus(jobUrl) {
return GlobalAPI.jobs.get(jobUrl);
}

export function fetchSubmission(id, onGetMonitoringSessionId) {
return (dispatch) => {
dispatch({ type: actionTypes.FETCH_SUBMISSION_REQUEST });
Expand All @@ -48,29 +52,6 @@ export function fetchSubmission(id, onGetMonitoringSessionId) {
window.location = data.newSessionUrl;
return;
}
data.answers
.filter((a) => a.autograding && a.autograding.path)
.forEach((answer, index) => {
setTimeout(() => {
pollJob(
answer.autograding.path,
() =>
dispatch(
getEvaluationResult(
id,
answer.fields.id,
answer.questionId,
),
),
() =>
dispatch({
type: actionTypes.AUTOGRADE_FAILURE,
questionId: answer.questionId,
}),
JOB_POLL_DELAY_MS,
);
}, JOB_STAGGER_DELAY_MS * index);
});
if (data.monitoringSessionId !== undefined)
onGetMonitoringSessionId?.(data.monitoringSessionId);
dispatch({
Expand Down
Loading