BaseQuestionVO.java 1.5 KB

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