import { z } from "zod"

export const CreateHomeworkAssignmentSchema = z.object({
  sourceExamId: z.string().optional(),
  classId: z.string().min(1),
  title: z.string().min(1, "Title is required for quick assignments"),
  description: z.string().optional(),
  availableAt: z.string().optional(),
  dueAt: z.string().optional(),
  allowLate: z.coerce.boolean().optional(),
  lateDueAt: z.string().optional(),
  maxAttempts: z.coerce.number().int().min(1).max(20).optional(),
  targetStudentIds: z.array(z.string().min(1)).optional(),
  publish: z.coerce.boolean().optional(),
})

export type CreateHomeworkAssignmentInput = z.infer<typeof CreateHomeworkAssignmentSchema>

export const GradeHomeworkSchema = z.object({
  submissionId: z.string().min(1),
  answers: z.array(
    z.object({
      id: z.string().min(1),
      score: z.coerce.number().min(0),
      feedback: z.string().optional(),
    })
  ),
})
