|
@@ -1,9 +1,11 @@
|
|
package cn.iselab.mooctest.site.service.fromKibug.impl;
|
|
package cn.iselab.mooctest.site.service.fromKibug.impl;
|
|
|
|
|
|
import cn.iselab.mooctest.site.common.enums.ScoreRuleKey;
|
|
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.WeightDao;
|
|
import cn.iselab.mooctest.site.dao.WeightGeneralDao;
|
|
import cn.iselab.mooctest.site.dao.WeightGeneralDao;
|
|
import cn.iselab.mooctest.site.dao.fromKibug.ScoreRuleDao;
|
|
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.WeightGeneral;
|
|
import cn.iselab.mooctest.site.models.fromKibug.ScoreRule;
|
|
import cn.iselab.mooctest.site.models.fromKibug.ScoreRule;
|
|
import cn.iselab.mooctest.site.models.fromKibug.ScoreRulePK;
|
|
import cn.iselab.mooctest.site.models.fromKibug.ScoreRulePK;
|
|
@@ -40,6 +42,8 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
|
|
private WeightGeneralDao weightGeneralDao;
|
|
private WeightGeneralDao weightGeneralDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ExamPythonCommunityService examPythonCommunityService;
|
|
private ExamPythonCommunityService examPythonCommunityService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CaseExtendsDao caseExtendsDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ScoreRuleItemVO> getKibugScoreRule(long taskId, long caseId){
|
|
public List<ScoreRuleItemVO> getKibugScoreRule(long taskId, long caseId){
|
|
@@ -62,30 +66,45 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
public List<ScoreRuleItemVO> getGenaralScoreRule(long taskId, long caseId) throws Exception {
|
|
public List<ScoreRuleItemVO> getGenaralScoreRule(long taskId, long caseId) throws Exception {
|
|
-
|
|
|
|
List<ScoreRuleItemVO> scoreRuleList = getGeneralScoreRule(taskId, caseId);
|
|
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;
|
|
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);
|
|
CaseGraphDTO caseGraph = caseLogic.getGraph(caseId, null);
|
|
-
|
|
|
|
if (caseGraph == null) return Optional.empty();
|
|
if (caseGraph == null) return Optional.empty();
|
|
List<Node> caseNodeList = caseGraph.getNodes();
|
|
List<Node> caseNodeList = caseGraph.getNodes();
|
|
Set<String> nodeTypeSet = new HashSet<>();
|
|
Set<String> nodeTypeSet = new HashSet<>();
|