Browse Source

处理班级试题作答详情和满分

tags/正式版本
雍文秀 2 years ago
parent
commit
ef02469d48

+ 12
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java View File

530
         return new ResultVo(0, "设置成功");
530
         return new ResultVo(0, "设置成功");
531
     }
531
     }
532
 
532
 
533
+    /*
534
+     * 处理班级试题作答详情和满分
535
+     * @Param []
536
+     * @Author ywx
537
+     * @Date 2022/11/23 15:13
538
+     * @return com.xhkjedu.vo.ResultVo
539
+     **/
540
+    @PostMapping("/handle_answerjson")
541
+    public ResultVo handleAnswerjson() {
542
+        eReportGenerateService.handleAnswerjson();
543
+        return new ResultVo(0, "设置成功");
544
+    }
533
 }
545
 }

+ 14
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/report/EReportGenerateMapper.java View File

1
 package com.xhkjedu.sexam.mapper.report;
1
 package com.xhkjedu.sexam.mapper.report;
2
 
2
 
3
+import com.xhkjedu.sexam.model.exam.EClass;
4
+import com.xhkjedu.sexam.model.reportclass.ERclassQuestion;
3
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
5
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
4
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
5
 
7
 
36
 
38
 
37
     //根据考试id获取考试模式
39
     //根据考试id获取考试模式
38
     Integer getExamModeById(@Param("examid") Integer examid);
40
     Integer getExamModeById(@Param("examid") Integer examid);
41
+
42
+    //获取未处理的学生作答情况
43
+    List<ERclassQuestion> listAnswerJson();
44
+
45
+    //获取复合题满分人数
46
+    Integer getFullscorenum(@Param("q") ERclassQuestion q);
47
+
48
+    //获取考试班级集合
49
+    List<EClass> listClassByExamIds(@Param("examids") List<Integer> examids);
50
+
51
+    //更新班级试题作答详情和满分
52
+    void updateClassQuestion(@Param("q") ERclassQuestion q);
39
 }
53
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/reportclass/ERclassQuestion.java View File

83
 
83
 
84
     //违规学生
84
     //违规学生
85
     private String badstujson;
85
     private String badstujson;
86
+
87
+    //满分人数
88
+    private Integer fullscorenum;
86
 }
89
 }

+ 74
- 5
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

14
 import com.xhkjedu.sexam.mapper.reportclass.*;
14
 import com.xhkjedu.sexam.mapper.reportclass.*;
15
 import com.xhkjedu.sexam.mapper.reportstu.*;
15
 import com.xhkjedu.sexam.mapper.reportstu.*;
16
 import com.xhkjedu.sexam.mapper.system.UserMapper;
16
 import com.xhkjedu.sexam.mapper.system.UserMapper;
17
+import com.xhkjedu.sexam.model.exam.EClass;
17
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
18
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
18
 import com.xhkjedu.sexam.model.report.ERbase;
19
 import com.xhkjedu.sexam.model.report.ERbase;
19
 import com.xhkjedu.sexam.model.report.ERrank;
20
 import com.xhkjedu.sexam.model.report.ERrank;
28
 import com.xhkjedu.sexam.vo.report.ExamPaperClassVo;
29
 import com.xhkjedu.sexam.vo.report.ExamPaperClassVo;
29
 import com.xhkjedu.sexam.vo.system.UserVo;
30
 import com.xhkjedu.sexam.vo.system.UserVo;
30
 import com.xhkjedu.utils.N_Utils;
31
 import com.xhkjedu.utils.N_Utils;
32
+import lombok.extern.slf4j.Slf4j;
31
 import org.springframework.stereotype.Service;
33
 import org.springframework.stereotype.Service;
32
 import org.springframework.transaction.annotation.Transactional;
34
 import org.springframework.transaction.annotation.Transactional;
33
 
35
 
44
  * @date 2022/8/8 10:04
46
  * @date 2022/8/8 10:04
45
  **/
47
  **/
46
 @Service
48
 @Service
49
+@Slf4j
47
 public class EReportGenerateService {
50
 public class EReportGenerateService {
48
     @Resource
51
     @Resource
49
     private EReportGenerateMapper eReportGenerateMapper;
52
     private EReportGenerateMapper eReportGenerateMapper;
1726
         String key2 = "";
1729
         String key2 = "";
1727
         String key3 = "";
1730
         String key3 = "";
1728
 
1731
 
1729
-        for (int i = 0; i < classStu.size(); i++) {
1732
+        Double qscore = q.getQscore();
1733
+        int stunum = classStu.size();
1734
+        for (int i = 0; i < stunum; i++) {
1730
             EPaperStudentQuestion sq = classStu.get(i);
1735
             EPaperStudentQuestion sq = classStu.get(i);
1731
             String stuanswer = sq.getStuanswer();
1736
             String stuanswer = sq.getStuanswer();
1732
             if (q.getCtype() == 1 || q.getCtype() == 2 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6) {
1737
             if (q.getCtype() == 1 || q.getCtype() == 2 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6) {
1761
                 if (i == 0) {
1766
                 if (i == 0) {
1762
                     answermap = new LinkedHashMap<>();
1767
                     answermap = new LinkedHashMap<>();
1763
                     //处理分数分段对应,用于分数段[0,50%)   [50%,80%),  [80%,100%]
1768
                     //处理分数分段对应,用于分数段[0,50%)   [50%,80%),  [80%,100%]
1764
-                    score8 = ExamUtil.getScoreRateScore(q.getQscore(), 0.8);
1765
-                    score5 = ExamUtil.getScoreRateScore(q.getQscore(), 0.5);
1766
-                    String str10 = N_Utils.formatDouble(q.getQscore());
1769
+                    score8 = ExamUtil.getScoreRateScore(qscore, 0.8);
1770
+                    score5 = ExamUtil.getScoreRateScore(qscore, 0.5);
1771
+                    String str10 = N_Utils.formatDouble(qscore);
1767
                     String str8 = N_Utils.formatDouble(score8);
1772
                     String str8 = N_Utils.formatDouble(score8);
1768
                     String str5 = N_Utils.formatDouble(score5);
1773
                     String str5 = N_Utils.formatDouble(score5);
1769
                     key1 = str8 + "-" + str10;
1774
                     key1 = str8 + "-" + str10;
1819
             }
1824
             }
1820
         }
1825
         }
1821
 
1826
 
1827
+        List<Map> dafblist = new ArrayList<>();//答案分布
1828
+        Map<String, Map> dafbmap = new HashMap<>();//答案分布
1829
+        for (Map.Entry<String, List<Map>> entry : answermap.entrySet()) {
1830
+            String key = entry.getKey();
1831
+            List<Map> students = entry.getValue();
1832
+            Map dafb = new HashMap();
1833
+            int num = students.size();
1834
+            dafb.put("students", students);
1835
+            dafb.put("num", num);
1836
+            dafb.put("numrate", N_Utils.getIntegerDivideAndMulitiply(num, stunum));
1837
+            dafbmap.put(key, dafb);
1838
+        }
1839
+
1822
         Map rtnmap = new HashMap();
1840
         Map rtnmap = new HashMap();
1823
-        rtnmap.put("answerlist", JSON.toJSONString(answermap));
1841
+        rtnmap.put("answerlist", JSON.toJSONString(dafbmap));
1842
+        long fullscorenum = classStu.stream().filter(c -> qscore.equals(c.getStuscore())).count();
1843
+        rtnmap.put("fullscorenum", fullscorenum);
1844
+        rtnmap.put("dafbjson", JSON.toJSONString(dafblist));
1824
         rtnmap.put("goodlist", JSON.toJSONString(goodlist));
1845
         rtnmap.put("goodlist", JSON.toJSONString(goodlist));
1825
         rtnmap.put("badlist", JSON.toJSONString(badlist));
1846
         rtnmap.put("badlist", JSON.toJSONString(badlist));
1826
         rtnmap.put("erroroption",erroroption);
1847
         rtnmap.put("erroroption",erroroption);
1905
                         ercq.setGradesrate(qgsrate);
1926
                         ercq.setGradesrate(qgsrate);
1906
                         //处理单选题选项情况
1927
                         //处理单选题选项情况
1907
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
1928
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
1929
+                        ercq.setFullscorenum(N_Utils.str2Int(stuansmap.get("fullscorenum").toString()));
1908
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
1930
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
1909
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
1931
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
1910
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
1932
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
2136
                         ercq.setGradesrate(N_Utils.getDoubleDivideAndMulitiply(qgstuscore,qgscore));
2158
                         ercq.setGradesrate(N_Utils.getDoubleDivideAndMulitiply(qgstuscore,qgscore));
2137
                         //处理单选题选项情况
2159
                         //处理单选题选项情况
2138
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
2160
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
2161
+                        ercq.setFullscorenum(N_Utils.str2Int(stuansmap.get("fullscorenum").toString()));
2139
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
2162
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
2140
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
2163
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
2141
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
2164
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
2441
             }
2464
             }
2442
         }
2465
         }
2443
     }
2466
     }
2467
+
2468
+    //处理班级试题作答详情和满分
2469
+    public void handleAnswerjson() {
2470
+        List<ERclassQuestion> list = eReportGenerateMapper.listAnswerJson();//获取未处理的学生作答情况
2471
+        List<Integer> examids = list.stream().map(l -> l.getExamid()).distinct().collect(Collectors.toList());
2472
+        List<EClass> classes = eReportGenerateMapper.listClassByExamIds(examids);//获取考试班级集合
2473
+        Map<String, Integer> classMap = classes.stream().collect(Collectors.toMap(
2474
+                c -> c.getExamid() + "_" + c.getClassid(), c -> c.getClassnum()));
2475
+        for (ERclassQuestion q : list) {
2476
+            new Thread(()->{
2477
+                try {
2478
+                    updateClassQuestion(classMap, q);
2479
+                }catch (Exception e){
2480
+                    log.error("处理单个班级试题重试:" + e.getMessage());
2481
+                    try {
2482
+                        updateClassQuestion(classMap, q);
2483
+                    }catch (Exception se){
2484
+                        log.error("处理单个班级试题重试出错:" + se.getMessage());
2485
+                    }
2486
+                }
2487
+            }).start();
2488
+        }
2489
+    }
2490
+
2491
+    //处理单个班级试题
2492
+    private void updateClassQuestion(Map<String, Integer> classMap, ERclassQuestion q) {
2493
+        if (N_Utils.isEmptyInteger(q.getEptqid())) {
2494
+            Integer fullscorenum = eReportGenerateMapper.getFullscorenum(q);
2495
+            q.setFullscorenum(fullscorenum);
2496
+        }
2497
+        Integer stunum = classMap.get(q.getExamid() + "_" + q.getClassid());
2498
+        Map<String, Map> dafbmap = new HashMap<>();//答案分布
2499
+        Map<String, List<Map>> answer = JSON.parseObject(q.getAnswerjson(), Map.class);
2500
+        for (Map.Entry<String, List<Map>> entry : answer.entrySet()) {
2501
+            String key = entry.getKey();
2502
+            List<Map> students = entry.getValue();
2503
+            int num = students.size();
2504
+            Map dafb = new HashMap();
2505
+            dafb.put("students", students);
2506
+            dafb.put("num", num);
2507
+            dafb.put("numrate", N_Utils.getIntegerDivideAndMulitiply(num, stunum));
2508
+            dafbmap.put(key, dafb);
2509
+        }
2510
+        q.setAnswerjson(JSON.toJSONString(dafbmap));
2511
+        eReportGenerateMapper.updateClassQuestion(q);
2512
+    }
2444
 }
2513
 }

+ 2
- 2
sexam/src/main/resources/mapper/report/EReportClassMapper.xml View File

11
     <!--试卷概况-题库-->
11
     <!--试卷概况-题库-->
12
     <select id="listTkSjGk" resultType="java.util.Map">
12
     <select id="listTkSjGk" resultType="java.util.Map">
13
         select erq.qn,erq.qorder,erq.classavgscore,erq.classsrate,erq.gradeavgscore,erq.gradesrate,erq.classratetype
13
         select erq.qn,erq.qorder,erq.classavgscore,erq.classsrate,erq.gradeavgscore,erq.gradesrate,erq.classratetype
14
-        ,erq.answerjson,erq.goodstujson,erq.badstujson,erq.questionid,erq.eptqid,erq.complexity,erq.score
14
+        ,erq.answerjson,erq.fullscorenum,erq.goodstujson,erq.badstujson,erq.questionid,erq.eptqid,erq.complexity,erq.score
15
         from e_rclass_question erq
15
         from e_rclass_question erq
16
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}
16
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}
17
         and erq.subjectid=#{rank.subjectid}
17
         and erq.subjectid=#{rank.subjectid}
30
     <!--试卷概况-附件-->
30
     <!--试卷概况-附件-->
31
     <select id="listFjSjGk" resultType="java.util.Map">
31
     <select id="listFjSjGk" resultType="java.util.Map">
32
         select erq.qn,erq.qorder,erq.classavgscore,erq.classsrate,erq.gradeavgscore,erq.gradesrate
32
         select erq.qn,erq.qorder,erq.classavgscore,erq.classsrate,erq.gradeavgscore,erq.gradesrate
33
-        ,erq.answerjson,erq.goodstujson,erq.badstujson,erq.eptqid,erq.classratetype
33
+        ,erq.answerjson,erq.fullscorenum,erq.goodstujson,erq.badstujson,erq.eptqid,erq.classratetype
34
         ,epqq.ctype,epqq.score,epqq.answer,epqq.qtypename,epqq.optionnum
34
         ,epqq.ctype,epqq.score,epqq.answer,epqq.qtypename,epqq.optionnum
35
         from e_rclass_question erq left join e_paper_qtype_question epqq on erq.eptqid = epqq.eptqid
35
         from e_rclass_question erq left join e_paper_qtype_question epqq on erq.eptqid = epqq.eptqid
36
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}
36
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}

+ 23
- 0
sexam/src/main/resources/mapper/report/EReportGenerateMapper.xml View File

64
     <select id="getExamModeById" resultType="java.lang.Integer">
64
     <select id="getExamModeById" resultType="java.lang.Integer">
65
         select exammode from e_base where examid=#{examid}
65
         select exammode from e_base where examid=#{examid}
66
     </select>
66
     </select>
67
+    <!--获取未处理的学生作答情况-->
68
+    <select id="listAnswerJson" resultType="com.xhkjedu.sexam.model.reportclass.ERclassQuestion">
69
+        select q.answerjson,q.rcqid,q.examid,q.epid,q.classid,q.qn,q.score,q.eptqid
70
+        ,(case when q.eptqid is not null then (select count(*) from e_paper_student_question s
71
+        where s.eptqid=q.eptqid and s.qscore=s.stuscore)
72
+        else 0 end)fullscorenum
73
+        from e_rclass_question q where q.answerjson not like '%numrate%'
74
+    </select>
75
+    <!--获取复合题满分人数-->
76
+    <select id="getFullscorenum" resultType="java.lang.Integer">
77
+        select count(*) from(select sum(s.stuscore)sscore,s.studentid
78
+        from e_paper_student_question s where s.epid=#{q.epid} and find_in_set(s.qn,#{q.qn})
79
+        group by s.studentid )a where a.sscore=#{q.score}
80
+    </select>
81
+    <!--获取考试班级集合-->
82
+    <select id="listClassByExamIds" resultType="com.xhkjedu.sexam.model.exam.EClass">
83
+        select ec.classid,ec.classnum,ec.examid from e_class ec where ec.examid in
84
+        <foreach collection="examids" item="examid" open="(" separator="," close=")">#{examid}</foreach>
85
+    </select>
86
+    <!--更新班级试题作答详情和满分-->
87
+    <update id="updateClassQuestion">
88
+        update e_rclass_question set answerjson=#{q.answerjson},fullscorenum=#{q.fullscorenum} where rcqid=#{q.rcqid}
89
+    </update>
67
 </mapper>
90
 </mapper>

Loading…
Cancel
Save