fix: make gradeData check for empty object and null/undefined
chore: remove duplicate/unused function
This commit is contained in:
committed by
leangseu-edx
parent
587caff980
commit
876f5d9413
@@ -49,8 +49,9 @@ export const loadSubmission = () => (dispatch, getState) => {
|
||||
dispatch(actions.grading.loadSubmission({ ...response, submissionUUID }));
|
||||
if (selectors.grading.selected.isGrading(getState())) {
|
||||
dispatch(actions.app.setShowRubric(true));
|
||||
// safety constraints
|
||||
let { gradeData } = response;
|
||||
if (gradeData === null) {
|
||||
if (gradeData === null || gradeData === undefined || Object.keys(gradeData).length) {
|
||||
gradeData = selectors.app.emptyGrade(getState());
|
||||
}
|
||||
const lockStatus = selectors.grading.selected.lockStatus(getState());
|
||||
@@ -75,7 +76,8 @@ export const startGrading = () => (dispatch, getState) => {
|
||||
onSuccess: (response) => {
|
||||
dispatch(actions.app.setShowRubric(true));
|
||||
let gradeData = selectors.grading.selected.gradeData(getState());
|
||||
if (gradeData === null) {
|
||||
// safety constraints
|
||||
if (gradeData === null || gradeData === undefined || Object.keys(gradeData).length) {
|
||||
gradeData = selectors.app.emptyGrade(getState());
|
||||
}
|
||||
dispatch(actions.grading.startGrading({ ...response, gradeData }));
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as thunkActions from './grading';
|
||||
|
||||
jest.mock('./requests', () => ({
|
||||
fetchSubmission: (args) => ({ fetchSubmission: args }),
|
||||
fetchSubmissionResponse: (args) => ({ fetchSubmissionResponse: args }),
|
||||
fetchSubmissionStatus: (args) => ({ fetchSubmissionStatus: args }),
|
||||
setLock: (args) => ({ setLock: args }),
|
||||
submitGrade: (args) => ({ submitGrade: args }),
|
||||
@@ -144,6 +143,8 @@ describe('grading thunkActions', () => {
|
||||
test('dispatches startGrading with selected gradeData if truthy', () => {
|
||||
actionArgs.onSuccess(startResponse);
|
||||
expect(dispatch.mock.calls).toContainEqual([
|
||||
actions.app.setShowRubric(true),
|
||||
], [
|
||||
actions.grading.startGrading({
|
||||
...startResponse,
|
||||
gradeData: selectors.grading.selected.gradeData(testState),
|
||||
|
||||
@@ -70,16 +70,6 @@ const fetchSubmissionStatus = (submissionUUID) => get(
|
||||
[paramKeys.submissionUUID]: submissionUUID,
|
||||
}),
|
||||
).then(response => response.data);
|
||||
/**
|
||||
* Fetches only the learner response for a given submission. Used for pre-fetching response
|
||||
* for neighboring submissions in the queue.
|
||||
*/
|
||||
export const fetchSubmissionResponse = (submissionUUID) => get(
|
||||
stringifyUrl(urls.fetchSubmissionUrl, {
|
||||
[paramKeys.oraLocation]: locationId,
|
||||
[paramKeys.submissionUUID]: submissionUUID,
|
||||
}),
|
||||
).then(response => response.data);
|
||||
|
||||
/**
|
||||
* post('api/lock', { ora_location, submissionUUID });
|
||||
@@ -117,7 +107,6 @@ const updateGrade = (submissionUUID, gradeData) => post(
|
||||
export default StrictDict({
|
||||
initializeApp,
|
||||
fetchSubmission,
|
||||
fetchSubmissionResponse,
|
||||
fetchSubmissionStatus,
|
||||
lockSubmission,
|
||||
updateGrade,
|
||||
|
||||
@@ -123,9 +123,6 @@ const mockApi = () => {
|
||||
api.fetchSubmissionStatus = jest.fn((submissionUUID) => new Promise(
|
||||
(resolve) => resolve(fakeData.mockSubmissionStatus(submissionUUID)),
|
||||
));
|
||||
api.fetchSubmissionResponse = jest.fn((submissionUUID) => new Promise(
|
||||
(resolve) => resolve({ response: fakeData.mockSubmission(submissionUUID).response }),
|
||||
));
|
||||
api.lockSubmission = jest.fn(() => new Promise(
|
||||
(resolve, reject) => {
|
||||
resolveFns.lock = {
|
||||
|
||||
Reference in New Issue
Block a user