1
0
Prechádzať zdrojové kódy

修复标准差除数为0的问题

ting.yin 6 rokov pred
rodič
commit
d53ce1a368

+ 1 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/ExamQuestionDao.java

@@ -55,7 +55,7 @@ public interface ExamQuestionDao extends JpaRepository<ExamQuestion, Integer>, J
     public void updateMainTitleByExamIdAndSubjectCodeAndObjectiveAndMainNumber(Integer examId, String subjectCode,
             boolean objective, Integer mainNumber, String mainTitle);
 
-    @Query("select DISTINCT q.paperType from ExamQuestion q where q.examId=?1 and  q.subjectCode=?2 and q.objective=?3 "
+    @Query("select DISTINCT q.paperType from ExamQuestion q where q.examId=?1 and  q.subjectCode=?2 and q.objective=?3 and q.paperType is not null "
             + "order by q.paperType")
     public List<String> getPaperType(int examId, String subjectCode,boolean objective);
 

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

@@ -83,7 +83,7 @@ public class BaseCalculatorUnit {
         avgScore = sumScore / count;
         // 递归法计算标准差
         tempSum = tempSum + 1.0 * (count - 1) / count * (score - avgScore) * (score - avgScore);
-        stdev = Math.sqrt(tempSum / (count - 1));
+        stdev = count==1?0:Math.sqrt(tempSum / (count - 1));
         // 难度
         difficulty = fullScore > 0 ? avgScore / fullScore : 0;
         // 差异系数

+ 2 - 4
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/PaperController.java

@@ -261,10 +261,8 @@ public class PaperController extends BaseExamController {
         List<String> list = this.questionService.getPaperType(examId, subjectCode);
         for (String paperType : list) {
             JSONObject obj = new JSONObject();
-            if(paperType!=null){
-                obj.accumulate("paperType", paperType);
-                array.add(obj);
-            }
+            obj.accumulate("paperType", paperType);
+            array.add(obj);
         }
         return array;
     }