|
@@ -443,7 +443,7 @@ public class MarkGroupController extends BaseExamController {
|
|
if (questionIds != null && reset.booleanValue()) {
|
|
if (questionIds != null && reset.booleanValue()) {
|
|
// advance update
|
|
// advance update
|
|
if (!checkSelective(examId, subjectCode, questionIds)) {
|
|
if (!checkSelective(examId, subjectCode, questionIds)) {
|
|
- addMessage(redirectAttributes, "选做题和非选做题不能在一组");
|
|
|
|
|
|
+ addMessage(redirectAttributes, "选做题不合法!选做题和非选做题不能在一组,选做题不能跨组或垮区设置");
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("number", number);
|
|
redirectAttributes.addAttribute("number", number);
|
|
return "redirect:/admin/exam/group/edit-simple";
|
|
return "redirect:/admin/exam/group/edit-simple";
|
|
@@ -523,43 +523,41 @@ public class MarkGroupController extends BaseExamController {
|
|
}
|
|
}
|
|
|
|
|
|
private boolean checkSelective(Integer examId, String subjectCode, Integer[] questionIds) {
|
|
private boolean checkSelective(Integer examId, String subjectCode, Integer[] questionIds) {
|
|
- Set<Integer> selectiveMainNumbers = new HashSet<Integer>();
|
|
|
|
- Set<Integer> mainNumbers = new HashSet<Integer>();
|
|
|
|
|
|
+ // 无选做题分组
|
|
List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
|
|
List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
|
|
- for (SelectiveGroup selectiveGroup : list) {
|
|
|
|
- selectiveMainNumbers.add(selectiveGroup.getMainNumber());
|
|
|
|
|
|
+ if (list.size() == 0) {
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
List<ExamQuestion> selectives = new ArrayList<ExamQuestion>();
|
|
List<ExamQuestion> selectives = new ArrayList<ExamQuestion>();
|
|
|
|
+ Set<Integer> selectiveIndexs = new HashSet<Integer>();
|
|
|
|
+ Set<Integer> selectiveParts = new HashSet<Integer>();
|
|
for (Integer questionId : questionIds) {
|
|
for (Integer questionId : questionIds) {
|
|
ExamQuestion question = questionService.findById(questionId);
|
|
ExamQuestion question = questionService.findById(questionId);
|
|
- if (selectiveMainNumbers.contains(question.getMainNumber())) {
|
|
|
|
- selectives.add(question);
|
|
|
|
|
|
+ for (SelectiveGroup selectiveGroup : list) {
|
|
|
|
+ if (selectiveGroup.getMainNumber().equals(question.getMainNumber())) {
|
|
|
|
+ selectives.add(question);
|
|
|
|
+ selectiveIndexs.add(selectiveGroup.getSelectiveIndex());
|
|
|
|
+ selectiveParts.add(selectiveGroup.getSelectivePart());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- mainNumbers.add(question.getMainNumber());
|
|
|
|
- }
|
|
|
|
- // 一个分组内只能有一个选做题大题
|
|
|
|
- // if (selectives.size() > 0 && mainNumbers.size() > 1) {
|
|
|
|
- // return false;
|
|
|
|
- // }
|
|
|
|
- // 一个选做题大题内的小题必须在一个分组
|
|
|
|
- // if (selectives.size() > 0) {
|
|
|
|
- // for (Integer mainNumber : mainNumbers) {
|
|
|
|
- // Long count =
|
|
|
|
- // questionService.countByExamAndSubjectAndObjectiveAndMainNumber(examId,
|
|
|
|
- // subjectCode, false,
|
|
|
|
- // mainNumber);
|
|
|
|
- // if (count != selectives.size()) {
|
|
|
|
- // return false;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- if (questionIds.length == selectives.size()) {
|
|
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
|
|
+ // 无选做题
|
|
if (selectives.size() == 0) {
|
|
if (selectives.size() == 0) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+ // 选做题和非选做题一组
|
|
|
|
+ if (selectives.size() != questionIds.length) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // 一个评卷分组内只能有一个选做题分组的题
|
|
|
|
+ if (selectiveIndexs.size() > 1) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // 一个评卷分组内只能有一个选做题分区的题
|
|
|
|
+ if (selectiveParts.size() > 1) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Logging(menu = "新增大题", type = LogType.ADD)
|
|
@Logging(menu = "新增大题", type = LogType.ADD)
|
|
@@ -587,7 +585,7 @@ public class MarkGroupController extends BaseExamController {
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
return "redirect:/admin/exam/group/add";
|
|
return "redirect:/admin/exam/group/add";
|
|
} else if (!checkSelective(examId, subjectCode, questionIds)) {
|
|
} else if (!checkSelective(examId, subjectCode, questionIds)) {
|
|
- addMessage(redirectAttributes, "选做题和非选做题不能在一组");
|
|
|
|
|
|
+ addMessage(redirectAttributes, "选做题不合法!选做题和非选做题不能在一组,选做题不能跨组或垮区设置");
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
return "redirect:/admin/exam/group/add";
|
|
return "redirect:/admin/exam/group/add";
|
|
} else {
|
|
} else {
|