package cn.com.qmth.stmms.biz.exam.model;

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "eb_exam_question")
public class ExamQuestion implements Serializable {

    private static final long serialVersionUID = -6614640229855098561L;

    @Id
    @GeneratedValue
    private Integer id;

    @Column(name = "exam_id", nullable = false)
    private Integer examId;

    @Column(name = "subject_code", nullable = false, length = 32)
    private String subjectCode;

    @Column(name = "paper_type", nullable = true, length = 32)
    private String paperType;

    @Column(name = "is_objective", nullable = false)
    private boolean objective;

    @Column(name = "main_number", nullable = false)
    private Integer mainNumber;

    @Column(name = "sub_number", nullable = false)
    private Integer subNumber;

    @Column(name = "main_title", nullable = false, length = 64)
    private String mainTitle;

    @Column(name = "group_number", nullable = false)
    private Integer groupNumber;

    @Column(name = "answer", nullable = true, length = 16)
    private String answer;

    @Column(name = "total_score", nullable = false)
    private Double totalScore;

    @Column(name = "interval_score", nullable = false)
    private Double intervalScore;

    /**
     * 考生人数
     */
    @Column(name = "total_count", nullable = true)
    private Integer totalCount;

    @Transient
    private ExamSubject subject;

    @Transient
    private String picList;

    @Transient
    private Double doubleRate;

    @Transient
    private Double arbitrateThreshold;

    @Transient
    private Integer scorePolicy;

    @Transient
    private String markMode;

    @Transient
    private Integer trialCount;

    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 Integer getSubNumber() {
        return subNumber;
    }

    public void setSubNumber(Integer 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) {
            for (double score = 0; score <= totalScore; score += intervalScore) {
                list.add(score);
            }
        }
        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 Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public ExamSubject getSubject() {
        return subject;
    }

    public void setSubject(ExamSubject subject) {
        this.subject = subject;
    }

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

    public String getPicList() {
        return picList;
    }

    public void setPicList(String picList) {
        this.picList = picList;
    }

    public Double getDoubleRate() {
        return doubleRate;
    }

    public void setDoubleRate(Double doubleRate) {
        this.doubleRate = doubleRate;
    }

    public Double getArbitrateThreshold() {
        return arbitrateThreshold;
    }

    public void setArbitrateThreshold(Double arbitrateThreshold) {
        this.arbitrateThreshold = arbitrateThreshold;
    }

    public Integer getScorePolicy() {
        return scorePolicy;
    }

    public void setScorePolicy(Integer scorePolicy) {
        this.scorePolicy = scorePolicy;
    }

    public String getMarkMode() {
        return markMode;
    }

    public void setMarkMode(String markMode) {
        this.markMode = markMode;
    }

    public Integer getTrialCount() {
        return trialCount;
    }

    public void setTrialCount(Integer trialCount) {
        this.trialCount = trialCount;
    }

    public Integer getGroupNumber() {
        return groupNumber;
    }

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

}
