package com.qmth.teachcloud.mark.params;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.qmth.teachcloud.common.enums.mark.MarkProblemType;
import com.qmth.teachcloud.mark.dto.mark.SpecialTagDTO;
import com.qmth.teachcloud.mark.dto.mark.manage.TrackDTO;
import com.qmth.teachcloud.mark.entity.MarkArbitrateHistory;
import com.qmth.teachcloud.mark.entity.MarkHeaderTag;
import com.qmth.teachcloud.mark.entity.MarkHeaderTrack;
import com.qmth.teachcloud.mark.entity.MarkSpecialTag;
import com.qmth.teachcloud.mark.entity.MarkTask;
import com.qmth.teachcloud.mark.entity.MarkTrack;

/**
 * 标准评卷结果对象
 * 
 */
public class MarkResult {

    public static final String SPLIT = ",";

    /**
     * 考生编号
     */
    private Long studentId;

    /**
     * 评卷任务编号
     */
    private Long taskId;

    /**
     * 总分
     */
    private double markerScore;

    /**
     * 分值列表
     */
    private Double[] scoreList;

    /**
     * 阅卷轨迹列表
     */
    private TrackDTO[] trackList;

    /**
     * 特殊标记列表
     */
    private SpecialTagDTO[] specialTagList;

    /**
     * 所花时间
     */
    private int spent;

    /**
     * 是否问题卷
     */
    private boolean problem;

    /**
     * 问题类型
     */
    private MarkProblemType problemType;
    
    /**
     * 问题卷备注
     */
    private String problemRemark;

    private boolean unselective;

    public Long getTaskId() {
        return taskId;
    }

    public void setTaskId(Long taskId) {
        this.taskId = taskId;
    }

    public double getMarkerScore() {
        return markerScore;
    }

    public void setMarkerScore(double markerScore) {
        this.markerScore = markerScore;
    }

    public String getScoreList() {
        List<Object> list = new ArrayList<Object>();
        for (int i = 0; i < scoreList.length; i++) {
            Double d = scoreList[i];
            if (d % 1 == 0) {
                list.add(d.intValue());
            } else {
                list.add(d);
            }
        }
        return StringUtils.join(list, SPLIT);
    }

    public void setScoreList(Double[] scoreList) {
        this.scoreList = scoreList;
    }

    public TrackDTO[] getTrackList() {
        return trackList;
    }

    public void setTrackList(TrackDTO[] trackList) {
        this.trackList = trackList;
    }
    public SpecialTagDTO[] getSpecialTagList() {
        return specialTagList;
    }

    public void setSpecialTagList(SpecialTagDTO[] specialTagList) {
        this.specialTagList = specialTagList;
    }
    public int getSpent() {
        return spent;
    }

    public void setSpent(int spent) {
        this.spent = spent;
    }

    public Long getStudentId() {
        return studentId;
    }

    public void setStudentId(Long studentId) {
        this.studentId = studentId;
    }

    public List<MarkHeaderTrack> getTrackList(MarkArbitrateHistory history) {
        List<MarkHeaderTrack> list = new LinkedList<>();
        if (trackList != null) {
            for (TrackDTO dto : trackList) {
                list.add(dto.transform(history));
            }
        }
        return list;
    }

    public List<MarkTrack> getTrackList(MarkTask markTask, Long userId) {
        List<MarkTrack> list = new LinkedList<>();
        if (trackList != null) {
            for (TrackDTO dto : trackList) {
                list.add(dto.transform(markTask, userId));
            }
        }
        return list;
    }

    public List<MarkHeaderTag> getHeaderTagList(MarkArbitrateHistory library) {
        List<MarkHeaderTag> list = new LinkedList<>();
        if (specialTagList != null) {
            for (SpecialTagDTO dto : specialTagList) {
                list.add(dto.transform(library));
            }
        }
        return list;
    }

    public List<MarkSpecialTag> getSpecialTagList(MarkTask markTask) {
        List<MarkSpecialTag> list = new LinkedList<>();
        if (specialTagList != null) {
            for (SpecialTagDTO dto : specialTagList) {
                list.add(dto.transform(markTask));
            }
        }
        return list;
    }

    public boolean isProblem() {
        return problem;
    }

    public void setProblem(boolean problem) {
        this.problem = problem;
    }


    public MarkProblemType getProblemType() {
		return problemType;
	}

	public void setProblemType(MarkProblemType problemType) {
		this.problemType = problemType;
	}

	public boolean isUnselective() {
        return unselective;
    }

    public void setUnselective(boolean unselective) {
        this.unselective = unselective;
    }

	public String getProblemRemark() {
		return problemRemark;
	}

	public void setProblemRemark(String problemRemark) {
		this.problemRemark = problemRemark;
	}

}
