Spaces:
Sleeping
Sleeping
| import { | |
| Controller, | |
| Get, | |
| Param, | |
| ParseIntPipe, | |
| Query, | |
| Req, | |
| UseGuards, | |
| } from '@nestjs/common'; | |
| import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; | |
| import { RoleName } from '../auth/entities/role.entity'; | |
| import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; | |
| import { RolesGuard } from '../auth/guards/roles.guard'; | |
| import { Roles } from '../auth/roles.decorator'; | |
| import { ExamDraftListQueryDto } from './dto/exam-query.dto'; | |
| import { ExamsService } from './exams.service'; | |
| type AuthenticatedRequest = { | |
| user: { | |
| userId: number; | |
| }; | |
| }; | |
| ('Exams') | |
| ('JWT-auth') | |
| (JwtAuthGuard, RolesGuard) | |
| ('api/exam-drafts') | |
| export class ExamDraftsController { | |
| constructor(private readonly examsService: ExamsService) {} | |
| () | |
| (RoleName.INSTRUCTOR) | |
| getDrafts( | |
| () req: AuthenticatedRequest, | |
| () query: ExamDraftListQueryDto, | |
| ) { | |
| return this.examsService.findDrafts( | |
| req.user.userId, | |
| query.page, | |
| query.limit, | |
| query, | |
| ); | |
| } | |
| ('list') | |
| (RoleName.INSTRUCTOR) | |
| listDrafts( | |
| () req: AuthenticatedRequest, | |
| () query: ExamDraftListQueryDto, | |
| ) { | |
| return this.examsService.findDrafts( | |
| req.user.userId, | |
| query.page, | |
| query.limit, | |
| query, | |
| ); | |
| } | |
| (':draftId') | |
| (RoleName.INSTRUCTOR) | |
| getDraftById( | |
| ('draftId', ParseIntPipe) draftId: number, | |
| () req: AuthenticatedRequest, | |
| ) { | |
| return this.examsService.findDraftById(draftId, req.user.userId); | |
| } | |
| } | |