BaseQuestionVO.java 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package nju.seec.helper.vo.question;
  2. import lombok.Data;
  3. import lombok.NonNull;
  4. import nju.seec.helper.util.enums.ExceptionType;
  5. import nju.seec.helper.util.enums.QuestionType;
  6. import nju.seec.helper.util.exception.HelperException;
  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. public static BaseQuestionVO convertBokQuestionToVO(@NonNull BokQuestion bokQuestion, boolean withAnswer) {
  19. switch (bokQuestion.getType()) {
  20. case "choice":
  21. return new ChoiceQuestionVO(bokQuestion, withAnswer);
  22. case "true_false":
  23. return new TrueOrFalseQuestionVO(bokQuestion, withAnswer);
  24. default:
  25. throw HelperException.of(ExceptionType.ERROR, "无法解析该题目");
  26. }
  27. }
  28. /**
  29. * 检查答案是否正确
  30. *
  31. * @param answer
  32. * @return
  33. */
  34. public abstract boolean pass(Object answer);
  35. }