Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 12x 27x 27x 3x 27x 3x 17x 18x 14x 14x 14x 12x 5x 12x 5x 2x 5x 12x | import { createSlice } from "@reduxjs/toolkit";
const TeacherCreateAssignment = createSlice({
name: "TeacherCreateAssignment",
initialState: {
assignmentData: {
step1: null,
step2: null,
step3: null,
viewAsStudent: false,
},
hasErrors: null,
isLoading: false,
},
reducers: {
_updateStep1: (state, action) => {
state.assignmentData.step1 = { ...state.assignmentData.step1, ...action.payload };
// EI-3182: mirror instructions + rubric to root assignmentData so the
// saveOperation in NewAssignment.jsx can read them via the same path
// used for re-used global assignments (assignmentData.instructions /
// assignmentData.rubric).
if (action.payload.instructions !== undefined) {
state.assignmentData.instructions = action.payload.instructions || undefined;
}
if (action.payload.rubric !== undefined) {
state.assignmentData.rubric = action.payload.rubric;
}
},
_updateStep2: (state, action) => {
state.assignmentData.step2 = { ...state.assignmentData.step2, ...action.payload };
},
_updateStep3: (state, action) => {
state.assignmentData.step3 = { ...state.assignmentData.step3, ...action.payload };
},
_editAssignment: (state, action) => {
Object.assign(state.assignmentData, action.payload);
// Mirror instructions + rubric from step1 to root assignmentData so
// saveOperation sees them via the same path used by _updateStep1.
// This ensures edit-load pre-populates the root fields without the
// user needing to re-visit Step1.
const step1 = action.payload.step1;
if (step1 !== undefined && step1 !== null) {
if (step1.instructions !== undefined) {
state.assignmentData.instructions = step1.instructions || undefined;
}
if (step1.rubric !== undefined) {
state.assignmentData.rubric = step1.rubric;
}
}
},
_updateViewAsStudent: (state, action) => {
state.assignmentData.viewAsStudent = action.payload;
},
_resetAllFields: (state, action) => {
state.assignmentData = {
step1: null,
step2: null,
step3: null,
viewAsStudent: false,
};
},
},
extraReducers: (builder) => {},
});
export const { _updateStep1, _updateStep2, _updateStep3, _resetAllFields, _editAssignment, _updateViewAsStudent } =
TeacherCreateAssignment.actions;
export default TeacherCreateAssignment;
|