Browse Source

修改学生试卷分值时列表

tags/正式版本
王宁 2 years ago
parent
commit
0052952b01

+ 0
- 4
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperQtypeController.java View File

68
     @PostMapping("/answer")
68
     @PostMapping("/answer")
69
     public ResultVo setPaperQuestionAnswer(@RequestBody EPaper paper){
69
     public ResultVo setPaperQuestionAnswer(@RequestBody EPaper paper){
70
         N_Utils.validation(new Object[]{paper.getEpid(),"试卷id",1});
70
         N_Utils.validation(new Object[]{paper.getEpid(),"试卷id",1});
71
-        List<EPaperQtypeQuestion> ques = paper.getQuestions();//试题
72
-        if(ques == null || ques.size() ==0){
73
-            return new ResultVo(1,"未设置试题");
74
-        }
75
         ePaperQtypeService.saveQuesitonAnswer(paper);
71
         ePaperQtypeService.saveQuesitonAnswer(paper);
76
         return new ResultVo(0,"设置成功");
72
         return new ResultVo(0,"设置成功");
77
     }
73
     }

+ 13
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java View File

150
         }
150
         }
151
     }
151
     }
152
 
152
 
153
+    //学生试卷作答及得分
154
+    @PostMapping("/spscore")
155
+    public ResultVo getStudentPaperScore(@RequestBody EPaperStudent ps) {
156
+        try {
157
+            N_Utils.validation(new Object[]{ps.getStudentid(),"学生id",1,ps.getEpid(),"试卷id",1});
158
+            Map map = ePaperStudentService.getStudentPaperScore(ps.getStudentid(),ps.getEpid());
159
+            return new ResultVo(0, "成功获取学生试卷作答及得分",map);
160
+        } catch (Exception e) {
161
+            log.error("获取学生试卷作答及得分失败:" + e.getMessage());
162
+            return new ResultVo(1, "获取学生试卷作答及得分失败");
163
+        }
164
+    }
165
+
153
 }
166
 }

+ 1
- 1
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EScanbatchController.java View File

28
     //保持批次信息
28
     //保持批次信息
29
     @PostMapping("/save")
29
     @PostMapping("/save")
30
     public ResultVo saveEscanbatch(@RequestBody EScanbatch eScanbatch) {
30
     public ResultVo saveEscanbatch(@RequestBody EScanbatch eScanbatch) {
31
-        N_Utils.validation(new Object[]{eScanbatch.getEpid(),"试卷id",1,eScanbatch.getMac(),"设备",2});
31
+        N_Utils.validation(new Object[]{eScanbatch.getEpid(),"试卷id",1,eScanbatch.getDevice(),"设备",2});
32
         Map map = eScanbatchService.saveScanBatch(eScanbatch);
32
         Map map = eScanbatchService.saveScanBatch(eScanbatch);
33
         return new ResultVo(0, "成功保存", map);
33
         return new ResultVo(0, "成功保存", map);
34
     }
34
     }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java View File

60
 
60
 
61
     //更改单个学生试卷分值
61
     //更改单个学生试卷分值
62
     void updateStuPaperscoreEpsid(@Param("epsid")Integer epsid);
62
     void updateStuPaperscoreEpsid(@Param("epsid")Integer epsid);
63
+
64
+    //获取学生试卷基础信息和得分
65
+    Map getStudentPaperScore(@Param("studentid") Integer studentid,@Param("epid") Integer epid);
63
 }
66
 }

+ 7
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentQuestionMapper.java View File

9
 import org.springframework.stereotype.Repository;
9
 import org.springframework.stereotype.Repository;
10
 
10
 
11
 import java.util.List;
11
 import java.util.List;
12
+import java.util.Map;
12
 
13
 
13
 /**
14
 /**
14
  * @Description 学生试卷试题
15
  * @Description 学生试卷试题
57
     //根据试题id获取考试信息
58
     //根据试题id获取考试信息
58
     EPaperStudentQuestion getExamPaperStudntQuestionbyEpsqid(@Param("epsqid")Integer epsqid);
59
     EPaperStudentQuestion getExamPaperStudntQuestionbyEpsqid(@Param("epsqid")Integer epsqid);
59
 
60
 
61
+    //学生作答得分试卷-题库
62
+    List<Map> listQStuQuestionScore(@Param("epsid")Integer epsid);
63
+
64
+    //学生作答得分试卷-附件
65
+    List<Map> listFjStuQuestionScore(@Param("epsid")Integer epsid);
66
+
60
 }
67
 }

+ 3
- 1
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EScanbatch.java View File

5
 
5
 
6
 import javax.persistence.Id;
6
 import javax.persistence.Id;
7
 import javax.persistence.Table;
7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8
 
9
 
9
 /**
10
 /**
10
  * @Description: 扫描答题卡批次表
11
  * @Description: 扫描答题卡批次表
45
     private Integer createtime;
46
     private Integer createtime;
46
 
47
 
47
     //扫描仪mac地址
48
     //扫描仪mac地址
48
-    private String mac;
49
+    @Transient
50
+    private String device;
49
 
51
 
50
 
52
 
51
 }
53
 }

+ 9
- 7
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java View File

490
     @Transactional(rollbackFor = Exception.class)
490
     @Transactional(rollbackFor = Exception.class)
491
     public void saveQuesitonAnswer(EPaper ePaper){
491
     public void saveQuesitonAnswer(EPaper ePaper){
492
         List<EPaperQtypeQuestion> questions = ePaper.getQuestions();
492
         List<EPaperQtypeQuestion> questions = ePaper.getQuestions();
493
-        ePaperQtypeMapper.updateBatchQuestionAnswer(questions);
494
-        ePaper.setAnswered(1);
495
-        ePaperMapper.updateEPaperAnswered(ePaper);
496
-        //设置完答案进行匹配
493
+        if(questions != null && questions.size() > 0){
494
+            ePaperQtypeMapper.updateBatchQuestionAnswer(questions);
495
+            ePaper.setAnswered(1);
496
+            ePaperMapper.updateEPaperAnswered(ePaper);
497
+            //设置完答案进行匹配
498
+            setChangeQuestionAnswer(questions,ePaper.getEpid());
499
+        }
497
     }
500
     }
498
 
501
 
502
+    //对于已经开始考试的试卷修改正确答案重新判断试题
499
     private void setChangeQuestionAnswer(List<EPaperQtypeQuestion> questions,Integer epid){
503
     private void setChangeQuestionAnswer(List<EPaperQtypeQuestion> questions,Integer epid){
500
         //获取考试对应的状态,如果考试状态未进行中或者已结束,则需要更改学生已提交试卷中对应试题的答案
504
         //获取考试对应的状态,如果考试状态未进行中或者已结束,则需要更改学生已提交试卷中对应试题的答案
501
         Map map = ePaperMapper.getExamPaperAndSubject(epid);
505
         Map map = ePaperMapper.getExamPaperAndSubject(epid);
527
                         for(EPaperStudentQuestion cq : cqlist){
531
                         for(EPaperStudentQuestion cq : cqlist){
528
                             Double stuscore = 0D;
532
                             Double stuscore = 0D;
529
                             List<String> stuanswers = JSON.parseArray(cq.getStuanswer(),String.class);
533
                             List<String> stuanswers = JSON.parseArray(cq.getStuanswer(),String.class);
530
-                            if(N_Utils.isListEmpty(stuanswers)){
531
-                                break;
532
-                            }else{
534
+                            if(N_Utils.isListNotEmpty(stuanswers)){
533
                                 if(q.getCtype() == 1 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6){
535
                                 if(q.getCtype() == 1 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6){
534
                                     if(q.getAnswer().equalsIgnoreCase(cq.getStuanswer())){
536
                                     if(q.getAnswer().equalsIgnoreCase(cq.getStuanswer())){
535
                                         stuscore = q.getScore();
537
                                         stuscore = q.getScore();

+ 48
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java View File

26
 
26
 
27
 import javax.annotation.Resource;
27
 import javax.annotation.Resource;
28
 import java.util.ArrayList;
28
 import java.util.ArrayList;
29
+import java.util.HashMap;
29
 import java.util.List;
30
 import java.util.List;
30
 import java.util.Map;
31
 import java.util.Map;
32
+import java.util.stream.Collectors;
31
 
33
 
32
 /**
34
 /**
33
  * @Description 学生试卷信息
35
  * @Description 学生试卷信息
537
         eScanbatchMapper.updateErrornum(eScanerror.getBatchid());
539
         eScanbatchMapper.updateErrornum(eScanerror.getBatchid());
538
     }
540
     }
539
 
541
 
542
+    /**
543
+     * @Description 学生试卷作答得分
544
+     * @Param [studentid, epid]
545
+     * @Return java.util.Map
546
+     * @Author wn
547
+     * @Date 2022/8/12 10:45
548
+     **/
549
+    public Map getStudentPaperScore(Integer studentid,Integer epid){
550
+        Map paper = ePaperStudentMapper.getStudentPaperScore(studentid,epid);
551
+        Integer ptype = Integer.parseInt(paper.get("ptype").toString());
552
+        Integer epsid = Integer.parseInt(paper.get("epsid").toString());
553
+        List<Map> qtypeques = null;
554
+        if(ptype == 1){
555
+            qtypeques = ePaperStudentQuestionMapper.listQStuQuestionScore(epsid);
556
+        }else{
557
+            qtypeques = ePaperStudentQuestionMapper.listFjStuQuestionScore(epsid);
558
+        }
559
+        paper.put("qtypes",qtypeques);
560
+        return paper;
561
+    }
562
+
563
+    private void setQuestionsForPaper(List<Map> qtypes){
564
+        for(Map mt : qtypes){
565
+            Integer ctype = Integer.parseInt(mt.get("ctype").toString());
566
+            if(ctype == 11 || ctype == 12){
567
+                List<Map> questions = (List<Map>) mt.get("questions");
568
+                Map<String,List<Map>> quemap = questions.stream().collect(Collectors.groupingBy(o -> o.get("questionpid").toString()));
569
+                List<Map> mqlist = new ArrayList<>();
570
+                for(Map.Entry<String,List<Map>> entry : quemap.entrySet()){
571
+                    List<Map> sonqlst = entry.getValue();
572
+                    Double sontotalsocre = sonqlst.stream().mapToDouble(o -> Double.parseDouble(o.get("score").toString())).sum();
573
+                    Map sque = sonqlst.get(0);
574
+                    Map mque = new HashMap();
575
+                    mque.put("questionid",sque.get("mquestionid").toString());
576
+                    mque.put("qstem",sque.get("mqstem").toString());
577
+                    mque.put("ctype",Integer.parseInt(sque.get("mctype").toString()));
578
+                    mque.put("qtypeid",sque.get("mqtypeid").toString());
579
+                    mque.put("qtypename",sque.get("mqtypename").toString());
580
+                    mque.put("qn",sque.get("qn").toString());
581
+
582
+                }
583
+
584
+            }
585
+        }
586
+    }
587
+
540
 }
588
 }

+ 1
- 1
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EScanbatchService.java View File

40
      * @date: 2022/8/11/011 9:42
40
      * @date: 2022/8/11/011 9:42
41
      **/
41
      **/
42
     public Map saveScanBatch(EScanbatch eScanbatch){
42
     public Map saveScanBatch(EScanbatch eScanbatch){
43
-        String batchname = eScanbatch.getMac() + "-" + eScanbatch.getEpid() + "-";
43
+        String batchname = eScanbatch.getDevice() + "-" + eScanbatch.getEpid() + "-";
44
         //获取数据库中该批次名的扫描批次数量
44
         //获取数据库中该批次名的扫描批次数量
45
         Integer bnum = eScanbatchMapper.getBatchNameLikeNum(batchname);
45
         Integer bnum = eScanbatchMapper.getBatchNameLikeNum(batchname);
46
         if(bnum == null || bnum == 0){
46
         if(bnum == null || bnum == 0){

+ 16
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml View File

98
             <result column="qtypename" property="qtypename"></result>
98
             <result column="qtypename" property="qtypename"></result>
99
             <result column="qctype" property="ctype"></result>
99
             <result column="qctype" property="ctype"></result>
100
             <result column="qstem" property="qstem"></result>
100
             <result column="qstem" property="qstem"></result>
101
+            <result column="hearfile" property="hearfile"></result>
101
             <result column="qoption" property="qoption"></result>
102
             <result column="qoption" property="qoption"></result>
102
             <result column="qanswer" property="qanswer"></result>
103
             <result column="qanswer" property="qanswer"></result>
103
             <result column="qanalyze" property="qanalyze"></result>
104
             <result column="qanalyze" property="qanalyze"></result>
110
             <result column="mqtypeid" property="mqtypeid"></result>
111
             <result column="mqtypeid" property="mqtypeid"></result>
111
             <result column="mqtypename" property="mqtypename"></result>
112
             <result column="mqtypename" property="mqtypename"></result>
112
             <result column="mctype" property="mctype"></result>
113
             <result column="mctype" property="mctype"></result>
114
+            <result column="mhearfile" property="mhearfile"></result>
113
         </collection>
115
         </collection>
114
     </resultMap>
116
     </resultMap>
115
     <!--试题详情-->
117
     <!--试题详情-->
119
                psq.epsqid,psq.questionid,psq.qorder,psq.qn,psq.qscore,psq.answered,psq.answertype,psq.stuanswer,
121
                psq.epsqid,psq.questionid,psq.qorder,psq.qn,psq.qscore,psq.answered,psq.answertype,psq.stuanswer,
120
                psq.stuanswertxt,psq.eptqid,q.qstem,q.qoption,q.ctype qctype,q.hearfile,q.qtypeid,
122
                psq.stuanswertxt,psq.eptqid,q.qstem,q.qoption,q.ctype qctype,q.hearfile,q.qtypeid,
121
                q.qtypename,q.qlevel,q.snum,q.sorder,q.questionpid,mq.questionid mquestionid,mq.qstem mqstem,
123
                q.qtypename,q.qlevel,q.snum,q.sorder,q.questionpid,mq.questionid mquestionid,mq.qstem mqstem,
122
-               mq.qoption mqoption,mq.ctype mctype,mq.qtypeid mqtypeid,mq.qtypename mqtypename
124
+               mq.qoption mqoption,mq.ctype mctype,mq.qtypeid mqtypeid,mq.qtypename mqtypename,mq.hearfile mhearfile
123
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
125
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
124
         left join e_paper_qtype pt on pt.eptid=ptq.eptid
126
         left join e_paper_qtype pt on pt.eptid=ptq.eptid
125
         left join t_question q on psq.questionid=q.questionid
127
         left join t_question q on psq.questionid=q.questionid
197
         update e_paper_student ps set ps.stuscore=(SELECT SUM(IFNULL(q.stuscore,0)) FROM e_paper_student_question q
199
         update e_paper_student ps set ps.stuscore=(SELECT SUM(IFNULL(q.stuscore,0)) FROM e_paper_student_question q
198
           WHERE q.epsid=#{epsid} ) where ps.epsid=#{epsid}
200
           WHERE q.epsid=#{epsid} ) where ps.epsid=#{epsid}
199
     </update>
201
     </update>
202
+
203
+    <!--获取学生试卷基础信息和得分-->
204
+    <select id="getStudentPaperScore" resultType="java.util.Map">
205
+        SELECT ps.epsid,ps.epid,ps.studentid,u.username stuname,u.loginname,ps.stuscore,s.subjectid,s.subjectname,
206
+        e.examname,e.gradeid,c.classname,p.ptype,p.hearfile
207
+        from e_paper_student ps left join e_subject s on ps.esid=s.esid
208
+        left join e_paper p on ps.epid = p.epid
209
+        left join e_base e on ps.examid=e.examid
210
+        left join t_user u on ps.studentid=u.userid
211
+        left join e_class_student cs on cs.studentid=ps.studentid
212
+        left join e_class c on cs.classid=c.classid
213
+        where ps.studentid=#{studentid} and ps.epid=#{epid} group by ps.studentid
214
+    </select>
200
 </mapper>
215
 </mapper>

+ 85
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml View File

147
         where q.epsqid=#{epsqid}
147
         where q.epsqid=#{epsqid}
148
     </select>
148
     </select>
149
 
149
 
150
+    <!--学生作答试卷题库-->
151
+    <resultMap id="qtypesQuestion" type="java.util.Map">
152
+        <result column="ctype" property="ctype"></result>
153
+        <result column="eptname" property="eptname"></result>
154
+        <result column="eptnum" property="eptnum"></result>
155
+        <result column="eptorder" property="eptorder"></result>
156
+        <result column="eptscore" property="eptscore"></result>
157
+        <collection property="questions" ofType="java.util.Map" javaType="java.util.List">
158
+            <result column="epsqid" property="epsqid"></result>
159
+            <result column="questionid" property="questionid"></result>
160
+            <result column="score" property="score"></result>
161
+            <result column="qorder" property="qorder"></result>
162
+            <result column="qn" property="qn"></result>
163
+            <result column="answer" property="answer"></result>
164
+            <result column="stuanswer" property="stuanswer"></result>
165
+            <result column="stuscore" property="stuscore"></result>
166
+            <result column="answered" property="answered"></result>
167
+            <result column="answertype" property="answertype"></result>
168
+            <result column="stuanswer" property="stuanswer"></result>
169
+            <result column="stuanswertxt" property="stuanswertxt"></result>
170
+            <result column="eptqid" property="eptqid"></result>
171
+            <result column="qtypeid" property="qtypeid"></result>
172
+            <result column="qtypename" property="qtypename"></result>
173
+            <result column="qctype" property="ctype"></result>
174
+            <result column="qstem" property="qstem"></result>
175
+            <result column="hearfile" property="hearfile"></result>
176
+            <result column="qoption" property="qoption"></result>
177
+            <result column="qlevel" property="qlevel"></result>
178
+            <result column="sorder" property="sorder"></result>
179
+            <result column="snum" property="snum"></result>
180
+            <result column="questionpid" property="questionpid"></result>
181
+            <result column="mquestionid" property="mquestionid"></result>
182
+            <result column="mqstem" property="mqstem"></result>
183
+            <result column="mqtypeid" property="mqtypeid"></result>
184
+            <result column="mqtypename" property="mqtypename"></result>
185
+            <result column="mctype" property="mctype"></result>
186
+            <result column="mhearfile" property="mhearfile"></result>
187
+        </collection>
188
+    </resultMap>
189
+    <select id="listQStuQuestionScore" resultMap="qtypesQuestion">
190
+        select pt.ctype,pt.eptname,pt.eptnum,pt.eptorder,pt.eptscore,
191
+               psq.epsqid,psq.questionid,psq.qorder,psq.qn,ptq.score,ptq.answer,psq.answered,psq.answertype,psq.stuanswer,
192
+               psq.stuanswertxt,psq.eptqid,psq.stuscore,q.qstem,q.qoption,q.ctype qctype,q.hearfile,q.qtypeid,
193
+               q.qtypename,q.qlevel,q.snum,q.sorder,q.questionpid,mq.questionid mquestionid,mq.qstem mqstem,
194
+               mq.qoption mqoption,mq.ctype mctype,mq.qtypeid mqtypeid,mq.qtypename mqtypename,mq.hearfile mhearfile
195
+        from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
196
+        left join e_paper_qtype pt on pt.eptid=ptq.eptid
197
+        left join t_question q on psq.questionid=q.questionid
198
+        left join t_question mq on q.questionpid=mq.questionid
199
+        where psq.epsid=#{epsid} order by pt.eptorder,psq.qorder
200
+    </select>
201
+
202
+
203
+    <!--学生作答得分试卷附件-->
204
+    <resultMap id="fjtypeQuestions" type="java.util.Map">
205
+        <result column="ctype" property="ctype"></result>
206
+        <result column="eptname" property="eptname"></result>
207
+        <result column="eptnum" property="eptnum"></result>
208
+        <result column="eptorder" property="eptorder"></result>
209
+        <result column="eptscore" property="eptscore"></result>
210
+        <collection property="questions" ofType="java.util.Map" javaType="java.util.Map">
211
+            <result column="epsqid" property="epsqid"></result>
212
+            <result column="score" property="score"></result>
213
+            <result column="qorder" property="qorder"></result>
214
+            <result column="qn" property="qn"></result>
215
+            <result column="eptqid" property="eptqid"></result>
216
+            <result column="qtypename" property="qtypename"></result>
217
+            <result column="qctype" property="ctype"></result>
218
+            <result column="optionnum" property="optionnum"></result>
219
+            <result column="answer" property="answer"></result>
220
+            <result column="stuscore" property="stuscore"></result>
221
+            <result column="answered" property="answered"></result>
222
+            <result column="answertype" property="answertype"></result>
223
+            <result column="stuanswer" property="stuanswer"></result>
224
+            <result column="stuanswertxt" property="stuanswertxt"></result>
225
+        </collection>
226
+    </resultMap>
227
+    <select id="listFjStuQuestionScore" resultMap="fjtypeQuestions">
228
+        select pt.ctype,pt.eptname,pt.eptnum,pt.eptorder,pt.eptscore,psq.epsqid,psq.qn,psq.qorder,psq.answered,psq.answertype,
229
+        psq.stuanswer,psq.stuanswertxt,psq.eptqid,psq.qscore score,psq.stuscore,pq.answer,pq.optionnum,pq.ctype qctype,pq.qtypename
230
+        from e_paper_student_question psq left join e_paper_qtype_question pq on psq.eptqid=pq.eptqid
231
+        left join e_paper_qtype pt on pq.eptid=pt.eptid
232
+        where psq.epsid=#{epsid} order by pt.eptorder, psq.qorder
233
+    </select>
234
+
150
 </mapper>
235
 </mapper>

Loading…
Cancel
Save