Browse Source

fix: tdd默认得分规则为cases自动评分

xuxuan 4 năm trước cách đây
mục cha
commit
7131683092

+ 36 - 17
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/fromKibug/impl/ScoreRuleServiceImpl.java

@@ -1,9 +1,11 @@
 package cn.iselab.mooctest.site.service.fromKibug.impl;
 
 import cn.iselab.mooctest.site.common.enums.ScoreRuleKey;
+import cn.iselab.mooctest.site.dao.CaseExtendsDao;
 import cn.iselab.mooctest.site.dao.WeightDao;
 import cn.iselab.mooctest.site.dao.WeightGeneralDao;
 import cn.iselab.mooctest.site.dao.fromKibug.ScoreRuleDao;
+import cn.iselab.mooctest.site.models.CaseExtends;
 import cn.iselab.mooctest.site.models.WeightGeneral;
 import cn.iselab.mooctest.site.models.fromKibug.ScoreRule;
 import cn.iselab.mooctest.site.models.fromKibug.ScoreRulePK;
@@ -40,6 +42,8 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
     private WeightGeneralDao weightGeneralDao;
     @Autowired
     private ExamPythonCommunityService examPythonCommunityService;
+    @Autowired
+    private CaseExtendsDao  caseExtendsDao;
 
     @Override
     public List<ScoreRuleItemVO> getKibugScoreRule(long taskId, long caseId){
@@ -62,30 +66,45 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
     }
     @Override
     public List<ScoreRuleItemVO> getGenaralScoreRule(long taskId, long caseId) throws Exception {
-
         List<ScoreRuleItemVO> scoreRuleList = getGeneralScoreRule(taskId, caseId);
-        if (scoreRuleList.isEmpty()) {
-            Optional<List<String>> opNodeTypeList = getNodeTypeList(caseId);
-            opNodeTypeList.ifPresent( (nodeTypeList) -> {
-                scoreRuleList.add(new ScoreRuleItemVO(nodeTypeList.get(0), 100));
-                weightGeneralService.setWeight(taskId, caseId, nodeTypeList.get(0), 100);
-            });
-            if(!opNodeTypeList.isPresent()) {
-                if(examPythonCommunityService.isPythonCommunityExam(taskId)){
-                    weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.cases.toString(),100);
-                }else{
-                    weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.manual.toString(), 100);
-                }
-            }
-
+        if (!scoreRuleList.isEmpty()) {
+            return scoreRuleList;
         }
+        return getDefaultScoreRule(taskId, caseId);
+    }
 
+    private List<ScoreRuleItemVO> getDefaultScoreRule(long taskId, long caseId) throws Exception {
+        List<ScoreRuleItemVO> scoreRuleList = new ArrayList<>();
+        Optional<List<String>> opNodeTypeList = getNodeTypeList(caseId);
+        opNodeTypeList.ifPresent( (nodeTypeList) ->{
+            scoreRuleList.add(new ScoreRuleItemVO(nodeTypeList.get(0), 100));
+            weightGeneralService.setWeight(taskId, caseId, nodeTypeList.get(0), 100);
+        });
+
+        boolean isTdd=justifyIsTdd(caseId);
+        if(!opNodeTypeList.isPresent()) {
+            if(examPythonCommunityService.isPythonCommunityExam(taskId)||isTdd){
+                weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.cases.toString(),100);
+            }else{
+                weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.manual.toString(), 100);
+            }
+        }
         return scoreRuleList;
     }
+//判断该案例不是不是Tdd
+    private boolean justifyIsTdd(long caseId) {
+        boolean isTdd=false;
+        CaseExtends  caseExtends=caseExtendsDao.findOne(caseId);
+        if (caseExtends!=null){
+            if(caseExtends.getSubjectId()==51||caseExtends.getSubjectId()==78){
+                isTdd=true;
+            }
+        }
+      return isTdd;
+    }
 
-    private Optional<List<String>> getNodeTypeList(Long caseId) throws Exception {
+    private Optional<List<String>> getNodeTypeList(Long caseId) throws Exception{
         CaseGraphDTO caseGraph = caseLogic.getGraph(caseId, null);
-
         if (caseGraph == null) return Optional.empty();
         List<Node> caseNodeList = caseGraph.getNodes();
         Set<String> nodeTypeSet = new HashSet<>();