|
|
@@ -1,14 +1,11 @@
|
|
|
package cn.iselab.mooctest.site.web.logic.impl;
|
|
|
|
|
|
import cn.iselab.mooctest.site.common.constant.SubsiteConstants;
|
|
|
-import cn.iselab.mooctest.site.models.AssignedTask;
|
|
|
-import cn.iselab.mooctest.site.models.CaseExtends;
|
|
|
-import cn.iselab.mooctest.site.models.Exam2Case;
|
|
|
-import cn.iselab.mooctest.site.service.AssignedTaskService;
|
|
|
-import cn.iselab.mooctest.site.service.CalculateScoreService;
|
|
|
-import cn.iselab.mooctest.site.service.CaseService;
|
|
|
-import cn.iselab.mooctest.site.service.Exam2CaseService;
|
|
|
+import cn.iselab.mooctest.site.data.CaseBlock;
|
|
|
+import cn.iselab.mooctest.site.models.*;
|
|
|
+import cn.iselab.mooctest.site.service.*;
|
|
|
import cn.iselab.mooctest.site.service.fromKibug.ScoreRuleService;
|
|
|
+import cn.iselab.mooctest.site.web.data.WeightDirtyVO;
|
|
|
import cn.iselab.mooctest.site.web.data.fromKibug.ScoreRuleItemVO;
|
|
|
import cn.iselab.mooctest.site.web.logic.CalculateSocreLogic;
|
|
|
import org.json.JSONArray;
|
|
|
@@ -26,21 +23,20 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class CalculateScoreLogicImpl implements CalculateSocreLogic {
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private CalculateScoreService calculateScoreService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private AssignedTaskService assignedTaskService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private Exam2CaseService exam2CaseService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ScoreRuleService scoreRuleService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private CaseService caseService;
|
|
|
+ @Autowired
|
|
|
+ private PaperService paperService;
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
|
|
|
@Override
|
|
|
public void calculateScore(long taskId, long caseId) throws Exception{
|
|
|
@@ -71,7 +67,32 @@ public class CalculateScoreLogicImpl implements CalculateSocreLogic {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Double> calculateExamScore(long examId, Long participantId) {
|
|
|
+ public List<Double> calculateExamScore(long examId, Long participantId,WeightDirtyVO weightDirtyVO) throws Exception{
|
|
|
+ //获取exam中应有的case
|
|
|
+ Paper paper = paperService.getByExamId(examId);
|
|
|
+ if(paper == null) {
|
|
|
+ throw new IllegalArgumentException("Cannot find paper of this exam.");
|
|
|
+ }
|
|
|
+ List<CaseBlock> caseBlocks = taskService.getCaseBlocks(paper.getId());
|
|
|
+ List<Long> casesId = new ArrayList<>();
|
|
|
+ for(CaseBlock caseBlock :caseBlocks){
|
|
|
+ for(Long caseId : caseBlock.getCaseIds()) {
|
|
|
+ casesId.add(caseId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //为null表示为发布成绩时,计算所有case的小分,再计算总分
|
|
|
+ if(weightDirtyVO == null) {
|
|
|
+ for(Long caseId:casesId){
|
|
|
+ calculateScore(examId,caseId);
|
|
|
+ }
|
|
|
+ }else {//如果不为null,表示保存评分规则时,需要对更改的评分规则的case进行计算,再计算总分
|
|
|
+ for(Long caseId:weightDirtyVO.getCaseDirty()){
|
|
|
+ if(casesId.contains(caseId))
|
|
|
+ calculateScore(examId,caseId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //最后计算task的总分
|
|
|
List<Double> scores = new ArrayList<>();
|
|
|
if(participantId != null){
|
|
|
AssignedTask assignedTask=assignedTaskService.getAssignedTask(examId,participantId);
|