feat: add API endpoint and service logic for reordering quiz questions.

This commit is contained in:
JakkrapartXD 2026-01-26 12:00:59 +07:00
parent 44c61c8fb2
commit 84e4d478c7
3 changed files with 125 additions and 0 deletions

View file

@ -22,6 +22,8 @@ import {
ReorderLessonsBody,
AddQuestionBody,
UpdateQuestionBody,
ReorderQuestionResponse,
ReorderQuestionBody,
} from '../types/ChaptersLesson.typs';
const chaptersLessonService = new ChaptersLessonService();
@ -305,6 +307,28 @@ export class ChaptersLessonInstructorController {
});
}
@Put('chapters/{chapterId}/lessons/{lessonId}/questions/{questionId}/reorder')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'Question reordered successfully')
public async reorderQuestion(
@Request() request: any,
@Path() courseId: number,
@Path() chapterId: number,
@Path() lessonId: number,
@Path() questionId: number,
@Body() body: ReorderQuestionBody
): Promise<ReorderQuestionResponse> {
const token = request.headers.authorization?.replace('Bearer ', '');
if (!token) throw new ValidationError('No token provided');
return await chaptersLessonService.reorderQuestion({
token,
course_id: courseId,
lesson_id: lessonId,
question_id: questionId,
sort_order: body.sort_order,
});
}
/**
*
* Delete a question