diff --git a/Backend/src/services/ChaptersLesson.service.ts b/Backend/src/services/ChaptersLesson.service.ts index 5483ff81..57462d69 100644 --- a/Backend/src/services/ChaptersLesson.service.ts +++ b/Backend/src/services/ChaptersLesson.service.ts @@ -182,6 +182,10 @@ export class ChaptersLessonService { if (!currentChapter) { throw new NotFoundError('Chapter not found'); } + // Validate chapter belongs to the specified course + if (currentChapter.course_id !== course_id) { + throw new NotFoundError('Chapter not found in this course'); + } const oldSortOrder = currentChapter.sort_order; // If same position, no need to reorder