ENCOA-260, ENCOA-259

This commit is contained in:
Carlos-Mesquita
2024-12-09 18:37:51 +00:00
parent 35d28fbff6
commit 7538392e44
12 changed files with 301 additions and 57 deletions

View File

@@ -15,6 +15,7 @@ export const defaultSettings = (module: Module) => {
isCategoryDropdownOpen: false,
isIntroDropdownOpen: false,
isExerciseDropdownOpen: false,
isTypeDropdownOpen: false,
}
switch (module) {
@@ -163,6 +164,9 @@ const defaultModuleSettings = (module: Module, minTimer: number): ModuleState =>
importing: false,
edit: [],
};
if (["reading", "writing"].includes(module)) {
state["type"] = "general";
}
return state;
}

View File

@@ -7,15 +7,12 @@ import { Module } from "@/interfaces";
import { updateExamWithUserSolutions } from "@/stores/exam/utils";
import { defaultExamUserSolutions } from "@/utils/exams";
type UpdateRoot = {
type: 'UPDATE_ROOT';
payload: {
updates: Partial<ExamEditorStore>
}
};
type RootActions = { type: 'FULL_RESET' } | { type: "INIT_EXAM_EDIT", payload: { exam: Exam; examModule: Module; id: string } };
type RootActions = { type: 'FULL_RESET' } |
{ type: 'INIT_EXAM_EDIT', payload: { exam: Exam; examModule: Module; id: string } } |
{ type: 'UPDATE_ROOT'; payload: { updates: Partial<ExamEditorStore> } } |
{ type: 'RESET_MODULE'; payload: { module: Module } };
export type Action = ModuleActions | SectionActions | UpdateRoot | RootActions;
export type Action = ModuleActions | SectionActions | RootActions;
export const rootReducer = (
state: ExamEditorStore,
@@ -55,6 +52,16 @@ export const rootReducer = (
...state,
...updates
};
case 'RESET_MODULE':
const { module } = action.payload;
const timer = ["reading", "writing", "level"].includes(module) ?
60 : (module === "speaking" ? 14 : 30);
return {
modules: {
...state.modules,
[module]: defaultModuleSettings(module, timer),
},
};
case 'FULL_RESET':
return {
title: "",

View File

@@ -16,6 +16,7 @@ export interface SectionSettings {
currentIntro: string | undefined;
isCategoryDropdownOpen: boolean;
isIntroDropdownOpen: boolean;
isTypeDropdownOpen: boolean;
}
export interface SpeakingSectionSettings extends SectionSettings {
@@ -114,6 +115,7 @@ export interface ModuleState {
importModule: boolean;
importing: boolean;
edit: number[];
type?: "general" | "academic";
}
export interface Avatar {