|
@@ -6,7 +6,6 @@ import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
import com.qmth.cqb.paper.model.PaperDetail;
|
|
import com.qmth.cqb.paper.model.PaperDetail;
|
|
import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
-import com.qmth.cqb.question.dao.QuesRepo;
|
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
import com.qmth.cqb.question.model.Question;
|
|
import com.qmth.cqb.question.service.QuesService;
|
|
import com.qmth.cqb.question.service.QuesService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,9 +23,6 @@ public class PaperDetailUnitService {
|
|
@Autowired
|
|
@Autowired
|
|
QuesService quesService;
|
|
QuesService quesService;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- QuesRepo quesRepo;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
PaperService paperService;
|
|
PaperService paperService;
|
|
|
|
|
|
@@ -59,9 +55,10 @@ public class PaperDetailUnitService {
|
|
public PaperDetailUnit savePaperDetailUnit(PaperDetailUnitExp pduExp) {
|
|
public PaperDetailUnit savePaperDetailUnit(PaperDetailUnitExp pduExp) {
|
|
PaperDetailUnit oldPdu = paperDetailUnitRepo.findOne(pduExp.getId());
|
|
PaperDetailUnit oldPdu = paperDetailUnitRepo.findOne(pduExp.getId());
|
|
if (oldPdu.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
if (oldPdu.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
- Question updateQuestion = null;
|
|
|
|
|
|
+ //套题情况下单独处理
|
|
|
|
+ Question oldQuestion = null;
|
|
if (pduExp.getQuestion().getId().equals(oldPdu.getQuestion().getId())) {
|
|
if (pduExp.getQuestion().getId().equals(oldPdu.getQuestion().getId())) {
|
|
- updateQuestion = oldPdu.getQuestion();
|
|
|
|
|
|
+ oldQuestion = oldPdu.getQuestion();
|
|
}
|
|
}
|
|
List<Double> subScoreList = oldPdu.getSubScoreList();
|
|
List<Double> subScoreList = oldPdu.getSubScoreList();
|
|
//套题需要判断更新的对象是套题本身还是子题
|
|
//套题需要判断更新的对象是套题本身还是子题
|
|
@@ -74,30 +71,25 @@ public class PaperDetailUnitService {
|
|
}
|
|
}
|
|
if (sub.getId().equals(pduExp.getQuestion().getId())) {
|
|
if (sub.getId().equals(pduExp.getQuestion().getId())) {
|
|
//匹配到子题
|
|
//匹配到子题
|
|
- updateQuestion = sub;
|
|
|
|
|
|
+ oldQuestion = sub;
|
|
subScoreList.set(index - 1, pduExp.getScore());
|
|
subScoreList.set(index - 1, pduExp.getScore());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (updateQuestion == null) {
|
|
|
|
|
|
+ if (oldQuestion == null) {
|
|
//匹配试题失败,参数错误直接返回
|
|
//匹配试题失败,参数错误直接返回
|
|
return oldPdu;
|
|
return oldPdu;
|
|
}
|
|
}
|
|
//更新套题unit当前总分
|
|
//更新套题unit当前总分
|
|
oldPdu.updateSubScore(subScoreList);
|
|
oldPdu.updateSubScore(subScoreList);
|
|
- if (updateQuestion.getId().equals(oldPdu.getQuestion().getId())) {
|
|
|
|
- //更新的是套题大题
|
|
|
|
- //oldPdu.setQuestion(updateQuestion);
|
|
|
|
- } else {
|
|
|
|
- //更新的是套题下的子题
|
|
|
|
|
|
+ if (oldQuestion.getId().equals(oldPdu.getQuestion().getId())) {
|
|
|
|
+ //更新的是套题大题,需要沿用之前的子题
|
|
|
|
+ pduExp.getQuestion().setSubQuestions(oldQuestion.getSubQuestions());
|
|
}
|
|
}
|
|
- //quesRepo.save(updateQuestion);// 暂时不支持修改套题内容
|
|
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
oldPdu.setScore(pduExp.getScore());
|
|
oldPdu.setScore(pduExp.getScore());
|
|
- oldPdu.setQuestion(pduExp.getQuestion());
|
|
|
|
- Question ques = pduExp.getQuestion();
|
|
|
|
- quesRepo.save(ques);// 同时要跟新小题里面的Qustion对象
|
|
|
|
}
|
|
}
|
|
|
|
+ oldPdu.setQuestion(pduExp.getQuestion());
|
|
|
|
+ quesService.saveQues(pduExp.getQuestion());// 同时要跟新小题里面的Qustion对象
|
|
paperService.formatPaper(oldPdu.getPaper());
|
|
paperService.formatPaper(oldPdu.getPaper());
|
|
return paperDetailUnitRepo.save(oldPdu);
|
|
return paperDetailUnitRepo.save(oldPdu);
|
|
}
|
|
}
|