Updated the eval calls to the backend, passed the navigation logic of level to useExamNavigation hook

This commit is contained in:
Carlos-Mesquita
2024-11-26 09:04:38 +00:00
parent bb5326a331
commit 2ed4e6509e
14 changed files with 452 additions and 493 deletions

View File

@@ -26,7 +26,7 @@ export const initialState: ExamState = {
inactivity: 0,
shuffles: [],
bgColor: "bg-white",
currentSolution: undefined,
evaluated: [],
user: undefined,
navigation: {
previousDisabled: false,
@@ -39,6 +39,7 @@ export const initialState: ExamState = {
reviewAll: false,
finalizeModule: false,
finalizeExam: false,
pendingEvaluation: false,
},
};
@@ -61,6 +62,8 @@ 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,
@@ -75,7 +78,6 @@ const useExamStore = create<ExamState & ExamFunctions>((set, get) => ({
}
})),
setTimeIsUp: (timeIsUp: boolean) => set((state) => ({ flags: { ...state.flags, timeIsUp } })),
reset: () => set(() => initialState),
@@ -162,12 +164,12 @@ export const usePersistentExamStore = create<ExamState & ExamFunctions>()(
setTimeIsUp: (timeIsUp: boolean) => set((state) => ({ flags: { ...state.flags, timeIsUp } })),
saveStats: async () => {},
saveSession: async () => {},
saveStats: async () => { },
saveSession: async () => { },
setEvaluated: (evaluated: UserSolution[]) => {},
reset: () => set(() => initialState),
dispatch: (action) => set((state) => rootReducer(state, action))
})),
{
name: 'persistent-exam-store',