|
|
@@ -1,6 +1,7 @@
|
|
|
package nju.seec.helper.service.impl;
|
|
|
|
|
|
import nju.seec.helper.dao.QuizDAO;
|
|
|
+import nju.seec.helper.dao.UserDAO;
|
|
|
import nju.seec.helper.dto.user.LoginUser;
|
|
|
import nju.seec.helper.entity.Quiz;
|
|
|
import nju.seec.helper.service.QuestionService;
|
|
|
@@ -24,11 +25,19 @@ import java.util.List;
|
|
|
@Service
|
|
|
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, BokUtil bokUtil) {
|
|
|
+ public QuestionServiceImpl(QuizDAO quizDAO
|
|
|
+ , UserDAO userDAO
|
|
|
+// , BaseQuestionDAO baseQuestionDAO
|
|
|
+ , BokUtil bokUtil) {
|
|
|
this.quizDAO = quizDAO;
|
|
|
+ this.userDAO = userDAO;
|
|
|
+// this.baseQuestionDAO = baseQuestionDAO;
|
|
|
this.bokUtil = bokUtil;
|
|
|
}
|
|
|
|
|
|
@@ -57,27 +66,32 @@ public class QuestionServiceImpl implements QuestionService {
|
|
|
return bokUtil.bokFindByIdIn(questionIds, true);
|
|
|
}
|
|
|
|
|
|
- // @Override
|
|
|
-// public BaseQuestionVO newQuestion(BaseQuestionVO newQuestion) {
|
|
|
-// try {
|
|
|
-// return bokUtil.postNewQuestion(newQuestion);
|
|
|
-// } catch (JsonProcessingException e) {
|
|
|
-// throw HelperException.of(ExceptionType.ERROR, "请求BOK题库数据错误:" + e.getMessage());
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
+// @Transactional(rollbackFor = Exception.class)
|
|
|
// @Override
|
|
|
-// public BaseQuestionVO updateQuestion(BaseQuestionVO newQuestion) {
|
|
|
-// try {
|
|
|
-// return bokUtil.putQuestion(newQuestion);
|
|
|
-// } catch (JsonProcessingException e) {
|
|
|
-// throw HelperException.of(ExceptionType.ERROR, "请求BOK题库数据错误:" + e.getMessage());
|
|
|
-// }
|
|
|
+// 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);
|
|
|
// }
|
|
|
//
|
|
|
-// @Override
|
|
|
-// public void deleteQuestion(String questionId) {
|
|
|
-// bokUtil.deleteQuestion(questionId);
|
|
|
+// 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, "暂时无法创建该类型的题目");
|
|
|
+// }
|
|
|
// }
|
|
|
-
|
|
|
}
|