import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  OneToMany,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { McqOptions } from '../../mcq_options/entities/mcq_options.entity';

export enum QuestionType {
  MOCK_TEST = 'mock_test',
  AI_TEST = 'ai_test',
  MANUAL = 'manual',
}

export enum QuestionFormat {
  MCQ = 'mcq',
  CODING = 'coding',
}

export enum Difficulty {
  EASY = 'easy',
  MEDIUM = 'medium',
  HARD = 'hard',
}

@Entity('question_bank')
export class QuestionBank {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    type: 'enum',
    enum: QuestionType,
    default: QuestionType.MOCK_TEST,
  })
  type: QuestionType;

  @Column({ nullable: true })
  role_id: number;

  @Column('text')
  question_text: string;

  @Column({
    type: 'enum',
    enum: QuestionFormat,
    default: QuestionFormat.MCQ,
  })
  question_type: QuestionFormat;

  @Column({
    type: 'enum',
    enum: Difficulty,
    default: Difficulty.EASY,
  })
  difficulty: Difficulty;

  @Column({ nullable: true })
  primary_skill_id: number;

  @Column('longtext', { nullable: true })
  topic_tags: string;

  @Column({ length: 50, nullable: true })
  experience_level: string;

  @Column({ default: false })
  ai_generated: boolean;

  @Column('longtext', { nullable: true })
  source_metadata: string;

  @Column('longtext', { nullable: true })
  metadata: string;

  @Column({ length: 64, nullable: true })
  created_by: string;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;

  @OneToMany(() => McqOptions, (option) => option.question)
  options: McqOptions[];
}
