Fix: map quiz_questions and content from backend to frontend Lesson type

- Add quizQuestions field to Lesson interface
- Map quiz_questions (snake_case) to quizQuestions (camelCase) in course mapping
- Map correct_index to correctOptionIndex for quiz rendering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-02-26 17:36:54 +01:00
parent 94006be778
commit 1698912a27
2 changed files with 18 additions and 1 deletions

View File

@@ -142,6 +142,14 @@ interface BackendCourse {
updated_at: string
}
interface BackendQuizQuestion {
id: string
question: string
options: string[]
correct_index: number
explanation: string
}
interface BackendLesson {
id: string
course_id: string
@@ -151,7 +159,7 @@ interface BackendLesson {
content_url?: string
duration_minutes: number
order_index: number
quiz_questions?: Array<{ question: string; options: string[]; correct_index: number; explanation: string }>
quiz_questions?: BackendQuizQuestion[]
}
function mapCourseFromBackend(bc: BackendCourse): Course {
@@ -170,6 +178,14 @@ function mapCourseFromBackend(bc: BackendCourse): Course {
contentMarkdown: l.content_url || '',
durationMinutes: l.duration_minutes || 0,
order: l.order_index,
quizQuestions: (l.quiz_questions || []).map(q => ({
id: q.id || `q-${Math.random().toString(36).slice(2)}`,
lessonId: l.id,
question: q.question,
options: q.options,
correctOptionIndex: q.correct_index,
explanation: q.explanation,
})),
})),
createdAt: bc.created_at,
updatedAt: bc.updated_at,

View File

@@ -131,6 +131,7 @@ export interface Lesson {
videoUrl?: string
order: number
durationMinutes: number
quizQuestions?: QuizQuestion[]
}
export interface QuizQuestion {