package com.qmth.teachcloud.eds.vo;

import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class ExamQuestion implements Serializable {

    private static final long serialVersionUID = -6614640229855098561L;

    private Integer id;

    @TableField(value = "exam_id")
    private Integer examId;

    @TableField(value = "subject_code")
    private String subjectCode;

    @TableField(value = "paper_type")
    private String paperType;

    @TableField(value = "is_objective")
    private boolean objective;

    @TableField(value = "main_number")
    private Integer mainNumber;

    @TableField(value = "sub_number")
    private String subNumber;

    @TableField(value = "main_title")
    private String mainTitle;

    @TableField(value = "group_number")
    private Integer groupNumber;

    @TableField(value = "answer")
    private String answer;

    @TableField(value = "total_score")
    private Double totalScore;

    @TableField(value = "interval_score")
    private Double intervalScore;

    /**
     * 客观题判分策略
     */
    @TableField(value = "objective_policy")
    private String objectivePolicy;

    @TableField(value = "question_type")
    private Integer type;

    @TableField(value = "name")
    private String name;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getExamId() {
        return examId;
    }

    public void setExamId(Integer examId) {
        this.examId = examId;
    }

    public String getSubjectCode() {
        return subjectCode;
    }

    public void setSubjectCode(String subjectCode) {
        this.subjectCode = subjectCode;
    }

    public String getPaperType() {
        return paperType;
    }

    public void setPaperType(String paperType) {
        this.paperType = paperType;
    }

    public boolean isObjective() {
        return objective;
    }

    public void setObjective(boolean objective) {
        this.objective = objective;
    }

    public Integer getMainNumber() {
        return mainNumber;
    }

    public void setMainNumber(Integer mainNumber) {
        this.mainNumber = mainNumber;
    }

    public String getSubNumber() {
        return subNumber;
    }

    public void setSubNumber(String subNumber) {
        this.subNumber = subNumber;
    }

    public String getMainTitle() {
        return mainTitle;
    }

    public void setMainTitle(String mainTitle) {
        this.mainTitle = mainTitle;
    }

    public Double getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(Double totalScore) {
        this.totalScore = totalScore;
    }

    // public String getName() {
    // if (mainTitle != null && getSubNumber() != null) {
    // return mainTitle + "-" + getSubNumber();
    // } else {
    // return "";
    // }
    // }

    public List<Double> getScoreList() {
        List<Double> list = new LinkedList<Double>();
        if (totalScore != null && intervalScore != null) {
            totalScore = totalScore * 100;
            intervalScore = intervalScore * 100;
            for (double score = 0; score <= totalScore; score += intervalScore) {
                list.add(score / 100);
            }
            totalScore = totalScore / 100;
            if (list.get(list.size() - 1) < totalScore) {
                list.add(totalScore);
            }
        }
        return list;
    }

    public double[] getScoreListArray() {
        List<Double> list = getScoreList();
        int length = list.size();
        double[] array = new double[length];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }
        return array;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public Double getIntervalScore() {
        return intervalScore;
    }

    public void setIntervalScore(Double intervalScore) {
        this.intervalScore = intervalScore;
    }

    public String getQuestionNumber() {
        return getMainNumber() + "." + getSubNumber();
    }

    public Integer getGroupNumber() {
        return groupNumber;
    }

    public void setGroupNumber(Integer groupNumber) {
        this.groupNumber = groupNumber;
    }

    public String getObjectivePolicy() {
        return objectivePolicy;
    }

    public void setObjectivePolicy(String objectivePolicy) {
        this.objectivePolicy = objectivePolicy;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
