your message

This commit is contained in:
root
2026-02-06 14:53:52 +00:00
parent c809d049fe
commit 3d488f22b7
47 changed files with 3127 additions and 425 deletions

View File

@ -12,6 +12,9 @@ import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { EnrollmentService } from './enrollment.service';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { User } from '@coursecraft/database';
import { SubmitQuizDto } from './dto/submit-quiz.dto';
import { CreateReviewDto } from './dto/create-review.dto';
import { SubmitHomeworkDto } from './dto/submit-homework.dto';
@ApiTags('enrollment')
@Controller('enrollment')
@ -55,10 +58,32 @@ export class EnrollmentController {
async submitQuiz(
@Param('courseId') courseId: string,
@Param('lessonId') lessonId: string,
@Body('score') score: number,
@Body() dto: SubmitQuizDto,
@CurrentUser() user: User,
): Promise<any> {
return this.enrollmentService.saveQuizScore(user.id, courseId, lessonId, score);
return this.enrollmentService.submitQuiz(user.id, courseId, lessonId, dto.answers);
}
@Get(':courseId/lessons/:lessonId/homework')
@ApiOperation({ summary: 'Get (or lazy-create) homework for lesson' })
async getHomework(
@Param('courseId') courseId: string,
@Param('lessonId') lessonId: string,
@CurrentUser() user: User,
): Promise<any> {
return this.enrollmentService.getHomework(user.id, courseId, lessonId);
}
@Post(':courseId/lessons/:lessonId/homework')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Submit written homework for lesson' })
async submitHomework(
@Param('courseId') courseId: string,
@Param('lessonId') lessonId: string,
@Body() dto: SubmitHomeworkDto,
@CurrentUser() user: User,
): Promise<any> {
return this.enrollmentService.submitHomework(user.id, courseId, lessonId, dto.content);
}
@Post(':courseId/review')
@ -66,7 +91,7 @@ export class EnrollmentController {
@ApiOperation({ summary: 'Leave a review' })
async createReview(
@Param('courseId') courseId: string,
@Body() body: { rating: number; title?: string; content?: string },
@Body() body: CreateReviewDto,
@CurrentUser() user: User,
): Promise<any> {
return this.enrollmentService.createReview(user.id, courseId, body.rating, body.title, body.content);