|
|
@@ -26,18 +26,15 @@ import java.util.List;
|
|
|
public class QuestionServiceImpl implements QuestionService {
|
|
|
private final QuizDAO quizDAO;
|
|
|
private final UserDAO userDAO;
|
|
|
-// private final BaseQuestionDAO baseQuestionDAO;
|
|
|
|
|
|
private final BokUtil bokUtil;
|
|
|
|
|
|
@Autowired
|
|
|
public QuestionServiceImpl(QuizDAO quizDAO
|
|
|
, UserDAO userDAO
|
|
|
-// , BaseQuestionDAO baseQuestionDAO
|
|
|
, BokUtil bokUtil) {
|
|
|
this.quizDAO = quizDAO;
|
|
|
this.userDAO = userDAO;
|
|
|
-// this.baseQuestionDAO = baseQuestionDAO;
|
|
|
this.bokUtil = bokUtil;
|
|
|
}
|
|
|
|
|
|
@@ -46,11 +43,6 @@ public class QuestionServiceImpl implements QuestionService {
|
|
|
return bokUtil.bokFindByStemLike(stem, pageable, true);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public BaseQuestionVO getQuestion(String questionId) {
|
|
|
- return bokUtil.bokFindById(questionId, true);
|
|
|
- }
|
|
|
-
|
|
|
@Transactional(readOnly = true)
|
|
|
@Override
|
|
|
public List<BaseQuestionVO> getQuestionsByQuiz(LoginUser user, Long quizId) {
|
|
|
@@ -66,32 +58,9 @@ public class QuestionServiceImpl implements QuestionService {
|
|
|
return bokUtil.bokFindByIdIn(questionIds, true);
|
|
|
}
|
|
|
|
|
|
-// @Transactional(rollbackFor = Exception.class)
|
|
|
-// @Override
|
|
|
-// public BaseQuestionVO createQuestion(LoginUser user, BaseQuestionDTO baseQuestionDTO) {
|
|
|
-// BaseQuestion baseQuestion = getQuestion(baseQuestionDTO);
|
|
|
-// baseQuestion.setTeacher(userDAO.findUserById(user.getId()));
|
|
|
-// baseQuestion = baseQuestionDAO.save(baseQuestion);
|
|
|
-// return BaseQuestionVO.convertBaseQuestionToVO(baseQuestion, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// private BaseQuestion getQuestion(BaseQuestionDTO baseQuestionDTO) {
|
|
|
-// switch (QuestionType.valueOf(baseQuestionDTO.getType())) {
|
|
|
-// case CHOICE:
|
|
|
-// ChoiceQuestion choiceQuestion = new ChoiceQuestion();
|
|
|
-// choiceQuestion.setStem(baseQuestionDTO.getStem());
|
|
|
-// choiceQuestion.setAnalysis(baseQuestionDTO.getAnalysis());
|
|
|
-// choiceQuestion.setOptions(((ChoiceQuestionDTO) baseQuestionDTO).getOptions());
|
|
|
-// choiceQuestion.setAnswer(((ChoiceQuestionDTO) baseQuestionDTO).getAnswer());
|
|
|
-// return choiceQuestion;
|
|
|
-// case TRUE_FALSE:
|
|
|
-// TrueOrFalseQuestion trueOrFalseQuestion = new TrueOrFalseQuestion();
|
|
|
-// trueOrFalseQuestion.setStem(baseQuestionDTO.getStem());
|
|
|
-// trueOrFalseQuestion.setAnalysis(baseQuestionDTO.getAnalysis());
|
|
|
-// trueOrFalseQuestion.setAnswer(((TrueOrFalseQuestionDTO) baseQuestionDTO).getAnswer());
|
|
|
-// return trueOrFalseQuestion;
|
|
|
-// default:
|
|
|
-// throw HelperException.of(ExceptionType.FORBIDDEN, "暂时无法创建该类型的题目");
|
|
|
-// }
|
|
|
-// }
|
|
|
+ @Transactional(readOnly = true)
|
|
|
+ @Override
|
|
|
+ public BaseQuestionVO getOneQuestion(LoginUser user, String questionId) {
|
|
|
+ return bokUtil.bokFindById(questionId, true);
|
|
|
+ }
|
|
|
}
|