feat: implement course cloning functionality including chapters, lessons, quizzes, and attachments for instructors.
All checks were successful
Build and Deploy Backend / Build Backend Docker Image (push) Successful in 24s
Build and Deploy Backend / Deploy E-learning Backend to Dev Server (push) Successful in 3s
Build and Deploy Backend / Notify Deployment Status (push) Successful in 1s

This commit is contained in:
JakkrapartXD 2026-02-13 17:41:01 +07:00
parent 5442f1beb6
commit c5aa195b13
4 changed files with 283 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import {
GetEnrolledStudentDetailResponse,
GetCourseApprovalHistoryResponse,
setCourseDraftResponse,
CloneCourseResponse,
} from '../types/CoursesInstructor.types';
import { CreateCourseValidator } from "../validators/CoursesInstructor.validator";
@ -178,6 +179,33 @@ export class CoursesInstructorController {
return await CoursesInstructorService.deleteCourse(token, courseId);
}
/**
* (Clone Course)
* Clone an existing course to a new one with copied chapters, lessons, quizzes, and attachments
* @param courseId - / Source Course ID
* @param body - / New course title
*/
@Post('{courseId}/clone')
@Security('jwt', ['instructor'])
@SuccessResponse('201', 'Course cloned successfully')
@Response('401', 'Invalid or expired token')
@Response('403', 'Not an instructor of this course')
@Response('404', 'Course not found')
public async cloneCourse(
@Request() request: any,
@Path() courseId: number,
@Body() body: { title: { th: string; en: string } }
): Promise<CloneCourseResponse> {
const token = request.headers.authorization?.replace('Bearer ', '');
if (!token) throw new ValidationError('No token provided');
return await CoursesInstructorService.cloneCourse({
token,
course_id: courseId,
title: body.title
});
}
/**
*
* Submit course for admin review and approval