From ee1b4aa1dcc705b86ab49d03e891086b9b7f7e75 Mon Sep 17 00:00:00 2001 From: Ben Warzeski Date: Mon, 27 Sep 2021 11:05:47 -0400 Subject: [PATCH] add grading actions --- src/data/reducers/grading.js | 38 +++++++++++++++++++++++++++++++++++- src/data/thunkActions/app.js | 1 - 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/data/reducers/grading.js b/src/data/reducers/grading.js index a954ede..56be392 100644 --- a/src/data/reducers/grading.js +++ b/src/data/reducers/grading.js @@ -39,7 +39,6 @@ const initialState = { * criteria: [{ * name: '', * feedback: '', - * score: 0, * selectedOption: '', * }], * } @@ -93,6 +92,43 @@ const app = createReducer(initialState, { [state.current.submissionId]: { ...payload }, }, }), + [actions.grading.setRubricFeedback]: (state, { payload }) => ({ + ...state, + gradingStatus: { + ...state.gradingStatus, + overallFeebadk: payload, + }, + }), + [actions.grading.setCriterionOption]: (state, { payload: { orderNum, value } }) => { + const entry = state.gradingStatus[state.current.submissionId]; + const { criteria } = entry; + criteria[orderNum] = { ...criteria[orderNum], selectedOption: value }; + return { + ...state, + gradingStatus: { + ...state.gradingStatus, + [state.current.submissionId]: { + ...entry, + criteria, + }, + }, + }; + }, + [actions.grading.setCriterionFeedback]: (state, { payload: { orderNum, value } }) => { + const entry = state.gradingStatus[state.current.submissionId]; + const { criteria } = entry; + criteria[orderNum] = { ...criteria[orderNum], feedback: value }; + return { + ...state, + gradingStatus: { + ...state.gradingStatus, + [state.current.submissionId]: { + ...entry, + criteria, + }, + }, + }; + }, [actions.grading.clearGrade]: (state) => { const gradingStatus = { ...state.gradingStatus }; delete gradingStatus[state.current.submissionId]; diff --git a/src/data/thunkActions/app.js b/src/data/thunkActions/app.js index 0b462bd..13c8236 100644 --- a/src/data/thunkActions/app.js +++ b/src/data/thunkActions/app.js @@ -11,7 +11,6 @@ const locationId = window.location.pathname.slice(1); */ export const initialize = () => (dispatch) => ( api.initializeApp(locationId).then((response) => { - console.log({ response }); dispatch(actions.app.loadOraMetadata(response.oraMetadata)); dispatch(actions.app.loadCourseMetadata(response.courseMetadata)); dispatch(actions.submissions.loadList(response.submissions));