فهرست منبع

修复题目难度/区分度等级的计数bug

luoshi 6 سال پیش
والد
کامیت
853005c8b2

+ 55 - 13
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/report/utils/module/SubjectClassQuestionLevelModule.java

@@ -52,14 +52,26 @@ public class SubjectClassQuestionLevelModule extends SubjectQuestionLevelModule
 
     @Override
     protected void beforeSave() {
-        for (Entry<String, List<ExamQuestion>> entry : questions.entrySet()) {
-            String[] s = entry.getKey().split("\t");
-            Set<String> classSet = classMap.get(s[0]);
+        // paperType集合
+        Map<String, Set<String>> paperTypes = new HashMap<String, Set<String>>();
+        // 遍历客观题
+        for (Entry<String, List<ExamQuestion>> entry : objectiveQuestions.entrySet()) {
+            String[] keys = entry.getKey().split("\t");
+            String subjectCode = keys[0];
+            String paperType = StringUtils.trimToNull(keys[1]);
+            if (paperType != null) {
+                Set<String> set = paperTypes.get(subjectCode);
+                if (set == null) {
+                    set = new HashSet<String>();
+                    paperTypes.put(subjectCode, set);
+                }
+                set.add(paperType);
+            }
+            Set<String> classSet = classMap.get(subjectCode);
             if (null == classSet || classSet.isEmpty()) {
                 continue;
             }
             for (String className : classSet) {
-                Set<String> subjectiveSet = new HashSet<String>();
                 String key = entry.getKey() + "\t" + className;
                 for (ExamQuestion question : entry.getValue()) {
                     if (question.getTotalScore() == null || question.getTotalScore() == 0) {
@@ -69,14 +81,6 @@ public class SubjectClassQuestionLevelModule extends SubjectQuestionLevelModule
                     if (calculator == null) {
                         continue;
                     }
-                    if (!question.isObjective()) {
-                        String number = question.getQuestionNumber();
-                        if (subjectiveSet.contains(number)) {
-                            continue;
-                        } else {
-                            subjectiveSet.add(number);
-                        }
-                    }
                     // 按全卷维度统计
                     findDifficulityLevelCounter(key).process(question, calculator.difficulty);
                     findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
@@ -86,7 +90,45 @@ public class SubjectClassQuestionLevelModule extends SubjectQuestionLevelModule
                     findDiscriminationLevelCounter(getGroupKey(question, className)).process(question,
                             calculator.discrimination);
                 }
-                subjectiveSet.clear();
+            }
+        }
+        // 遍历主观题
+        for (Entry<String, List<ExamQuestion>> entry : subjectiveQuestions.entrySet()) {
+            String subjectCode = entry.getKey();
+            Set<String> classSet = classMap.get(subjectCode);
+            if (null == classSet || classSet.isEmpty()) {
+                continue;
+            }
+            for (String className : classSet) {
+                for (ExamQuestion question : entry.getValue()) {
+                    if (question.getTotalScore() == null || question.getTotalScore() == 0) {
+                        continue;
+                    }
+                    BaseCalculatorUnit calculator = provider.getCalculator(question);
+                    if (calculator == null) {
+                        continue;
+                    }
+                    // 按全卷维度统计
+                    Set<String> paperTypeSet = paperTypes.get(subjectCode);
+                    if (paperTypeSet == null || paperTypeSet.isEmpty()) {
+                        // 不区分paperType
+                        String key = subjectCode + "\t\t" + className;
+                        findDifficulityLevelCounter(key).process(question, calculator.difficulty);
+                        findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
+                    } else {
+                        // 遍历已存在的paperType
+                        for (String paperType : paperTypeSet) {
+                            String key = subjectCode + "\t" + paperType + "\t" + className;
+                            findDifficulityLevelCounter(key).process(question, calculator.difficulty);
+                            findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
+                        }
+                    }
+                    // 按大题维度统计
+                    findDifficulityLevelCounter(getGroupKey(question, className)).process(question,
+                            calculator.difficulty);
+                    findDiscriminationLevelCounter(getGroupKey(question, className)).process(question,
+                            calculator.discrimination);
+                }
             }
         }
     }

+ 61 - 21
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/report/utils/module/SubjectQuestionLevelModule.java

@@ -37,7 +37,7 @@ public class SubjectQuestionLevelModule implements Module {
 
     protected QuestionCalculatorProvider provider;
 
-    protected Map<String, List<ExamQuestion>> questions;
+    protected Map<String, List<ExamQuestion>> objectiveQuestions, subjectiveQuestions;
 
     protected Map<String, QuestionCounter> difficulityLevels, discriminationLevels;
 
@@ -46,7 +46,8 @@ public class SubjectQuestionLevelModule implements Module {
     public SubjectQuestionLevelModule(ReportContext context, QuestionCalculatorProvider provider) {
         this.context = context;
         this.provider = provider;
-        this.questions = new HashMap<String, List<ExamQuestion>>();
+        this.objectiveQuestions = new HashMap<String, List<ExamQuestion>>();
+        this.subjectiveQuestions = new HashMap<String, List<ExamQuestion>>();
         this.difficulityLevels = new HashMap<String, QuestionCounter>();
         this.discriminationLevels = new HashMap<String, QuestionCounter>();
         this.difficulityLevelConfig = context.getDifficulityLevelConfig();
@@ -56,12 +57,17 @@ public class SubjectQuestionLevelModule implements Module {
     @Override
     public void process(ExamStudent student) {
         String key = student.getSubjectCode() + "\t" + StringUtils.trimToEmpty(student.getPaperType());
-        List<ExamQuestion> list = questions.get(key);
-        if (list == null) {
-            list = new ArrayList<ExamQuestion>();
-            questions.put(key, list);
-            list.addAll(student.getObjectiveQuestionList());
-            list.addAll(student.getSubjectiveQuestionList());
+        List<ExamQuestion> olist = objectiveQuestions.get(key);
+        if (olist == null) {
+            olist = new ArrayList<ExamQuestion>();
+            objectiveQuestions.put(key, olist);
+            olist.addAll(student.getObjectiveQuestionList());
+        }
+        List<ExamQuestion> slist = subjectiveQuestions.get(student.getSubjectCode());
+        if (slist == null) {
+            slist = new ArrayList<ExamQuestion>();
+            subjectiveQuestions.put(key, slist);
+            slist.addAll(student.getSubjectiveQuestionList());
         }
     }
 
@@ -138,9 +144,21 @@ public class SubjectQuestionLevelModule implements Module {
     }
 
     protected void beforeSave() {
-        for (Entry<String, List<ExamQuestion>> entry : questions.entrySet()) {
-            Set<String> subjectiveSet = new HashSet<String>();
-            String key = entry.getKey();
+        // paperType集合
+        Map<String, Set<String>> paperTypes = new HashMap<String, Set<String>>();
+        // 遍历客观题
+        for (Entry<String, List<ExamQuestion>> entry : objectiveQuestions.entrySet()) {
+            String[] keys = entry.getKey().split("\t");
+            String subjectCode = keys[0];
+            String paperType = StringUtils.trimToNull(keys[1]);
+            if (paperType != null) {
+                Set<String> set = paperTypes.get(subjectCode);
+                if (set == null) {
+                    set = new HashSet<String>();
+                    paperTypes.put(subjectCode, set);
+                }
+                set.add(paperType);
+            }
             for (ExamQuestion question : entry.getValue()) {
                 if (question.getTotalScore() == null || question.getTotalScore() == 0) {
                     continue;
@@ -149,22 +167,44 @@ public class SubjectQuestionLevelModule implements Module {
                 if (calculator == null) {
                     continue;
                 }
-                if (!question.isObjective()) {
-                    String number = question.getQuestionNumber();
-                    if (subjectiveSet.contains(number)) {
-                        continue;
-                    } else {
-                        subjectiveSet.add(number);
-                    }
+                // 按全卷维度统计
+                findDifficulityLevelCounter(entry.getKey()).process(question, calculator.difficulty);
+                findDiscriminationLevelCounter(entry.getKey()).process(question, calculator.discrimination);
+                // 按大题维度统计
+                findDifficulityLevelCounter(getGroupKey(question)).process(question, calculator.difficulty);
+                findDiscriminationLevelCounter(getGroupKey(question)).process(question, calculator.discrimination);
+            }
+        }
+        // 遍历主观题
+        for (Entry<String, List<ExamQuestion>> entry : subjectiveQuestions.entrySet()) {
+            String subjectCode = entry.getKey();
+            for (ExamQuestion question : entry.getValue()) {
+                if (question.getTotalScore() == null || question.getTotalScore() == 0) {
+                    continue;
+                }
+                BaseCalculatorUnit calculator = provider.getCalculator(question);
+                if (calculator == null) {
+                    continue;
                 }
                 // 按全卷维度统计
-                findDifficulityLevelCounter(key).process(question, calculator.difficulty);
-                findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
+                Set<String> paperTypeSet = paperTypes.get(subjectCode);
+                if (paperTypeSet == null || paperTypeSet.isEmpty()) {
+                    // 不区分paperType
+                    String key = subjectCode + "\t";
+                    findDifficulityLevelCounter(key).process(question, calculator.difficulty);
+                    findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
+                } else {
+                    // 遍历已存在的paperType
+                    for (String paperType : paperTypeSet) {
+                        String key = subjectCode + "\t" + paperType;
+                        findDifficulityLevelCounter(key).process(question, calculator.difficulty);
+                        findDiscriminationLevelCounter(key).process(question, calculator.discrimination);
+                    }
+                }
                 // 按大题维度统计
                 findDifficulityLevelCounter(getGroupKey(question)).process(question, calculator.difficulty);
                 findDiscriminationLevelCounter(getGroupKey(question)).process(question, calculator.discrimination);
             }
-            subjectiveSet.clear();
         }
     }