add check quizz for student
This commit is contained in:
parent
76f8ab120a
commit
c982ab2c05
3 changed files with 232 additions and 0 deletions
|
|
@ -11,6 +11,8 @@ import {
|
|||
SaveVideoProgressBody,
|
||||
GetVideoProgressResponse,
|
||||
CompleteLessonResponse,
|
||||
SubmitQuizResponse,
|
||||
SubmitQuizBody,
|
||||
} from '../types/CoursesStudent.types';
|
||||
import { EnrollmentStatus } from '@prisma/client';
|
||||
|
||||
|
|
@ -202,4 +204,34 @@ export class CoursesStudentController {
|
|||
}
|
||||
return await this.service.completeLesson({ token, lesson_id: lessonId });
|
||||
}
|
||||
|
||||
/**
|
||||
* ส่งคำตอบ Quiz และรับผลคะแนน
|
||||
* Submit quiz answers and get score
|
||||
* @param courseId - รหัสคอร์ส / Course ID
|
||||
* @param lessonId - รหัสบทเรียน / Lesson ID
|
||||
*/
|
||||
@Post('courses/{courseId}/lessons/{lessonId}/quiz/submit')
|
||||
@Security('jwt', ['student'])
|
||||
@SuccessResponse('200', 'Quiz submitted successfully')
|
||||
@Response('401', 'Invalid or expired token')
|
||||
@Response('403', 'Not enrolled in this course')
|
||||
@Response('404', 'Lesson or quiz not found')
|
||||
public async submitQuiz(
|
||||
@Request() request: any,
|
||||
@Path() courseId: number,
|
||||
@Path() lessonId: number,
|
||||
@Body() body: SubmitQuizBody
|
||||
): Promise<SubmitQuizResponse> {
|
||||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) {
|
||||
throw new ValidationError('No token provided');
|
||||
}
|
||||
return await this.service.submitQuiz({
|
||||
token,
|
||||
course_id: courseId,
|
||||
lesson_id: lessonId,
|
||||
answers: body.answers,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue