package cn.seecoder.judgement.vo.question;
import cn.seecoder.bok.common.QuestionType;
import cn.seecoder.bok.common.vo.QuestionVO;
import lombok.Data;
import lombok.NonNull;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author XuShengTao
*
* updated by cst
*/
@Data
public abstract class BaseQuestionVO {
protected String id;
protected QuestionType type;
protected Map options;
protected String stem;
protected String analysis;
protected String keyPoints;
protected List tags;
protected List knowledgeId;
protected Date lastModified;
public static BaseQuestionVO convertBokQuestionToVO(@NonNull QuestionVO questionVO, boolean withAnswer) {
switch (questionVO.getType()) {
case CHOICE:
return new ChoiceQuestionVO(questionVO, withAnswer);
case TRUE_FALSE:
return new TrueOrFalseQuestionVO(questionVO, withAnswer);
case BLANK:
return new BlankQuestionVO(questionVO, withAnswer);
case MULTIPLE_CHOICE:
return new MultipleChoiceQuestionVO(questionVO, withAnswer);
default:
return null;
}
}
protected BaseQuestionVO(QuestionVO questionVO) {
this.id = questionVO.getId();
this.type = questionVO.getType();
this.options = questionVO.getOptions();
this.stem = questionVO.getStem();
this.keyPoints = questionVO.getKeyPoints();
this.tags = questionVO.getTags();
this.knowledgeId = questionVO.getKnowledgeId();
this.lastModified = Date.from(questionVO.getLastModifiedTime());
}
/**
* 检查答案是否正确
*
* @param answer 答案
* @return 是否正确
*/
public abstract boolean pass(Object answer);
}