Added the capability for users to resume their previously stopped sessions
This commit is contained in:
@@ -16,6 +16,7 @@ export interface ExamState {
|
||||
exam?: Exam;
|
||||
partIndex: number;
|
||||
exerciseIndex: number;
|
||||
questionIndex: number;
|
||||
}
|
||||
|
||||
export interface ExamFunctions {
|
||||
@@ -24,13 +25,14 @@ export interface ExamFunctions {
|
||||
setShowSolutions: (showSolutions: boolean) => void;
|
||||
setHasExamEnded: (hasExamEnded: boolean) => void;
|
||||
setSelectedModules: (modules: Module[]) => void;
|
||||
setAssignment: (assignment: Assignment) => void;
|
||||
setAssignment: (assignment?: Assignment) => void;
|
||||
setTimeSpent: (timeSpent: number) => void;
|
||||
setSessionId: (sessionId: string) => void;
|
||||
setModuleIndex: (moduleIndex: number) => void;
|
||||
setExam: (exam?: Exam) => void;
|
||||
setPartIndex: (partIndex: number) => void;
|
||||
setExerciseIndex: (exerciseIndex: number) => void;
|
||||
setQuestionIndex: (questionIndex: number) => void;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
@@ -46,7 +48,8 @@ export const initialState: ExamState = {
|
||||
exam: undefined,
|
||||
moduleIndex: 0,
|
||||
partIndex: 0,
|
||||
exerciseIndex: 0,
|
||||
exerciseIndex: -1,
|
||||
questionIndex: 0,
|
||||
};
|
||||
|
||||
const useExamStore = create<ExamState & ExamFunctions>((set) => ({
|
||||
@@ -57,13 +60,14 @@ const useExamStore = create<ExamState & ExamFunctions>((set) => ({
|
||||
setShowSolutions: (showSolutions: boolean) => set(() => ({showSolutions})),
|
||||
setSelectedModules: (modules: Module[]) => set(() => ({selectedModules: modules})),
|
||||
setHasExamEnded: (hasExamEnded: boolean) => set(() => ({hasExamEnded})),
|
||||
setAssignment: (assignment: Assignment) => set(() => ({assignment})),
|
||||
setAssignment: (assignment?: Assignment) => set(() => ({assignment})),
|
||||
setTimeSpent: (timeSpent) => set(() => ({timeSpent})),
|
||||
setSessionId: (sessionId: string) => set(() => ({sessionId})),
|
||||
setExam: (exam?: Exam) => set(() => ({exam})),
|
||||
setModuleIndex: (moduleIndex: number) => set(() => ({moduleIndex})),
|
||||
setPartIndex: (partIndex: number) => set(() => ({partIndex})),
|
||||
setExerciseIndex: (exerciseIndex: number) => set(() => ({exerciseIndex})),
|
||||
setQuestionIndex: (questionIndex: number) => set(() => ({questionIndex})),
|
||||
|
||||
reset: () => set(() => initialState),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user