feat: add is_skippable field to Quiz model with default value true
Add is_skippable boolean field to Quiz schema, update quiz creation and update logic to handle the new field, and include it in student course content responses. Update seed data and type definitions accordingly.
This commit is contained in:
parent
b60a3853cd
commit
18b8f4501f
6 changed files with 9 additions and 1 deletions
|
|
@ -302,6 +302,7 @@ model Quiz {
|
|||
shuffle_questions Boolean @default(false)
|
||||
shuffle_choices Boolean @default(false)
|
||||
show_answers_after_completion Boolean @default(true)
|
||||
is_skippable Boolean @default(true)
|
||||
created_at DateTime @default(now())
|
||||
created_by Int
|
||||
updated_at DateTime? @updatedAt
|
||||
|
|
|
|||
|
|
@ -299,6 +299,7 @@ async function main() {
|
|||
time_limit: 10,
|
||||
shuffle_questions: true,
|
||||
shuffle_choices: true,
|
||||
is_skippable: true,
|
||||
created_by: instructor.id,
|
||||
questions: {
|
||||
create: [
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,7 @@ export class ChaptersLessonService {
|
|||
*/
|
||||
async updateQuiz(request: UpdateQuizInput): Promise<UpdateQuizResponse> {
|
||||
try {
|
||||
const { token, course_id, lesson_id, title, description, passing_score, time_limit, shuffle_questions, shuffle_choices, show_answers_after_completion } = request;
|
||||
const { token, course_id, lesson_id, title, description, passing_score, time_limit, shuffle_questions, shuffle_choices, show_answers_after_completion, is_skippable } = request;
|
||||
const decodedToken = jwt.verify(token, config.jwt.secret) as { id: number };
|
||||
await CoursesInstructorService.validateCourseStatus(course_id);
|
||||
|
||||
|
|
@ -1217,6 +1217,7 @@ export class ChaptersLessonService {
|
|||
if (shuffle_questions !== undefined) updateData.shuffle_questions = shuffle_questions;
|
||||
if (shuffle_choices !== undefined) updateData.shuffle_choices = shuffle_choices;
|
||||
if (show_answers_after_completion !== undefined) updateData.show_answers_after_completion = show_answers_after_completion;
|
||||
if (is_skippable !== undefined) updateData.is_skippable = is_skippable;
|
||||
|
||||
// Update the quiz
|
||||
const updatedQuiz = await prisma.quiz.update({
|
||||
|
|
|
|||
|
|
@ -575,6 +575,7 @@ export class CoursesStudentService {
|
|||
time_limit: lesson.quiz.time_limit,
|
||||
shuffle_questions: lesson.quiz.shuffle_questions,
|
||||
shuffle_choices: lesson.quiz.shuffle_choices,
|
||||
is_skippable: lesson.quiz.is_skippable,
|
||||
questions: lesson.quiz.questions.map(q => ({
|
||||
id: q.id,
|
||||
question: q.question as { th: string; en: string },
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ export interface QuizData {
|
|||
shuffle_questions: boolean;
|
||||
shuffle_choices: boolean;
|
||||
show_answers_after_completion: boolean;
|
||||
is_skippable: boolean;
|
||||
created_at: Date;
|
||||
created_by: number;
|
||||
updated_at: Date | null;
|
||||
|
|
@ -570,6 +571,7 @@ export interface UpdateQuizInput {
|
|||
shuffle_questions?: boolean;
|
||||
shuffle_choices?: boolean;
|
||||
show_answers_after_completion?: boolean;
|
||||
is_skippable?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -650,4 +652,5 @@ export interface UpdateQuizBody {
|
|||
shuffle_questions?: boolean;
|
||||
shuffle_choices?: boolean;
|
||||
show_answers_after_completion?: boolean;
|
||||
is_skippable?: boolean;
|
||||
}
|
||||
|
|
@ -157,6 +157,7 @@ export interface LessonContentData {
|
|||
time_limit: number | null;
|
||||
shuffle_questions: boolean;
|
||||
shuffle_choices: boolean;
|
||||
is_skippable: boolean;
|
||||
questions: {
|
||||
id: number;
|
||||
question: MultiLangText;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue