import 'package:json_annotation/json_annotation.dart';

part 'marking_text_question_job.g.dart';

@JsonSerializable()
class MarkingTextQuestionJob extends Object {
  @JsonKey(name: 'paperId')
  int paperId;

  int? nextPageIndex; // 下一个页面
  int? previousPageIndex; // 上一

  @JsonKey(name: 'pageIndex')
  int pageIndex;

  @JsonKey(name: 'taskId')
  int taskId;

  @JsonKey(name: 'schoolName')
  String schoolName;

  @JsonKey(name: 'className')
  String className;

  @JsonKey(name: 'studentId')
  int studentId;

  @JsonKey(name: 'studentName')
  String studentName;

  @JsonKey(name: 'isFinish')
  bool isFinish;

  @JsonKey(name: 'current')
  int current;

  @JsonKey(name: 'prevId')
  int prevId;

  @JsonKey(name: 'nextId')
  int nextId;

  @JsonKey(name: 'questions')
  List<Questions> questions;

  @JsonKey(name: 'imageUrl')
  String imageUrl;

  @JsonKey(name: 'commentImageUrl')
  String? commentImageUrl;

  bool isFirst;

  String? lastModifyTime;

  MarkingTextQuestionJob(
    this.paperId,
    this.pageIndex,
    this.taskId,
    this.schoolName,
    this.className,
    this.studentId,
    this.studentName,
    this.isFinish,
    this.current,
    this.prevId,
    this.nextId,
    this.questions,
    this.imageUrl,
    this.commentImageUrl,
    this.lastModifyTime,
    this.isFirst,
  ) {
    if (lastModifyTime != null) imageUrl = imageUrl + '?$lastModifyTime';
  }

  factory MarkingTextQuestionJob.fromJson(Map<String, dynamic> srcJson) => _$MarkingTextQuestionJobFromJson(srcJson);

  Map<String, dynamic> toJson() => _$MarkingTextQuestionJobToJson(this);
}

@JsonSerializable()
class Questions extends Object {
  @JsonKey(name: 'questionNo')
  String questionNo;

  @JsonKey(name: 'answer')
  String answer;

  @JsonKey(name: 'score')
  double? score;

  double accuracy; // 当前题正确率

  Questions(this.questionNo, this.answer, this.accuracy, [this.score]);

  factory Questions.fromJson(Map<String, dynamic> srcJson) => _$QuestionsFromJson(srcJson);

  Map<String, dynamic> toJson() => _$QuestionsToJson(this);
}
