feat: add search and filter capabilities to student and quiz endpoints, implement YouTube video support for lessons

Add search and status filter parameters to getEnrolledStudents endpoint to filter students by name/email/username and enrollment status. Add search and isPassed filter parameters to getQuizScores endpoint to filter quiz results by student details and pass status. Remove separate searchStudents endpoint as its functionality is now integrated into getEnrolledStudents. Add setYouTubeVideo endpoint to
This commit is contained in:
JakkrapartXD 2026-02-03 17:23:35 +07:00
parent e8a10e5024
commit ff841c7638
6 changed files with 246 additions and 125 deletions

View file

@ -1,4 +1,4 @@
import { Delete, Path, Post, Put, Request, Response, Route, Security, SuccessResponse, Tags, UploadedFile } from 'tsoa';
import { Body, Delete, Path, Post, Put, Request, Response, Route, Security, SuccessResponse, Tags, UploadedFile } from 'tsoa';
import { ValidationError } from '../middleware/errorHandler';
import { ChaptersLessonService } from '../services/ChaptersLesson.service';
import {
@ -7,7 +7,9 @@ import {
UpdateLessonResponse,
VideoOperationResponse,
AttachmentOperationResponse,
DeleteAttachmentResponse
DeleteAttachmentResponse,
YouTubeVideoResponse,
SetYouTubeVideoBody,
} from '../types/ChaptersLesson.typs';
const chaptersLessonService = new ChaptersLessonService();
@ -184,4 +186,46 @@ export class LessonsController {
attachment_id: attachmentId,
});
}
/**
* YouTube ()
* Set YouTube video for a lesson (replaces existing video if any)
*
* @param courseId Course ID
* @param chapterId Chapter ID
* @param lessonId Lesson ID
* @param body YouTube video info
*/
@Post('{lessonId}/youtube-video')
@Security('jwt', ['instructor'])
@SuccessResponse('200', 'YouTube video set successfully')
@Response('400', 'Validation error')
@Response('401', 'Unauthorized')
@Response('403', 'Forbidden')
@Response('404', 'Lesson not found')
public async setYouTubeVideo(
@Request() request: any,
@Path() courseId: number,
@Path() chapterId: number,
@Path() lessonId: number,
@Body() body: SetYouTubeVideoBody
): Promise<YouTubeVideoResponse> {
const token = request.headers.authorization?.replace('Bearer ', '');
if (!token) throw new ValidationError('No token provided');
if (!body.youtube_video_id) {
throw new ValidationError('YouTube video ID is required');
}
if (!body.video_title) {
throw new ValidationError('Video title is required');
}
return await chaptersLessonService.setYouTubeVideo({
token,
course_id: courseId,
lesson_id: lessonId,
youtube_video_id: body.youtube_video_id,
video_title: body.video_title,
});
}
}