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

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 统计得分率
 *
 */
@Entity
@Table(name = "s_score_rate")
public class ScoreRate implements Serializable {

	private static final long serialVersionUID = -4245565490416790325L;

	@EmbeddedId
    private ScoreRatePK pk;

    @Column(name = "main_title")
    private String mainTitle;

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

    @Column(name = "avg_score")
    private Double avgScore;

    @Transient
    private ExamSubject subject;
    
    @Transient
    private double rate;

    public ScoreRate() {
        this.pk = new ScoreRatePK();
    }

    public Integer getExamId() {
        return pk.getExamId();
    }

    public void setExamId(Integer examId) {
        pk.setExamId(examId);
    }
    
    public String getCampusName() {
		return pk.getCampusName();
	}

	public void setCampusName(String campusName) {
		pk.setCampusName(campusName);
	}

    public String getSubjectCode() {
        return pk.getSubjectCode();
    }

    public void setSubjectCode(String subjectCode) {
        pk.setSubjectCode(subjectCode);
    }

    public Integer getMainNumber() {
        return pk.getMainNumber();
    }

    public void setMainNumber(Integer mainNumber) {
        pk.setMainNumber(mainNumber);
    }

    public Integer getSubNumber() {
        return pk.getSubNumber();
    }

    public void setSubNumber(Integer subNumber) {
        pk.setSubNumber(subNumber);
    }

    public String getMainTitle() {
        return mainTitle;
    }

    public void setObjective(boolean objective) {
        pk.setObjective(objective);
    }

    public boolean isObjective() {
        return pk.isObjective();
    }

    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 ExamSubject getSubject() {
        return subject;
    }

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

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

	public Double getAvgScore() {
		return avgScore;
	}

	public void setAvgScore(Double avgScore) {
		this.avgScore = avgScore;
	}

	public double getRate() {
		return new BigDecimal(getAvgScore()*100.00/getTotalScore()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public void setRate(double rate) {
		this.rate = rate;
	}

}
