Sfoglia il codice sorgente

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

tags/正式版本
雍文秀 2 anni fa
parent
commit
ef02469d48

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

@@ -530,4 +530,16 @@ public class EBaseController {
530 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 Vedi File

@@ -1,5 +1,7 @@
1 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 5
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
4 6
 import org.apache.ibatis.annotations.Param;
5 7
 
@@ -36,4 +38,16 @@ public interface EReportGenerateMapper {
36 38
 
37 39
     //根据考试id获取考试模式
38 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 Vedi File

@@ -83,4 +83,7 @@ public class ERclassQuestion extends BaseBean {
83 83
 
84 84
     //违规学生
85 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 Vedi File

@@ -14,6 +14,7 @@ import com.xhkjedu.sexam.mapper.report.ERsubjectMapper;
14 14
 import com.xhkjedu.sexam.mapper.reportclass.*;
15 15
 import com.xhkjedu.sexam.mapper.reportstu.*;
16 16
 import com.xhkjedu.sexam.mapper.system.UserMapper;
17
+import com.xhkjedu.sexam.model.exam.EClass;
17 18
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
18 19
 import com.xhkjedu.sexam.model.report.ERbase;
19 20
 import com.xhkjedu.sexam.model.report.ERrank;
@@ -28,6 +29,7 @@ import com.xhkjedu.sexam.vo.report.ERPointStuScoreVo;
28 29
 import com.xhkjedu.sexam.vo.report.ExamPaperClassVo;
29 30
 import com.xhkjedu.sexam.vo.system.UserVo;
30 31
 import com.xhkjedu.utils.N_Utils;
32
+import lombok.extern.slf4j.Slf4j;
31 33
 import org.springframework.stereotype.Service;
32 34
 import org.springframework.transaction.annotation.Transactional;
33 35
 
@@ -44,6 +46,7 @@ import java.util.stream.Collectors;
44 46
  * @date 2022/8/8 10:04
45 47
  **/
46 48
 @Service
49
+@Slf4j
47 50
 public class EReportGenerateService {
48 51
     @Resource
49 52
     private EReportGenerateMapper eReportGenerateMapper;
@@ -1726,7 +1729,9 @@ public class EReportGenerateService {
1726 1729
         String key2 = "";
1727 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 1735
             EPaperStudentQuestion sq = classStu.get(i);
1731 1736
             String stuanswer = sq.getStuanswer();
1732 1737
             if (q.getCtype() == 1 || q.getCtype() == 2 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6) {
@@ -1761,9 +1766,9 @@ public class EReportGenerateService {
1761 1766
                 if (i == 0) {
1762 1767
                     answermap = new LinkedHashMap<>();
1763 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 1772
                     String str8 = N_Utils.formatDouble(score8);
1768 1773
                     String str5 = N_Utils.formatDouble(score5);
1769 1774
                     key1 = str8 + "-" + str10;
@@ -1819,8 +1824,24 @@ public class EReportGenerateService {
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 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 1845
         rtnmap.put("goodlist", JSON.toJSONString(goodlist));
1825 1846
         rtnmap.put("badlist", JSON.toJSONString(badlist));
1826 1847
         rtnmap.put("erroroption",erroroption);
@@ -1905,6 +1926,7 @@ public class EReportGenerateService {
1905 1926
                         ercq.setGradesrate(qgsrate);
1906 1927
                         //处理单选题选项情况
1907 1928
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
1929
+                        ercq.setFullscorenum(N_Utils.str2Int(stuansmap.get("fullscorenum").toString()));
1908 1930
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
1909 1931
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
1910 1932
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
@@ -2136,6 +2158,7 @@ public class EReportGenerateService {
2136 2158
                         ercq.setGradesrate(N_Utils.getDoubleDivideAndMulitiply(qgstuscore,qgscore));
2137 2159
                         //处理单选题选项情况
2138 2160
                         Map stuansmap = setPaperQuestionsForStuAnswer(qcstulist);
2161
+                        ercq.setFullscorenum(N_Utils.str2Int(stuansmap.get("fullscorenum").toString()));
2139 2162
                         ercq.setAnswerjson(stuansmap.get("answerlist").toString());
2140 2163
                         if(N_Utils.isNotEmpty(stuansmap.get("goodlist"))){
2141 2164
                             ercq.setGoodstujson(stuansmap.get("goodlist").toString());
@@ -2441,4 +2464,50 @@ public class EReportGenerateService {
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 Vedi File

@@ -11,7 +11,7 @@
11 11
     <!--试卷概况-题库-->
12 12
     <select id="listTkSjGk" resultType="java.util.Map">
13 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 15
         from e_rclass_question erq
16 16
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}
17 17
         and erq.subjectid=#{rank.subjectid}
@@ -30,7 +30,7 @@
30 30
     <!--试卷概况-附件-->
31 31
     <select id="listFjSjGk" resultType="java.util.Map">
32 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 34
         ,epqq.ctype,epqq.score,epqq.answer,epqq.qtypename,epqq.optionnum
35 35
         from e_rclass_question erq left join e_paper_qtype_question epqq on erq.eptqid = epqq.eptqid
36 36
         where erq.examid=#{rank.examid} and erq.classid=#{rank.classid}

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

@@ -64,4 +64,27 @@
64 64
     <select id="getExamModeById" resultType="java.lang.Integer">
65 65
         select exammode from e_base where examid=#{examid}
66 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 90
 </mapper>

Loading…
Annulla
Salva