feat: exam actions and data safety fixes

This commit is contained in:
SpecialX
2025-12-30 17:48:22 +08:00
parent e7c902e8e1
commit f7ff018490
27 changed files with 896 additions and 194 deletions

View File

@@ -80,7 +80,12 @@ async function seed() {
const qId = createId()
questionIds.push(qId)
const type = faker.helpers.arrayElement(["single_choice", "multiple_choice", "text", "judgment"])
const type = faker.helpers.arrayElement([
"single_choice",
"multiple_choice",
"text",
"judgment",
] as const)
await db.insert(questions).values({
id: qId,
@@ -93,7 +98,7 @@ async function seed() {
{ id: "D", text: faker.lorem.sentence(), isCorrect: false },
] : undefined
},
type: type as any,
type,
difficulty: faker.helpers.arrayElement(DIFFICULTY),
authorId: teacherId,
})
@@ -105,7 +110,7 @@ async function seed() {
const examId = createId()
const subject = faker.helpers.arrayElement(SUBJECTS)
const grade = faker.helpers.arrayElement(GRADES)
const status = faker.helpers.arrayElement(["draft", "published", "archived"])
const status = faker.helpers.arrayElement(["draft", "published", "archived"] as const)
const scheduledAt = faker.date.soon({ days: 30 })
@@ -126,7 +131,7 @@ async function seed() {
description: JSON.stringify(meta),
creatorId: teacherId,
startTime: scheduledAt,
status: status as any,
status,
})
// Link some questions to this exam (random 5 questions)