forked from hangshuo652/aurak
134 lines
3.7 KiB
TypeScript
134 lines
3.7 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
OneToMany,
|
|
} from 'typeorm';
|
|
import { User } from '../../user/user.entity';
|
|
import { KnowledgeBase } from '../../knowledge-base/knowledge-base.entity';
|
|
import { KnowledgeGroup } from '../../knowledge-group/knowledge-group.entity';
|
|
import type { AssessmentQuestion } from './assessment-question.entity';
|
|
import { AssessmentTemplate } from './assessment-template.entity';
|
|
|
|
export enum AssessmentStatus {
|
|
IN_PROGRESS = 'IN_PROGRESS',
|
|
COMPLETED = 'COMPLETED',
|
|
}
|
|
|
|
@Entity('assessment_sessions')
|
|
export class AssessmentSession {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'user_id', type: 'text' })
|
|
userId: string;
|
|
|
|
@ManyToOne(() => User)
|
|
@JoinColumn({ name: 'user_id' })
|
|
user: User;
|
|
|
|
@Column({ name: 'tenant_id', nullable: true, type: 'text' })
|
|
tenantId: string;
|
|
|
|
@Column({ name: 'knowledge_base_id', nullable: true, type: 'text' })
|
|
knowledgeBaseId: string | null;
|
|
|
|
@ManyToOne(() => KnowledgeBase, { nullable: true })
|
|
@JoinColumn({ name: 'knowledge_base_id' })
|
|
knowledgeBase: KnowledgeBase;
|
|
|
|
@Column({ name: 'knowledge_group_id', nullable: true, type: 'text' })
|
|
knowledgeGroupId: string | null;
|
|
|
|
@ManyToOne(() => KnowledgeGroup, { nullable: true })
|
|
@JoinColumn({ name: 'knowledge_group_id' })
|
|
knowledgeGroup: KnowledgeGroup;
|
|
|
|
@Column({ name: 'thread_id', nullable: true, type: 'text' })
|
|
threadId: string;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
enum: AssessmentStatus,
|
|
default: AssessmentStatus.IN_PROGRESS,
|
|
})
|
|
status: AssessmentStatus;
|
|
|
|
@Column({ type: 'float', name: 'final_score', nullable: true })
|
|
finalScore: number;
|
|
|
|
@Column({ type: 'float', name: 'original_score', nullable: true })
|
|
originalScore: number;
|
|
|
|
@Column({ type: 'text', name: 'final_report', nullable: true })
|
|
finalReport: string;
|
|
|
|
@Column({ type: 'simple-json', nullable: true })
|
|
messages: any[];
|
|
|
|
@Column({ type: 'simple-json', name: 'feedback_history', nullable: true })
|
|
feedbackHistory: any[];
|
|
|
|
@Column({ name: 'reviewed_by', nullable: true, type: 'text' })
|
|
reviewedBy: string | null;
|
|
|
|
@Column({ name: 'reviewed_at', nullable: true, type: 'datetime' })
|
|
reviewedAt: Date | null;
|
|
|
|
@Column({ name: 'review_comment', nullable: true, type: 'text' })
|
|
reviewComment: string | null;
|
|
|
|
@Column({ type: 'simple-json', name: 'review_history', nullable: true })
|
|
reviewHistory: any[];
|
|
|
|
@Column({ name: 'started_at', nullable: true, type: 'datetime' })
|
|
startedAt: Date | null;
|
|
|
|
@Column({ name: 'current_question_started_at', nullable: true, type: 'datetime' })
|
|
currentQuestionStartedAt: Date | null;
|
|
|
|
@Column({ type: 'int', name: 'total_time_limit', default: 1800 })
|
|
totalTimeLimit: number;
|
|
|
|
@Column({ type: 'int', name: 'per_question_time_limit', default: 300 })
|
|
perQuestionTimeLimit: number;
|
|
|
|
@Column({ type: 'int', name: 'current_question_index', default: 0 })
|
|
currentQuestionIndex: number;
|
|
|
|
@Column({ type: 'int', name: 'follow_up_count', default: 0 })
|
|
followUpCount: number;
|
|
|
|
@Column({ type: 'simple-json', nullable: true })
|
|
questions_json: any[];
|
|
|
|
@Column({ type: 'varchar', length: 10, default: 'zh' })
|
|
language: string;
|
|
|
|
@Column({ name: 'template_id', nullable: true, type: 'text' })
|
|
templateId: string;
|
|
|
|
@ManyToOne(() => AssessmentTemplate, { nullable: true })
|
|
@JoinColumn({ name: 'template_id' })
|
|
template: AssessmentTemplate;
|
|
|
|
@Column({ type: 'simple-json', name: 'template_json', nullable: true })
|
|
templateJson: any;
|
|
|
|
@OneToMany(
|
|
'AssessmentQuestion',
|
|
(question: AssessmentQuestion) => question.session,
|
|
)
|
|
questions: AssessmentQuestion[];
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
updatedAt: Date;
|
|
}
|