package cn.com.qmth.examcloud.core.questions.dao.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import cn.com.qmth.examcloud.core.questions.base.Constants;
import org.springframework.data.annotation.Transient;

import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
import cn.com.qmth.examcloud.core.questions.dao.entity.base.MongoBaseEntity;
import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;

/**
 * Created by songyue on 16/12/27.
 */
public class Question extends MongoBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 448493904015571457L;

	private String quesBody;// 题干,默认为html

	private String quesBodyWord;// 题干word

	/**
	 * 试题wordpkg对象序列化数据
	 */
	// private byte[] quesPkg;

	/**
	 * 试题pkg路径Id
	 */
	private String quesPkgPathId;

	private String quesAnswer;// 答案,默认为html

	private String quesAnswerWord;// 答案word

	private String quesAnswerAnalysis;// 答案解析,默认为html

	private String quesAnswerAnalysisWord;// 答案word解析

	private List<QuesOption> quesOptions;// 试题选项

	private String quesOptionsWord;// 试题选项word解析

	private List<QuesResource> quesResource;// 试题resource(试题资源库集合,适用于多媒体介质试题)

	private QuesStructType questionType;// 试题结构类型

	private String createTime;// 创建时间

	private String updateTime;// 更新时间

	private List<Question> subQuestions;// 子题目,用于套题

	private Double score;// 预设分值

	@Deprecated
	private String courseNo;// 课程CODE

	@Deprecated
	private String courseName;// 课程名称

	@Deprecated
	private String courseLevel;// 课程层次

	@Deprecated
	private String courseMajor;// 课程专业

	private Course course;

	private String orgId; // 机构ID

	private Map<String, String> quesParams;// 试题属性

	/**
	 * 是否包含音频
	 */
	private Boolean hasAudio;

	private List<QuestionAudio> questionAudios;

	private String quesName;// 来源大题

	private Integer number;

	private Specialty specialty;

	/*
	 * 作答类型
	 */
	private AnswerType answerType;

	/**
	 * 试题属性
	 */
	private List<QuesProperty> quesProperties;// 关联多组属性

	private Double difficultyDegree; // 难度系数

	private Boolean publicity; // 公开度

	private String difficulty;// 难度

	private List<String> propertyGroup;// 试题属性组合（蓝图组卷使用）

	/**
	 * 试题标签，用于K12做查询条件
	 */
	private Map<String, String> properties;

	/**
	 * 是否脱离试卷存在,如果为true,是K12的导入题
	 */
	private Boolean isolated;

	@Transient
	private List<QuestionAudio> audioList;// 音频列表(复制试卷使用，不存数据)

	/**
	 * 下载试卷小题显示序号
	 */
	@Transient
	private int questionSeq;

	// 来源数据id，外部
	private String fromId;

	public void addAudio(QuestionAudio audio) {
		if (audioList == null) {
			audioList = new ArrayList<>();
		}
		audioList.add(audio);
	}

	public List<QuestionAudio> getAudioList() {
		return audioList;
	}

	public void setAudioList(List<QuestionAudio> audioList) {
		this.audioList = audioList;
	}

	public String getQuesBody() {
		return quesBody;
	}

	public void setQuesBody(String quesBody) {
		this.quesBody = quesBody;
	}

	public String getQuesBodyWord() {
		return quesBodyWord;
	}

	public void setQuesBodyWord(String quesBodyWord) {
		this.quesBodyWord = quesBodyWord;
	}

	public String getQuesAnswer() {
		return quesAnswer;
	}

	public void setQuesAnswer(String quesAnswer) {
		this.quesAnswer = quesAnswer;
	}

	public String getQuesAnswerWord() {
		return quesAnswerWord;
	}

	public void setQuesAnswerWord(String quesAnswerWord) {
		this.quesAnswerWord = quesAnswerWord;
	}

	public String getQuesAnswerAnalysis() {
		return quesAnswerAnalysis;
	}

	public void setQuesAnswerAnalysis(String quesAnswerAnalysis) {
		this.quesAnswerAnalysis = quesAnswerAnalysis;
	}

	public String getQuesAnswerAnalysisWord() {
		return quesAnswerAnalysisWord;
	}

	public void setQuesAnswerAnalysisWord(String quesAnswerAnalysisWord) {
		this.quesAnswerAnalysisWord = quesAnswerAnalysisWord;
	}

	public List<QuesOption> getQuesOptions() {
		return quesOptions;
	}

	public void setQuesOptions(List<QuesOption> quesOptions) {
		this.quesOptions = quesOptions;
	}

	public List<QuesResource> getQuesResource() {
		return quesResource;
	}

	public void setQuesResource(List<QuesResource> quesResource) {
		this.quesResource = quesResource;
	}

	public QuesStructType getQuestionType() {
		return questionType;
	}

	public void setQuestionType(QuesStructType questionType) {
		this.questionType = questionType;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}

	public List<Question> getSubQuestions() {
		return subQuestions;
	}

	public void setSubQuestions(List<Question> subQuestions) {
		this.subQuestions = subQuestions;
	}

	public Map<String, String> getQuesParams() {
		return quesParams;
	}

	public void setQuesParams(Map<String, String> quesParams) {
		this.quesParams = quesParams;
	}

	// public byte[] getQuesPkg() {
	// return quesPkg;
	// }
	//
	// public WordprocessingMLPackage getPkgObj() {
	// if (this.quesPkg != null && this.quesPkg.length > 0) {
	// return DocxProcessUtil.getPkg(this.quesPkg);
	// } else {
	// return null;
	// }
	//
	// }
	//
	// public void setQuesPkg(byte[] quesPkg) {
	// this.quesPkg = quesPkg;
	// }

	public Double getScore() {
		return score;
	}

	public void setScore(Double score) {
		this.score = score;
	}

	public String getCourseNo() {
		return courseNo;
	}

	public void setCourseNo(String courseNo) {
		this.courseNo = courseNo;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getCourseLevel() {
		return courseLevel;
	}

	public void setCourseLevel(String courseLevel) {
		this.courseLevel = courseLevel;
	}

	public String getCourseMajor() {
		return courseMajor;
	}

	public void setCourseMajor(String courseMajor) {
		this.courseMajor = courseMajor;
	}

	public Boolean getHasAudio() {
		return hasAudio;
	}

	public void setHasAudio(Boolean hasAudio) {
		this.hasAudio = hasAudio;
	}

	public List<QuestionAudio> getQuestionAudios() {
		return questionAudios;
	}

	public void setQuestionAudios(List<QuestionAudio> questionAudios) {
		this.questionAudios = questionAudios;
	}

	public Course getCourse() {
		return course;
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public String getQuesName() {
		return quesName;
	}

	public void setQuesName(String quesName) {
		this.quesName = quesName;
	}

	public Integer getNumber() {
		return number;
	}

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

	public Specialty getSpecialty() {
		return specialty;
	}

	public void setSpecialty(Specialty specialty) {
		this.specialty = specialty;
	}

	public String getQuesPkgPathId() {
		return quesPkgPathId;
	}

	public void setQuesPkgPathId(String quesPkgPathId) {
		this.quesPkgPathId = quesPkgPathId;
	}

	public Boolean getPublicity() {
		return publicity;
	}

	public void setPublicity(Boolean publicity) {
		this.publicity = publicity;
	}

	public List<QuesProperty> getQuesProperties() {
		return quesProperties;
	}

	public void setQuesProperties(List<QuesProperty> quesProperties) {
		this.quesProperties = quesProperties;
	}

	public Double getDifficultyDegree() {
		if(difficultyDegree == null){
			difficultyDegree = Constants.DEFAULT_DIFFICULTY_DEGREE;
		}
		return difficultyDegree;
	}

	public void setDifficultyDegree(Double difficultyDegree) {
		this.difficultyDegree = difficultyDegree;
	}

	public String getDifficulty() {
		return difficulty;
	}

	public void setDifficulty(String difficulty) {
		this.difficulty = difficulty;
	}

	public List<String> getPropertyGroup() {
		return propertyGroup;
	}

	public void setPropertyGroup(List<String> propertyGroup) {
		this.propertyGroup = propertyGroup;
	}

	public Map<String, String> getProperties() {
		return properties;
	}

	public void setProperties(Map<String, String> properties) {
		this.properties = properties;
	}

	public Boolean getIsolated() {
		return isolated;
	}

	public void setIsolated(Boolean isolated) {
		this.isolated = isolated;
	}

	public AnswerType getAnswerType() {
		return answerType;
	}

	public void setAnswerType(AnswerType answerType) {
		this.answerType = answerType;
	}

	public String getQuesOptionsWord() {
		return quesOptionsWord;
	}

	public void setQuesOptionsWord(String quesOptionsWord) {
		this.quesOptionsWord = quesOptionsWord;
	}

	public int getQuestionSeq() {
		return questionSeq;
	}

	public void setQuestionSeq(int questionSeq) {
		this.questionSeq = questionSeq;
	}

	public String getFromId() {
		return fromId;
	}

	public void setFromId(String fromId) {
		this.fromId = fromId;
	}

}