import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { UserAiInterviews } from '../../user_ai_interviews/entities/user_ai_interviews.entity';
import { QuestionBank } from '../../question_bank/entities/question_bank.entity';

@Entity('user_ai_answers')
export class UserAiAnswers {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'int' })
  interview_id: number;

  @Column({ type: 'int' })
  question_id: number;

  @ManyToOne(() => QuestionBank)
  @JoinColumn({ name: 'question_id' })
  question: QuestionBank;

  @Column({ type: 'text', nullable: true })
  answer_text: string;

  @Column({ type: 'json', nullable: true })
  chosen_option_ids: any;

  @Column({ type: 'tinyint', width: 1, nullable: true })
  is_correct: boolean;

  @Column({ type: 'decimal', precision: 5, scale: 2, nullable: true })
  score: number;

  @CreateDateColumn({ name: 'answered_at' })
  answered_at: Date;
}
