ENCOA-255 Fixed the level import

This commit is contained in:
Carlos-Mesquita
2024-12-03 12:00:04 +00:00
parent 490c5ad7d3
commit 5252faafb7
5 changed files with 31 additions and 25 deletions

View File

@@ -9,9 +9,8 @@ import useExamEditorStore from '@/stores/examEditor';
import { LevelPart, ListeningPart, ReadingPart } from '@/interfaces/exam';
import { defaultSectionSettings } from '@/stores/examEditor/defaults';
const WordUploader: React.FC<{ module: Module, setNumberOfLevelParts: React.Dispatch<React.SetStateAction<number>> }> = ({ module, setNumberOfLevelParts }) => {
const WordUploader: React.FC<{ module: Module, setNumberOfLevelParts: (parts: number) => void; }> = ({ module, setNumberOfLevelParts }) => {
const { currentModule, dispatch } = useExamEditorStore();
const {sectionLabels} = useExamEditorStore(state => state.modules[currentModule]);
const examInputRef = useRef<HTMLInputElement>(null);
const solutionsInputRef = useRef<HTMLInputElement>(null);
@@ -77,16 +76,7 @@ const WordUploader: React.FC<{ module: Module, setNumberOfLevelParts: React.Disp
);
if (module === "level") {
// default is 1
const newLabelCount = data.parts.length - 2;
setNumberOfLevelParts(newLabelCount);
const newLabels = Array.from({ length: newLabelCount }, (_, index) => ({
id: index + 2,
label: `Part ${index + 2}`
}));
dispatch({type: "UPDATE_MODULE", payload: { updates: { sectionLabels: [...sectionLabels, ...newLabels] }}})
setNumberOfLevelParts(data.parts.length);
}
dispatch({