feat: add medical test entities

This commit is contained in:
2026-05-23 11:02:20 +03:30
parent 7186af8e7f
commit 7dda2564a8
32 changed files with 389 additions and 11 deletions
@@ -0,0 +1,48 @@
import { Test } from '@/modules/tests/entities/test.entity';
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
import { QuestionType } from '../enums/question-type.enum';
import type { QuestionMetadata } from '../types/question-metadata.type';
import { Choice } from './choice.entity';
@Entity()
export class Question {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(() => Test, (test) => test.questions, {
onDelete: 'CASCADE',
})
test: Test;
@Column({
type: 'enum',
enum: QuestionType,
default: QuestionType.MULTI_CHOICE,
})
type: QuestionType;
@Column({ type: 'text' })
content: string;
@Column({ type: 'int', nullable: false })
order: number;
@Column({ type: 'boolean', default: true })
required: boolean;
@Column({ type: 'jsonb', nullable: true })
metadata: QuestionMetadata;
@OneToMany(() => Choice, (choice) => choice.question)
choices?: Array<Choice>;
@CreateDateColumn()
createdAt: Date;
}