Ver código fonte

calculate report score

tangss 8 anos atrás
pai
commit
60b1a275fd

+ 12 - 5
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ReportLogicImpl.java

@@ -17,6 +17,7 @@ import cn.iselab.mooctest.site.service.fromKibug.ReportService;
 import cn.iselab.mooctest.site.web.data.fromKibug.ReportScriptResultVO;
 import cn.iselab.mooctest.site.web.data.fromKibug.ReportVO;
 import cn.iselab.mooctest.site.web.exception.IllegalOperationException;
+import cn.iselab.mooctest.site.web.logic.CalculateSocreLogic;
 import cn.iselab.mooctest.site.web.logic.ReportLogic;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -41,6 +42,8 @@ public class ReportLogicImpl implements ReportLogic {
     private ScriptAutoResultDao scriptAutoResultDao;
     @Autowired
     private CaseTakeDao caseTakeDao;
+    @Autowired
+    private CalculateSocreLogic calculateSocreLogic;
 
     @Override
     public Long createReport(ReportVO vo) throws Exception {
@@ -80,12 +83,14 @@ public class ReportLogicImpl implements ReportLogic {
     @Override
     public void recordReportScript(long reportId, ReportScriptResultVO vo) throws Exception {
         ScriptAutoResult scriptAutoResult = reportService.getScriptAutoResult(reportId);
+
+        Report report = reportService.getReport(reportId);
+        if (report == null) {
+            throw new IllegalOperationException("错误的报告Id");
+        }
+        CaseTake caseTake = caseTakeDao.findOne(report.getCaseTakeId());
+
         if (scriptAutoResult == null) {
-            Report report = reportService.getReport(reportId);
-            if (report == null) {
-                throw new IllegalOperationException("错误的报告Id");
-            }
-            CaseTake caseTake = caseTakeDao.findOne(report.getCaseTakeId());
             scriptAutoResult = new ScriptAutoResult();
             scriptAutoResult.setReportId(reportId);
             scriptAutoResult.setApplicationId(caseTake.getApplicationId());
@@ -99,5 +104,7 @@ public class ReportLogicImpl implements ReportLogic {
             scriptAutoResult.setResult(vo.getResult());
         }
         scriptAutoResultDao.save(scriptAutoResult);
+
+        calculateSocreLogic.calculateScore(caseTake.getTaskId(),caseTake.getCaseId(),caseTake.getParticipantId());
     }
 }