Преглед на файлове

优化小题分析,错题集

tags/正式版本
王宁 преди 2 години
родител
ревизия
c811ef83da

+ 17
- 0
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java Целия файл

@@ -9,6 +9,7 @@ import java.io.IOException;
9 9
 import java.io.InputStreamReader;
10 10
 import java.io.OutputStreamWriter;
11 11
 import java.math.BigDecimal;
12
+import java.math.RoundingMode;
12 13
 import java.net.URL;
13 14
 import java.net.URLConnection;
14 15
 import java.text.ParseException;
@@ -648,6 +649,22 @@ public class N_Utils {
648 649
         return num2;
649 650
     }
650 651
 
652
+    /**
653
+     * @Description  格式化double类型,如果未小数点后为0反正整式,
654
+     * @Param [score]
655
+     * @Return java.lang.String
656
+     * @Author wn
657
+     * @Date 2022/9/2 16:34
658
+     **/
659
+    public static String formatDouble(Double score){
660
+        BigDecimal bg = new BigDecimal(score).setScale(1, RoundingMode.HALF_DOWN);
661
+        double num = bg.doubleValue();
662
+        if (Math.round(num) - num == 0) {
663
+            return String.valueOf((long) num);
664
+        }
665
+        return String.valueOf(num);
666
+    }
667
+
651 668
     /**
652 669
      * 格式化百分比
653 670
      * @Param [arr]

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EPaperStudentQuestion.java Целия файл

@@ -94,4 +94,7 @@ public class EPaperStudentQuestion extends BaseBean {
94 94
     @Transient
95 95
     private String checkname;//批阅人
96 96
 
97
+    @Transient
98
+    private String answer;//试题正确答案
99
+
97 100
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/reportclass/ERclassQuestion.java Целия файл

@@ -58,6 +58,9 @@ public class ERclassQuestion extends BaseBean {
58 58
     //年级得分率
59 59
     private Double gradesrate;
60 60
 
61
+    //高频错误选项
62
+    private String erroroption;
63
+
61 64
     //学生作答情况
62 65
     private String answerjson;
63 66
 

+ 3
- 2
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java Целия файл

@@ -299,6 +299,7 @@ public class EPaperQtypeService {
299 299
             tmap.put("num",qt.getEptnum());
300 300
             tmap.put("score",qt.getEptscore());
301 301
             tmap.put("srate",storerate);
302
+            qtypeqlist = qtypeqlist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList());
302 303
             tmap.put("ques",qtypeqlist);
303 304
             typelist.add(tmap);
304 305
         }
@@ -341,7 +342,7 @@ public class EPaperQtypeService {
341 342
                 prate.put("level",Integer.parseInt(entry.getKey()));
342 343
                 prate.put("score",score);
343 344
                 prate.put("srate",srate);
344
-                prate.put("ques",pgblist);
345
+                prate.put("ques",pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
345 346
                 clist.add(prate);
346 347
             }
347 348
         }
@@ -361,7 +362,7 @@ public class EPaperQtypeService {
361 362
                 prate.put("pointname",pgblist.get(0).getName());
362 363
                 prate.put("score",score);
363 364
                 prate.put("srate",srate);
364
-                prate.put("ques",pgblist);
365
+                prate.put("ques",pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
365 366
                 pointlist.add(prate);
366 367
             }
367 368
         }

+ 107
- 62
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Целия файл

@@ -319,8 +319,8 @@ public class EReportGenerateService {
319 319
         Map<String, List<ERclass>> collect = classList.stream().collect(Collectors.groupingBy(c -> c.getSubjectid()));
320 320
         for (Map.Entry<String, List<ERclass>> centry : collect.entrySet()) {
321 321
             List<Map.Entry<Double, List<ERclass>>> gslist2 = centry.getValue().stream()
322
-                    .collect(Collectors.groupingBy(ERclass::getClassavgscore)).entrySet()
323
-                    .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
322
+                                                                   .collect(Collectors.groupingBy(ERclass::getClassavgscore)).entrySet()
323
+                                                                   .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
324 324
             Integer index = 1;
325 325
             for (Map.Entry<Double, List<ERclass>> entry : gslist2) {
326 326
                 for (ERclass rc : entry.getValue()) {
@@ -373,9 +373,9 @@ public class EReportGenerateService {
373 373
                     int num = list.size();
374 374
                     subject.put("num", num);
375 375
                     subject.put("nrate", N_Utils.getIntegerDivideAndMulitiply(num, znum));
376
-                    List<Map> students=new ArrayList<>();
376
+                    List<Map> students = new ArrayList<>();
377 377
                     for (Map s : list) {
378
-                        Map stu=new HashMap();
378
+                        Map stu = new HashMap();
379 379
                         Integer studentid = (Integer) s.get("studentid");
380 380
                         stu.put("studentid", studentid);
381 381
                         stu.put("num", s.get("num"));
@@ -548,7 +548,7 @@ public class EReportGenerateService {
548 548
 
549 549
                     //班级科目统计
550 550
                     Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
551
-                            .collect(Collectors.groupingBy(s -> s.getClassid()));
551
+                                                                     .collect(Collectors.groupingBy(s -> s.getClassid()));
552 552
                     for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
553 553
                         classid = entry.getKey();
554 554
                         list = entry.getValue();
@@ -594,7 +594,7 @@ public class EReportGenerateService {
594 594
 
595 595
                     //班级科目统计
596 596
                     Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
597
-                            .collect(Collectors.groupingBy(s -> s.getClassid()));
597
+                                                                     .collect(Collectors.groupingBy(s -> s.getClassid()));
598 598
                     for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
599 599
                         classid = entry.getKey();
600 600
                         list = entry.getValue();
@@ -635,7 +635,7 @@ public class EReportGenerateService {
635 635
 
636 636
                 //班级科目统计
637 637
                 Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
638
-                        .collect(Collectors.groupingBy(s -> s.getClassid()));
638
+                                                                 .collect(Collectors.groupingBy(s -> s.getClassid()));
639 639
                 for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
640 640
                     classid = entry.getKey();
641 641
                     list = entry.getValue();
@@ -674,7 +674,7 @@ public class EReportGenerateService {
674 674
 
675 675
                 //班级科目统计
676 676
                 Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
677
-                        .collect(Collectors.groupingBy(s -> s.getClassid()));
677
+                                                                 .collect(Collectors.groupingBy(s -> s.getClassid()));
678 678
                 for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
679 679
                     classid = entry.getKey();
680 680
                     list = entry.getValue();
@@ -703,7 +703,7 @@ public class EReportGenerateService {
703 703
 
704 704
                 //班级科目统计
705 705
                 Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
706
-                        .collect(Collectors.groupingBy(s -> s.getClassid()));
706
+                                                                 .collect(Collectors.groupingBy(s -> s.getClassid()));
707 707
                 for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
708 708
                     classid = entry.getKey();
709 709
                     list = entry.getValue();
@@ -734,7 +734,7 @@ public class EReportGenerateService {
734 734
 
735 735
                 //班级科目统计
736 736
                 Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
737
-                        .collect(Collectors.groupingBy(s -> s.getClassid()));
737
+                                                                 .collect(Collectors.groupingBy(s -> s.getClassid()));
738 738
                 for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
739 739
                     classid = entry.getKey();
740 740
                     list = entry.getValue();
@@ -941,7 +941,7 @@ public class EReportGenerateService {
941 941
         cr.setStunum(stunum);
942 942
         cr.setSturate(N_Utils.getIntegerDivideAndMulitiply(stunum, gstunum));
943 943
         setStudentName(list2, userMap);
944
-        String stujson = list2.stream().map(s -> s.getStudentname()+"("+s.getSchoolrank()+"名)").sorted().collect(Collectors.joining("、"));
944
+        String stujson = list2.stream().map(s -> s.getStudentname() + "(" + s.getSchoolrank() + "名)").sorted().collect(Collectors.joining("、"));
945 945
         cr.setStujson(stujson);
946 946
         rclassRankList.add(cr);
947 947
     }
@@ -979,8 +979,8 @@ public class EReportGenerateService {
979 979
     //分数排名
980 980
     private void setRank(List<ERstudent> students, Map<String, Integer> rank, Integer code) {
981 981
         List<Map.Entry<Double, List<ERstudent>>> gslist2 = students.stream()
982
-                .collect(Collectors.groupingBy(ERstudent::getScore)).entrySet()
983
-                .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
982
+                                                                   .collect(Collectors.groupingBy(ERstudent::getScore)).entrySet()
983
+                                                                   .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
984 984
         Integer index = 1;
985 985
         String key;
986 986
         for (Map.Entry<Double, List<ERstudent>> entry : gslist2) {
@@ -1003,12 +1003,11 @@ public class EReportGenerateService {
1003 1003
         }
1004 1004
     }
1005 1005
 
1006
-
1007 1006
     @Transactional(rollbackFor = Exception.class)
1008
-    public void saveClassQuestions(Integer examid){
1007
+    public void saveClassQuestions(Integer examid) {
1009 1008
         List<Map> classes = eClassMapper.listByExamId(examid);
1010 1009
         List<Map> subjects = eReportGenerateMapper.listSubject(examid);
1011
-        setClassQuestion(examid,subjects,classes);
1010
+        setClassQuestion(examid, subjects, classes);
1012 1011
 
1013 1012
     }
1014 1013
 
@@ -1061,7 +1060,6 @@ public class EReportGenerateService {
1061 1060
             }
1062 1061
         }
1063 1062
 
1064
-
1065 1063
         eRclassQtypeMapper.insertList(rtypelist);
1066 1064
         eRstudentQtypeMapper.insertList(stutypelist);
1067 1065
         eRclassQuestionMapper.insertList(rqueslist);
@@ -1075,7 +1073,7 @@ public class EReportGenerateService {
1075 1073
     private Map setPaperQuestionsForStuAnswer(List<EPaperStudentQuestion> classStu) {
1076 1074
         EPaperStudentQuestion q = classStu.get(0);//取第一条数据
1077 1075
 
1078
-        Map<String, List<Map>> answermap = new HashMap<>();
1076
+        Map<String, List<Map>> answermap = null;
1079 1077
         List<Map> goodlist = new ArrayList<>();
1080 1078
         List<Map> badlist = new ArrayList<>();
1081 1079
 
@@ -1092,11 +1090,15 @@ public class EReportGenerateService {
1092 1090
                 String answeroption = "未作答";
1093 1091
                 if (N_Utils.isNotEmpty(stuanswer)) {
1094 1092
                     List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
1095
-                    if(N_Utils.isListNotEmpty(stuanswers)){
1093
+                    if (N_Utils.isListNotEmpty(stuanswers)) {
1096 1094
                         answeroption = stuanswers.get(0);
1097 1095
                     }
1098 1096
                 }
1099 1097
 
1098
+                if(i == 0){
1099
+                    answermap = new TreeMap<>();
1100
+                }
1101
+
1100 1102
                 Map stumap = new HashMap();
1101 1103
                 stumap.put("studentid", sq.getStudentid());
1102 1104
                 stumap.put("stuname", sq.getStuname());
@@ -1111,12 +1113,16 @@ public class EReportGenerateService {
1111 1113
             } else {
1112 1114
                 //主观题
1113 1115
                 if (i == 0) {
1116
+                    answermap = new LinkedHashMap<>();
1114 1117
                     //处理分数分段对应,用于分数段[0,50%)   [50%,80%),  [80%,100%]
1115 1118
                     score8 = ExamUtil.getScoreRateScore(q.getQscore(), 0.8);
1116
-                    score5 = ExamUtil.getScoreRateScore(q.getQscore(), 0.8);
1117
-                    key1 = score8 + "-" + q.getQscore();
1118
-                    key2 = score8 + "-" + score5;
1119
-                    key3 = score5 + "-" + 0;
1119
+                    score5 = ExamUtil.getScoreRateScore(q.getQscore(), 0.5);
1120
+                    String str10 = N_Utils.formatDouble(q.getQscore());
1121
+                    String str8 = N_Utils.formatDouble(score8);
1122
+                    String str5 = N_Utils.formatDouble(score5);
1123
+                    key1 = str8 + "-" + str10;
1124
+                    key2 = str5 + "-" + str8;
1125
+                    key3 = 0 + "-" + str5;
1120 1126
                     answermap.put(key1, new ArrayList<>());
1121 1127
                     answermap.put(key2, new ArrayList<>());
1122 1128
                     answermap.put(key3, new ArrayList<>());
@@ -1151,10 +1157,37 @@ public class EReportGenerateService {
1151 1157
             }
1152 1158
         }
1153 1159
 
1160
+        String erroroption = "";//高频错误项
1161
+        if (q.getCtype() == 1 || q.getCtype() == 2 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6) {
1162
+            String answer = q.getAnswer();//试题正确答案
1163
+            List<String> answerlist = JSON.parseArray(answer, String.class);
1164
+            int num = 0;
1165
+            for (Map.Entry<String, List<Map>> entry : answermap.entrySet()) {
1166
+                if (!entry.getKey().equalsIgnoreCase(answerlist.get(0))) {
1167
+                    //当前选项不是正确答案时,数量大的为高频错误选项
1168
+                    if (num < entry.getValue().size()) {
1169
+                        num = entry.getValue().size();
1170
+                        erroroption = entry.getKey();
1171
+                    }
1172
+                }
1173
+            }
1174
+        }
1175
+
1154 1176
         Map rtnmap = new HashMap();
1155 1177
         rtnmap.put("answerlist", JSON.toJSONString(answermap));
1156
-        rtnmap.put("goodlist", JSON.toJSONString(goodlist));
1178
+        if(goodlist.size()>0){
1179
+            rtnmap.put("goodlist", JSON.toJSONString(goodlist));
1180
+        }else{
1181
+            rtnmap.put("goodlist", "");
1182
+        }
1183
+        if(badlist.size()>0){
1184
+            rtnmap.put("badlist", JSON.toJSONString(badlist));
1185
+        }else{
1186
+            rtnmap.put("badlist", "");
1187
+        }
1188
+
1157 1189
         rtnmap.put("badlist", JSON.toJSONString(badlist));
1190
+        rtnmap.put("erroroption",erroroption);
1158 1191
         return rtnmap;
1159 1192
     }
1160 1193
 
@@ -1224,8 +1257,14 @@ public class EReportGenerateService {
1224 1257
                     //处理单选题选项情况
1225 1258
                     Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
1226 1259
                     ercq.setAnswerjson(stuansmap.get("answerlist").toString());
1227
-                    ercq.setGoodstujson(stuansmap.get("goodlist").toString());
1228
-                    ercq.setBadstujson(stuansmap.get("badlist").toString());
1260
+                    if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
1261
+                        ercq.setGoodstujson(stuansmap.get("goodlist").toString());
1262
+                    }
1263
+                    if(N_Utils.isNotEmpty(stuansmap.get("badlist"))){
1264
+                        ercq.setBadstujson(stuansmap.get("badlist").toString());
1265
+                    }
1266
+
1267
+                    ercq.setErroroption(stuansmap.get("erroroption").toString());
1229 1268
                     rqueslist.add(ercq);//单个试题统计
1230 1269
 
1231 1270
                     if (tclassmap.containsKey(classid)) {
@@ -1249,7 +1288,7 @@ public class EReportGenerateService {
1249 1288
                             sq.setClassid(psq.getClassid());
1250 1289
                             sq.setStudentid(psq.getStudentid());
1251 1290
                             sq.setStuscore(psq.getStuscore());
1252
-                            tstumap.put(psq.getStudentid(),sq);
1291
+                            tstumap.put(psq.getStudentid(), sq);
1253 1292
                         }
1254 1293
                     }
1255 1294
                 }
@@ -1362,8 +1401,13 @@ public class EReportGenerateService {
1362 1401
                         //处理单选题选项情况
1363 1402
                         Map stuansmap = setPaperQuestionsForStuAnswer(sqcstulist);
1364 1403
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
1365
-                        ercq.setGoodstujson(stuansmap.get("goodlist").toString());
1366
-                        ercq.setBadstujson(stuansmap.get("badlist").toString());
1404
+                        if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
1405
+                            ercq.setGoodstujson(stuansmap.get("goodlist").toString());
1406
+                        }
1407
+                        if(N_Utils.isNotEmpty(stuansmap.get("badlist"))){
1408
+                            ercq.setBadstujson(stuansmap.get("badlist").toString());
1409
+                        }
1410
+                        ercq.setErroroption(stuansmap.get("erroroption").toString());
1367 1411
                         rqueslist.add(ercq);//单个试题统计
1368 1412
                     }
1369 1413
                 }
@@ -1443,7 +1487,7 @@ public class EReportGenerateService {
1443 1487
                             sq.setClassid(psq.getClassid());
1444 1488
                             sq.setStudentid(psq.getStudentid());
1445 1489
                             sq.setStuscore(psq.getStuscore());
1446
-                            tstumap.put(psq.getStudentid(),sq);
1490
+                            tstumap.put(psq.getStudentid(), sq);
1447 1491
                         }
1448 1492
                     }
1449 1493
                 }
@@ -1504,21 +1548,21 @@ public class EReportGenerateService {
1504 1548
         for (int i = 0; i < quepointlist.size(); i++) {
1505 1549
             QuestionPointVo qpoint = quepointlist.get(i);
1506 1550
             List<Map> points = qpoint.getPointids();
1507
-            if(N_Utils.isListNotEmpty(points)){
1508
-                if(qpoint.getQlevel()==1 || !N_Utils.isEmptyInteger(qpoint.getEptqid())){
1551
+            if (N_Utils.isListNotEmpty(points)) {
1552
+                if (qpoint.getQlevel() == 1 || !N_Utils.isEmptyInteger(qpoint.getEptqid())) {
1509 1553
                     //说明本题为单题,获取该题下所有学生的得分情况
1510 1554
                     List<EPaperStudentQuestion> stuqueslist = paperstulist.stream().filter(s -> s.getEptqid().equals(qpoint.getEptqid())).collect(Collectors.toList());
1511
-                    for(EPaperStudentQuestion sq : stuqueslist){
1512
-                        setEPaperQuestionPointsForStuQues(gradestulist,sq,points,qpoint.getEptqid().toString());
1555
+                    for (EPaperStudentQuestion sq : stuqueslist) {
1556
+                        setEPaperQuestionPointsForStuQues(gradestulist, sq, points, qpoint.getEptqid().toString());
1513 1557
                     }
1514
-                }else{
1558
+                } else {
1515 1559
                     //说明该题为复合题,获取所有子题
1516 1560
                     List<Integer> eptqids = qpoint.getEptqids();
1517 1561
                     String eptqidsStr = eptqids.stream().map(String::valueOf).collect(Collectors.joining(","));
1518
-                    List<EPaperStudentQuestion> stuqueslist = paperstulist.stream().filter(s ->eptqids.contains(s.getEptqid())).collect(Collectors.toList());
1562
+                    List<EPaperStudentQuestion> stuqueslist = paperstulist.stream().filter(s -> eptqids.contains(s.getEptqid())).collect(Collectors.toList());
1519 1563
                     //根据每个学生分组获取每个学生该题分值
1520
-                    Map<Integer,List<EPaperStudentQuestion>> stuquesmap = stuqueslist.stream().collect(Collectors.groupingBy(EPaperStudentQuestion::getStudentid));
1521
-                    for(Map.Entry<Integer,List<EPaperStudentQuestion>> entry : stuquesmap.entrySet()){
1564
+                    Map<Integer, List<EPaperStudentQuestion>> stuquesmap = stuqueslist.stream().collect(Collectors.groupingBy(EPaperStudentQuestion::getStudentid));
1565
+                    for (Map.Entry<Integer, List<EPaperStudentQuestion>> entry : stuquesmap.entrySet()) {
1522 1566
                         List<EPaperStudentQuestion> stuques = entry.getValue();
1523 1567
                         Double stuscore = stuques.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1524 1568
                         EPaperStudentQuestion sqfirst = stuques.get(0);
@@ -1526,14 +1570,14 @@ public class EReportGenerateService {
1526 1570
                         sq.setStudentid(entry.getKey());
1527 1571
                         sq.setClassid(sqfirst.getClassid());
1528 1572
                         sq.setStuscore(stuscore);
1529
-                        setEPaperQuestionPointsForStuQues(gradestulist,sq,points,eptqidsStr);
1573
+                        setEPaperQuestionPointsForStuQues(gradestulist, sq, points, eptqidsStr);
1530 1574
                     }
1531 1575
                 }
1532 1576
             }
1533 1577
         }
1534 1578
         List<Map> classes = examPaperClassVo.getClasses();
1535 1579
         //根据试卷知识点分析进行生成学生、班级、年级知识点分析
1536
-        for(Map map : pointlist){
1580
+        for (Map map : pointlist) {
1537 1581
             String pointid = map.get("pointid").toString();
1538 1582
             String pointname = map.get("pointname").toString();
1539 1583
             Double pointscore = Double.parseDouble(map.get("score").toString());
@@ -1545,8 +1589,8 @@ public class EReportGenerateService {
1545 1589
             List<ERPointStuScoreVo> gradepointstulist = gradestulist.stream().filter(s -> s.getPointid().equals(pointid)).collect(Collectors.toList());
1546 1590
 
1547 1591
             List<ERPointStuScoreVo> pointstuscorelist = new ArrayList<>(); //知识点下多个试题,处理成单个学生总分值情况
1548
-            Map<Integer,List<ERPointStuScoreVo>> pointstuscoremap = gradepointstulist.stream().collect(Collectors.groupingBy(ERPointStuScoreVo::getStudentid));
1549
-            for(Map.Entry<Integer,List<ERPointStuScoreVo>> entry : pointstuscoremap.entrySet()){
1592
+            Map<Integer, List<ERPointStuScoreVo>> pointstuscoremap = gradepointstulist.stream().collect(Collectors.groupingBy(ERPointStuScoreVo::getStudentid));
1593
+            for (Map.Entry<Integer, List<ERPointStuScoreVo>> entry : pointstuscoremap.entrySet()) {
1550 1594
                 List<ERPointStuScoreVo> stuscorelist = entry.getValue();
1551 1595
                 Double stuscore = stuscorelist.stream().mapToDouble(ERPointStuScoreVo::getStuscore).sum();
1552 1596
                 ERPointStuScoreVo sscorevofirst = stuscorelist.get(0);
@@ -1558,16 +1602,16 @@ public class EReportGenerateService {
1558 1602
             }
1559 1603
 
1560 1604
             Double gstuscore = pointstuscorelist.stream().mapToDouble(ERPointStuScoreVo::getStuscore).sum();
1561
-            Double gavgscore = N_Utils.getDoubleDivideForAvg(gstuscore,pointstuscorelist.size());
1562
-            Double gsrate = N_Utils.getDoubleDivideAndMulitiply(gstuscore,pointscore * pointstuscorelist.size());
1605
+            Double gavgscore = N_Utils.getDoubleDivideForAvg(gstuscore, pointstuscorelist.size());
1606
+            Double gsrate = N_Utils.getDoubleDivideAndMulitiply(gstuscore, pointscore * pointstuscorelist.size());
1563 1607
 
1564
-            for(Map classm : classes){
1608
+            for (Map classm : classes) {
1565 1609
                 Integer classid = Integer.parseInt(classm.get("classid").toString());
1566
-                List<ERPointStuScoreVo> classpointstulist = pointstuscorelist.stream().filter(s->s.getClassid().equals(classid)).collect(Collectors.toList());
1610
+                List<ERPointStuScoreVo> classpointstulist = pointstuscorelist.stream().filter(s -> s.getClassid().equals(classid)).collect(Collectors.toList());
1567 1611
                 Double cstuscore = classpointstulist.stream().mapToDouble(ERPointStuScoreVo::getStuscore).sum();
1568 1612
 //                Double cscore = classpointstulist.stream().mapToDouble(ERPointStuScoreVo::getScore).sum();
1569
-                Double cavgscore = N_Utils.getDoubleDivideForAvg(cstuscore,classpointstulist.size());
1570
-                Double csrate = N_Utils.getDoubleDivideAndMulitiply(cstuscore,pointscore * classpointstulist.size());
1613
+                Double cavgscore = N_Utils.getDoubleDivideForAvg(cstuscore, classpointstulist.size());
1614
+                Double csrate = N_Utils.getDoubleDivideAndMulitiply(cstuscore, pointscore * classpointstulist.size());
1571 1615
 
1572 1616
                 ERclassPoint eRclassPoint = new ERclassPoint();
1573 1617
                 eRclassPoint.setExamid(examPaperClassVo.getExamid());
@@ -1588,7 +1632,7 @@ public class EReportGenerateService {
1588 1632
                 cpointlist.add(eRclassPoint);
1589 1633
 
1590 1634
                 //遍历单个学生
1591
-                for(ERPointStuScoreVo stu : classpointstulist){
1635
+                for (ERPointStuScoreVo stu : classpointstulist) {
1592 1636
                     ERstudentPoint erstupoint = new ERstudentPoint();
1593 1637
                     erstupoint.setExamid(examPaperClassVo.getExamid());
1594 1638
                     erstupoint.setSubjectid(examPaperClassVo.getSubjectid());
@@ -1598,7 +1642,7 @@ public class EReportGenerateService {
1598 1642
                     erstupoint.setPointid(pointid);
1599 1643
                     erstupoint.setPointname(pointname);
1600 1644
                     erstupoint.setStuscore(stu.getStuscore());
1601
-                    erstupoint.setStusrate(N_Utils.getDoubleDivideAndMulitiply(stu.getStuscore(),pointscore));
1645
+                    erstupoint.setStusrate(N_Utils.getDoubleDivideAndMulitiply(stu.getStuscore(), pointscore));
1602 1646
                     stupointlist.add(erstupoint);
1603 1647
                 }
1604 1648
             }
@@ -1607,9 +1651,10 @@ public class EReportGenerateService {
1607 1651
 
1608 1652
 
1609 1653
     }
1654
+
1610 1655
     //题型、试题、知识点、难易度--知识点:设置每个学生每个试题知识点得分
1611
-    private void setEPaperQuestionPointsForStuQues(List<ERPointStuScoreVo> gradestulist,EPaperStudentQuestion sq,List<Map> points,String eptqids){
1612
-        if(points.size() == 1){
1656
+    private void setEPaperQuestionPointsForStuQues(List<ERPointStuScoreVo> gradestulist, EPaperStudentQuestion sq, List<Map> points, String eptqids) {
1657
+        if (points.size() == 1) {
1613 1658
             Map pointmap = points.get(0);
1614 1659
             //说明该试题仅有一个知识点得分直接为改知识点分值
1615 1660
             ERPointStuScoreVo pscvo = new ERPointStuScoreVo();
@@ -1620,10 +1665,10 @@ public class EReportGenerateService {
1620 1665
             pscvo.setPointid(pointid);
1621 1666
             pscvo.setEptqids(eptqids);
1622 1667
             gradestulist.add(pscvo);
1623
-        }else{
1668
+        } else {
1624 1669
             //计算每个知识点所占分值(平均分配)
1625
-            Double[] avgps = ExamUtil.getPointAvgScore(points.size(),sq.getStuscore());
1626
-            for(int j=0;j<points.size();j++){
1670
+            Double[] avgps = ExamUtil.getPointAvgScore(points.size(), sq.getStuscore());
1671
+            for (int j = 0; j < points.size(); j++) {
1627 1672
                 Map pointmap = points.get(j);
1628 1673
                 ERPointStuScoreVo pscvo = new ERPointStuScoreVo();
1629 1674
                 pscvo.setClassid(sq.getClassid());
@@ -1631,9 +1676,9 @@ public class EReportGenerateService {
1631 1676
                 String pointid = pointmap.get("pointid").toString();
1632 1677
                 pscvo.setPointid(pointid);
1633 1678
                 pscvo.setEptqids(eptqids);
1634
-                if(avgps.length == 2 && (j+1) == points.size()){
1679
+                if (avgps.length == 2 && (j + 1) == points.size()) {
1635 1680
                     pscvo.setStuscore(avgps[1]);
1636
-                }else{
1681
+                } else {
1637 1682
                     pscvo.setStuscore(avgps[0]);
1638 1683
                 }
1639 1684
 
@@ -1662,9 +1707,9 @@ public class EReportGenerateService {
1662 1707
             }
1663 1708
 
1664 1709
             List<EPaperStudentQuestion> levelstuquelist = new ArrayList<>();//难易度下所有试题
1665
-            for(Integer eptqid : leveleptqids){
1666
-               List<EPaperStudentQuestion> petqqueslit = paperstulist.stream().filter(s -> eptqid.equals(s.getEptqid())).collect(Collectors.toList());
1667
-               levelstuquelist.addAll(petqqueslit);
1710
+            for (Integer eptqid : leveleptqids) {
1711
+                List<EPaperStudentQuestion> petqqueslit = paperstulist.stream().filter(s -> eptqid.equals(s.getEptqid())).collect(Collectors.toList());
1712
+                levelstuquelist.addAll(petqqueslit);
1668 1713
             }
1669 1714
 
1670 1715
             List<EPaperStudentQuestion> qgstulist = new ArrayList<>();//每个学生难易度下得分
@@ -1693,8 +1738,8 @@ public class EReportGenerateService {
1693 1738
                 stucomplist.add(stucomp);
1694 1739
             }
1695 1740
 
1696
-            Double tgstuscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion :: getStuscore).sum();//难易度下学生得分
1697
-            Double tgscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion :: getQscore).sum();//难易度下试题总分
1741
+            Double tgstuscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();//难易度下学生得分
1742
+            Double tgscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();//难易度下试题总分
1698 1743
             Double tgsrate = N_Utils.getDoubleDivideAndMulitiply(tgstuscore, tgscore);//年级得分率
1699 1744
 
1700 1745
             for (Map classm : classes) {

+ 48
- 48
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportStudentService.java Целия файл

@@ -160,8 +160,8 @@ public class EReportStudentService {
160 160
             Double qscore = Double.parseDouble(m.get("qscore").toString());
161 161
             Double stusrate = N_Utils.getDoubleDivideAndMulitiply(stuscore, qscore);
162 162
             m.put("stusrate", stusrate);
163
-            Double srate = N_Utils.getDoubleDivideAndMulitiply(qscore,paperscore);
164
-            m.put("srate",srate);
163
+            Double srate = N_Utils.getDoubleDivideAndMulitiply(qscore, paperscore);
164
+            m.put("srate", srate);
165 165
         }
166 166
         return list;
167 167
     }
@@ -183,10 +183,10 @@ public class EReportStudentService {
183 183
             setPaperQuestionForTK(list);
184 184
         } else {
185 185
             list = eRstudentMapper.listStudentQuestionsFj(epid, studentid);
186
-            for(Map qmap : list){
186
+            for (Map qmap : list) {
187 187
                 Double stuscore = Double.parseDouble(qmap.get("stuscore").toString());
188
-                Double pscore = Double .parseDouble(qmap.get("qscore").toString());
189
-                qmap.put("srate",N_Utils.getDoubleDivideAndMulitiply(stuscore,pscore));
188
+                Double pscore = Double.parseDouble(qmap.get("qscore").toString());
189
+                qmap.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));
190 190
             }
191 191
             List<Map> files = ePaperFileMapper.listPaperFiles(epid);
192 192
             map.put("files", files);
@@ -209,8 +209,8 @@ public class EReportStudentService {
209 209
                 map.put("ctype", Integer.parseInt(q.get("ctype").toString()));
210 210
                 map.put("qn", q.get("qn").toString());
211 211
                 map.put("qorder", Integer.parseInt(q.get("qorder").toString()));
212
-                Double stuscore = Double.parseDouble(q.get("qscore").toString());
213
-                Double pscore = Double .parseDouble(map.get("qscore").toString());
212
+                Double stuscore = Double.parseDouble(q.get("stuscore").toString());
213
+                Double pscore = Double.parseDouble(q.get("qscore").toString());
214 214
                 map.put("qscore", pscore);
215 215
                 map.put("stuscore", stuscore);
216 216
                 map.put("answered", Integer.parseInt(q.get("answered").toString()));
@@ -219,27 +219,27 @@ public class EReportStudentService {
219 219
                 map.put("stuanswertxt", q.get("stuanswertxt").toString());
220 220
                 map.put("answer", q.get("answer").toString());
221 221
                 map.put("qstem", q.get("qstem").toString());
222
-                if(N_Utils.isNotEmpty(q.get("qoption"))){
222
+                if (N_Utils.isNotEmpty(q.get("qoption"))) {
223 223
                     map.put("qoption", q.get("qoption").toString());
224
-                }else{
224
+                } else {
225 225
                     map.put("qoption", "");
226 226
                 }
227
-                if(N_Utils.isNotEmpty(q.get("qanalyze"))){
227
+                if (N_Utils.isNotEmpty(q.get("qanalyze"))) {
228 228
                     map.put("qanalyze", q.get("qanalyze").toString());
229
-                }else{
229
+                } else {
230 230
                     map.put("qanalyze", "");
231 231
                 }
232 232
 
233 233
                 Integer hashear = Integer.parseInt(q.get("hashear").toString());
234 234
                 map.put("hashear", hashear);
235
-                if(hashear == 1){
235
+                if (hashear == 1) {
236 236
                     map.put("hearfile", q.get("hearfile").toString());
237 237
                 }
238 238
 
239 239
                 map.put("qlevel", qlevel);
240 240
                 map.put("classavgscore", Double.parseDouble(q.get("classavgscore").toString()));
241 241
                 map.put("gradeavgscore", Double.parseDouble(q.get("gradeavgscore").toString()));
242
-                map.put("srate",N_Utils.getDoubleDivideAndMulitiply(stuscore,pscore));//得分率
242
+                map.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));//得分率
243 243
 
244 244
                 if (q.get("points") != null) {
245 245
                     List<Map> points = (List<Map>) q.get("points");
@@ -252,32 +252,33 @@ public class EReportStudentService {
252 252
                 if (!questiopids.contains(questionpid)) {
253 253
                     questiopids.add(questionpid);
254 254
                     //获取所有试题
255
-                    List<Map> sonqueslist = list.stream().filter(s -> s.get("questionpid").toString().equals(questionpid)).collect(Collectors.toList());
255
+                    List<Map> sonqueslist =
256
+                            list.stream().filter(s -> Integer.parseInt(s.get("qlevel").toString()) == 3 && questionpid.equals(s.get("questionpid").toString())).collect(Collectors.toList());
256 257
                     Map mq = new HashMap();
257 258
                     mq.put("questionid", questionpid);
258 259
                     mq.put("qlevel", 2);
259 260
                     mq.put("qorder", Integer.parseInt(q.get("qorder").toString()));
260 261
                     mq.put("ctype", Integer.parseInt(q.get("mctype").toString()));
261 262
                     mq.put("qstem", q.get("mqstem").toString());
262
-                    if(N_Utils.isNotEmpty(q.get("mqoption"))){
263
+                    if (N_Utils.isNotEmpty(q.get("mqoption"))) {
263 264
                         mq.put("qoption", q.get("mqoption").toString());
264
-                    }else{
265
+                    } else {
265 266
                         mq.put("qoption", "");
266 267
                     }
267
-                    if(N_Utils.isNotEmpty(q.get("mqanalyze"))){
268
+                    if (N_Utils.isNotEmpty(q.get("mqanalyze"))) {
268 269
                         mq.put("qanalyze", q.get("mqanalyze").toString());
269
-                    }else{
270
+                    } else {
270 271
                         mq.put("qanalyze", "");
271 272
                     }
272
-                    if(N_Utils.isNotEmpty(q.get("mqanswer"))){
273
+                    if (N_Utils.isNotEmpty(q.get("mqanswer"))) {
273 274
                         mq.put("qanalyze", q.get("mqanswer").toString());
274
-                    }else{
275
+                    } else {
275 276
                         mq.put("qanalyze", "");
276 277
                     }
277 278
 
278 279
                     Integer hashear = Integer.parseInt(q.get("mhashear").toString());
279 280
                     mq.put("hashear", hashear);
280
-                    if(hashear == 1){
281
+                    if (hashear == 1) {
281 282
                         mq.put("hearfile", q.get("mhearfile").toString());
282 283
                     }
283 284
                     if (q.get("points") != null) {
@@ -286,9 +287,8 @@ public class EReportStudentService {
286 287
                     }
287 288
 
288 289
                     Double stuscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("stuscore").toString())).sum();
289
-                    Double pscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("pscore").toString())).sum();
290
-                    mq.put("srate",N_Utils.getDoubleDivideAndMulitiply(stuscore,pscore));
291
-
290
+                    Double pscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("qscore").toString())).sum();
291
+                    mq.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));
292 292
                     mq.put("sonques", sonqueslist);
293 293
                     rtnlist.add(mq);
294 294
                 }
@@ -309,22 +309,22 @@ public class EReportStudentService {
309 309
         for (Map map : list) {
310 310
             List<Map> queslist = (List<Map>) map.get("questions");
311 311
             Integer ptype = Integer.parseInt(map.get("ptype").toString());
312
-            if(ptype==1){
312
+            if (ptype == 1) {
313 313
                 //单题的数量
314 314
                 List<Map> dtlist = queslist.stream().filter(s -> Integer.parseInt(s.get("qlevel").toString()) == 1).collect(Collectors.toList());
315 315
                 //子题
316 316
                 List<Map> sonlist = queslist.stream().filter(s -> Integer.parseInt(s.get("qlevel").toString()) == 3).collect(Collectors.toList());
317
-                Map<String,List<Map>> mtmap = sonlist.stream().collect(Collectors.groupingBy(s -> s.get("questionpid").toString()));
317
+                Map<String, List<Map>> mtmap = sonlist.stream().collect(Collectors.groupingBy(s -> s.get("questionpid").toString()));
318 318
                 int num = 0;
319
-                if(N_Utils.isListNotEmpty(dtlist)){
319
+                if (N_Utils.isListNotEmpty(dtlist)) {
320 320
                     num = dtlist.size();
321 321
                 }
322
-                if(mtmap!=null && mtmap.size()>0){
322
+                if (mtmap != null && mtmap.size() > 0) {
323 323
                     num = num + mtmap.size();
324 324
                 }
325
-                map.put("num",num);
326
-            }else{
327
-                map.put("num",queslist.size());
325
+                map.put("num", num);
326
+            } else {
327
+                map.put("num", queslist.size());
328 328
             }
329 329
             map.remove("questions");
330 330
         }
@@ -338,33 +338,33 @@ public class EReportStudentService {
338 338
      * @Author wn
339 339
      * @Date 2022/8/29 16:15
340 340
      **/
341
-    public Map listStudentErrorQuestionsTk(Integer examid, Integer studentid,String subjectid){
342
-        List<Map> list = eRstudentMapper.listStudentErrorQuestionsForTk(examid,studentid,subjectid);
343
-        Map panalyze = ePaperAnalyzeMapper.getPaperAnalzyeBySubjectid(examid,subjectid);
341
+    public Map listStudentErrorQuestionsTk(Integer examid, Integer studentid, String subjectid) {
342
+        List<Map> list = eRstudentMapper.listStudentErrorQuestionsForTk(examid, studentid, subjectid);
343
+        Map panalyze = ePaperAnalyzeMapper.getPaperAnalzyeBySubjectid(examid, subjectid);
344 344
         String pointjson = panalyze.get("pointjson").toString();
345 345
         List<Map> pointlist = JSON.parseArray(pointjson, Map.class);
346 346
         List<Map> pointqueslist = new ArrayList<>();
347
-        for(Map pointmap : pointlist){
347
+        for (Map pointmap : pointlist) {
348 348
             //知识点包含的试题
349 349
             List<Map> ques = (List<Map>) pointmap.get("ques");
350 350
             List<Integer> eptqidlist = new ArrayList<>();//知识点关联的所有试题
351
-            for(Map qovo : ques){
351
+            for (Map qovo : ques) {
352 352
                 List<Integer> eptqids = (List<Integer>) qovo.get("eptqids");
353 353
                 eptqidlist.addAll(eptqids);
354 354
             }
355 355
             //获取知识点下试题
356 356
             List<Map> poinques = list.stream().filter(s -> eptqidlist.contains(Integer.parseInt(s.get("eptqid").toString()))).collect(Collectors.toList());
357
-            if(N_Utils.isListNotEmpty(poinques)){
357
+            if (N_Utils.isListNotEmpty(poinques)) {
358 358
                 Map pmap = new HashMap();
359
-                pmap.put("pointid",pointmap.get("pointid").toString());
360
-                pmap.put("pointname",pointmap.get("pointname").toString());
361
-                pmap.put("questions",setPaperQuestionForTK(poinques));
359
+                pmap.put("pointid", pointmap.get("pointid").toString());
360
+                pmap.put("pointname", pointmap.get("pointname").toString());
361
+                pmap.put("questions", setPaperQuestionForTK(poinques));
362 362
                 pointqueslist.add(pmap);
363 363
             }
364 364
         }
365 365
         Map map = new HashMap();
366
-        map.put("questions",setPaperQuestionForTK(list));
367
-        map.put("points",pointqueslist);
366
+        map.put("questions", setPaperQuestionForTK(list));
367
+        map.put("points", pointqueslist);
368 368
         return map;
369 369
     }
370 370
 
@@ -375,13 +375,13 @@ public class EReportStudentService {
375 375
      * @Author wn
376 376
      * @Date 2022/8/29 16:15
377 377
      **/
378
-    public List<Map> listStudentErrorQuestionsFj(Integer examid, Integer studentid,String subjectid){
379
-        List<Map> list = eRstudentMapper.listStudentErrorQuestionsForFj(examid,studentid,subjectid);
380
-        for(Map map : list){
378
+    public List<Map> listStudentErrorQuestionsFj(Integer examid, Integer studentid, String subjectid) {
379
+        List<Map> list = eRstudentMapper.listStudentErrorQuestionsForFj(examid, studentid, subjectid);
380
+        for (Map map : list) {
381 381
             Double stuscore = Double.parseDouble(map.get("stuscore").toString());
382
-            Double pscore = Double .parseDouble(map.get("qscore").toString());
383
-            Double srate = N_Utils.getDoubleDivideAndMulitiply(stuscore,pscore);
384
-            map.put("srate",srate);
382
+            Double pscore = Double.parseDouble(map.get("qscore").toString());
383
+            Double srate = N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore);
384
+            map.put("srate", srate);
385 385
         }
386 386
         return list;
387 387
     }

+ 3
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml Целия файл

@@ -132,8 +132,10 @@
132 132
 
133 133
     <!--报告生成-学生试卷-->
134 134
     <select id="listExamStudentsAnswer" resultType="com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion">
135
-        select q.epsqid,q.classid,q.studentid,q.epid,q.eptqid,q.ctype,q.qn,q.answertype,q.stuanswer,q.qscore,q.stuscore,q.good,q.bad,u.username stuname
135
+        select q.epsqid,q.classid,q.studentid,q.epid,q.eptqid,q.ctype,q.qn,q.answertype,q.stuanswer,q.qscore,
136
+        q.stuscore,q.good,q.bad,u.username stuname,pq.answer
136 137
         from e_paper_student_question q left join e_paper_student s on s.epsid=q.epsid
138
+        left join e_paper_qtype_question pq on q.eptqid=pq.eptqid
137 139
         left join t_user u on q.studentid=u.userid where s.examid=#{examid} and s.sstate=2 group by q.epsqid
138 140
     </select>
139 141
 

+ 10
- 1
sexam/src/test/java/com/xhkjedu/sexam/SexamApplicationTests.java Целия файл

@@ -1,13 +1,22 @@
1 1
 package com.xhkjedu.sexam;
2 2
 
3
+import com.xhkjedu.sexam.model.paper.EPaper;
4
+import com.xhkjedu.sexam.service.paper.EPaperQtypeService;
5
+import com.xhkjedu.sexam.service.report.EReportGenerateService;
3 6
 import org.junit.jupiter.api.Test;
4 7
 import org.springframework.boot.test.context.SpringBootTest;
8
+
9
+import javax.annotation.Resource;
10
+
5 11
 @SpringBootTest
6 12
 class SexamApplicationTests {
7 13
 
14
+    @Resource
15
+    private EReportGenerateService eReportGenerateService;
16
+
8 17
     @Test
9 18
     void contextLoads() {
10
-
19
+//        eReportGenerateService.saveClassQuestions(2);
11 20
     }
12 21
 
13 22
 }

Loading…
Отказ
Запис