feat: implement course cloning functionality including chapters, lessons, quizzes, and attachments for instructors.
This commit is contained in:
parent
5442f1beb6
commit
c5aa195b13
4 changed files with 283 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue