BaseQuestionVO.java 1.4 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.Set;
  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 Set<String> tags;
  20. protected Set<String> knowledgeId;
  21. private Date lastModified;
  22. public static BaseQuestionVO convertBokQuestionToVO(@NonNull BokQuestion bokQuestion, boolean withAnswer) {
  23. switch (bokQuestion.getType()) {
  24. case "choice":
  25. return new ChoiceQuestionVO(bokQuestion, withAnswer);
  26. case "true_false":
  27. return new TrueOrFalseQuestionVO(bokQuestion, withAnswer);
  28. default:
  29. return null;
  30. }
  31. }
  32. public BaseQuestionVO(BokQuestion bokQuestion) {
  33. this.id = bokQuestion.getId();
  34. this.stem = bokQuestion.getStem();
  35. this.keyPoints = bokQuestion.getKeyPoints();
  36. this.tags = bokQuestion.getTags();
  37. this.knowledgeId = bokQuestion.getKnowledgeId();
  38. this.lastModified = bokQuestion.getLastModified();
  39. }
  40. /**
  41. * 检查答案是否正确
  42. *
  43. * @param answer 答案
  44. * @return 是否正确
  45. */
  46. public abstract boolean pass(Object answer);
  47. }