소스 검색

修改编辑套题的小题分值和难度值后,套题和试卷的难度值都不会随着改变的bug

weiwenhai 7 년 전
부모
커밋
521a257057

+ 4 - 2
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java

@@ -1081,6 +1081,7 @@ public class ImportPaperService {
     // 设置套题主题干的 难度,公开度,一级属性,二级属性
     // 设置套题主题干的 难度,公开度,一级属性,二级属性
     private void setAttributes(Question question,List<Question> subQuesList) {
     private void setAttributes(Question question,List<Question> subQuesList) {
     	if(subQuesList != null && subQuesList.size()>0){
     	if(subQuesList != null && subQuesList.size()>0){
+    		Double totalDouble = 0d;
     		Double sum = 0.0;
     		Double sum = 0.0;
     		Boolean publicity = false;
     		Boolean publicity = false;
     		List<QuesProperty> subQuesProperties = new ArrayList<QuesProperty>();
     		List<QuesProperty> subQuesProperties = new ArrayList<QuesProperty>();
@@ -1096,9 +1097,10 @@ public class ImportPaperService {
     			if(subQuestion.getPublicity()){
     			if(subQuestion.getPublicity()){
     				publicity = true;
     				publicity = true;
     			}
     			}
-    			sum = subQuestion.getDifficultyDegree() + sum;
+    			sum = subQuestion.getDifficultyDegree()*subQuestion.getScore() + sum;
+    			totalDouble = subQuestion.getScore() + totalDouble;
     		}
     		}
-    		BigDecimal b = new BigDecimal(sum / (subQuesList.size()));  
+    		BigDecimal b = new BigDecimal(sum / totalDouble);  
 			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
 			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
 			//给属性去重
 			//给属性去重
 			Set<QuesProperty> ts = new HashSet<QuesProperty>();
 			Set<QuesProperty> ts = new HashSet<QuesProperty>();

+ 20 - 17
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/PaperDetailUnitServiceImpl.java

@@ -95,6 +95,25 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
                         // 匹配到子题
                         // 匹配到子题
                         subScoreList.set(index - 1, pduExp.getScore());
                         subScoreList.set(index - 1, pduExp.getScore());
                         oldPdu.getQuestion().getSubQuestions().set(index - 1, pduExp.getQuestion());
                         oldPdu.getQuestion().getSubQuestions().set(index - 1, pduExp.getQuestion());
+                        //重新计算套题的难度,公开度
+                        boolean publicity = false;
+                        double totalSum = 0d;
+                        double totalDou = 0d;
+                        for(Question subQuestion:oldPdu.getQuestion().getSubQuestions()){
+                			//设置公开度
+                			if(subQuestion.getPublicity()){
+                				publicity = true;
+                			}
+                			if(subQuestion.getDifficultyDegree() == null){
+                				subQuestion.setDifficultyDegree(0.5);
+                			}
+                			totalSum = subQuestion.getDifficultyDegree()*subQuestion.getScore() + totalSum;
+                			totalDou = subQuestion.getScore() + totalDou;
+                		}
+                		BigDecimal b = new BigDecimal(totalSum / totalDou);  
+            			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+            			oldPdu.getQuestion().setDifficultyDegree(difficulty);
+            			oldPdu.getQuestion().setPublicity(publicity);
                         match = true;
                         match = true;
                     }
                     }
                 }
                 }
@@ -103,23 +122,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
                 }
                 }
                 // 更新套题unit当前总分与子题分数
                 // 更新套题unit当前总分与子题分数
                 oldPdu.setSubScoreList(subScoreList);
                 oldPdu.setSubScoreList(subScoreList);
-                //重新计算套题的难度,公开度
-                boolean publicity = false;
-                double totalSum = 0d;
-                for(Question subQuestion:oldPdu.getQuestion().getSubQuestions()){
-        			//设置公开度
-        			if(subQuestion.getPublicity()){
-        				publicity = true;
-        			}
-        			if(subQuestion.getDifficultyDegree() == null){
-        				subQuestion.setDifficultyDegree(0.5);
-        			}
-        			totalSum = subQuestion.getDifficultyDegree() + totalSum;
-        		}
-        		BigDecimal b = new BigDecimal(totalSum / (oldPdu.getQuestion().getSubQuestions().size()));  
-    			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-    			oldPdu.getQuestion().setDifficultyDegree(difficulty);
-    			oldPdu.getQuestion().setPublicity(publicity);
+              
             }
             }
         } else {
         } else {
             oldPdu.setQuestion(quesService.saveQues(pduExp.getQuestion()));
             oldPdu.setQuestion(quesService.saveQues(pduExp.getQuestion()));