Prechádzať zdrojové kódy

clean kibug getScoreRules

Tony 5 rokov pred
rodič
commit
c30382e8ee

+ 0 - 8
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/WeightGeneralDao.java

@@ -18,12 +18,4 @@ public interface WeightGeneralDao extends JpaRepository<WeightGeneral,Long> {
   WeightGeneral findByExamIdAndCaseIdAndType(long taskId, long caseId, String type);
 
   List<WeightGeneral> findByExamIdAndCaseId(long taskId, long caseId);
-
-//  @Query("select distinct w.type from WeightGeneral w "
-//      + "where w.examId = :examId and w.caseId = :caseId")
-//  List<String> retrieveCategoriesByExamIdAndCaseId(@Param("examId") long examId, @Param("caseId")
-//      long caseId);
-
-
-
 }

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

@@ -70,12 +70,13 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
                 scoreRuleList.add(new ScoreRuleItemVO(nodeTypeList.get(0), 100));
                 weightGeneralService.setWeight(taskId, caseId, nodeTypeList.get(0), 100);
             });
-            if(!opNodeTypeList.isPresent())
+            if(!opNodeTypeList.isPresent()) {
                 if(examPythonCommunityService.isPythonCommunityExam(taskId)){
                     weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.cases.toString(),100);
                 }else{
                     weightGeneralService.setWeight(taskId, caseId, ScoreRuleKey.manual.toString(), 100);
                 }
+            }
 
         }
 
@@ -129,11 +130,13 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
         return getNodeTypeList(caseId).orElseGet(ArrayList::new);
     }
 
+    @Override
     public List<ScoreRuleItemVO> getGeneralScoreRule(long taskId, long caseId) {
 
         List<WeightGeneral> rules = weightGeneralDao.findByExamIdAndCaseId(taskId, caseId);
-        if (rules == null)
+        if (rules == null) {
             rules = new ArrayList<>();
+        }
 
         return rules.stream()
                 .map(weightGeneral -> {

+ 9 - 22
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/fromKibug/ScoreRuleController.java

@@ -46,34 +46,13 @@ public class ScoreRuleController  extends BaseController {
     @RequestMapping(value= UrlConstants.API_KIBUG+"scoreRule", method = RequestMethod.GET)
     public Map<String, Object> get(@RequestParam(name = "taskId") Long taskId,
                                    @RequestParam(name = "caseId") Long caseId) throws Exception {
-        Exam exam = examService.getTask(taskId);
-        CaseExtends caseExtends = caseService.getCaseExtendsById(caseId);
         List<ScoreRuleItemVO> scoreRules = scoreRuleService.getGenaralScoreRule(taskId, caseId);
         List<String> options = new ArrayList<>();
-        if(examPythonCommunityService.isPythonCommunityExam(taskId) || caseService.getCaseProperties(caseId).get("testType").equals("8")){
+        if(isScoreByPassCaseCount(taskId, caseId)){
             options.add(ScoreRuleKey.cases.toString());
         }
         options.add(ScoreRuleKey.manual.toString());
         options.addAll(scoreRuleService.getOptionsFromNode(taskId, caseId));
-//        switch(caseExtends.getAnswerWay().intValue()){
-//            case (int) AnswerWayConstants.DEV_ECLIPSE:
-//            case (int) AnswerWayConstants.JMETER:
-//            case (int) AnswerWayConstants.WEB_ECLIPSE: //selenium
-//
-//
-//                break;
-//            case (int) AnswerWayConstants.APP_ECLIPSE:
-//
-//
-//            case (int) AnswerWayConstants.THIRD_PARTY:
-//            case (int) AnswerWayConstants.REPORT:
-//            case (int) AnswerWayConstants.ZHICEYUN:
-//                scoreRules = scoreRuleService.getKibugScoreRule(examId,caseId);
-//                options = scoreRuleService.getKibugOptions();
-//                break;
-//            default :return new ErrorResult(StatusCode.PARAMETER_ERROR);
-//        }
-
         ScoreRuleVO vo = new ScoreRuleVO();
         vo.setCaseId(caseId);
         vo.setTaskId(taskId);
@@ -82,6 +61,14 @@ public class ScoreRuleController  extends BaseController {
         return SuccessResult.ok(ResponseMessage.ITEM_RESULT, vo);
     }
 
+    public boolean isScoreByPassCaseCount(Long taskId, Long caseId) {
+        return examPythonCommunityService.isPythonCommunityExam(taskId) || isTddCase(caseId);
+    }
+
+    public boolean isTddCase(Long caseId) {
+        return caseService.getCaseProperties(caseId).get("testType").equals("8");
+    }
+
     @RequestMapping(value= UrlConstants.API_KIBUG+"scoreRule/{taskId}/{caseId}", method = RequestMethod.POST)
     public Map<String, Object> updateScoreRule(@PathVariable @NotNull Long caseId,
                                                @PathVariable @NotNull Long taskId,