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

import java.io.Serializable;
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_subjective_block")
public class SubjectiveBlock implements Serializable {

    private static final long serialVersionUID = 3197160699047369929L;

    @Id
    @GeneratedValue
    private Integer id;

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

    @Column(name = "subject_code")
    private String subjectCode;

    @Column(name = "number")
    private Integer number;

    @Column(name = "title ")
    private String title;

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

    @Column(name = "mistake_value")
    private Double mistakeValue;

    @Column(name = "re_mark_percent")
    private Double reMarkPercent;

    @Column(name = "mark_self_frequency")
    private Integer markSelfFrequency;

    @Column(name = "standard_frequency")
    private Integer standardFrequency;

    @Column(name = "is_avg")
    private boolean avg;

    @Column(name = "picture_config")
    private String pictureConfig;

    @Column(name = "selective_group_id")
    private Integer selectiveGroupId;

    @Column(name = "selective_group_index")
    private Integer selectiveGroupIndex;

    @Column(name = "step_count")
    private Integer stepCount;

    @Transient
    private Integer selectiveGroupNumber;

    @Transient
    private List<MarkStep> markStepList;

    @Transient
    private long markerCount;

    @Transient
    private long totalCount;

    @Transient
    private long markedCount;

    @Transient
    private String markedPercent;

    @Transient
    private int toDispatchedCount;

    @Transient
    private ExamSubject examSubject;

    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 Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Double getTotalScore() {
        return totalScore;
    }

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

    public Double getMistakeValue() {
        return mistakeValue;
    }

    public void setMistakeValue(Double mistakeValue) {
        this.mistakeValue = mistakeValue;
    }

    public Double getReMarkPercent() {
        return reMarkPercent;
    }

    public void setReMarkPercent(Double reMarkPercent) {
        this.reMarkPercent = reMarkPercent;
    }

    public Integer getMarkSelfFrequency() {
        return markSelfFrequency;
    }

    public void setMarkSelfFrequency(Integer markSelfFrequency) {
        this.markSelfFrequency = markSelfFrequency;
    }

    public Integer getStandardFrequency() {
        return standardFrequency;
    }

    public void setStandardFrequency(Integer standardFrequency) {
        this.standardFrequency = standardFrequency;
    }

    public Integer getSelectiveGroupId() {
        return selectiveGroupId;
    }

    public void setSelectiveGroupId(Integer selectiveGroupId) {
        this.selectiveGroupId = selectiveGroupId;
    }

    public List<MarkStep> getMarkStepList() {
        return markStepList;
    }

    public void setMarkStepList(List<MarkStep> markStepList) {
        this.markStepList = markStepList;
    }

    public long getTotalCount() {
        return totalCount;
    }

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

    public int getToDispatchedCount() {
        return toDispatchedCount;
    }

    public void setToDispatchedCount(int toDispatchedCount) {
        this.toDispatchedCount = toDispatchedCount;
    }

    public Integer getSelectiveGroupNumber() {
        return selectiveGroupNumber;
    }

    public void setSelectiveGroupNumber(Integer selectiveGroupNumber) {
        this.selectiveGroupNumber = selectiveGroupNumber;
    }

    public Integer getSelectiveGroupIndex() {
        return selectiveGroupIndex;
    }

    public void setSelectiveGroupIndex(Integer selectiveGroupIndex) {
        this.selectiveGroupIndex = selectiveGroupIndex;
    }

    public String getPictureConfig() {
        return pictureConfig;
    }

    public void setPictureConfig(String pictureConfig) {
        this.pictureConfig = pictureConfig;
    }

    public ExamSubject getExamSubject() {
        return examSubject;
    }

    public void setExamSubject(ExamSubject examSubject) {
        this.examSubject = examSubject;
    }

    public void updateTotalScore() {
        if (markStepList != null && markStepList.size() > 0) {
            double score = 0d;
            int count = 0;
            for (MarkStep step : markStepList) {
                score += step.getTotalScore();
                count++;
            }
            this.totalScore = score;
            this.stepCount = count;
        }
    }

    public long getMarkedCount() {
        return markedCount;
    }

    public void setMarkedCount(long markedCount) {
        this.markedCount = markedCount;
    }

    public String getMarkedPercent() {
        return markedPercent;
    }

    public void setMarkedPercent(String markedPercent) {
        this.markedPercent = markedPercent;
    }

    public long getMarkerCount() {
        return markerCount;
    }

    public void setMarkerCount(long markerCount) {
        this.markerCount = markerCount;
    }

    public boolean isAvg() {
        return avg;
    }

    public void setAvg(boolean avg) {
        this.avg = avg;
    }

    public Integer getStepCount() {
        return stepCount;
    }

    public void setStepCount(Integer stepCount) {
        this.stepCount = stepCount;
    }
}
