Explorar el Código

间隔分不能为负数;修复统计问题;

ting.yin hace 2 años
padre
commit
b7f4244b11

+ 8 - 5
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/report/service/impl/ReportServiceImpl.java

@@ -432,10 +432,13 @@ public class ReportServiceImpl implements ReportService {
         int total = (int) Math.ceil(totalScore / range);
         for (int i = total; i >= 0; i--) {
             int start = i * range;
-            int end = (i - 1) * range + 1;
+            int end = (i + 1) * range;
             if (start > totalScore) {
                 start = (int) Math.ceil(totalScore);
             }
+            if (end > totalScore) {
+                end = (int) Math.ceil(totalScore);
+            }
             if (end < 0) {
                 end = 0;
             }
@@ -449,13 +452,13 @@ public class ReportServiceImpl implements ReportService {
     private int getSumCount(JSONObject jsonObject, int start, int end) {
         int sumCount = 0;
         int currentCount = 0;
-        if (start < end) {
-            for (int i = start; i <= end; i++) {
+        if (start <= end) {
+            for (int i = start; i < end; i++) {
                 currentCount = jsonObject.getInt(String.valueOf(i));
                 sumCount = sumCount + currentCount;
             }
-        } else if (start >= end) {
-            for (int i = end; i <= start; i++) {
+        } else if (start > end) {
+            for (int i = end; i < start; i++) {
                 currentCount = jsonObject.getInt(String.valueOf(i));
                 sumCount = sumCount + currentCount;
             }

+ 26 - 16
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/report/utils/unit/BaseCalculatorUnit.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.stmms.biz.report.utils.unit;
 
+import cn.com.qmth.stmms.common.utils.BigDecimalUtils;
+
 public class BaseCalculatorUnit {
 
     public int count;
@@ -73,39 +75,47 @@ public class BaseCalculatorUnit {
         if (excellentScore != null && score >= excellentScore) {
             excellentCount++;
         }
-        sumScore += score;
-        sumScore2 += (score * score);
-        aggScore += (score * totalScore);
-        sumTotalScore += totalScore;
-        sumTotalScore2 += (totalScore * totalScore);
+        sumScore = BigDecimalUtils.add(score, sumScore);
+        sumScore2 = BigDecimalUtils.add(sumScore2, BigDecimalUtils.mul(score, score));
+        aggScore = BigDecimalUtils.add(aggScore, BigDecimalUtils.mul(score, totalScore));
+        sumTotalScore = BigDecimalUtils.add(sumTotalScore, totalScore);
+        sumTotalScore2 = BigDecimalUtils.add(sumTotalScore2, BigDecimalUtils.mul(totalScore, totalScore));
         maxScore = Math.max(maxScore, score);
         minScore = Math.min(minScore, score);
-        avgScore = sumScore / count;
+        avgScore = BigDecimalUtils.div(sumScore, count);
         // 递归法计算标准差
-        stdev = Math.sqrt(sumScore2 / count - Math.pow(sumScore / count, 2));
+        stdev = Math.sqrt(BigDecimalUtils.sub(BigDecimalUtils.div(sumScore2, count),
+                BigDecimalUtils.mul(avgScore, avgScore)));
+        if (stdev == Double.NaN) {
+            stdev = 0;
+        }
         // 难度
-        difficulty = fullScore > 0 ? avgScore / fullScore : 0;
+        difficulty = fullScore > 0 ? BigDecimalUtils.div(avgScore, fullScore) : 0;
         // 差异系数
-        coefficient = avgScore > 0 ? stdev * 100 / avgScore : 0;
+        coefficient = avgScore > 0 ? BigDecimalUtils.div(stdev * 100, avgScore) : 0;
         // 区分度
-        double temp = Math.sqrt((sumScore2 - sumScore * sumScore / count) * (sumTotalScore2 - sumTotalScore * sumTotalScore / count));
+        double temp = Math.sqrt((sumScore2 - sumScore * sumScore / count)
+                * (sumTotalScore2 - sumTotalScore * sumTotalScore / count));
         if (temp != 0 && Double.NaN != temp) {
             discrimination = (aggScore - sumScore * sumTotalScore / count) / temp;
         } else {
             discrimination = 0;
         }
+        if (Double.NaN == discrimination) {
+            discrimination = 0;
+        }
         // 及格率
-        passRate = passCount * 1.0 / count;
+        passRate = BigDecimalUtils.div(passCount, count);
         // 优秀率
-        excellentRate = excellentCount * 1.0 / count;
+        excellentRate = BigDecimalUtils.div(excellentCount, count);
         // 满分率
-        fullScoreRate = fullCount * 1.0 / count;
+        fullScoreRate = BigDecimalUtils.div(fullCount, count);
     }
 
     @Override
     public String toString() {
-        return "count=" + count + ",zeroCount=" + zeroCount + ",fullCount=" + fullCount + ",fullScore=" + fullScore + ",maxScore="
-                + maxScore + ",minScore=" + minScore + ",avgScore=" + avgScore + ",stdev=" + stdev + ",difficulty=" + difficulty
-                + ",coefficient=" + coefficient + ",discrimination=" + discrimination;
+        return "count=" + count + ",zeroCount=" + zeroCount + ",fullCount=" + fullCount + ",fullScore=" + fullScore
+                + ",maxScore=" + maxScore + ",minScore=" + minScore + ",avgScore=" + avgScore + ",stdev=" + stdev
+                + ",difficulty=" + difficulty + ",coefficient=" + coefficient + ",discrimination=" + discrimination;
     }
 }

+ 4 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/dto/SubjectQuestionDTO.java

@@ -146,6 +146,10 @@ public class SubjectQuestionDTO {
                         error.add("[" + subjectCode + "] 有间隔分为小数超2位的记录");
                         return false;
                     }
+                    if (!objective && question.getIntervalScore() <= 0) {
+                        error.add("[" + subjectCode + "] 有间隔分有小于等于0的记录");
+                        return false;
+                    }
                     if (objective && StringUtils.isBlank(question.getAnswer())) {
                         error.add("[" + subjectCode + "] 有答案为空的记录");
                         return false;

+ 5 - 1
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/PaperController.java

@@ -802,11 +802,15 @@ public class PaperController extends BaseExamController {
                     + "&level=" + query.getLevel() + "&upload=" + u + "&totalScoreNotEqual=" + t;
         }
         question.setExamId(examId);
-        if (question.getPaperType() == null) {
+        if (StringUtils.isNotBlank(question.getPaperType())) {
             question.setPaperType(NULL_PAPER_TYPE_PLACEHOLDER);
         }
         if (question.isObjective()) {
             question.setGroupNumber(0);
+        } else {
+            question.setObjectivePolicy(null);
+            question.setAnswer(null);
+            question.setType(null);
         }
         Map<Integer, String> titleMap = new HashMap<>();
         List<ExamQuestion> current = questionService.findByExamAndSubjectAndObjective(examId,

+ 4 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/report/ReportSubjectRangeController.java

@@ -158,6 +158,10 @@ public class ReportSubjectRangeController extends BaseExamController {
                     addFileToZip(examId, writer, subjectName);
                 }
             } else {
+                if (StringUtils.isBlank(query.getSubjectCode())) {
+                    addMessage(redirectAttributes, "导出分析失败!请先查询出结果再导出");
+                    return "redirect:/admin/exam/reportSubjectRange";
+                }
                 ExamSubject subject = subjectService.find(examId, query.getSubjectCode());
                 String subjectName = subject.getCode() + "-" + subject.getName();
                 response.setHeader("Content-Disposition",

+ 2 - 2
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/groupEditSimple.jsp

@@ -169,7 +169,7 @@
         $('.interval-score-input').each(function () {
             var score = $(this).val();
             var reg= /^-?\d+\.?\d{0,2}$/; 
-            if (score == '' || !reg.test(score)) {
+            if (score == '' || !reg.test(score) ||score<=0) {
                 fill = false;
             } else {
                 array.push(score);
@@ -179,7 +179,7 @@
             $('#intervalScoreList').val(array.join(','));
             $('#inputForm').submit();
         } else {
-            alert('间隔分不能为空且只支持两位小数');
+        	alert('间隔分不能为空,必须大于等于0分且只支持两位小数');
         }
     });
 </script>

+ 2 - 2
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/questionAdd.jsp

@@ -36,8 +36,8 @@
             $('#btnSubmit').click(function () {
                     var score = $('#interval-score-input').val();
                     var reg= /^-?\d+\.?\d{0,2}$/; 
-                    if (score == '' || !reg.test(score)) {
-                    	alert('间隔分不能为空且只支持两位小数');
+                    if (score == '' || !reg.test(score) ||score<=0) {
+                    	alert('间隔分不能为空,必须大于等于0分且只支持两位小数');
                     	return false;
                     }
                     var total = $('#total-score-input').val();

+ 2 - 2
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/questionEdit.jsp

@@ -30,8 +30,8 @@
             $('#btnSubmit').click(function () {
                 var score = $('#interval-score-input').val();
                 var reg= /^-?\d+\.?\d{0,2}$/; 
-                if (score == '' || !reg.test(score)) {
-                	alert('间隔分不能为空且只支持两位小数');
+                if (score == '' || !reg.test(score) ||score<=0) {
+                	alert('间隔分不能为空,必须大于等于0分且只支持两位小数');
                 	return false;
                 }
                 var total = $('#total-score-input').val();