import { z } from 'zod';

export const QuizQuestionSchema = z.object({
  type: z.enum(['choice', 'fill', 'judge']),
  stem: z.string().min(1).max(2000),
  options: z.array(z.string().max(500)).min(2).max(6).optional(),
  answer: z.string().min(1).max(500),
  explanation: z.string().min(1).max(2000),
  sourceBlockIds: z.array(z.string().max(100)).max(10).optional(),
});

export const QuizGenerationResultSchema = z.object({
  quizTitle: z.string().min(1).max(255),
  quizDescription: z.string().max(1000).optional(),
  questions: z.array(QuizQuestionSchema).min(1).max(50),
});

export type QuizGenerationResult = z.infer<typeof QuizGenerationResultSchema>;

export const QUIZ_OUTPUT_SCHEMA_DESC = `{
  "quizTitle": "光合作用基础测验",
  "quizDescription": "检验对光合作用基本概念和过程的理解",
  "questions": [
    {
      "type": "choice",
      "stem": "光合作用中，光反应产生的气体是什么？",
      "options": ["氧气", "二氧化碳", "氮气", "氢气"],
      "answer": "0",
      "explanation": "光反应中水分子分解产生氧气",
      "sourceBlockIds": ["ki_001"]
    },
    {
      "type": "fill",
      "stem": "光合作用主要在植物细胞的____中进行。",
      "answer": "叶绿体",
      "explanation": "叶绿体是光合作用的场所"
    },
    {
      "type": "judge",
      "stem": "光合作用只能在有光条件下进行。",
      "answer": "true",
      "explanation": "光合作用的光反应需要光能，暗反应虽不直接需光但依赖光反应产物"
    }
  ]
}`;
