Browse Source

优化学生报告

tags/正式版本
王宁 2 years ago
parent
commit
82bc13df67

+ 68
- 94
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sexam.service.report;
2 2
 
3
+import ch.qos.logback.core.net.SyslogOutputStream;
3 4
 import com.alibaba.fastjson.JSON;
4 5
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
5 6
 import com.xhkjedu.sexam.mapper.paper.EPaperAnalyzeMapper;
@@ -1010,7 +1011,6 @@ public class EReportGenerateService {
1010 1011
     private void setClassQuestion(Integer examid, List<Map> subjects, List<Map> classes) {
1011 1012
         //考试所有学生提交试卷作答情况
1012 1013
         List<EPaperStudentQuestion> stulist = ePaperStudentQuestionMapper.listExamStudentsAnswer(examid);
1013
-
1014 1014
         List<ERclassQtype> rtypelist = new ArrayList<>();//班级题型
1015 1015
         List<ERStudentQtype> stutypelist = new ArrayList<>();//学生题型
1016 1016
         List<ERclassQuestion> rqueslist = new ArrayList<>();//班级试题
@@ -1036,12 +1036,12 @@ public class EReportGenerateService {
1036 1036
 
1037 1037
             if (ptype == 1) {
1038 1038
                 //处理题型下试题:题库显示题号时为母题的题号即order(qn是英语为顺延题号其他学科为母题号和子题排序拼接)
1039
-//                String qtypejson = panalyze.get("qnumjson").toString();//原试卷题型分析
1040
-//                List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
1041
-//                setPaperQuestionTkQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo);
1039
+                String qtypejson = panalyze.get("qnumjson").toString();//原试卷题型分析
1040
+                List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
1041
+                setPaperQuestionTkQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo);
1042 1042
 
1043 1043
                 //处理知识点
1044
-//                setEPaperQuestionPoints(panalyze, paperstulist, rpointlist, stupointlist, examPaperClassVo);
1044
+                setEPaperQuestionPoints(panalyze, paperstulist, rpointlist, stupointlist, examPaperClassVo);
1045 1045
 
1046 1046
                 //处理难易度
1047 1047
                 String complexityjson = panalyze.get("complexityjson").toString();
@@ -1055,13 +1055,15 @@ public class EReportGenerateService {
1055 1055
                 setPaperQuestionFjQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo);
1056 1056
             }
1057 1057
         }
1058
-//        eRclassQtypeMapper.insertList(rtypelist);
1059
-//        eRstudentQtypeMapper.insertList(stutypelist);
1060
-//        eRclassQuestionMapper.insertList(rqueslist);
1058
+
1059
+
1060
+        eRclassQtypeMapper.insertList(rtypelist);
1061
+        eRstudentQtypeMapper.insertList(stutypelist);
1062
+        eRclassQuestionMapper.insertList(rqueslist);
1061 1063
         eRclassComplexityMapper.insertList(complist);
1062 1064
         erStudentComplexityMapper.insertList(stucomplist);
1063
-//        eRclassPointMapper.insertList(rpointlist);
1064
-//        eRstudentPointMapper.insertList(stupointlist);
1065
+        eRclassPointMapper.insertList(rpointlist);
1066
+        eRstudentPointMapper.insertList(stupointlist);
1065 1067
     }
1066 1068
 
1067 1069
     //题型、试题、知识点、难易度--处理学生选项情况和得分情况
@@ -1373,7 +1375,11 @@ public class EReportGenerateService {
1373 1375
                     Map<Integer, List<EPaperStudentQuestion>> stuQuesMap = stuqlist.stream().collect(Collectors.groupingBy(EPaperStudentQuestion::getStudentid));
1374 1376
                     for (Map.Entry<Integer, List<EPaperStudentQuestion>> entry : stuQuesMap.entrySet()) {
1375 1377
                         List<EPaperStudentQuestion> stuqueslist = entry.getValue();
1376
-                        EPaperStudentQuestion pstq = stuqueslist.get(0);
1378
+                        EPaperStudentQuestion pfist = stuqueslist.get(0);
1379
+                        EPaperStudentQuestion pstq = new EPaperStudentQuestion();
1380
+                        pstq.setClassid(pfist.getClassid());
1381
+                        pstq.setStudentid(entry.getKey());
1382
+
1377 1383
                         Double qstuscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1378 1384
                         Double qscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1379 1385
                         pstq.setQscore(qscore);
@@ -1510,7 +1516,10 @@ public class EReportGenerateService {
1510 1516
                     for(Map.Entry<Integer,List<EPaperStudentQuestion>> entry : stuquesmap.entrySet()){
1511 1517
                         List<EPaperStudentQuestion> stuques = entry.getValue();
1512 1518
                         Double stuscore = stuques.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1513
-                        EPaperStudentQuestion sq = stuques.get(0);
1519
+                        EPaperStudentQuestion sqfirst = stuques.get(0);
1520
+                        EPaperStudentQuestion sq = new EPaperStudentQuestion();
1521
+                        sq.setStudentid(entry.getKey());
1522
+                        sq.setClassid(sqfirst.getClassid());
1514 1523
                         sq.setStuscore(stuscore);
1515 1524
                         setEPaperQuestionPointsForStuQues(gradestulist,sq,points,eptqidsStr);
1516 1525
                     }
@@ -1535,10 +1544,11 @@ public class EReportGenerateService {
1535 1544
             for(Map.Entry<Integer,List<ERPointStuScoreVo>> entry : pointstuscoremap.entrySet()){
1536 1545
                 List<ERPointStuScoreVo> stuscorelist = entry.getValue();
1537 1546
                 Double stuscore = stuscorelist.stream().mapToDouble(ERPointStuScoreVo::getStuscore).sum();
1538
-//                Double qscore = stuscorelist.stream().mapToDouble(ERPointStuScoreVo::getScore).sum();
1539
-                ERPointStuScoreVo sscorevo = stuscorelist.get(0);
1547
+                ERPointStuScoreVo sscorevofirst = stuscorelist.get(0);
1548
+                ERPointStuScoreVo sscorevo = new ERPointStuScoreVo();
1549
+                sscorevo.setStudentid(sscorevofirst.getStudentid());
1550
+                sscorevo.setClassid(sscorevofirst.getClassid());
1540 1551
                 sscorevo.setStuscore(stuscore);
1541
-//                sscorevo.setScore(qscore);
1542 1552
                 pointstuscorelist.add(sscorevo);
1543 1553
             }
1544 1554
 
@@ -1638,107 +1648,71 @@ public class EReportGenerateService {
1638 1648
             List<Map> queslist = (List<Map>) compmap.get("ques");//试题相关对象(数量为几个代表几个母题)
1639 1649
 
1640 1650
             String qns = "";
1641
-            Double tgstuscore = 0.0;//难易度下学生得分
1642
-            Double tgscore = 0.0;//难易度下试题总分
1643
-            Map<Integer, ERClassScoreVo> tclassmap = new HashMap<>();
1644
-            Map<Integer, ERStudentComplexity> tstumap = new HashMap<>();
1645
-
1651
+            List<Integer> leveleptqids = new ArrayList<>();//所有试题id
1646 1652
             for (Map quesmap : queslist) {
1647 1653
                 List<Integer> eptqids = (List<Integer>) quesmap.get("eptqids");
1648
-                Integer qlevel = Integer.parseInt(quesmap.get("qlevel").toString());
1649 1654
                 String order = quesmap.get("order").toString();//试题母题题号
1650 1655
                 qns = qns + order + ",";
1656
+                leveleptqids.addAll(eptqids);
1657
+            }
1651 1658
 
1652
-                //获取集合中对应子题集合的数据
1653
-                List<EPaperStudentQuestion> qgstulist = null;
1654
-                if (qlevel == 1) {
1655
-                    //该题未单题
1656
-                    qgstulist = paperstulist.stream().filter(s -> s.getEptqid().equals(eptqids.get(0))).collect(Collectors.toList());
1657
-                } else {
1658
-                    //该题未复合型试题
1659
-                    qgstulist = new ArrayList<>();
1660
-                    List<EPaperStudentQuestion> stuquelist = paperstulist.stream().filter(s -> eptqids.contains(s.getEptqid())).collect(Collectors.toList());
1661
-                    //母子题情况,计算所有子题的和即为母题。把试题按照学生分组,分组为一组的即为
1662
-                    Map<Integer, List<EPaperStudentQuestion>> stuQuesMap = stuquelist.stream().collect(Collectors.groupingBy(EPaperStudentQuestion::getStudentid));
1663
-                    for (Map.Entry<Integer, List<EPaperStudentQuestion>> entry : stuQuesMap.entrySet()) {
1664
-                        List<EPaperStudentQuestion> stuqueslist = entry.getValue();
1665
-                        EPaperStudentQuestion pstq = stuqueslist.get(0);
1666
-                        Double qstuscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1667
-                        Double qscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1668
-                        pstq.setQscore(qscore);
1669
-                        pstq.setStuscore(qstuscore);
1670
-                        qgstulist.add(pstq);
1671
-                    }
1672
-                }
1673
-                Double qgscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1674
-                Double qgstuscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1675
-                tgscore = ExamUtil.add(tgscore, qgscore);
1676
-                tgstuscore = ExamUtil.add(tgstuscore, qgstuscore);
1677
-
1678
-                for (Map classm : classes) {
1679
-                    Integer classid = Integer.parseInt(classm.get("classid").toString());
1680
-                    List<EPaperStudentQuestion> qcstulist = qgstulist.stream().filter(s -> s.getClassid().equals(classid)).collect(Collectors.toList());
1681
-                    int cstunum = qcstulist.size();//班级下试题作答学生数量
1682
-                    Double qcscore = qcstulist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1683
-                    Double qcstuscore = qcstulist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1684
-
1685
-                    if (tclassmap.containsKey(classid)) {
1686
-                        ERClassScoreVo erClassScoreVo = tclassmap.get(classid);
1687
-                        erClassScoreVo.setStuscore(ExamUtil.add(erClassScoreVo.getStuscore(), qcstuscore));
1688
-                        erClassScoreVo.setCscore(ExamUtil.add(erClassScoreVo.getCscore(), qcscore));
1689
-                    } else {
1690
-                        ERClassScoreVo erClassScoreVo = new ERClassScoreVo();
1691
-                        erClassScoreVo.setStunum(cstunum);
1692
-                        erClassScoreVo.setStuscore(qcstuscore);
1693
-                        erClassScoreVo.setCscore(qcscore);
1694
-                        tclassmap.put(classid, erClassScoreVo);
1695
-                    }
1659
+            List<EPaperStudentQuestion> levelstuquelist = new ArrayList<>();//难易度下所有试题
1660
+            for(Integer eptqid : leveleptqids){
1661
+               List<EPaperStudentQuestion> petqqueslit = paperstulist.stream().filter(s -> eptqid.equals(s.getEptqid())).collect(Collectors.toList());
1662
+               levelstuquelist.addAll(petqqueslit);
1663
+            }
1696 1664
 
1697
-                    for (EPaperStudentQuestion q : qcstulist) {
1698
-                        if (tstumap.containsKey(q.getStudentid())) {
1699
-                            ERStudentComplexity sq = tstumap.get(q.getStudentid());
1700
-                            sq.setStuscore(ExamUtil.add(sq.getStuscore(), q.getStuscore()));
1701
-                        } else {
1702
-                            ERStudentComplexity sq = new ERStudentComplexity();
1703
-                            sq.setClassid(q.getClassid());
1704
-                            sq.setStudentid(q.getStudentid());
1705
-                            sq.setStuscore(q.getStuscore());
1706
-                            tstumap.put(q.getStudentid(),sq);
1707
-                        }
1708
-                    }
1709
-                }
1665
+            List<EPaperStudentQuestion> qgstulist = new ArrayList<>();//每个学生难易度下得分
1666
+            Map<Integer, List<EPaperStudentQuestion>> stuQuesMap = levelstuquelist.stream().collect(Collectors.groupingBy(EPaperStudentQuestion::getStudentid));
1667
+            for (Map.Entry<Integer, List<EPaperStudentQuestion>> entry : stuQuesMap.entrySet()) {
1668
+                List<EPaperStudentQuestion> stuqueslist = entry.getValue();
1669
+                EPaperStudentQuestion pfirst = stuqueslist.get(0);
1670
+                EPaperStudentQuestion pstq = new EPaperStudentQuestion();
1671
+                pstq.setStudentid(entry.getKey());
1672
+                pstq.setClassid(pfirst.getClassid());
1673
+                Double qstuscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1674
+                Double qscore = stuqueslist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1675
+                pstq.setQscore(qscore);
1676
+                pstq.setStuscore(qstuscore);
1677
+                qgstulist.add(pstq);
1678
+
1679
+                ERStudentComplexity stucomp = new ERStudentComplexity();
1680
+                stucomp.setStudentid(entry.getKey());
1681
+                stucomp.setClassid(pstq.getClassid());
1682
+                stucomp.setExamid(examPaperClassVo.getExamid());
1683
+                stucomp.setSubjectid(examPaperClassVo.getSubjectid());
1684
+                stucomp.setEpid(examPaperClassVo.getEpid());
1685
+                stucomp.setComplexity(complexity);
1686
+                stucomp.setStuscore(qstuscore);
1687
+                stucomp.setStusrate(N_Utils.getDoubleDivideAndMulitiply(qstuscore, qscore));
1688
+                stucomplist.add(stucomp);
1710 1689
             }
1711 1690
 
1691
+            Double tgstuscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion :: getStuscore).sum();//难易度下学生得分
1692
+            Double tgscore = qgstulist.stream().mapToDouble(EPaperStudentQuestion :: getQscore).sum();//难易度下试题总分
1712 1693
             Double tgsrate = N_Utils.getDoubleDivideAndMulitiply(tgstuscore, tgscore);//年级得分率
1713 1694
 
1714
-            //难易度--班级得分
1715
-            for (Map.Entry<Integer, ERClassScoreVo> entry : tclassmap.entrySet()) {
1716
-                ERClassScoreVo erClassScoreVo = entry.getValue();
1695
+            for (Map classm : classes) {
1696
+                Integer classid = Integer.parseInt(classm.get("classid").toString());
1697
+                List<EPaperStudentQuestion> qcstulist = qgstulist.stream().filter(s -> s.getClassid().equals(classid)).collect(Collectors.toList());
1698
+                Double qcscore = qcstulist.stream().mapToDouble(EPaperStudentQuestion::getQscore).sum();
1699
+                Double qcstuscore = qcstulist.stream().mapToDouble(EPaperStudentQuestion::getStuscore).sum();
1700
+
1717 1701
                 ERclassComplexity erc = new ERclassComplexity();
1718 1702
                 erc.setExamid(examPaperClassVo.getExamid());
1719 1703
                 erc.setSubjectid(examPaperClassVo.getSubjectid());
1720 1704
                 erc.setEpid(examPaperClassVo.getEpid());
1721
-                erc.setClassid(entry.getKey());
1705
+                erc.setClassid(classid);
1722 1706
                 erc.setComplexity(complexity);
1723 1707
                 erc.setScore(score);
1724 1708
                 erc.setSrate(srate);
1725 1709
                 erc.setGradescore(tgstuscore);
1726 1710
                 erc.setGradesrate(tgsrate);
1727
-                erc.setClassscore(erClassScoreVo.getStuscore());
1728
-                erc.setClasssrate(N_Utils.getDoubleDivideAndMulitiply(erClassScoreVo.getStuscore(), erClassScoreVo.getCscore()));
1711
+                erc.setClassscore(qcstuscore);
1712
+                erc.setClasssrate(N_Utils.getDoubleDivideAndMulitiply(qcstuscore, qcscore));
1729 1713
                 erc.setQns(qns.substring(0, qns.lastIndexOf(",")));
1730 1714
                 complist.add(erc);
1731 1715
             }
1732
-            //难易度--学生得分
1733
-            for (Map.Entry<Integer, ERStudentComplexity> entry : tstumap.entrySet()) {
1734
-                ERStudentComplexity stucomp = entry.getValue();
1735
-                stucomp.setExamid(examPaperClassVo.getExamid());
1736
-                stucomp.setSubjectid(examPaperClassVo.getSubjectid());
1737
-                stucomp.setEpid(examPaperClassVo.getEpid());
1738
-                stucomp.setComplexity(complexity);
1739
-                stucomp.setStusrate(N_Utils.getDoubleDivideAndMulitiply(stucomp.getStuscore(), score));
1740
-                stucomplist.add(stucomp);
1741
-            }
1742 1716
         }
1743 1717
     }
1744 1718
 }

+ 0
- 10
sexam/src/test/java/com/xhkjedu/sexam/SexamApplicationTests.java View File

@@ -1,17 +1,7 @@
1 1
 package com.xhkjedu.sexam;
2 2
 
3
-import com.xhkjedu.sexam.model.paper.EPaper;
4
-import com.xhkjedu.sexam.model.paper.EPaperQtype;
5
-import com.xhkjedu.sexam.model.paper.EPaperQtypeQuestion;
6
-import com.xhkjedu.sexam.service.paper.EPaperQtypeService;
7 3
 import org.junit.jupiter.api.Test;
8 4
 import org.springframework.boot.test.context.SpringBootTest;
9
-
10
-import javax.annotation.Resource;
11
-import java.util.ArrayList;
12
-import java.util.List;
13
-import java.util.Map;
14
-
15 5
 @SpringBootTest
16 6
 class SexamApplicationTests {
17 7
 

Loading…
Cancel
Save