/*
 * @Author: wangyang 1147192855@qq.com
 * @Date: 2022-07-21 14:03:51
 * @LastEditors: wangyang 1147192855@qq.com
 * @LastEditTime: 2022-07-28 18:10:43
 * @FilePath: \marking_app\lib\common\model\review\review_item.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:json_annotation/json_annotation.dart';

part 'review_item.g.dart';

@JsonSerializable(checked: true)
class ReviewItem extends Object {
  @JsonKey(name: 'markingUserDetailId')
  String markingUserDetailId;

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

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

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

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

  @JsonKey(name: 'studentAnswerList')
  List<String> studentAnswerList;

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

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

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

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

  ReviewItem(this.markingUserDetailId, this.questionNum, this.score, this.finishedTime, this.isFinish, this.answer,
      this.questionNo, this.studentName,
      {this.isException = false, this.studentAnswerList = const []}) {
    if (finishedTime.length == 19) {
      finishedTime = finishedTime.substring(0, 16);
    }
    if (answer != null) studentAnswerList = [answer!];
  }

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

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