update api chapterlesson
This commit is contained in:
parent
2fc0fb7a76
commit
5c2b5d55aa
11 changed files with 855 additions and 85 deletions
|
|
@ -260,7 +260,8 @@ export class ChaptersLessonInstructorController {
|
|||
token,
|
||||
course_id: courseId,
|
||||
chapter_id: chapterId,
|
||||
lesson_ids: body.lesson_ids,
|
||||
lesson_id: body.lesson_id,
|
||||
sort_order: body.sort_order,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
import { Get, Path, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
||||
import { ValidationError } from '../middleware/errorHandler';
|
||||
import { ChaptersLessonService } from '../services/ChaptersLesson.service';
|
||||
import {
|
||||
ListChaptersResponse,
|
||||
GetLessonResponse,
|
||||
} from '../types/ChaptersLesson.typs';
|
||||
|
||||
const chaptersLessonService = new ChaptersLessonService();
|
||||
|
||||
@Route('api/students/courses/{courseId}')
|
||||
@Tags('ChaptersLessons - Student')
|
||||
export class ChaptersLessonStudentController {
|
||||
|
||||
// ============================================
|
||||
// Chapter Endpoints (Read-only for students)
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* ดึง chapters ทั้งหมดของ course (พร้อม lessons) - สำหรับนักเรียนที่ลงทะเบียนแล้ว
|
||||
* Get all chapters of a course with lessons - for enrolled students
|
||||
*/
|
||||
@Get('chapters')
|
||||
@Security('jwt', ['student'])
|
||||
@SuccessResponse('200', 'Chapters retrieved successfully')
|
||||
@Response('401', 'Unauthorized')
|
||||
@Response('403', 'Not enrolled in this course')
|
||||
public async listChapters(@Request() request: any, @Path() courseId: number): Promise<ListChaptersResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
return await chaptersLessonService.listChapters({ token, course_id: courseId });
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Lesson Endpoints (Read-only for students)
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* ดึงข้อมูล lesson พร้อม attachments และ quiz - สำหรับนักเรียนที่ลงทะเบียนแล้ว
|
||||
* Get lesson with attachments and quiz - for enrolled students
|
||||
* หมายเหตุ: จะดูได้เฉพาะ lesson ที่ is_published = true
|
||||
*/
|
||||
@Get('chapters/{chapterId}/lessons/{lessonId}')
|
||||
@Security('jwt', ['student'])
|
||||
@SuccessResponse('200', 'Lesson retrieved successfully')
|
||||
@Response('401', 'Unauthorized')
|
||||
@Response('403', 'Not enrolled or lesson not published')
|
||||
@Response('404', 'Lesson not found')
|
||||
public async getLesson(
|
||||
@Request() request: any,
|
||||
@Path() courseId: number,
|
||||
@Path() chapterId: number,
|
||||
@Path() lessonId: number
|
||||
): Promise<GetLessonResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
return await chaptersLessonService.getLesson({ token, course_id: courseId, chapter_id: chapterId, lesson_id: lessonId });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue