ting.yin před 1 rokem
rodič
revize
559ecff517

+ 6 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/ExamSubjectDao.java

@@ -2,6 +2,7 @@ package cn.com.qmth.stmms.biz.exam.dao;
 
 import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
 import cn.com.qmth.stmms.biz.exam.model.ExamSubjectPK;
+
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
@@ -71,6 +72,10 @@ public interface ExamSubjectDao extends PagingAndSortingRepository<ExamSubject,
 
     @Modifying
     @Query("update ExamSubject s set s.inspectRound=s.inspectRound+1 where s.pk.examId=?1 and s.pk.code=?2")
-	public void nextInspectRound(int examId, String subjectCode);
+    public void nextInspectRound(int examId, String subjectCode);
+
+    @Modifying
+    @Query("update ExamSubject s set s.selective=?3 where s.pk.examId=?1 and s.pk.code=?2")
+    public void updateSelective(int examId, String subjectCode, boolean selective);
 
 }

+ 11 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/MarkGroup.java

@@ -154,6 +154,9 @@ public class MarkGroup implements Serializable {
     @Transient
     private String questionTitle;
 
+    @Transient
+    private Integer selectiveIndex;
+
     public MarkGroup() {
         this.pk = new MarkGroupPK();
     }
@@ -464,4 +467,12 @@ public class MarkGroup implements Serializable {
         this.questionTitle = questionTitle;
     }
 
+    public Integer getSelectiveIndex() {
+        return selectiveIndex;
+    }
+
+    public void setSelectiveIndex(Integer selectiveIndex) {
+        this.selectiveIndex = selectiveIndex;
+    }
+
 }

+ 4 - 2
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/ExamSubjectService.java

@@ -45,8 +45,10 @@ public interface ExamSubjectService {
 
     void updateTrialCount(int examId, String subjectCode, int trialCount);
 
-	int findMaxInspectRound(int examId, Set<String> subjectCodes);
+    int findMaxInspectRound(int examId, Set<String> subjectCodes);
 
-	void nextInspectRound(int examId, String subjectCode);
+    void nextInspectRound(int examId, String subjectCode);
+
+    void updateSelective(int examId, String subjectCode, boolean selective);
 
 }

+ 6 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/ExamSubjectServiceImpl.java

@@ -236,4 +236,10 @@ public class ExamSubjectServiceImpl extends BaseQueryService<ExamSubject> implem
         examStudentDao.cancelInspect(examId, subjectCode);
     }
 
+    @Transactional
+    @Override
+    public void updateSelective(int examId, String subjectCode, boolean selective) {
+        subjectDao.updateSelective(examId, subjectCode, selective);
+    }
+
 }

+ 17 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/SelectiveGroupServiceImpl.java

@@ -17,6 +17,7 @@ import cn.com.qmth.stmms.biz.exam.dao.SelectiveGroupDao;
 import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 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.ExamSubjectService;
 import cn.com.qmth.stmms.biz.exam.service.SelectiveGroupService;
 
 @Service("selectiveGroupService")
@@ -28,6 +29,9 @@ public class SelectiveGroupServiceImpl extends BaseQueryService<SelectiveGroup>
     @Autowired
     private ExamQuestionService questionService;
 
+    @Autowired
+    private ExamSubjectService subjectService;
+
     @Transactional
     @Override
     public SelectiveGroup save(SelectiveGroup group) {
@@ -37,7 +41,14 @@ public class SelectiveGroupServiceImpl extends BaseQueryService<SelectiveGroup>
     @Transactional
     @Override
     public void save(List<SelectiveGroup> list) {
-        selectiveGroupDao.save(list);
+        if (!list.isEmpty()) {
+            selectiveGroupDao.save(list);
+            int examId = list.get(0).getExamId();
+            String subjectCode = list.get(0).getSubjectCode();
+            subjectService.updateSelective(examId, subjectCode, true);
+            subjectService.updateScore(examId, subjectCode, false,
+                    questionService.sumTotalScore(examId, subjectCode, false));
+        }
     }
 
     @Override
@@ -54,6 +65,11 @@ public class SelectiveGroupServiceImpl extends BaseQueryService<SelectiveGroup>
     @Override
     public void deleteByExamIdAndSubjectCodeAndSelectiveIndex(int examId, String subjectCode, int selectiveIndex) {
         selectiveGroupDao.deleteByExamIdAndSubjectCodeAndSelectiveIndex(examId, subjectCode, selectiveIndex);
+        if (countByExamIdAndSubjectCode(examId, subjectCode) <= 0) {
+            subjectService.updateSelective(examId, subjectCode, false);
+        }
+        subjectService.updateScore(examId, subjectCode, false,
+                questionService.sumTotalScore(examId, subjectCode, false));
     }
 
     @Override

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

@@ -131,8 +131,9 @@ public class MarkGroupController extends BaseExamController {
         }
         List<MarkGroup> list = groupService.findByExamAndSubject(examId, subject.getCode());
         for (MarkGroup group : list) {
-            group.setQuestionList(questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
-                    subject.getCode(), false, group.getNumber()));
+            List<ExamQuestion> qList = questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
+                    subject.getCode(), false, group.getNumber());
+            group.setQuestionList(qList);
             group.setMarkerCount(markerService.countByExamAndSubjectAndGroup(examId, subject.getCode(),
                     group.getNumber()));
             group.setCurrentCount(markService.applyCount(group));
@@ -141,6 +142,9 @@ public class MarkGroupController extends BaseExamController {
             group.setPercent(percent);
             group.setDeleting(lockService.isLocked(LockType.GROUP_DELETE, group.getExamId(), group.getSubjectCode(),
                     group.getNumber()));
+            SelectiveGroup selectiveGroup = selectiveGroupService.findOne(examId, subjectCode, qList.get(0)
+                    .getMainNumber());
+            group.setSelectiveIndex(selectiveGroup.getSelectiveIndex());
         }
         model.addAttribute("resultList", list);
         model.addAttribute("subject", subject);
@@ -638,7 +642,8 @@ public class MarkGroupController extends BaseExamController {
 
                     studentService.updateSubjectiveStatusAndScoreAndInspectorId(examId, subjectCode,
                             SubjectiveStatus.UNMARK, 0, null, null, null);
-                    //studentService.resetSubjectiveStatusAndScoreWithoutTrial(examId, subjectCode);
+                    // studentService.resetSubjectiveStatusAndScoreWithoutTrial(examId,
+                    // subjectCode);
                     inspectHistoryService.deleteByExamIdAndSubjectCode(examId, subjectCode);
                     redirectAttributes.addAttribute("subjectCode", subjectCode);
                     return "redirect:/admin/exam/group";

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

@@ -426,9 +426,7 @@ public class PaperController extends BaseExamController {
                         error.add("[" + subject.getCode() + "] 已存在分组");
                         continue;
                     }
-                    long selectiveGroupCount = selectiveGroupService.countByExamIdAndSubjectCode(examId,
-                            subject.getCode());
-                    if (selectiveGroupCount > 0) {
+                    if (subject.isSelective()) {
                         error.add("[" + subject.getCode() + "] 已存在选做题分组");
                         continue;
                     }

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

@@ -71,6 +71,7 @@ public class SelectiveGroupController extends BaseExamController {
                 examQuestion.setSelective(true);
                 examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
                 examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
+                examQuestion.setScorePolicy(map.get(examQuestion.getMainNumber()).getScorePolicy().getValue());
             }
         }
         model.addAttribute("subject", subject);
@@ -175,8 +176,6 @@ public class SelectiveGroupController extends BaseExamController {
             }
             selectiveGroupService.save(list);
         }
-        subjectService.updateScore(examId, subjectCode, false,
-                questionService.sumTotalScore(examId, subjectCode, false));
         return "redirect:/admin/exam/selectiveGroup?subjectCode=" + subjectCode;
     }
 
@@ -209,8 +208,6 @@ public class SelectiveGroupController extends BaseExamController {
             return "redirect:/admin/exam/selectiveGroup?subjectCode=" + subjectCode;
         }
         selectiveGroupService.deleteByExamIdAndSubjectCodeAndSelectiveIndex(examId, subjectCode, selectiveIndex);
-        subjectService.updateScore(examId, subjectCode, false,
-                questionService.sumTotalScore(examId, subjectCode, false));
         return "redirect:/admin/exam/selectiveGroup?subjectCode=" + subjectCode;
     }
 

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

@@ -53,6 +53,7 @@
         <th>大题号</th>
         <th>大题名称</th>
         <th>步骤分</th>
+        <th>选做题组</th>
         <th>评卷员人数</th>
         <th>任务总数</th>
         <th>完成总数</th>
@@ -71,6 +72,7 @@
             <td>${result.mainNumber}</td>
             <td>${result.title}</td>
             <td>${result.scoreList}</td>
+            <td>${result.selectiveIndex}</td>
             <td>
                 <a href="${ctx}/admin/exam/marker?subjectCode=${result.subjectCode}&groupNumber=${result.number}">${result.markerCount}</a>
             </td>

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

@@ -116,7 +116,11 @@
 				<td>${question.subNumber}</td>
 				<td><fmt:formatNumber pattern="###.###" value="${question.totalScore}"/></td>
 				<td><fmt:formatNumber pattern="###.###" value="${question.intervalScore}"/></td>
-				<td>${question.selectiveIndex}</td>
+				<td>${question.selectiveIndex}-
+					<c:if test="${question.scorePolicy==1}">平均分</c:if>
+					<c:if test="${question.scorePolicy==2}">取高分</c:if>
+					<c:if test="${question.scorePolicy==3}">取低分</c:if>
+				</td>
 				<td>${question.selectiveIndex}-${question.selectivePart}</td>
 			</tr>
 		</c:forEach>