|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.task.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
@@ -196,6 +197,13 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
ExamCourseDataReportBean bean = examCourseDataReport.get(key);
|
|
|
bean.setStd(std(scores.get(key), bean.getAvgScore()));
|
|
|
}
|
|
|
+ // 计算差异系数
|
|
|
+ for (String key : examCourseDataReport.keySet()) {
|
|
|
+ ExamCourseDataReportBean bean = examCourseDataReport.get(key);
|
|
|
+ bean.setCdi(getPercentage(bean.getStd(), bean.getAvgScore()));
|
|
|
+ bean.setAvgScore(getTwoDecimal(bean.getAvgScore()));
|
|
|
+ }
|
|
|
+
|
|
|
// 判断任务终止
|
|
|
checkIsStoping(et.getId());
|
|
|
// 计算basePaperId对应的难度系数
|
|
@@ -333,22 +341,40 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
|
|
|
private Double avgDifficultyDegree(String dataKey, Map<String, Set<String>> basePapers,
|
|
|
Map<String, Double> basePapersDegree) {
|
|
|
+ //考试课程对应的basePapers
|
|
|
Set<String> set = basePapers.get(dataKey);
|
|
|
- if (set == null) {
|
|
|
+ if (set == null||set.size()==0) {
|
|
|
return null;
|
|
|
}
|
|
|
double total = 0.0;
|
|
|
+ //算平均难度时剔除没有难度系数的试卷
|
|
|
+ int nullCount=0;
|
|
|
for (String s : set) {
|
|
|
- total = total + basePapersDegree.get(s);
|
|
|
+ Double td=basePapersDegree.get(s);
|
|
|
+ if(td==null) {
|
|
|
+ nullCount++;
|
|
|
+ }else {
|
|
|
+ total = total + basePapersDegree.get(s);
|
|
|
+ }
|
|
|
}
|
|
|
- return total / set.size();
|
|
|
+ if(nullCount==set.size()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return getTwoDecimal(total / (set.size()-nullCount));
|
|
|
}
|
|
|
|
|
|
- private double difficultyDegree(Map<String, TopicScoreDto> map) {
|
|
|
+ private Double difficultyDegree(Map<String, TopicScoreDto> map) {
|
|
|
+ //剔除整张卷子没有小题答题的
|
|
|
+ if(map==null||map.size()==0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
double totalAvg = 0.0;
|
|
|
double totalFull = 0.0;
|
|
|
for (String k : map.keySet()) {
|
|
|
TopicScoreDto dto = map.get(k);
|
|
|
+ if(dto.getTotal()==0) {
|
|
|
+ throw new StatusException("100001", "小题满分不能为0 QuestionId:"+dto.getQuestionId()+" QuestionOrder:"+dto.getQuestionOrder());
|
|
|
+ }
|
|
|
totalAvg = totalAvg + dto.getAvg();
|
|
|
totalFull = totalFull + dto.getTotal();
|
|
|
}
|
|
@@ -364,7 +390,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
total += Math.pow((list.get(i) - average), 2);
|
|
|
}
|
|
|
double standardDeviation = Math.sqrt(total / list.size());
|
|
|
- return standardDeviation;
|
|
|
+ return getTwoDecimal(standardDeviation);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -388,7 +414,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
if (list == null || list.size() == 0) {
|
|
|
break;
|
|
|
}
|
|
|
- startId = list.get(list.size() - 1).getExamStudentId();
|
|
|
+ startId = res.getNextId();
|
|
|
for (ExamStudentDataBean st : list) {
|
|
|
// 判断任务终止
|
|
|
checkIsStoping(jobId);
|
|
@@ -412,7 +438,6 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
// 学习中心id集合
|
|
|
Set<Long> ordIds = (Set<Long>) result.get("ordIds");
|
|
|
ordIds.add(st.getOrgId());
|
|
|
- Map<String, List<Double>> scores = (Map<String, List<Double>>) result.get("scores");
|
|
|
Map<String, ExamOrgReportBean> examOrgReport = (Map<String, ExamOrgReportBean>) result.get("examOrgReport");
|
|
|
String key = st.getExamId() + "-" + st.getOrgId();
|
|
|
ExamOrgReportBean bean = examOrgReport.get(key);
|
|
@@ -432,6 +457,9 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
bean.setParticipantCount(bean.getParticipantCount() + 1);
|
|
|
}
|
|
|
// 及格人数
|
|
|
+ if (!st.getAbsent() && st.getScore()==null) {
|
|
|
+ throw new StatusException("10030","未缺考的考生分数不能为空 ExamStudentId:"+st.getExamStudentId());
|
|
|
+ }
|
|
|
if (!st.getAbsent() && st.getScore() >= pro.getPassScore()) {
|
|
|
bean.setPassCount(bean.getPassCount() + 1);
|
|
|
}
|
|
@@ -439,16 +467,6 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
if (!st.getAbsent()) {
|
|
|
addPartitionData(st.getScore(), pro, bean.getPartitionData());
|
|
|
}
|
|
|
- // 分数集合
|
|
|
- if (!st.getAbsent()) {
|
|
|
- List<Double> list = scores.get(key);
|
|
|
- if (list == null) {
|
|
|
- list = new ArrayList<Double>();
|
|
|
- scores.put(key, list);
|
|
|
- }
|
|
|
- list.add(st.getScore());
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -505,6 +523,8 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
// 设置满分数值
|
|
|
if (st.getTotalScore() != null) {
|
|
|
bean.setTotalScore(st.getTotalScore());
|
|
|
+ }else {
|
|
|
+ throw new StatusException("10020","试卷满分不能为空 ExamStudentId:"+st.getExamStudentId());
|
|
|
}
|
|
|
// 最高分
|
|
|
if (!st.getAbsent() && st.getScore() > bean.getMaxScore()) {
|
|
@@ -551,6 +571,14 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
.get("basePapersTopicScore");
|
|
|
|
|
|
if (!st.getAbsent()) {
|
|
|
+ Map<String, List<Double>> scores = (Map<String, List<Double>>) result.get("scores");
|
|
|
+ // 分数集合-计算标准差
|
|
|
+ List<Double> list = scores.get(key);
|
|
|
+ if (list == null) {
|
|
|
+ list = new ArrayList<Double>();
|
|
|
+ scores.put(key, list);
|
|
|
+ }
|
|
|
+ list.add(st.getScore());
|
|
|
// 考试课程对应的basePaperId集合
|
|
|
Set<String> set = basePapers.get(key);
|
|
|
if (set == null) {
|
|
@@ -567,6 +595,10 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
}
|
|
|
// 考生小题得分详情
|
|
|
List<ExamStudentScoreDataBean> scoreDetails = st.getScoreDetails();
|
|
|
+ if(scoreDetails==null||scoreDetails.size()==0) {
|
|
|
+ throw new StatusException("10040","考生小题得分详情不能为空 ExamStudentId:"+st.getExamStudentId());
|
|
|
+ }
|
|
|
+
|
|
|
// 计算每个小题的平均分
|
|
|
for (ExamStudentScoreDataBean b : scoreDetails) {
|
|
|
if (b.getScore() != null) {
|
|
@@ -575,6 +607,8 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
TopicScoreDto tem = temmap.get(topicScoreKey);
|
|
|
if (tem == null) {
|
|
|
tem = new TopicScoreDto();
|
|
|
+ tem.setQuestionId(b.getQuestionId());
|
|
|
+ tem.setQuestionOrder(b.getQuestionOrder());
|
|
|
tem.setTotal(b.getTotalScore());
|
|
|
temmap.put(topicScoreKey, tem);
|
|
|
}
|
|
@@ -609,7 +643,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
et.setStartTime(new Date());
|
|
|
reportsComputeRepo.save(et);
|
|
|
UpdateProjectStatusReq req = new UpdateProjectStatusReq();
|
|
|
- req.setProjectId(et.getId());
|
|
|
+ req.setProjectId(et.getProjectId());
|
|
|
req.setStatus(2);
|
|
|
projectCloudService.updateProjectStatus(req);
|
|
|
}
|
|
@@ -621,7 +655,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
et.setEndTime(new Date());
|
|
|
reportsComputeRepo.save(et);
|
|
|
UpdateProjectStatusReq req = new UpdateProjectStatusReq();
|
|
|
- req.setProjectId(et.getId());
|
|
|
+ req.setProjectId(et.getProjectId());
|
|
|
req.setStatus(3);
|
|
|
projectCloudService.updateProjectStatus(req);
|
|
|
}
|
|
@@ -634,7 +668,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
et.setEndTime(new Date());
|
|
|
reportsComputeRepo.save(et);
|
|
|
UpdateProjectStatusReq req = new UpdateProjectStatusReq();
|
|
|
- req.setProjectId(et.getId());
|
|
|
+ req.setProjectId(et.getProjectId());
|
|
|
req.setStatus(4);
|
|
|
projectCloudService.updateProjectStatus(req);
|
|
|
}
|
|
@@ -656,7 +690,7 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
et.setEndTime(new Date());
|
|
|
reportsComputeRepo.save(et);
|
|
|
UpdateProjectStatusReq req = new UpdateProjectStatusReq();
|
|
|
- req.setProjectId(et.getId());
|
|
|
+ req.setProjectId(et.getProjectId());
|
|
|
req.setStatus(5);
|
|
|
projectCloudService.updateProjectStatus(req);
|
|
|
// 清除缓存终止标志
|
|
@@ -678,4 +712,24 @@ public class ReportsComputeServiceImpl implements ReportsComputeService {
|
|
|
reportsComputeRepo.save(e);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int getTodoDataCount() {
|
|
|
+ return reportsComputeRepo.getTodoDataCount();
|
|
|
+ }
|
|
|
+ private Double getPercentage(Double a, Double b) {
|
|
|
+ if (b == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ BigDecimal bd = new BigDecimal(a * 100 / b);
|
|
|
+ Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ return tem;
|
|
|
+ }
|
|
|
+ private Double getTwoDecimal(Double b) {
|
|
|
+ if (b == null) {
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+ BigDecimal bd = new BigDecimal(b);
|
|
|
+ Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ return tem;
|
|
|
+ }
|
|
|
}
|