Files
examjam-frontend/types/exam.d.ts
shafin-r 6f4f2a8668 feat(ui): add topic, subject screen
fix(api): fix api endpoint logic for pretest screen
2025-08-21 14:19:55 +06:00

79 lines
1.6 KiB
TypeScript

export interface Metadata {
attempt_id: string;
total_possible_score: number;
deduction: string;
num_questions: number;
name: string;
start_time: Date;
time_limit_minutes: number;
}
export interface MockMeta extends Metadata {
test_id: string;
}
export interface SubjectMeta extends Metadata {
subject_id: string;
subject_name: string;
}
export interface TopicMeta extends Metadata {
topic_id: string;
topic_name: string;
}
export type Question = {
question_id: string;
question: string;
options: string[];
type: string;
};
export interface Test {
metadata: Metadata;
questions: Question[];
}
type Answers = number | null;
export interface TestAttempt {
user_id: string;
test_id: string;
attempt_id: string;
start_time: Date;
end_time: Date;
user_questions: {
question_id: string;
question: string;
options: string[];
type: string;
};
user_answers: Record<string, Answers>;
correct_answers: Record<string, Answers>;
correct_answers_count: number;
wrong_answers_count: number;
skipped_questions_count: number;
}
export interface ExamContextType {
currentExam: Test | null;
currentAttempt: TestAttempt | null;
isHydrated: boolean;
isInitialized: boolean;
// Actions
setCurrentExam: (exam: Test) => void;
startExam: (exam?: Test) => void;
setAnswer: (questionId: string, answer: Answers) => void;
submitExam: () => TestAttempt | null;
clearExam: () => void;
setApiResponse: (response: any) => void;
// Getters
getAnswer: (questionId: string) => Answers;
getProgress: () => number;
isExamStarted: () => boolean;
isExamCompleted: () => boolean;
getApiResponse: () => any;
}