zhangxin 7 роки тому
батько
коміт
af3f5f741a

+ 3 - 61
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/CalculateScoreLogicImpl.java

@@ -274,14 +274,16 @@ public class CalculateScoreLogicImpl implements CalculateSocreLogic {
         } else {
             for (CaughtNodeDTO caughtNodeDTO : caughtNodeDTOs) {
                 CaughtNodeDTO oldcnDTO = caughtNodeService.getCaughtNodeDTO(examId, caseId, caughtNodeDTO.getNodeName());
-                if (oldcnDTO == null){
+                if (oldcnDTO == null) {
                     throw new HttpNotFoundException("this node in this exam not exist");
                 }
                 List<Long> userIds = oldcnDTO.getUserIds();
                 userIds.add(userId);
                 oldcnDTO.setUserIds(userIds);
+
                 if (caughtNodeDTO.getIfCatch().equals(Boolean.TRUE)) {
                     oldcnDTO.setCatchNum(oldcnDTO.getCatchNum() + 1);
+                    oldcnDTO.setIfCatch(caughtNodeDTO.getIfCatch());
                 }
                 oldcnDTO.setTotalNum(oldcnDTO.getTotalNum() + 1);
                 cn = caughtNodeService.updateCaughtNodeDTO(oldcnDTO);
@@ -313,66 +315,6 @@ public class CalculateScoreLogicImpl implements CalculateSocreLogic {
     }
 
 
-//        List<CaughtNodeDTO> caughtNodeDTOList = new ArrayList<>();
-//        for (CaughtNodeDTO caughtNodeDTO : caughtNodeDTOs) {
-//
-//            if (!caughtNodeDTO.getNodeName().isEmpty()) {
-//                String nodeName = caughtNodeDTO.getNodeName();
-//                //caughtNode
-//                caughtNodeDTO = caughtNodeService.getCaughtNodeDTO(examId, caseId, nodeName);
-//                if (caughtNodeDTO != null) {
-//                    List<CaughtNodeDTO> cnDTOs = caughtNodeService.getCaughtNodeList(examId, caseId);
-//                    addTotalNum(cnDTOs);
-//
-//                    List<Long> userIds = caughtNodeDTO.getUserIds();
-//                    userIds.add(userId);
-//                    caughtNodeDTO.setUserIds(userIds);
-//                    caughtNodeDTO.setCatchNum(caughtNodeDTO.getCatchNum() + 1);
-//                    caughtNodeDTO = caughtNodeService.updateCaughtNodeDTO(caughtNodeDTO);
-////                    caughtNodeDTOList.add(caughtNodeService.updateCaughtNodeDTO(caughtNodeDTO));
-//
-//                } else {
-//                    List<CaughtNodeDTO> cnDTOs = caughtNodeService.getCaughtNodeList(examId, caseId);
-//                    if (cnDTOs != null) {
-//                        addTotalNum(cnDTOs);
-//
-//                        caughtNodeDTO = createNewCaughtNodeDTO(userId, caseId, examId, nodeName);
-//                        caughtNodeDTO.setTotalNum(caughtNodeService.getCaughtNodeList(examId, caseId).get(0).getTotalNum() + 1);
-//                    } else {
-//                        caughtNodeDTO = createNewCaughtNodeDTO(userId, caseId, examId, nodeName);
-//                    }
-//
-//                    caughtNodeDTOList.add(caughtNodeService.updateCaughtNodeDTO(caughtNodeDTO));
-//                }
-
-//    //userCatch
-//    UserCatchDTO userCatchDTO = userCatchService.getUserCatchDTO(userId);
-//    if(userCatchDTO!=null)
-//
-//    {
-//        List<String> nodeNames = userCatchDTO.getNodeNames();
-//        nodeNames.add(caughtNodeDTO.getNodeName());
-//        List<String> distinctNodeNames = nodeNames.stream().distinct().collect(Collectors.toList());
-//        userCatchDTO.setNodeNames(distinctNodeNames);
-//    }
-//
-//    else
-//
-//    {
-//        userCatchDTO = new UserCatchDTO();
-//        userCatchDTO.setUserId(userId);
-//        List<String> nodeNames = new ArrayList<>();
-//        nodeNames.add(caughtNodeDTO.getNodeName());
-//        userCatchDTO.setNodeNames(nodeNames);
-//    }
-//
-//    userCatchService.updateUserCatch(userCatchDTO);
-//}
-//}
-//        return caughtNodeDTOList;
-//        }
-
-
     private CaughtNodeDTO createNewCaughtNodeDTO(Long userId, Long caseId, Long examId, String nodeName, Boolean ifCatch) {
         CaughtNodeDTO caughtNodeDTO = new CaughtNodeDTO();
         List<Long> userIds = new ArrayList<>();