generated from muhtadeetaron/nextjs-template
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
export type Metadata = {
|
|
test_id: string;
|
|
total_possible_score: number;
|
|
deduction: number;
|
|
num_questions: number;
|
|
name: string;
|
|
start_time: Date;
|
|
time_limit_minutes: number;
|
|
}
|
|
|
|
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;
|
|
}
|