package cn.com.qmth.stmms.api.dto;

import org.apache.commons.lang.StringUtils;

import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
import cn.com.qmth.stmms.common.enums.ObjectivePolicy;
import cn.com.qmth.stmms.common.enums.QuestionType;

public class QuestionDTO {

    private Integer mainNumber;

    private String subNumber;

    private String mainTitle;

    private String answer;

    private Double totalScore;

    private QuestionType type;

    private ObjectivePolicy objectivePolicy;

    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 (totalScore % 1 == 0) {
            question.setIntervalScore(1d);
        } else {
            question.setIntervalScore(0.5);
        }
        question.setType(type);
        question.setObjectivePolicy(objectivePolicy);
        return question;
    }

    public QuestionDTO() {
    }

    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 QuestionType getType() {
        return type;
    }

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

    public ObjectivePolicy getObjectivePolicy() {
        return objectivePolicy;
    }

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

}
