Spaces:
Sleeping
Sleeping
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Put, | |
| Delete, | |
| Param, | |
| Body, | |
| Query, | |
| UseGuards, | |
| Request, | |
| } from '@nestjs/common'; | |
| import { | |
| ApiTags, | |
| ApiOperation, | |
| ApiResponse, | |
| ApiBearerAuth, | |
| ApiParam, | |
| ApiQuery, | |
| } from '@nestjs/swagger'; | |
| import { RubricsService } from '../services'; | |
| import { CreateRubricDto } from '../dto'; | |
| import { Roles } from '../../auth/roles.decorator'; | |
| import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard'; | |
| import { RolesGuard } from '../../auth/guards/roles.guard'; | |
| import { RoleName } from '../../auth/entities/role.entity'; | |
| ('๐ Rubrics') | |
| ('api/rubrics') | |
| (JwtAuthGuard, RolesGuard) | |
| ('JWT-auth') | |
| export class RubricsController { | |
| constructor(private readonly rubricsService: RubricsService) {} | |
| () | |
| (RoleName.INSTRUCTOR, RoleName.TA) | |
| ({ summary: 'List rubrics for a course' }) | |
| ({ name: 'courseId', required: true, type: Number, description: 'Course ID', example: 1 }) | |
| ({ status: 200, description: 'List of rubrics' }) | |
| async findAll(('courseId') courseId: number) { | |
| return this.rubricsService.findAll(courseId); | |
| } | |
| () | |
| (RoleName.INSTRUCTOR, RoleName.TA) | |
| ({ summary: 'Create a rubric' }) | |
| ({ status: 201, description: 'Rubric created' }) | |
| async create(() dto: CreateRubricDto, () req) { | |
| const userId = req.user.userId || req.user.id; | |
| return this.rubricsService.create(dto, userId); | |
| } | |
| (':id') | |
| (RoleName.INSTRUCTOR, RoleName.TA) | |
| ({ summary: 'Update a rubric' }) | |
| ({ name: 'id', description: 'Rubric ID', type: Number, example: 1 }) | |
| ({ status: 200, description: 'Rubric updated' }) | |
| async update(('id') id: number, () dto: Partial<CreateRubricDto>) { | |
| return this.rubricsService.update(id, dto); | |
| } | |
| (':id') | |
| (RoleName.INSTRUCTOR, RoleName.TA) | |
| ({ summary: 'Delete a rubric' }) | |
| ({ name: 'id', description: 'Rubric ID', type: Number, example: 1 }) | |
| ({ status: 200, description: 'Rubric deleted' }) | |
| async remove(('id') id: number) { | |
| return this.rubricsService.remove(id); | |
| } | |
| } | |