BaseQuestionVO.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package cn.seecoder.judgement.vo.question;
  2. import cn.seecoder.bok.common.QuestionType;
  3. import cn.seecoder.bok.common.vo.QuestionVO;
  4. import lombok.Data;
  5. import lombok.NonNull;
  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. case BLANK:
  32. return new BlankQuestionVO(questionVO, withAnswer);
  33. case MULTIPLE_CHOICE:
  34. return new MultipleChoiceQuestionVO(questionVO, withAnswer);
  35. default:
  36. return null;
  37. }
  38. }
  39. protected BaseQuestionVO(QuestionVO questionVO) {
  40. this.id = questionVO.getId();
  41. this.type = questionVO.getType();
  42. this.options = questionVO.getOptions();
  43. this.stem = questionVO.getStem();
  44. this.keyPoints = questionVO.getKeyPoints();
  45. this.tags = questionVO.getTags();
  46. this.knowledgeId = questionVO.getKnowledgeId();
  47. this.lastModified = Date.from(questionVO.getLastModifiedTime());
  48. }
  49. /**
  50. * 检查答案是否正确
  51. *
  52. * @param answer 答案
  53. * @return 是否正确
  54. */
  55. public abstract boolean pass(Object answer);
  56. }