deason пре 1 година
родитељ
комит
55132963b1

+ 8 - 9
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamScoreController.java

@@ -42,7 +42,7 @@ public class ExamScoreController extends ControllerSupport {
     @Autowired
     private ExamScoreService examScoreService;
 
-    @DataRule(type = {DataRuleType.COURSE, DataRuleType.ORG})
+    @DataRule(type = { DataRuleType.COURSE, DataRuleType.ORG })
     @PostMapping("/statistic/list")
     @ApiOperation(value = "分页查询成绩明细列表")
     public Page<ExamScoreInfo> scoreDetails(@RequestBody ExamScoreQuery query) {
@@ -71,13 +71,14 @@ public class ExamScoreController extends ControllerSupport {
     }
 
     @GetMapping("/statistic/list/export/async")
-    @ApiOperation(value = "导出“成绩统计”列表(异步)",
-            notes = "参数示例:query={\"rootOrgId\":0,\"examId\":1,\"startLimit\":1,\"endLimit\":1}")
+    @ApiOperation(value = "导出“成绩统计”列表(异步)", notes = "参数示例:query={\"rootOrgId\":0,\"examId\":1,\"startLimit\":1,\"endLimit\":1}")
     public void exportExamScores(@RequestParam String query) {
         User user = getAccessUser();
         asyncExportService.exportExamScoreStatistics(query, user);
         AsyncExportConcurrentUtil.checkOrStartJob();
-        ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), AdminOperateType.TYPE18.getDesc(), "导出条件:" + query));
+        ReportsUtil.report(
+                new AdminOperateReport(user.getRootOrgId(), user.getUserId(), AdminOperateType.TYPE18.getDesc(),
+                        "导出条件:" + query));
     }
 
     @ApiOperation(value = "根据examStudentId获取客观分信息")
@@ -86,13 +87,11 @@ public class ExamScoreController extends ControllerSupport {
         return examScoreService.queryObjectiveScoreList(examStudentId);
     }
 
-    @ApiOperation(value = "按考生ID更新正确答案并重新算分(用于实施小工具)")
+    @ApiOperation(value = "按考生ID重新成绩(用于实施小工具)")
     @GetMapping("/updateCorrectAnswerAndReFixScore")
-    public void updateCorrectAnswerAndReFixScore(
-            @RequestParam Long examId,
-            @RequestParam Long courseId,
+    public void reFixScoreByExamStudentId(@RequestParam Long examId, @RequestParam Long courseId,
             @RequestParam Long examStudentId) {
-        examScoreService.updateCorrectAnswerAndReFixScore(examId, courseId, examStudentId);
+        examScoreService.reFixScoreByExamStudentId(examId, courseId, examStudentId);
     }
 
 }

+ 6 - 3
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamScoreService.java

@@ -45,7 +45,6 @@ public interface ExamScoreService {
      */
     public void createExamScoreWithOffline(Long examRecordDataId);
 
-
     /**
      * 使用考生ID查询客观分信息
      * 客观分是指考生完成过一次考试后,有效的客观分,
@@ -57,6 +56,10 @@ public interface ExamScoreService {
 
     List<ExamScoreInfo> exportExamScoreListForAsync(UserDataRules uds, ExamScoreQuery query);
 
-    void updateCorrectAnswerAndReFixScore(Long examId, Long courseId, Long examStudentId);
+    /**
+     * 按考生ID重新计算成绩分数(用于实施小工具)
+     * 适用场景:修改试题正确答案、试题分值
+     */
+    void reFixScoreByExamStudentId(Long examId, Long courseId, Long examStudentId);
 
-}
+}

+ 54 - 49
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamScoreServiceImpl.java

@@ -110,8 +110,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
 
         // 阅卷方式
-        String markingType = ExamCacheTransferHelper
-                .getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
+        String markingType = ExamCacheTransferHelper.getDefaultCachedExamProperty(query.getExamId(),
+                ExamProperties.MARKING_TYPE.name()).getValue();
 
         // 获取考生列表
         Page<ExamStudentInfo> page = examStudentService.getExamStudentListPage(uds, ExamScoreEntityConvert.of(query));
@@ -141,9 +141,9 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 info.setExamStageOrder(stage.getStageOrder());
                 info.setStageStartTime(stage.getStartTime());
                 info.setStageEndTime(stage.getEndTime());
-                info.setExamStage(stage.getStageOrder() + "("
-                        + DateUtil.format(stage.getStartTime(), DateUtil.DatePatterns.CHINA_DEFAULT) + "至"
-                        + DateUtil.format(stage.getEndTime(), DateUtil.DatePatterns.CHINA_DEFAULT) + ")");
+                info.setExamStage(stage.getStageOrder() + "(" + DateUtil.format(stage.getStartTime(),
+                        DateUtil.DatePatterns.CHINA_DEFAULT) + "至" + DateUtil.format(stage.getEndTime(),
+                        DateUtil.DatePatterns.CHINA_DEFAULT) + ")");
             }
         }
     }
@@ -159,9 +159,9 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 info.setExamStageOrder(stage.getStageOrder());
                 info.setStageStartTime(stage.getStartTime());
                 info.setStageEndTime(stage.getEndTime());
-                info.setExamStage(stage.getStageOrder() + "("
-                        + DateUtil.format(stage.getStartTime(), DateUtil.DatePatterns.CHINA_DEFAULT) + "至"
-                        + DateUtil.format(stage.getEndTime(), DateUtil.DatePatterns.CHINA_DEFAULT) + ")");
+                info.setExamStage(stage.getStageOrder() + "(" + DateUtil.format(stage.getStartTime(),
+                        DateUtil.DatePatterns.CHINA_DEFAULT) + "至" + DateUtil.format(stage.getEndTime(),
+                        DateUtil.DatePatterns.CHINA_DEFAULT) + ")");
             }
         }
     }
@@ -211,8 +211,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         Check.isNull(query.getExamId(), "请先选择考试批次!");
 
         // 阅卷方式
-        String markingType = ExamCacheTransferHelper
-                .getDefaultCachedExamProperty(query.getExamId(), ExamProperties.MARKING_TYPE.name()).getValue();
+        String markingType = ExamCacheTransferHelper.getDefaultCachedExamProperty(query.getExamId(),
+                ExamProperties.MARKING_TYPE.name()).getValue();
         //        if (query.getStartLimit() != null && query.getEndLimit() != null) {
         //            return getExamStudentInfoListOfScoreExport(uds, query, markingType);
         //        } else {
@@ -251,7 +251,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     }
 
     private List<ExamStudentEntity> getExamStudentInfoListOfScoreExportByPage(UserDataRules uds, ExamScoreQuery query,
-                                                                              String markingType, List<Long> ids) {
+            String markingType, List<Long> ids) {
         // 查询条件
         StringBuffer sql = new StringBuffer();
         sql.append(
@@ -263,6 +263,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
 
         List<ExamStudentEntity> examStudentList = jdbcTemplate.query(sql.toString(),
                 new RowMapper<ExamStudentEntity>() {
+
                     @Override
                     public ExamStudentEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
                         return getExamStudentEntityByResultSet(rs);
@@ -273,7 +274,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     }
 
     private List<Long> getExamStudentInfoListOfScoreExportByPageOnlyId(UserDataRules uds, ExamScoreQuery query,
-                                                                       String markingType) {
+            String markingType) {
         // 查询条件
         StringBuffer sql = new StringBuffer();
         sql.append("select id from ec_oe_exam_student where 1=1 ");
@@ -330,8 +331,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
 
     @Override
     public List<ExamScoreEntity> getAllExamScoreList(Long examId, String identityNumber, Long courseId) {
-        List<ExamRecordDataEntity> allExamRecordDataList = examRecordDataRepo
-                .findByExamIdAndIdentityNumberAndCourseId(examId, identityNumber, courseId);
+        List<ExamRecordDataEntity> allExamRecordDataList = examRecordDataRepo.findByExamIdAndIdentityNumberAndCourseId(
+                examId, identityNumber, courseId);
         if (allExamRecordDataList == null || allExamRecordDataList.isEmpty()) {
             return null;
         }
@@ -409,7 +410,7 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     //    }
 
     private ExamScoreInfo convertToExamScoreInfo(ExamStudentEntity examStudent, CourseCacheBean courseBean,
-                                                 OrgCacheBean orgBean, String markingType) {
+            OrgCacheBean orgBean, String markingType) {
         if (examStudent == null) {
             return null;
         }
@@ -453,12 +454,12 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     }
 
     private ExamScoreInfo setCommomScoreInfo(ExamScoreInfo examScoreInfo, Boolean finished, long examStudentId,
-                                             ExamSettingsCacheBean examBean, String markingType) {
+            ExamSettingsCacheBean examBean, String markingType) {
         // 查询考试记录
         if (finished != null && finished) {
             // 查询考试记录
-            List<ExamRecordDataEntity> examRecordList = examRecordService
-                    .getExamRecordListByExamStudentId(examStudentId);
+            List<ExamRecordDataEntity> examRecordList = examRecordService.getExamRecordListByExamStudentId(
+                    examStudentId);
             examScoreInfo.setIsFinished("是");// 是否完成考试
             examScoreInfo.setIsAbsent("否");// 是否缺考
             // 违纪次数
@@ -467,8 +468,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
             examScoreInfo.setSubmitCount(submitCount(examRecordList));
 
             // 设置相关成绩(总分,主观分,客观分)
-            ExamStudentFinalScoreEntity finalExamScore = examStudentFinalScoreService
-                    .getFinalEffectiveExamScore(examStudentId);
+            ExamStudentFinalScoreEntity finalExamScore = examStudentFinalScoreService.getFinalEffectiveExamScore(
+                    examStudentId);
             setFinalExamScore(examScoreInfo, finalExamScore);
 
             if (finalExamScore != null) {
@@ -643,8 +644,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
             if (examRecordDataEntity.getIsIllegality() == null || !examRecordDataEntity.getIsIllegality()) {
                 if (examRecordDataEntity.getIsWarn() && !examRecordDataEntity.getIsAudit()) {
                     objectiveScoreInfo.setIsAuditing(true);
-                } else if (!examRecordDataEntity.getIsWarn()
-                        || (examRecordDataEntity.getIsWarn() && examRecordDataEntity.getIsAudit())) {
+                } else if (!examRecordDataEntity.getIsWarn() || (examRecordDataEntity.getIsWarn()
+                        && examRecordDataEntity.getIsAudit())) {
                     ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordDataEntity.getId());
                     objectiveScoreInfo.setIsAuditing(false);
                     objectiveScoreInfo.setObjectiveScore(examScore.getObjectiveScore());
@@ -676,15 +677,15 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 Integer examUsedNum = 0;
 
                 for (Long examRecordDataId : unSyncedExamRecordDataIds) {
-                    ExamRecordData examRecordData = redisClient
-                            .get(RedisKeyHelper.getBuilder().examRecordDataKey(examRecordDataId), ExamRecordData.class);
+                    ExamRecordData examRecordData = redisClient.get(
+                            RedisKeyHelper.getBuilder().examRecordDataKey(examRecordDataId), ExamRecordData.class);
                     if (null == examRecordData) {
                         throw new StatusException("100001", "考试记录的缓存数据有误");
                     }
 
                     // 考试中的数据不展示
-                    if (cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_ING == examRecordData
-                            .getExamRecordStatus()) {
+                    if (cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_ING
+                            == examRecordData.getExamRecordStatus()) {
                         continue;
                     }
 
@@ -717,9 +718,9 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         }
 
         if (examRecordData.getIsIllegality() == null || !examRecordData.getIsIllegality()) {
-            if ((null != examRecordData.getIsWarn() && !examRecordData.getIsWarn())
-                    || (null != examRecordData.getIsWarn() && examRecordData.getIsWarn()
-                    && null != examRecordData.getIsAudit() && examRecordData.getIsAudit())) {
+            if ((null != examRecordData.getIsWarn() && !examRecordData.getIsWarn()) || (
+                    null != examRecordData.getIsWarn() && examRecordData.getIsWarn()
+                            && null != examRecordData.getIsAudit() && examRecordData.getIsAudit())) {
                 objectiveScoreInfo.setIsAuditing(true);
 
                 // 缓存中的分数是存储在临时考试记录表中的,所以需要从考试记录缓存中取
@@ -759,10 +760,10 @@ public class ExamScoreServiceImpl implements ExamScoreService {
     private boolean isExamRecordEnded(ExamRecordData examRecordData) {
         // 如果考试记录状态为已处理,则直接返回true.
         if (examRecordData.getExamRecordStatus() == cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_END
-                || examRecordData
-                .getExamRecordStatus() == cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_OVERDUE
-                || examRecordData
-                .getExamRecordStatus() == cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_INVALID) {
+                || examRecordData.getExamRecordStatus()
+                == cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_OVERDUE
+                || examRecordData.getExamRecordStatus()
+                == cn.com.qmth.examcloud.support.enums.ExamRecordStatus.EXAM_INVALID) {
             return true;
         }
         return false;
@@ -778,12 +779,17 @@ public class ExamScoreServiceImpl implements ExamScoreService {
         return false;
     }
 
+    /**
+     * 按考生ID重新计算成绩分数(用于实施小工具)
+     * 适用场景:修改试题正确答案、试题分值
+     */
     @Override
-    public void updateCorrectAnswerAndReFixScore(Long examId, Long courseId, Long examStudentId) {
-        List<ExamRecordDataEntity> examRecordDataList = examRecordDataRepo
-                .findByExamIdAndCourseIdAndExamStudentId(examId, courseId, examStudentId);
+    public void reFixScoreByExamStudentId(Long examId, Long courseId, Long examStudentId) {
+        // 单场考试可能存在多条考试记录
+        List<ExamRecordDataEntity> examRecordDataList = examRecordDataRepo.findByExamIdAndCourseIdAndExamStudentId(
+                examId, courseId, examStudentId);
         if (CollectionUtils.isEmpty(examRecordDataList)) {
-            log.warn("updateCorrectAnswerAndReFixScore examRecordDataList is empty, examStudentId = {}", examStudentId);
+            log.warn("ReFixScore examRecordDataList is empty, examStudentId = {}", examStudentId);
             return;
         }
 
@@ -797,11 +803,10 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 continue;
             }
 
-            ExamRecordQuestionsEntity examRecordQuestion = examRecordQuestionsService
-                    .getExamRecordQuestionsAndFixExamRecordDataIfNecessary(examRecordData);
+            ExamRecordQuestionsEntity examRecordQuestion = examRecordQuestionsService.getExamRecordQuestionsAndFixExamRecordDataIfNecessary(
+                    examRecordData);
             if (examRecordQuestion == null) {
-                log.warn("updateCorrectAnswerAndReFixScore examRecordQuestions is null, examRecordDataId = {}",
-                        examRecordData.getId());
+                log.warn("ReFixScore examRecordQuestions is null, examRecordDataId = {}", examRecordData.getId());
                 continue;
             }
 
@@ -839,12 +844,12 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                 }
 
                 if (CollectionUtils.isEmpty(rightAnswers)) {
-                    log.warn("updateCorrectAnswerAndReFixScore rightAnswers is empty, questionId = {}", curQuestionId);
+                    log.warn("ReFixScore rightAnswers is empty, questionId = {}", curQuestionId);
                     continue;
                 }
 
                 if (questionUnits.size() != rightAnswers.size()) {
-                    log.warn("updateCorrectAnswerAndReFixScore rightAnswers incorrect, questionId = {}", curQuestionId);
+                    log.warn("ReFixScore rightAnswers incorrect, questionId = {}", curQuestionId);
                     continue;
                 }
 
@@ -887,7 +892,8 @@ public class ExamScoreServiceImpl implements ExamScoreService {
 
                 ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
                 if (examScore != null) {
-                    double subjectiveScore = examScore.getSubjectiveScore() != null ? examScore.getSubjectiveScore() : 0d;
+                    double subjectiveScore =
+                            examScore.getSubjectiveScore() != null ? examScore.getSubjectiveScore() : 0d;
 
                     double objectiveAccuracy = 0d;// 客观题正确率
                     if (totalObjective > 0) {
@@ -901,21 +907,20 @@ public class ExamScoreServiceImpl implements ExamScoreService {
                     examScoreRepo.save(examScore);
                 }
 
-                ExamRecordForMarkingEntity examRecordForMarking = examRecordForMarkingRepo
-                        .findByExamRecordDataId(examRecordData.getId());
+                ExamRecordForMarkingEntity examRecordForMarking = examRecordForMarkingRepo.findByExamRecordDataId(
+                        examRecordData.getId());
                 if (examRecordForMarking != null) {
                     examRecordForMarking.setObjectiveScore(objectiveScore);
                     examRecordForMarkingRepo.save(examRecordForMarking);
                 }
 
-                log.info("updateCorrectAnswerAndReFixScore examRecordQuestions examRecordDataId = {}",
-                        examRecordData.getId());
+                log.info("ReFixScore examRecordQuestions examRecordDataId = {}", examRecordData.getId());
             }
         }
 
         if (needUpdateFinalScore) {
             examStudentFinalScoreService.calcAndSaveFinalScore(examStudentId);
-            log.info("updateCorrectAnswerAndReFixScore finalScore examStudentId = {}", examStudentId);
+            log.info("ReFixScore finalScore examStudentId = {}", examStudentId);
         }
     }