Public Access
feat: Implement API modules for admin, auth, exam, result, and setup functionalities
- Created adminApi.ts for admin-related operations including user management and site settings. - Developed authApi.ts for authentication processes such as registration, login, and profile management. - Added examApi.ts for handling exam CRUD operations. - Introduced resultApi.ts for managing results submission and retrieval. - Established setupApi.ts for initial setup processes and status checks. - Created ErrorBoundary component to handle rendering errors gracefully in the frontend. - Re-exported shared API utilities in index.ts for easier access.
This commit is contained in:
1 parent
62af83ce53
commit
c64cdcd9e3
46 files changed
+2227
-1125
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const answerValueSchema = z.union([z.string(), z.array(z.string()), z.record(z.string(), z.string())])
|
||||
|
||||
export const submitResultSchema = z.object({
|
||||
exam_id: z.number().nullable().optional(),
|
||||
title: z.string().min(1),
|
||||
score_points: z.number(),
|
||||
total_points: z.number(),
|
||||
correct_count: z.number(),
|
||||
graded_count: z.number(),
|
||||
passing_score: z.number().optional(),
|
||||
elapsed_ms: z.number(),
|
||||
state: z.object({
|
||||
answers: z.record(z.string(), answerValueSchema),
|
||||
gradedAnswers: z.record(z.string(), z.object({
|
||||
correct: z.boolean(),
|
||||
points: z.number(),
|
||||
explanation: z.string().optional(),
|
||||
})),
|
||||
answeredCount: z.number(),
|
||||
score: z.number(),
|
||||
correctCount: z.number(),
|
||||
gradedCount: z.number(),
|
||||
timeExpired: z.boolean().optional(),
|
||||
}),
|
||||
exam: z.object({
|
||||
id: z.string().optional(),
|
||||
title: z.string(),
|
||||
subtitle: z.string().optional(),
|
||||
questions: z.array(z.any()),
|
||||
timeLimitMinutes: z.number().nullable().optional(),
|
||||
passingScore: z.number().optional(),
|
||||
feedbackMode: z.enum(['end', 'immediate']).optional(),
|
||||
}).passthrough(),
|
||||
})
|
||||
|
||||
export const resultIdParamSchema = z.object({
|
||||
id: z.string().regex(/^\d+$/, 'ID must be a number'),
|
||||
})
|
||||
Reference in new issue
Block a user