|
@@ -33,6 +33,7 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.QuesService;
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.RandomPaperQuestionService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.BasePaperCache;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.ExtractConfigPaperCache;
|
|
@@ -75,7 +76,9 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
|
|
|
|
|
|
@Autowired
|
|
|
RedisTemplate<String, Object> redisTemplate;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RandomPaperQuestionService randomPaperQuestionService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据Id获得对应的试题对象
|
|
|
*
|
|
@@ -138,7 +141,10 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
|
|
|
PaperDetailUnit baseUnit = Model.of(paperDetailUnitRepo.findById(updateUnit.getId()));
|
|
|
Paper cpaper=baseUnit.getPaper();
|
|
|
if(cpaper.getInUse()!=null&&cpaper.getInUse()==1) {
|
|
|
- checkUpdate(updateUnit, baseUnit);
|
|
|
+ checkUpdate(updateUnit, baseUnit,"试卷已调用,");
|
|
|
+ }
|
|
|
+ if(randomPaperQuestionService.existQuestion(updateUnit.getQuestion().getId())) {
|
|
|
+ checkUpdateOption(updateUnit, baseUnit,"小题已被抽题模板使用,");
|
|
|
}
|
|
|
Question baseQuestion = baseUnit.getQuestion();
|
|
|
Question updateQuestion = updateUnit.getQuestion();
|
|
@@ -266,7 +272,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
|
|
|
return baseUnit;
|
|
|
}
|
|
|
|
|
|
- private void checkUpdate(PaperDetailUnitExp updateUnit,PaperDetailUnit baseUnit) {
|
|
|
+ private void checkUpdate(PaperDetailUnitExp updateUnit,PaperDetailUnit baseUnit,String msg) {
|
|
|
Question baseQuestion = baseUnit.getQuestion();
|
|
|
Question updateQuestion = updateUnit.getQuestion();
|
|
|
if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
@@ -280,32 +286,64 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
|
|
|
Question sub = baseQuestion.getSubQuestions().get(index - 1);
|
|
|
if (updateQuestion.getId().equals(sub.getId())) {
|
|
|
if(updateQuestion.getScore().doubleValue()!=baseUnit.getSubScoreList().get(index - 1).doubleValue()) {
|
|
|
- throw new StatusException("500", "试卷已调用,不能修改分数");
|
|
|
+ throw new StatusException("500", msg+"不能修改分数");
|
|
|
}
|
|
|
- checkUpdate(updateQuestion, sub);
|
|
|
+ checkUpdate(updateQuestion, sub,msg);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if(updateUnit.getScore().doubleValue()!=baseUnit.getScore().doubleValue()) {
|
|
|
- throw new StatusException("500", "试卷已调用,不能修改分数");
|
|
|
+ throw new StatusException("500", msg+"不能修改分数");
|
|
|
}
|
|
|
- checkUpdate(updateQuestion, baseQuestion);
|
|
|
+ checkUpdate(updateQuestion, baseQuestion,msg);
|
|
|
}
|
|
|
}
|
|
|
- private void checkUpdate(Question update,Question base) {
|
|
|
+ private void checkUpdate(Question update,Question base,String msg) {
|
|
|
if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
|
|
|
||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())){
|
|
|
if(update.getQuesOptions().size()!=base.getQuesOptions().size()) {
|
|
|
- throw new StatusException("500", "试卷已调用,不能修改选项数量");
|
|
|
+ throw new StatusException("500", msg+"不能修改选项数量");
|
|
|
}
|
|
|
}
|
|
|
if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
|
|
|
||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())
|
|
|
||QuesStructType.BOOL_ANSWER_QUESTION.equals(base.getQuestionType())){
|
|
|
if(!update.getQuesAnswer().equals(base.getQuesAnswer())) {
|
|
|
- throw new StatusException("500", "试卷已调用,不能修改客观题答案");
|
|
|
+ throw new StatusException("500", msg+"不能修改客观题答案");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkUpdateOption(PaperDetailUnitExp updateUnit,PaperDetailUnit baseUnit,String msg) {
|
|
|
+ Question baseQuestion = baseUnit.getQuestion();
|
|
|
+ Question updateQuestion = updateUnit.getQuestion();
|
|
|
+ if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
+ if (updateQuestion.getId().equals(baseQuestion.getId())) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ int size = baseQuestion.getSubQuestions().size();
|
|
|
+ // 判断更新的对象是哪个子题
|
|
|
+ for (int index = 1; index <= size; index++) {
|
|
|
+
|
|
|
+ Question sub = baseQuestion.getSubQuestions().get(index - 1);
|
|
|
+ if (updateQuestion.getId().equals(sub.getId())) {
|
|
|
+ checkUpdateOption(updateQuestion, sub,msg);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ checkUpdateOption(updateQuestion, baseQuestion,msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkUpdateOption(Question update,Question base,String msg) {
|
|
|
+ if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
|
|
|
+ ||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())){
|
|
|
+ if(update.getQuesOptions().size()!=base.getQuesOptions().size()) {
|
|
|
+ throw new StatusException("500", msg+"不能修改选项数量");
|
|
|
}
|
|
|
}
|
|
|
}
|