fix(api): fix api logic for exam screen

needs more work for the timercontext
This commit is contained in:
shafin-r
2025-08-31 02:20:55 +06:00
parent 08a560abe5
commit b112a8fdac
7 changed files with 301 additions and 684 deletions

39
types/exam.d.ts vendored
View File

@ -24,42 +24,3 @@ export interface Test {
export type Answer = number | null;
export type AnswersMap = Record<string, Answer>;
export interface TestAttempt {
user_id: string | undefined;
test_id: string;
subject_id: string;
topic_id: string;
test_type: "Subject" | "Topic" | "Mock" | "Past";
attempt_id: string;
start_time: string;
end_time: string;
user_questions: Question[];
user_answers: (number | null)[];
correct_answers: number[];
correct_answers_count: number;
wrong_answers_count: number;
skipped_questions_count: number;
}
export interface TestContextType {
currentExam: Test | null;
currentAttempt: TestAttempt | null;
isHydrated: boolean;
isInitialized: boolean;
// Actions
setCurrentExam: (exam: Test) => void;
startExam: (exam?: Test) => void;
setAnswer: (questionId: string, answer: Answer) => void;
submitExam: () => TestAttempt | null; // or Promise<TestAttempt | null> if API
clearExam: () => void;
setApiResponse: (response: any) => void;
// Getters
getAnswer: (questionId: string) => Answer;
getProgress: () => number;
isExamStarted: () => boolean;
isExamCompleted: () => boolean;
getApiResponse: () => any;
}