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:
@@ -142,6 +142,14 @@ interface BackendCourse {
|
|||||||
updated_at: string
|
updated_at: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BackendQuizQuestion {
|
||||||
|
id: string
|
||||||
|
question: string
|
||||||
|
options: string[]
|
||||||
|
correct_index: number
|
||||||
|
explanation: string
|
||||||
|
}
|
||||||
|
|
||||||
interface BackendLesson {
|
interface BackendLesson {
|
||||||
id: string
|
id: string
|
||||||
course_id: string
|
course_id: string
|
||||||
@@ -151,7 +159,7 @@ interface BackendLesson {
|
|||||||
content_url?: string
|
content_url?: string
|
||||||
duration_minutes: number
|
duration_minutes: number
|
||||||
order_index: number
|
order_index: number
|
||||||
quiz_questions?: Array<{ question: string; options: string[]; correct_index: number; explanation: string }>
|
quiz_questions?: BackendQuizQuestion[]
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapCourseFromBackend(bc: BackendCourse): Course {
|
function mapCourseFromBackend(bc: BackendCourse): Course {
|
||||||
@@ -170,6 +178,14 @@ function mapCourseFromBackend(bc: BackendCourse): Course {
|
|||||||
contentMarkdown: l.content_url || '',
|
contentMarkdown: l.content_url || '',
|
||||||
durationMinutes: l.duration_minutes || 0,
|
durationMinutes: l.duration_minutes || 0,
|
||||||
order: l.order_index,
|
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,
|
createdAt: bc.created_at,
|
||||||
updatedAt: bc.updated_at,
|
updatedAt: bc.updated_at,
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ export interface Lesson {
|
|||||||
videoUrl?: string
|
videoUrl?: string
|
||||||
order: number
|
order: number
|
||||||
durationMinutes: number
|
durationMinutes: number
|
||||||
|
quizQuestions?: QuizQuestion[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QuizQuestion {
|
export interface QuizQuestion {
|
||||||
|
|||||||
Reference in New Issue
Block a user