feat: add user submission functionality
This commit is contained in:
@@ -9,6 +9,8 @@ import { AdminAuthService } from './auth/providers/admin-auth.service';
|
||||
import { QuestionsModule } from '../questions/questions.module';
|
||||
import { AdminQuestionsController } from './questions/admin-questions.controller';
|
||||
import { AdminChoicesController } from './choices/admin-choices.controller';
|
||||
import { ScoringModule } from '../scoring/scoring.module';
|
||||
import { AdminScoringController } from './scoring/admin-scoring.controller';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -17,12 +19,14 @@ import { AdminChoicesController } from './choices/admin-choices.controller';
|
||||
AuthModule,
|
||||
HashingModule,
|
||||
UsersModule,
|
||||
ScoringModule,
|
||||
],
|
||||
controllers: [
|
||||
AdminTestsController,
|
||||
AdminAuthController,
|
||||
AdminQuestionsController,
|
||||
AdminChoicesController,
|
||||
AdminScoringController,
|
||||
],
|
||||
providers: [AdminAuthService],
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GET {{baseUrl}}/admin/choices/
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
|
||||
GET {{baseUrl}}/admin/choices/1
|
||||
GET {{baseUrl}}/admin/choices/3
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
PATCH {{baseUrl}}/admin/choices/1
|
||||
PATCH {{baseUrl}}/admin/choices/3
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"question": 4
|
||||
"text": "Option 1",
|
||||
"order": 1
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ Content-Type: application/json
|
||||
{
|
||||
"question": 4,
|
||||
"text": "Option 2",
|
||||
"value": 2,
|
||||
"order": 2
|
||||
"value": 1,
|
||||
"order": 2,
|
||||
"score": 2
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
GET {{baseUrl}}/admin/questions
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
|
||||
GET {{baseUrl}}/admin/questions/1
|
||||
GET {{baseUrl}}/admin/questions/4
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
|
||||
GET {{baseUrl}}/admin/questions/range-rules?limit=1&page=2&sortBy=id&order=ASC
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
PATCH {{baseUrl}}/admin/questions/4
|
||||
PATCH {{baseUrl}}/admin/questions/1
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"test": 4
|
||||
"type": "multi-choice"
|
||||
}
|
||||
|
||||
PATCH {{baseUrl}}/admin/questions/range-rules/1
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { Role } from '@/common/enums/roles.enum';
|
||||
import { Roles } from '@/modules/auth/decorators/roles.decorator';
|
||||
import { CreateResultRangeDTO } from '@/modules/scoring/dtos/create-result-range.dto';
|
||||
import { FindResultRangeDTO } from '@/modules/scoring/dtos/find-result-range.dto';
|
||||
import { UpdateResultRangeDTO } from '@/modules/scoring/dtos/update-result-range.dto';
|
||||
import { ResultRangeService } from '@/modules/scoring/providers/result-range.service';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
|
||||
@Controller('admin/scoring')
|
||||
@Roles(Role.SUPERUSER, Role.ADMIN)
|
||||
export class AdminScoringController {
|
||||
constructor(
|
||||
/**
|
||||
* Inject ResultRange Service
|
||||
*/
|
||||
private readonly resultRangeService: ResultRangeService,
|
||||
) {}
|
||||
|
||||
@Post('result-ranges')
|
||||
public async createResultRanges(
|
||||
@Body() createResultRangeDto: CreateResultRangeDTO,
|
||||
) {
|
||||
return await this.resultRangeService.createOne(createResultRangeDto);
|
||||
}
|
||||
|
||||
@Get('result-ranges')
|
||||
public async getAllResultRanges(@Query() query: FindResultRangeDTO) {
|
||||
return await this.resultRangeService.findAllForAdmin(query);
|
||||
}
|
||||
|
||||
@Get('result-ranges/:id')
|
||||
public async getResultRangeById(@Param('id', ParseIntPipe) id: number) {
|
||||
return await this.resultRangeService.findOneForAdmin(id);
|
||||
}
|
||||
|
||||
@Patch('result-ranges/:id')
|
||||
public async updateResultRange(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() updateResultRangeDto: UpdateResultRangeDTO,
|
||||
) {
|
||||
return await this.resultRangeService.updateOne(id, updateResultRangeDto);
|
||||
}
|
||||
|
||||
@Delete('result-ranges/:id')
|
||||
public async deleteResultRange(@Param('id', ParseIntPipe) id: number) {
|
||||
return await this.resultRangeService.deleteOne(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
GET {{baseUrl}}/admin/scoring/result-ranges/
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
@@ -0,0 +1,11 @@
|
||||
POST {{baseUrl}}/admin/scoring/result-ranges/
|
||||
Authorization: Bearer {{$global.accessToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"test": 4,
|
||||
"title": "احتمال خیلی بالا",
|
||||
"description": "احتمال ابتلا خیلی بالا است.",
|
||||
"minScore": 21,
|
||||
"maxScore": 40
|
||||
}
|
||||
Reference in New Issue
Block a user