Public Access
refactor: update result schemas and tests for improved state management and feedback modes
This commit is contained in:
1 parent
ae8a01bc54
commit
95603f93a0
4 files changed
+47
-46
No files matched your search
@@ -1,7 +1,5 @@
|
||||
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),
|
||||
@@ -11,28 +9,8 @@ export const submitResultSchema = z.object({
|
||||
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(),
|
||||
state: z.record(z.unknown()),
|
||||
exam: z.record(z.unknown()),
|
||||
})
|
||||
|
||||
export const resultIdParamSchema = z.object({
|
||||
|
||||
Reference in new issue
Block a user