feat: change scoring strategy

This commit is contained in:
2026-06-20 07:48:33 +03:30
parent 84b9267735
commit afb5045cf0
33 changed files with 634 additions and 34 deletions
@@ -1,8 +1,12 @@
import { Role } from '@/common/enums/roles.enum';
import { Roles } from '@/modules/auth/decorators/roles.decorator';
import { CreateQuestionRangeRuleDTO } from '@/modules/questions/dtos/create-question-range-rule.dto';
import { CreateQuestionDTO } from '@/modules/questions/dtos/create-question.dto';
import { FindQuestionRangeRuleDTO } from '@/modules/questions/dtos/find-question-range-rule.dto';
import { FindQuestionsDTO } from '@/modules/questions/dtos/find-questions.dto';
import { UpdateQuestionRangeRuleDTO } from '@/modules/questions/dtos/update-question-range-rule.dto';
import { UpdateQuestionDTO } from '@/modules/questions/dtos/update-question.dto';
import { QuestionRangeRuleService } from '@/modules/questions/providers/question-range-rule.service';
import { QuestionsService } from '@/modules/questions/providers/questions.service';
import {
Body,
@@ -26,6 +30,11 @@ export class AdminQuestionsController {
* Inject Questions Service Provider
*/
private readonly questionsService: QuestionsService,
/**
* Inject Questions Range Rules Service
*/
private readonly questionRangeRulesService: QuestionRangeRuleService,
) {}
@Post()
@@ -38,6 +47,44 @@ export class AdminQuestionsController {
return await this.questionsService.findAllForAdmin(query);
}
@Post('range-rules')
public async createQuestionRangeRule(
@Body() createQuestionRangeRuleDto: CreateQuestionRangeRuleDTO,
) {
return await this.questionRangeRulesService.createOne(
createQuestionRangeRuleDto,
);
}
@Get('range-rules')
public async getAllQuestionRangeRules(
@Query() query: FindQuestionRangeRuleDTO,
) {
return await this.questionRangeRulesService.findAllForAdmin(query);
}
@Get('range-rules/:id')
public async getQuestionRangeRuleById(@Param('id', ParseIntPipe) id: number) {
return await this.questionRangeRulesService.findOneForAdmin(id);
}
@Patch('range-rules/:id')
public async updateQuestionRangeRule(
@Param('id', ParseIntPipe) id: number,
@Body() updateQuestionRangeRuleDto: UpdateQuestionRangeRuleDTO,
) {
return await this.questionRangeRulesService.updateOne(
id,
updateQuestionRangeRuleDto,
);
}
@Delete('range-rules/:id')
@HttpCode(HttpStatus.NO_CONTENT)
public async deleteQuestionRangeRule(@Param('id', ParseIntPipe) id: number) {
return await this.questionRangeRulesService.deleteOne(id);
}
@Get(':id')
public async getQuestionById(@Param('id', ParseIntPipe) id: number) {
return await this.questionsService.findOneForAdmin(id);
@@ -1,2 +1,5 @@
DELETE {{baseUrl}}/admin/questions/11
Authorization: Bearer {{$global.accessToken}}
DELETE {{baseUrl}}/admin/questions/range-rules/3
Authorization: Bearer {{$global.accessToken}}
@@ -3,3 +3,9 @@ Authorization: Bearer {{$global.accessToken}}
GET {{baseUrl}}/admin/questions/1
Authorization: Bearer {{$global.accessToken}}
GET {{baseUrl}}/admin/questions/range-rules?limit=1&page=2&sortBy=id&order=ASC
Authorization: Bearer {{$global.accessToken}}
GET {{baseUrl}}/admin/questions/range-rules/2
Authorization: Bearer {{$global.accessToken}}
@@ -5,3 +5,12 @@ Content-Type: application/json
{
"test": 4
}
PATCH {{baseUrl}}/admin/questions/range-rules/1
Authorization: Bearer {{$global.accessToken}}
Content-Type: application/json
{
"min": 6
}
@@ -9,4 +9,15 @@ Content-Type: application/json
"required": true,
"type": "numeric",
"metadata": { "min": 1, "max": 100 }
}
POST {{baseUrl}}/admin/questions/range-rules
Authorization: Bearer {{$global.accessToken}}
Content-Type: application/json
{
"question": 8,
"min": 1,
"max": 5,
"score": 7
}