Blanks Exercises were removing the blanks on the editor and text but not on solutions, added submit and preview to writing and reading

This commit is contained in:
Carlos-Mesquita
2024-11-05 17:53:55 +00:00
parent 15c9c4d4bd
commit ffa2045a2d
28 changed files with 519 additions and 264 deletions

View File

@@ -2,6 +2,7 @@ import { Module } from "@/interfaces";
import ExamEditorStore, { Generating, ReadingSectionSettings, Section, SectionSettings, SectionState } from "../types";
import { DragEndEvent } from "@dnd-kit/core";
import { LevelPart, ListeningPart, ReadingPart } from "@/interfaces/exam";
import { reorderSection } from "../reorder/global";
export type SectionActions =
| { type: 'UPDATE_SECTION_SINGLE_FIELD'; payload: { module: Module; sectionId: number; field: string; value: any } }
@@ -80,7 +81,7 @@ export const sectionReducer = (
...modules[currentModule],
sections: sections.map(section =>
section.sectionId === sectionId
? { ...section, state: {...section.state, ...updatedState} }
? { ...section, state: { ...section.state, ...updatedState } }
: section
)
}
@@ -93,10 +94,18 @@ export const sectionReducer = (
const oldIndex = active.id as number;
const newIndex = over.id as number;
const currentSectionState = sections.find((s) => s.sectionId = sectionId)!.state as ReadingPart | ListeningPart | LevelPart;
const currentSectionState = sections.find((s) => s.sectionId === sectionId)!.state as ReadingPart | ListeningPart | LevelPart;
const exercises = [...currentSectionState.exercises];
const [removed] = exercises.splice(oldIndex, 1);
exercises.splice(newIndex, 0, removed);
const { exercises: reorderedExercises } = reorderSection(exercises, 1);
const newSectionState = {
...currentSectionState,
exercises: reorderedExercises
};
const [removed] = currentSectionState.exercises.splice(oldIndex, 1);
currentSectionState.exercises.splice(newIndex, 0, removed);
return {
...state,
modules: {
@@ -105,7 +114,7 @@ export const sectionReducer = (
...modules[currentModule],
sections: sections.map(section =>
section.sectionId === sectionId
? { ...section, state: currentSectionState }
? { ...section, state: newSectionState }
: section
)
}