enum QuestionsOptionStatus { correct, wrong, selected, unSelected }

enum QuestionCardStatus { question, wrongAnswer, correctAnswer, skippedAnswer, completed, findingWinner, winnerFound }

class QuestionModel {
  String? id;
  String? titleEn;
  String? titleAr;
  String? marathonId;
  int? questionTypeId;
  int? questionTime;
  int? nextQuestGap;
  int? gapType;
  String? gapText;
  String? gapImage;
  int? questOptionsLimit;
  int? remainingParticipantCount;
  List<QuestionOptions>? questionOptions;

  QuestionModel({
    String? id,
    String? titleEn,
    String? titleAr,
    String? marathonId,
    int? questionTypeId,
    int? questionTime,
    int? nextQuestGap,
    int? gapType,
    String? gapText,
    String? gapImage,
    int? questOptionsLimit,
    int? remainingParticipantCount,
    List<QuestionOptions>? questionOptions,
  });

  QuestionModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    titleEn = json['titleEn'];
    titleAr = json['titleAr'];
    marathonId = json['marathonId'];
    questionTypeId = json['questionTypeId'];
    questionTime = json['questionTime'];
    nextQuestGap = json['nextQuestGap'];
    gapType = json['gapType'];
    gapText = json['gapText'];
    gapImage = json['gapImage'];
    questOptionsLimit = json['questOptionsLimit'];
    remainingParticipantCount = json['remainingParticipantCount'];
    if (json['questionOptions'] != null) {
      questionOptions = <QuestionOptions>[];
      json['questionOptions'].forEach((v) {
        questionOptions!.add(QuestionOptions.fromJson(v));
      });
      questionOptions!.sort((QuestionOptions a, QuestionOptions b) => a.sequence!.compareTo(b.sequence!));
    }
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['titleEn'] = titleEn;
    data['titleAr'] = titleAr;
    data['marathonId'] = marathonId;
    data['questionTypeId'] = questionTypeId;
    data['questionTime'] = questionTime;
    data['nextQuestGap'] = nextQuestGap;
    data['gapType'] = gapType;
    data['gapText'] = gapText;
    data['gapImage'] = gapImage;
    data['questOptionsLimit'] = questOptionsLimit;
    data['remainingParticipantCount'] = remainingParticipantCount;
    if (questionOptions != null) {
      data['questionOptions'] = questionOptions!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class QuestionOptions {
  String? id;
  String? titleEn;
  String? titleAr;
  String? questionId;
  int? sequence;
  String? image;
  bool? isCorrectOption;
  QuestionsOptionStatus? optionStatus;

  QuestionOptions({
    String? id,
    String? titleEn,
    String? titleAr,
    String? questionId,
    int? sequence,
    String? image,
    bool? isCorrectOption,
    QuestionsOptionStatus? optionStatus,
  });

  QuestionOptions.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    titleEn = json['titleEn'];
    titleAr = json['titleAr'];
    questionId = json['questionId'];
    sequence = json['sequence'];
    image = json['image'];
    isCorrectOption = json['isCorrectOption'];
    optionStatus = QuestionsOptionStatus.unSelected;
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['titleEn'] = titleEn;
    data['titleAr'] = titleAr;
    data['questionId'] = questionId;
    data['sequence'] = sequence;
    data['image'] = image;
    data['isCorrectOption'] = isCorrectOption;
    return data;
  }
}
