ENCOA-315

This commit is contained in:
Carlos-Mesquita
2025-01-22 04:46:24 +00:00
parent 4724e98993
commit e36b24ea3f
12 changed files with 425 additions and 231 deletions

View File

@@ -26,7 +26,6 @@ export const initialState: ExamState = {
inactivity: 0,
shuffles: [],
bgColor: "bg-white",
evaluated: [],
user: undefined,
navigation: {
previousDisabled: false,
@@ -39,7 +38,6 @@ export const initialState: ExamState = {
reviewAll: false,
finalizeModule: false,
finalizeExam: false,
pendingEvaluation: false,
},
};
@@ -62,8 +60,6 @@ const useExamStore = create<ExamState & ExamFunctions>((set, get) => ({
setQuestionIndex: (questionIndex: number) => set(() => ({ questionIndex })),
setBgColor: (bgColor: string) => set(() => ({ bgColor })),
setEvaluated: (evaluated: UserSolution[]) => set(() => ({ evaluated })),
setNavigation: (updates: Partial<Navigation>) => set((state) => ({
navigation: {
...state.navigation,
@@ -166,7 +162,7 @@ export const usePersistentExamStore = create<ExamState & ExamFunctions>()(
saveStats: async () => { },
saveSession: async () => { },
setEvaluated: (evaluated: UserSolution[]) => {},
setEvalSolutions: (evaluated: UserSolution[]) => {},
reset: () => set(() => initialState),
dispatch: (action) => set((state) => rootReducer(state, action))

View File

@@ -93,20 +93,11 @@ export const rootReducer = (
};
case 'FINALIZE_MODULE': {
const { updateTimers } = action.payload;
const solutions = state.userSolutions;
const evaluated = state.evaluated;
const hasUnevaluatedSolutions = solutions.some(solution =>
(solution.type === 'speaking' ||
solution.type === 'writing' ||
solution.type === 'interactiveSpeaking') &&
!evaluated.some(evaluation => evaluation.exercise === solution.exercise)
);
// To finalize a module first flag the timers to be updated
if (updateTimers) {
return {
flags: { ...state.flags, finalizeModule: true, pendingEvaluation: hasUnevaluatedSolutions }
flags: { ...state.flags, finalizeModule: true }
}
} else {
// then check whether there are more modules in the exam, if there are
@@ -118,7 +109,6 @@ export const rootReducer = (
...state.flags,
finalizeModule: false,
finalizeExam: true,
pendingEvaluation: hasUnevaluatedSolutions,
}
}
} else if (state.moduleIndex < state.selectedModules.length - 1) {

View File

@@ -16,7 +16,6 @@ export interface StateFlags {
reviewAll: boolean;
finalizeModule: boolean;
finalizeExam: boolean;
pendingEvaluation: boolean;
}
export interface ExamState {
@@ -39,8 +38,7 @@ export interface ExamState {
user: undefined | string;
currentSolution?: UserSolution | undefined;
navigation: Navigation;
flags: StateFlags,
evaluated: UserSolution[];
flags: StateFlags;
}
@@ -65,8 +63,6 @@ export interface ExamFunctions {
setTimeIsUp: (timeIsUp: boolean) => void;
setEvaluated: (evaluated: UserSolution[]) => void,
saveSession: () => Promise<void>;
saveStats: () => Promise<void>;