feat: AI-powered quiz generation with caching
- Add Quiz model to store generated questions in DB - Integrate OpenRouter API to generate quiz from lesson content - Cache quiz results to avoid regenerating on every request - Extract text from TipTap JSON and send to AI - Fallback to default questions if AI fails or no API key Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -241,6 +241,7 @@ model Lesson {
|
||||
// Relations
|
||||
chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade)
|
||||
homework Homework[]
|
||||
quiz Quiz?
|
||||
|
||||
// Vector embedding for semantic search
|
||||
embedding Unsupported("vector(1536)")?
|
||||
@ -249,6 +250,18 @@ model Lesson {
|
||||
@@map("lessons")
|
||||
}
|
||||
|
||||
model Quiz {
|
||||
id String @id @default(uuid())
|
||||
lessonId String @unique @map("lesson_id")
|
||||
questions Json // Array of {id, question, options, correctAnswer}
|
||||
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("quizzes")
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// AI Course Generation
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user