feat: change scoring strategy
This commit is contained in:
@@ -42,4 +42,12 @@ export class CreateChoiceDTO {
|
||||
}),
|
||||
})
|
||||
order!: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(questions.fields.score)',
|
||||
}),
|
||||
})
|
||||
score!: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IsNotEmpty, IsNumber } from 'class-validator';
|
||||
import { IsValidRange } from '../decorators/is-valid-range.decorator';
|
||||
|
||||
export class CreateQuestionRangeRuleDTO {
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
question!: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
min!: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
max!: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
score!: number;
|
||||
|
||||
@IsValidRange()
|
||||
private readonly _questionRangeValidation!: never;
|
||||
}
|
||||
@@ -50,6 +50,14 @@ export class CreateQuestionDTO {
|
||||
})
|
||||
order!: number;
|
||||
|
||||
@IsPositive({
|
||||
message: t('validation.wrongField', {
|
||||
field: '$t(questions.fields.weight)',
|
||||
}),
|
||||
})
|
||||
@IsOptional()
|
||||
weight?: number;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
required?: boolean;
|
||||
|
||||
@@ -24,6 +24,10 @@ export class FindChoicesDTO extends PartialType(PaginationQueryDTO) {
|
||||
@IsOptional()
|
||||
choiceOrder?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
score?: number;
|
||||
|
||||
@IsEnum(ChoiceSortField)
|
||||
@IsOptional()
|
||||
sortBy?: ChoiceSortField;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { PaginationQueryDTO } from '@/common/dtos/pagination-query.dto';
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { IsEnum, IsNumber, IsOptional } from 'class-validator';
|
||||
import { QuestionRangeRuleSortField } from '../enums/question-range-rule-sort-field.enum';
|
||||
|
||||
export class FindQuestionRangeRuleDTO extends PartialType(PaginationQueryDTO) {
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
id?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
question?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
min?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
max?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
score?: number;
|
||||
|
||||
@IsEnum(QuestionRangeRuleSortField)
|
||||
@IsOptional()
|
||||
sortBy?: QuestionRangeRuleSortField;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IsEnum,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsPositive,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
import { QuestionSortField } from '../enums/question-sort-field.enum';
|
||||
@@ -31,6 +32,10 @@ export class FindQuestionsDTO extends PartialType(PaginationQueryDTO) {
|
||||
@IsOptional()
|
||||
questionOrder?: number;
|
||||
|
||||
@IsPositive()
|
||||
@IsOptional()
|
||||
weight?: number;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
required?: boolean;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateQuestionRangeRuleDTO } from './create-question-range-rule.dto';
|
||||
|
||||
export class UpdateQuestionRangeRuleDTO extends PartialType(
|
||||
CreateQuestionRangeRuleDTO,
|
||||
) {}
|
||||
@@ -35,6 +35,14 @@ export class UpdateQuestionDTO {
|
||||
@IsOptional()
|
||||
order?: number;
|
||||
|
||||
@IsPositive({
|
||||
message: t('validation.wrongField', {
|
||||
field: '$t(questions.fields.weight)',
|
||||
}),
|
||||
})
|
||||
@IsOptional()
|
||||
weight?: number;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
required?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user