package cn.com.qmth.stmms.admin.vo;

import org.apache.commons.lang.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;

@JsonIgnoreProperties(ignoreUnknown = true)
public class StructQuestion {

    @JsonProperty("mainNumber")
    private Integer mainNumber;

    @JsonProperty("subNumber")
    private String subNumber;

    @JsonProperty("mainTitle")
    private String mainTitle;

    @JsonProperty("answer")
    private String answer;

    @JsonProperty("totalScore")
    private Double totalScore;

    @JsonProperty("intervalScore")
    private Double intervalScore;

    public ExamQuestion transform() {
        ExamQuestion question = new ExamQuestion();
        question.setMainNumber(mainNumber);
        question.setSubNumber(subNumber);
        question.setMainTitle(StringUtils.trimToNull(mainTitle));
        question.setAnswer(StringUtils.trimToNull(answer));
        question.setTotalScore(totalScore);
        if (intervalScore == null) {
            question.setIntervalScore(intervalScore);
        } else {
            if (totalScore % 1 == 0) {
                question.setIntervalScore(1d);
            } else {
                question.setIntervalScore(0.5);
            }
        }
        return question;
    }

    public StructQuestion() {
    }

    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 String getAnswer() {
        return answer;
    }

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

    public Double getTotalScore() {
        return totalScore;
    }

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

    public Double getIntervalScore() {
        return intervalScore;
    }

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

}
