import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document } from 'mongoose';


export class QuestionAnswer  {
  user: number;
  time: Date;
  valid: boolean;
}

export type QuestionDocument = Question & Document;


@Schema()
export class Question {
  @Prop()
  text: string;
  @Prop()
  answers: string[];
  @Prop()
  valid: string;
  @Prop()
  answered: boolean;
  @Prop()
  answeredBy: number;
  @Prop()
  note: string | null;
  @Prop()
  qId: string;
  @Prop([ { user: { type: Number }, time: { type: Date }, valid: { type: Boolean}}])
  userAnswers: QuestionAnswer[];
  @Prop({ default: false })
  scoreCalculated: boolean;
  @Prop({ default: false})
  countdownFinished: boolean;
}
export const QuestionSchema = SchemaFactory.createForClass(Question);
