add quastion to api
This commit is contained in:
parent
dcf0385a87
commit
76f8ab120a
2 changed files with 37 additions and 3 deletions
|
|
@ -283,14 +283,25 @@ export class CoursesStudentService {
|
||||||
throw new ForbiddenError('You are not enrolled in this course');
|
throw new ForbiddenError('You are not enrolled in this course');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get lesson with attachments and quiz
|
// Get lesson with attachments and quiz (including questions and choices)
|
||||||
const lesson = await prisma.lesson.findUnique({
|
const lesson = await prisma.lesson.findUnique({
|
||||||
where: { id: lesson_id },
|
where: { id: lesson_id },
|
||||||
include: {
|
include: {
|
||||||
attachments: {
|
attachments: {
|
||||||
orderBy: { sort_order: 'asc' },
|
orderBy: { sort_order: 'asc' },
|
||||||
},
|
},
|
||||||
quiz: true,
|
quiz: {
|
||||||
|
include: {
|
||||||
|
questions: {
|
||||||
|
orderBy: { sort_order: 'asc' },
|
||||||
|
include: {
|
||||||
|
choices: {
|
||||||
|
orderBy: { sort_order: 'asc' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
chapter: {
|
chapter: {
|
||||||
include: {
|
include: {
|
||||||
lessons: {
|
lessons: {
|
||||||
|
|
@ -420,6 +431,18 @@ export class CoursesStudentService {
|
||||||
time_limit: lesson.quiz.time_limit,
|
time_limit: lesson.quiz.time_limit,
|
||||||
shuffle_questions: lesson.quiz.shuffle_questions,
|
shuffle_questions: lesson.quiz.shuffle_questions,
|
||||||
shuffle_choices: lesson.quiz.shuffle_choices,
|
shuffle_choices: lesson.quiz.shuffle_choices,
|
||||||
|
questions: lesson.quiz.questions.map(q => ({
|
||||||
|
id: q.id,
|
||||||
|
question: q.question as { th: string; en: string },
|
||||||
|
question_type: q.question_type,
|
||||||
|
score: q.score,
|
||||||
|
sort_order: q.sort_order,
|
||||||
|
choices: q.choices.map(c => ({
|
||||||
|
id: c.id,
|
||||||
|
text: c.text as { th: string; en: string },
|
||||||
|
sort_order: c.sort_order,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
} : null,
|
} : null,
|
||||||
prev_lesson_id: prevLessonId,
|
prev_lesson_id: prevLessonId,
|
||||||
next_lesson_id: nextLessonId,
|
next_lesson_id: nextLessonId,
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,6 @@ export interface LessonContentData {
|
||||||
presigned_url: string | null; // Presigned URL for attachment
|
presigned_url: string | null; // Presigned URL for attachment
|
||||||
}[];
|
}[];
|
||||||
quiz?: {
|
quiz?: {
|
||||||
|
|
||||||
id: number;
|
id: number;
|
||||||
title: MultiLangText;
|
title: MultiLangText;
|
||||||
description: MultiLangText | null;
|
description: MultiLangText | null;
|
||||||
|
|
@ -158,6 +157,18 @@ export interface LessonContentData {
|
||||||
time_limit: number | null;
|
time_limit: number | null;
|
||||||
shuffle_questions: boolean;
|
shuffle_questions: boolean;
|
||||||
shuffle_choices: boolean;
|
shuffle_choices: boolean;
|
||||||
|
questions: {
|
||||||
|
id: number;
|
||||||
|
question: MultiLangText;
|
||||||
|
question_type: 'MULTIPLE_CHOICE' | 'TRUE_FALSE' | 'SHORT_ANSWER';
|
||||||
|
score: number;
|
||||||
|
sort_order: number;
|
||||||
|
choices: {
|
||||||
|
id: number;
|
||||||
|
text: MultiLangText;
|
||||||
|
sort_order: number;
|
||||||
|
}[];
|
||||||
|
}[];
|
||||||
} | null;
|
} | null;
|
||||||
// Navigation
|
// Navigation
|
||||||
prev_lesson_id: number | null;
|
prev_lesson_id: number | null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue