ting.yin 2 năm trước cách đây
mục cha
commit
c8748293cd

+ 12 - 6
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/MarkGroupController.java

@@ -2,8 +2,10 @@ package cn.com.qmth.stmms.admin.exam;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
@@ -300,13 +302,15 @@ public class MarkGroupController extends BaseExamController {
         model.addAttribute("exam", examService.findById(examId));
         model.addAttribute("exam", examService.findById(examId));
         List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
         List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
         List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
         List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
-        Set<Integer> mainNumbers = new HashSet<Integer>();
+        Map<Integer, SelectiveGroup> map = new HashMap<Integer, SelectiveGroup>();
         for (SelectiveGroup selectiveGroup : list) {
         for (SelectiveGroup selectiveGroup : list) {
-            mainNumbers.add(selectiveGroup.getMainNumber());
+            map.put(selectiveGroup.getMainNumber(), selectiveGroup);
         }
         }
         for (ExamQuestion examQuestion : questions) {
         for (ExamQuestion examQuestion : questions) {
-            if (mainNumbers.contains(examQuestion.getMainNumber())) {
+            if (map.containsKey(examQuestion.getMainNumber())) {
                 examQuestion.setSelective(true);
                 examQuestion.setSelective(true);
+                examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
+                examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
             }
             }
         }
         }
         model.addAttribute("questionList", questions);
         model.addAttribute("questionList", questions);
@@ -352,13 +356,15 @@ public class MarkGroupController extends BaseExamController {
             group.setPicList(buildPictureConfig(group));
             group.setPicList(buildPictureConfig(group));
             List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
             List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
             List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
             List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
-            Set<Integer> mainNumbers = new HashSet<Integer>();
+            Map<Integer, SelectiveGroup> map = new HashMap<Integer, SelectiveGroup>();
             for (SelectiveGroup selectiveGroup : list) {
             for (SelectiveGroup selectiveGroup : list) {
-                mainNumbers.add(selectiveGroup.getMainNumber());
+                map.put(selectiveGroup.getMainNumber(), selectiveGroup);
             }
             }
             for (ExamQuestion examQuestion : questions) {
             for (ExamQuestion examQuestion : questions) {
-                if (mainNumbers.contains(examQuestion.getMainNumber())) {
+                if (map.containsKey(examQuestion.getMainNumber())) {
                     examQuestion.setSelective(true);
                     examQuestion.setSelective(true);
+                    examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
+                    examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
                 }
                 }
             }
             }
             model.addAttribute("group", group);
             model.addAttribute("group", group);

+ 12 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/PaperController.java

@@ -42,6 +42,7 @@ import cn.com.qmth.stmms.biz.exam.model.Exam;
 import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
 import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
 import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
 import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
+import cn.com.qmth.stmms.biz.exam.model.SelectiveGroup;
 import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
 import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
 import cn.com.qmth.stmms.biz.exam.service.ExamService;
 import cn.com.qmth.stmms.biz.exam.service.ExamService;
 import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
 import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
@@ -310,6 +311,12 @@ public class PaperController extends BaseExamController {
                             subjectService.updateScore(examId, subject.getCode(), objective, dto.getTotalScore());
                             subjectService.updateScore(examId, subject.getCode(), objective, dto.getTotalScore());
                         } else {
                         } else {
                             int questionCount = 0;
                             int questionCount = 0;
+                            List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId,
+                                    subject.getCode());
+                            Map<Integer, SelectiveGroup> selectiveMap = new HashMap<Integer, SelectiveGroup>();
+                            for (SelectiveGroup selectiveGroup : list) {
+                                selectiveMap.put(selectiveGroup.getMainNumber(), selectiveGroup);
+                            }
                             for (ExamQuestion question : dto.getQuestionList()) {
                             for (ExamQuestion question : dto.getQuestionList()) {
                                 ExamQuestion old = questionService
                                 ExamQuestion old = questionService
                                         .findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(examId,
                                         .findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(examId,
@@ -321,6 +328,11 @@ public class PaperController extends BaseExamController {
                                                 + question.getSubNumber() + "已有分组");
                                                 + question.getSubNumber() + "已有分组");
                                         continue;
                                         continue;
                                     }
                                     }
+                                    if (selectiveMap.containsKey(question.getMainNumber())) {
+                                        error.add("[" + subject.getCode() + "] 大题号" + question.getMainNumber() + " 小题号"
+                                                + question.getSubNumber() + "已有选做题分组");
+                                        continue;
+                                    }
                                     old.setTotalScore(question.getTotalScore());
                                     old.setTotalScore(question.getTotalScore());
                                     old.setIntervalScore(question.getIntervalScore());
                                     old.setIntervalScore(question.getIntervalScore());
                                     questionService.save(old);
                                     questionService.save(old);

+ 3 - 3
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/SelectiveGroupController.java

@@ -68,7 +68,7 @@ public class SelectiveGroupController extends BaseExamController {
         }
         }
         List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
         List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
         for (ExamQuestion examQuestion : questions) {
         for (ExamQuestion examQuestion : questions) {
-            if (map.get(examQuestion.getMainNumber()) != null) {
+            if (map.containsKey(examQuestion.getMainNumber())) {
                 examQuestion.setSelective(true);
                 examQuestion.setSelective(true);
                 examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                 examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                 examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
                 examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
@@ -105,7 +105,7 @@ public class SelectiveGroupController extends BaseExamController {
         }
         }
         List<ExamQuestion> questions = questionService.findMainByExamAndSubjectAndObjective(examId, subjectCode, false);
         List<ExamQuestion> questions = questionService.findMainByExamAndSubjectAndObjective(examId, subjectCode, false);
         for (ExamQuestion examQuestion : questions) {
         for (ExamQuestion examQuestion : questions) {
-            if (map.get(examQuestion.getMainNumber()) != null) {
+            if (map.containsKey(examQuestion.getMainNumber())) {
                 examQuestion.setSelective(true);
                 examQuestion.setSelective(true);
                 examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                 examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
             }
             }
@@ -223,7 +223,7 @@ public class SelectiveGroupController extends BaseExamController {
             }
             }
             List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
             List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
             for (ExamQuestion examQuestion : questions) {
             for (ExamQuestion examQuestion : questions) {
-                if (map.get(examQuestion.getMainNumber()) != null) {
+                if (map.containsKey(examQuestion.getMainNumber())) {
                     examQuestion.setSelective(true);
                     examQuestion.setSelective(true);
                     examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                     examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                 } else {
                 } else {

+ 4 - 3
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/ExamInfoController.java

@@ -202,11 +202,12 @@ public class ExamInfoController extends BaseApiController {
         return success;
         return success;
     }
     }
 
 
-    @RequestMapping(value = "/questions/{examId}", method = RequestMethod.GET)
+    @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER, Role.SUBJECT_HEADER })
+    @RequestMapping(value = "/questions/{examId}", method = RequestMethod.POST)
     @ResponseBody
     @ResponseBody
     public JSONArray getQuestion(HttpServletRequest request, @PathVariable Integer examId,
     public JSONArray getQuestion(HttpServletRequest request, @PathVariable Integer examId,
-            @RequestParam String[] subjectCodes, @RequestParam(required = false, defaultValue = "#") String paperType,
-            @RequestParam Boolean objective) {
+            @RequestParam List<String> subjectCodes,
+            @RequestParam(required = false, defaultValue = "#") String paperType, @RequestParam Boolean objective) {
         ApiUser user = RequestUtils.getApiUser(request);
         ApiUser user = RequestUtils.getApiUser(request);
         JSONArray result = new JSONArray();
         JSONArray result = new JSONArray();
         // 输入字段预处理并初步校验
         // 输入字段预处理并初步校验

+ 4 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/groupAdd.jsp

@@ -83,6 +83,8 @@
         		 <th>名称</th>
         		 <th>名称</th>
         		 <th>分数</th>
         		 <th>分数</th>
         		 <th>是否选做题</th>
         		 <th>是否选做题</th>
+        		 <th>选做题分组</th>
+				 <th>选做题区</th>
         		 <th></th>
         		 <th></th>
 			</tr>
 			</tr>
         	</thead>
         	</thead>
@@ -93,6 +95,8 @@
 			<td>${item.mainTitle }</td>
 			<td>${item.mainTitle }</td>
 			<td><fmt:formatNumber pattern="###.###" value="${item.totalScore}"/></td>
 			<td><fmt:formatNumber pattern="###.###" value="${item.totalScore}"/></td>
 			<td><c:if test="${item.selective }">选做题</c:if></td>
 			<td><c:if test="${item.selective }">选做题</c:if></td>
+			<td>${item.selectiveIndex}</td>
+			<td>${item.selectiveIndex}-${item.selectivePart}</td>
 			<td><input type="checkbox" name="questionIds" value="${item.id }" <c:if test="${item.groupNumber!=null}"> disabled="disabled"</c:if>></td>
 			<td><input type="checkbox" name="questionIds" value="${item.id }" <c:if test="${item.groupNumber!=null}"> disabled="disabled"</c:if>></td>
 			</tr>
 			</tr>
 			</c:forEach>
 			</c:forEach>

+ 6 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/groupEditFull.jsp

@@ -95,6 +95,9 @@
         		 <th>小题号</th>
         		 <th>小题号</th>
         		 <th>名称</th>
         		 <th>名称</th>
         		 <th>分数</th>
         		 <th>分数</th>
+        		 <th>是否选做题</th>
+        		 <th>选做题分组</th>
+				 <th>选做题区</th>
         		 <th></th>
         		 <th></th>
 			</tr>
 			</tr>
         	</thead>
         	</thead>
@@ -104,6 +107,9 @@
 		    <td>${item.subNumber }</td>
 		    <td>${item.subNumber }</td>
 			<td>${item.mainTitle }</td>
 			<td>${item.mainTitle }</td>
 			<td><fmt:formatNumber pattern="###.###" value="${item.totalScore}"/></td>
 			<td><fmt:formatNumber pattern="###.###" value="${item.totalScore}"/></td>
+			<td><c:if test="${item.selective }">选做题</c:if></td>
+			<td>${item.selectiveIndex}</td>
+			<td>${item.selectiveIndex}-${item.selectivePart}</td>
 			<td><input type="checkbox" name="questionIds" value="${item.id }" <c:if test="${item.groupNumber!=null && item.groupNumber!=group.number}"> disabled="disabled"</c:if> <c:if test="${item.groupNumber==group.number}"> checked</c:if>></td>
 			<td><input type="checkbox" name="questionIds" value="${item.id }" <c:if test="${item.groupNumber!=null && item.groupNumber!=group.number}"> disabled="disabled"</c:if> <c:if test="${item.groupNumber==group.number}"> checked</c:if>></td>
 			</tr>
 			</tr>
 			</c:forEach>
 			</c:forEach>

+ 1 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/selectiveList.jsp

@@ -117,7 +117,7 @@
 				<td><fmt:formatNumber pattern="###.###" value="${question.totalScore}"/></td>
 				<td><fmt:formatNumber pattern="###.###" value="${question.totalScore}"/></td>
 				<td><fmt:formatNumber pattern="###.###" value="${question.intervalScore}"/></td>
 				<td><fmt:formatNumber pattern="###.###" value="${question.intervalScore}"/></td>
 				<td>${question.selectiveIndex}</td>
 				<td>${question.selectiveIndex}</td>
-				<td>${question.selectivePart}</td>
+				<td>${question.selectiveIndex}-${question.selectivePart}</td>
 			</tr>
 			</tr>
 		</c:forEach>
 		</c:forEach>
 		</tbody>
 		</tbody>