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,10 +68,6 @@ public class EPaperQtypeController {
68 68
     @PostMapping("/answer")
69 69
     public ResultVo setPaperQuestionAnswer(@RequestBody EPaper paper){
70 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 71
         ePaperQtypeService.saveQuesitonAnswer(paper);
76 72
         return new ResultVo(0,"设置成功");
77 73
     }

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

@@ -150,4 +150,17 @@ public class EPaperStudentController {
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,7 +28,7 @@ public class EScanbatchController {
28 28
     //保持批次信息
29 29
     @PostMapping("/save")
30 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 32
         Map map = eScanbatchService.saveScanBatch(eScanbatch);
33 33
         return new ResultVo(0, "成功保存", map);
34 34
     }

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

@@ -60,4 +60,7 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
60 60
 
61 61
     //更改单个学生试卷分值
62 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,6 +9,7 @@ import org.springframework.jmx.export.annotation.ManagedOperationParameter;
9 9
 import org.springframework.stereotype.Repository;
10 10
 
11 11
 import java.util.List;
12
+import java.util.Map;
12 13
 
13 14
 /**
14 15
  * @Description 学生试卷试题
@@ -57,4 +58,10 @@ public interface EPaperStudentQuestionMapper extends TkMapper<EPaperStudentQuest
57 58
     //根据试题id获取考试信息
58 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,6 +5,7 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8 9
 
9 10
 /**
10 11
  * @Description: 扫描答题卡批次表
@@ -45,7 +46,8 @@ public class EScanbatch extends BaseBean {
45 46
     private Integer createtime;
46 47
 
47 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,12 +490,16 @@ public class EPaperQtypeService {
490 490
     @Transactional(rollbackFor = Exception.class)
491 491
     public void saveQuesitonAnswer(EPaper ePaper){
492 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 503
     private void setChangeQuestionAnswer(List<EPaperQtypeQuestion> questions,Integer epid){
500 504
         //获取考试对应的状态,如果考试状态未进行中或者已结束,则需要更改学生已提交试卷中对应试题的答案
501 505
         Map map = ePaperMapper.getExamPaperAndSubject(epid);
@@ -527,9 +531,7 @@ public class EPaperQtypeService {
527 531
                         for(EPaperStudentQuestion cq : cqlist){
528 532
                             Double stuscore = 0D;
529 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 535
                                 if(q.getCtype() == 1 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6){
534 536
                                     if(q.getAnswer().equalsIgnoreCase(cq.getStuanswer())){
535 537
                                         stuscore = q.getScore();

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

@@ -26,8 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
26 26
 
27 27
 import javax.annotation.Resource;
28 28
 import java.util.ArrayList;
29
+import java.util.HashMap;
29 30
 import java.util.List;
30 31
 import java.util.Map;
32
+import java.util.stream.Collectors;
31 33
 
32 34
 /**
33 35
  * @Description 学生试卷信息
@@ -537,4 +539,50 @@ public class EPaperStudentService {
537 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,7 +40,7 @@ public class EScanbatchService {
40 40
      * @date: 2022/8/11/011 9:42
41 41
      **/
42 42
     public Map saveScanBatch(EScanbatch eScanbatch){
43
-        String batchname = eScanbatch.getMac() + "-" + eScanbatch.getEpid() + "-";
43
+        String batchname = eScanbatch.getDevice() + "-" + eScanbatch.getEpid() + "-";
44 44
         //获取数据库中该批次名的扫描批次数量
45 45
         Integer bnum = eScanbatchMapper.getBatchNameLikeNum(batchname);
46 46
         if(bnum == null || bnum == 0){

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

@@ -98,6 +98,7 @@
98 98
             <result column="qtypename" property="qtypename"></result>
99 99
             <result column="qctype" property="ctype"></result>
100 100
             <result column="qstem" property="qstem"></result>
101
+            <result column="hearfile" property="hearfile"></result>
101 102
             <result column="qoption" property="qoption"></result>
102 103
             <result column="qanswer" property="qanswer"></result>
103 104
             <result column="qanalyze" property="qanalyze"></result>
@@ -110,6 +111,7 @@
110 111
             <result column="mqtypeid" property="mqtypeid"></result>
111 112
             <result column="mqtypename" property="mqtypename"></result>
112 113
             <result column="mctype" property="mctype"></result>
114
+            <result column="mhearfile" property="mhearfile"></result>
113 115
         </collection>
114 116
     </resultMap>
115 117
     <!--试题详情-->
@@ -119,7 +121,7 @@
119 121
                psq.epsqid,psq.questionid,psq.qorder,psq.qn,psq.qscore,psq.answered,psq.answertype,psq.stuanswer,
120 122
                psq.stuanswertxt,psq.eptqid,q.qstem,q.qoption,q.ctype qctype,q.hearfile,q.qtypeid,
121 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 125
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
124 126
         left join e_paper_qtype pt on pt.eptid=ptq.eptid
125 127
         left join t_question q on psq.questionid=q.questionid
@@ -197,4 +199,17 @@
197 199
         update e_paper_student ps set ps.stuscore=(SELECT SUM(IFNULL(q.stuscore,0)) FROM e_paper_student_question q
198 200
           WHERE q.epsid=#{epsid} ) where ps.epsid=#{epsid}
199 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 215
 </mapper>

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

@@ -147,4 +147,89 @@
147 147
         where q.epsqid=#{epsqid}
148 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 235
 </mapper>

Loading…
Cancel
Save