BaseQuestionVO.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package nju.seec.helper.vo.question;
  2. import lombok.Data;
  3. import lombok.NonNull;
  4. import nju.seec.helper.api.bok.constant.QuestionType;
  5. import nju.seec.helper.api.bok.vo.QuestionVO;
  6. import java.util.Date;
  7. import java.util.List;
  8. import java.util.Map;
  9. /**
  10. * @author XuShengTao
  11. * <p>
  12. * updated by cst
  13. */
  14. @Data
  15. public abstract class BaseQuestionVO {
  16. protected String id;
  17. protected QuestionType type;
  18. protected Map<String, String> options;
  19. protected String stem;
  20. protected String analysis;
  21. protected String keyPoints;
  22. protected List<String> tags;
  23. protected List<String> knowledgeId;
  24. protected Date lastModified;
  25. public static BaseQuestionVO convertBokQuestionToVO(@NonNull QuestionVO questionVO, boolean withAnswer) {
  26. switch (questionVO.getType()) {
  27. case choice:
  28. return new ChoiceQuestionVO(questionVO, withAnswer);
  29. case true_false:
  30. return new TrueOrFalseQuestionVO(questionVO, withAnswer);
  31. default:
  32. return null;
  33. }
  34. }
  35. protected BaseQuestionVO(QuestionVO questionVO) {
  36. this.id = questionVO.getId();
  37. this.type = questionVO.getType();
  38. this.options = questionVO.getOptions();
  39. this.stem = questionVO.getStem();
  40. this.keyPoints = questionVO.getKeyPoints();
  41. this.tags = questionVO.getTags();
  42. this.knowledgeId = questionVO.getKnowledgeId();
  43. this.lastModified = questionVO.getLastModifiedTime();
  44. }
  45. /**
  46. * 检查答案是否正确
  47. *
  48. * @param answer 答案
  49. * @return 是否正确
  50. */
  51. public abstract boolean pass(Object answer);
  52. }