|
@@ -2352,6 +2352,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
// 题号重复校验
|
|
// 题号重复校验
|
|
// 导入的客观题题号集合
|
|
// 导入的客观题题号集合
|
|
Set<String> questionNumberCheckSet = new HashSet<>();
|
|
Set<String> questionNumberCheckSet = new HashSet<>();
|
|
|
|
+ // 客观题选项个数在大题下一致性校验
|
|
|
|
+ Map<String, Integer> questionOptionCountMap = new HashMap<>();
|
|
// 该试卷已存在的主观题题号集合
|
|
// 该试卷已存在的主观题题号集合
|
|
Set<String> dbSubjectiveQuestionNumberSet = markQuestionService.list(
|
|
Set<String> dbSubjectiveQuestionNumberSet = markQuestionService.list(
|
|
new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
@@ -2374,6 +2376,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
Integer mainNumber = objectiveStructDto.getMainNumber();
|
|
Integer mainNumber = objectiveStructDto.getMainNumber();
|
|
Integer subNumber = objectiveStructDto.getSubNumber();
|
|
Integer subNumber = objectiveStructDto.getSubNumber();
|
|
String answer = objectiveStructDto.getAnswer();
|
|
String answer = objectiveStructDto.getAnswer();
|
|
|
|
+ Integer optionCount = objectiveStructDto.getOptionCount();
|
|
Double totalScore = objectiveStructDto.getTotalScore();
|
|
Double totalScore = objectiveStructDto.getTotalScore();
|
|
Integer questionType = objectiveStructDto.getQuestionType();
|
|
Integer questionType = objectiveStructDto.getQuestionType();
|
|
String errorMsg = objectiveStructDto.getErrorMsg();
|
|
String errorMsg = objectiveStructDto.getErrorMsg();
|
|
@@ -2391,6 +2394,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (dbSubjectiveQuestionNumberSet.contains(questionNumberKey)) {
|
|
if (dbSubjectiveQuestionNumberSet.contains(questionNumberKey)) {
|
|
logicErrorList.add("该题号已存在主观题中");
|
|
logicErrorList.add("该题号已存在主观题中");
|
|
}
|
|
}
|
|
|
|
+ String mainQuestionKey = paperNumber + SystemConstant.HYPHEN + mainNumber;
|
|
|
|
+ if (questionOptionCountMap.containsKey(mainQuestionKey)) {
|
|
|
|
+ if (!Objects.equals(questionOptionCountMap.get(mainQuestionKey), optionCount)) {
|
|
|
|
+ logicErrorList.add("选项个数和该大题中的其他小题不一致");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ questionOptionCountMap.put(mainQuestionKey, optionCount);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// 2.校验课程编号,课程名称,试卷在考试下是否存在
|
|
// 2.校验课程编号,课程名称,试卷在考试下是否存在
|
|
@@ -2404,14 +2415,35 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
logicErrorList.add("试卷不存在");
|
|
logicErrorList.add("试卷不存在");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 3.客观题答案必须是OptionsEnum中的编号
|
|
|
|
- if (SystemConstant.strNotNull(answer)) {
|
|
|
|
- for (String s : answer.split("")) {
|
|
|
|
- if (OptionsEnum.getByCode(s) == null) {
|
|
|
|
- logicErrorList.add("客观题答案必须是[A-Z]中的大写英文字母");
|
|
|
|
- break;
|
|
|
|
|
|
+ // 3.选项越界校验
|
|
|
|
+ List<String> optionScope = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ for (int j = 1; j <= optionCount; j++) {
|
|
|
|
+ String code = OptionsEnum.getCodeByIndex(j);
|
|
|
|
+ optionScope.add(code);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(logicErrorCommonNotice + "[选项个数]不能超过26");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 答案选项越界校验
|
|
|
|
+ List<String> answerList = Arrays.asList(answer.split(""));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(answerList)) {
|
|
|
|
+ for (String cell : answerList) {
|
|
|
|
+ String outOfBoundsException = String.format("答案[%s]错误。答案只能从[%s]中选择", cell, String.join("", optionScope));
|
|
|
|
+ try {
|
|
|
|
+ OptionsEnum optionsEnum = OptionsEnum.getByCode(cell);
|
|
|
|
+ int optionIndex = optionsEnum.getIndex();
|
|
|
|
+ if (optionIndex > optionCount) {
|
|
|
|
+ // 答案选项超出范围
|
|
|
|
+ logicErrorList.add(outOfBoundsException);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logicErrorList.add(outOfBoundsException);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ logicErrorList.add("答案必填");
|
|
}
|
|
}
|
|
|
|
|
|
// 4.判断答案是否符合题型
|
|
// 4.判断答案是否符合题型
|
|
@@ -2452,6 +2484,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
markQuestion.setSubNumber(subNumber);
|
|
markQuestion.setSubNumber(subNumber);
|
|
markQuestion.setMainTitle(mainTitle);
|
|
markQuestion.setMainTitle(mainTitle);
|
|
markQuestion.setAnswer(answer);
|
|
markQuestion.setAnswer(answer);
|
|
|
|
+ markQuestion.setOptionCount(optionCount);
|
|
markQuestion.setTotalScore(totalScore);
|
|
markQuestion.setTotalScore(totalScore);
|
|
markQuestion.setObjectivePolicy(ObjectivePolicy.NONE);
|
|
markQuestion.setObjectivePolicy(ObjectivePolicy.NONE);
|
|
markQuestion.setQuestionType(questionType);
|
|
markQuestion.setQuestionType(questionType);
|