package com.ruoyi.web.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.mxjb.domain.MxjbContants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@ApiModel("考卷")
public class PaperDto {
    @ApiModelProperty("测评id")
    Long evaluationId;
    @ApiModelProperty("考生类型 1是测评evaluation(default)，2是竞赛competitor 3 ai 4 test 6 ie")
    Integer examineeType;
    @ApiModelProperty("考生答题卡")
    Long examineeId;
    @ApiModelProperty("测评名称")
    String name;
    @ApiModelProperty("考试开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    Date beginTime;
    @ApiModelProperty("考试结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    Date endTime;
    @Deprecated
    @ApiModelProperty("考试时间 弃用")
    Long minutes;
    @ApiModelProperty("考试时间 单位秒")
    Long remaining;
    @ApiModelProperty("试卷类型 standard(AI已有) custom(AI新建)")
    String paperType;
    @Excel(name = "试卷id")
    private Long paperId;
    @ApiModelProperty("阅卷类型 1 自阅卷 2 老师阅卷")
    private String scoringType;
    @ApiModelProperty("是否公布")
    private Boolean publish;
    @ApiModelProperty("考场模式 90, 120, xxx")
    private Long mode;
    @ApiModelProperty("答卷状态 examinee_status")
    Long state;
    @ApiModelProperty("测评 evaluation_status")
    Long evaluationState;
    @ApiModelProperty("答卷状态名称")
    String stateStr;
    @ApiModelProperty("是否可答题")
    Boolean allowAnswer;
    @ApiModelProperty("是否可阅卷")
    Boolean allowScore;
    List<QuestionDto> questions = Lists.newArrayList();
    @ApiModelProperty("试卷统计")
    Map<String, DynamicTable> questionStat;

    public void calculateAllow() {
        allowAnswer = false;
        allowScore = false;
        if (MxjbContants.ExamineeStatusExamine.equals(state)) {
            allowAnswer = true;
        } else if (MxjbContants.ExamineeStatusReview.equals(state)) {
            allowScore = true;
        }
    }
}
