72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const courseSchema = z.object({
|
|
name: z.string().min(1, "课程名称不能为空"),
|
|
description: z.string().optional(),
|
|
});
|
|
|
|
export const classroomSchema = z.object({
|
|
name: z.string().min(1, "班级名称不能为空"),
|
|
description: z.string().optional(),
|
|
courseId: z.number().int().positive(),
|
|
});
|
|
|
|
export const assignmentSchema = z.object({
|
|
title: z.string().min(1, "作业标题不能为空"),
|
|
description: z.string().optional(),
|
|
courseId: z.number().int().positive(),
|
|
classroomId: z.number().int().positive(),
|
|
gradingCriteria: z.string().optional(),
|
|
autoEvaluate: z.boolean().optional(),
|
|
formSchema: z
|
|
.object({
|
|
fields: z
|
|
.array(
|
|
z.object({
|
|
name: z.string().min(1),
|
|
label: z.string().min(1),
|
|
type: z.enum(["text", "textarea"]).default("text"),
|
|
placeholder: z.string().optional(),
|
|
required: z.boolean().optional(),
|
|
}),
|
|
)
|
|
.default([]),
|
|
file_upload: z
|
|
.object({
|
|
accept: z.array(z.string()).default([".pdf"]),
|
|
label: z.string().optional(),
|
|
})
|
|
.default({ accept: [".pdf"], label: "上传 PDF 文件" }),
|
|
})
|
|
.default({
|
|
fields: [
|
|
{
|
|
name: "student_id",
|
|
label: "学号",
|
|
type: "text",
|
|
placeholder: "请输入学号",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "student_name",
|
|
label: "姓名",
|
|
type: "text",
|
|
placeholder: "请输入姓名",
|
|
required: true,
|
|
},
|
|
],
|
|
file_upload: { accept: [".pdf"], label: "上传 PDF 文件" },
|
|
}),
|
|
});
|
|
|
|
export const submissionSchema = z.object({
|
|
formPayload: z.record(z.any()).optional(),
|
|
studentId: z.string().min(1, "学号不能为空"),
|
|
studentName: z.string().min(1, "姓名不能为空"),
|
|
});
|
|
|
|
export const assignmentUpdateSchema = z.object({
|
|
gradingCriteria: z.string().nullable().optional(),
|
|
autoEvaluate: z.boolean().optional(),
|
|
});
|