Ver código fonte

保存扫码答题卡内容

tags/正式版本
王宁 2 anos atrás
pai
commit
e062280521

+ 11
- 4
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java Ver arquivo

@@ -123,15 +123,22 @@ public class EPaperStudentController {
123 123
         }
124 124
     }
125 125
 
126
+    /**
127
+     * @Description 保存扫描的答题卡
128
+     * @Param [ps]
129
+     * @Return com.xhkjedu.vo.ResultVo
130
+     * @Author wn
131
+     * @Date 2022/8/3 14:35
132
+     **/
126 133
     @PostMapping("/sca")
127 134
     public ResultVo saveCommitPaperScantron(@RequestBody PaperStudentWebVo ps) {
128 135
         try {
129
-            N_Utils.validation(new Object[]{ps.getEpid(), "试卷id", 1});
136
+            N_Utils.validation(new Object[]{ps.getEpid(), "试卷id", 1,ps.getExamno(),"考号",2});
130 137
             ePaperStudentService.saveCommitPaperForScantron(ps);
131
-            return new ResultVo(0, "成功提交试卷");
138
+            return new ResultVo(0, "成功保存学生答题卡");
132 139
         } catch (Exception e) {
133
-            log.error("提交试卷(web)失败:" + e.getMessage());
134
-            return new ResultVo(1, "提交失败");
140
+            log.error("保存学生答题卡失败:" + e.getMessage());
141
+            return new ResultVo(1, "保存学生答题卡失败");
135 142
         }
136 143
     }
137 144
 

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java Ver arquivo

@@ -51,4 +51,7 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
51 51
 
52 52
     //根据试卷id批量修改该试卷学生得分
53 53
     void updateBathStudentPaperScoreByEpid(@Param("epid")Integer epid);
54
+
55
+    //根据试卷id和学生id获取学生试卷信息
56
+    EPaperStudent getPaperStudentByStuidAndEpid(@Param("epid")Integer epid,@Param("studentid")Integer studentid);
54 57
 }

+ 5
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentQuestionMapper.java Ver arquivo

@@ -44,4 +44,9 @@ public interface EPaperStudentQuestionMapper extends TkMapper<EPaperStudentQuest
44 44
 
45 45
     //批量修改学生试题分值
46 46
     void updateBatchStuQuestionScore(@Param("list")List<EPaperStudentQuestion> list);
47
+
48
+    //修改缺考学生试卷试题批阅状态
49
+    void updateStuQuestionChecked(@Param("epsid")Integer epsid,@Param("studentid")Integer studentid);
50
+
51
+
47 52
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/system/UserMapper.java Ver arquivo

@@ -21,4 +21,7 @@ public interface UserMapper {
21 21
 
22 22
     //主监考人快捷查找
23 23
     List<Map> listQuickMasterTeacher(@Param("usernames") String[] usernames, @Param("schoolid") Integer schoolid);
24
+
25
+    //根据准考证号获取学生id
26
+    Integer getUseridByExamno(@Param("examno")String examno);
24 27
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EPaperStudent.java Ver arquivo

@@ -58,6 +58,9 @@ public class EPaperStudent extends BaseBean {
58 58
     //学生答题卡作答图片
59 59
     private String stupic;
60 60
 
61
+    //会否违规0未违规1违规
62
+    private Integer hasbad;
63
+
61 64
     //创建时间
62 65
     private Integer createtime;
63 66
 }

+ 1
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Ver arquivo

@@ -195,6 +195,7 @@ public class EBaseService {
195 195
                 es.setStuscore(0.0);
196 196
                 es.setCosttime(0);
197 197
                 es.setCreatetime(timestamp);
198
+                es.setHasbad(0);
198 199
                 studentList.add(es);
199 200
             }
200 201
         }

+ 9
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java Ver arquivo

@@ -604,6 +604,15 @@ public class EPaperQtypeService {
604 604
                     }
605 605
                 }
606 606
             }
607
+
608
+            //设置答题卡需要默认值
609
+            if(eps.get("scantronnote") == null){
610
+                String scantronnote = "1.答题前,考生先将自己的姓名、班级、考场填写清楚,并认真核对条形码上的姓名和准考证号。\n" +
611
+                        "2.选择题部分请按题号用2B铅笔填涂方框,修改时用橡皮擦干净,不留痕迹。\n" +
612
+                        "3.非选择题部分请按题号用0.5毫米黑色墨水签字笔书写,否则作答无效。要求字体工整、笔迹清晰。作图时,必须使用2B铅笔,并描浓\n" +
613
+                        "4.在草稿纸、试题卷上答题无效。";
614
+                eps.put("scantronnote",scantronnote);
615
+            }
607 616
         }
608 617
 
609 618
         Map rtnmap = new HashMap();

+ 42
- 21
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java Ver arquivo

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
4 4
 import com.xhkjedu.sexam.mapper.paper.EPaperQtypeMapper;
5 5
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
6 6
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
7
+import com.xhkjedu.sexam.mapper.system.UserMapper;
7 8
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
8 9
 import com.xhkjedu.sexam.model.paper.EPaperQtypeQuestion;
9 10
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
@@ -38,6 +39,8 @@ public class EPaperStudentService {
38 39
     private EPaperQtypeMapper ePaperQtypeMapper;
39 40
     @Resource
40 41
     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
42
+    @Resource
43
+    private UserMapper userMapper;
41 44
     @Autowired
42 45
     private ConvertUtil convertUtil;
43 46
 
@@ -186,7 +189,7 @@ public class EPaperStudentService {
186 189
         try {
187 190
             //学生作答提交时先判断试卷是否设置的正确答案
188 191
             PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
189
-            setCommitQuestion(psq,answerVo,1);
192
+            setCommitQuestion(psq,answerVo);
190 193
             ePaperStudentQuestionMapper.updateStuAnswer(psq);
191 194
         }catch (Exception e){
192 195
             log.error("提交试题失败:"+e.getMessage());
@@ -195,8 +198,8 @@ public class EPaperStudentService {
195 198
 
196 199
     }
197 200
 
198
-    //判断道题情况
199
-    private void setCommitQuestion(EPaperStudentQuestion psq,PsqAnswerVo answerVo,Integer type){
201
+    //判断道题情况
202
+    private void setCommitQuestion(EPaperStudentQuestion psq,PsqAnswerVo answerVo){
200 203
         int timestamp = N_Utils.getSecondTimestamp();
201 204
         psq.setAnswertime(timestamp);
202 205
         int coverted = 1;//是否转换0未转换1已转换2转换失败
@@ -277,13 +280,8 @@ public class EPaperStudentService {
277 280
                         psq.setChecked(2);
278 281
                         psq.setChecktime(timestamp);
279 282
                     }else{
280
-
281 283
                         if(stuanswers.size() > 0){
282 284
                             coverted = 0;//上传的多张图片设为0未转换
283
-                            if(type == 2){
284
-                                //网页端提交试卷时直接合并多张图片试题
285
-                                convertUtil.imgMerge(psq.getEptqid(),stuanswers,1);
286
-                            }
287 285
                         }
288 286
                     }
289 287
                     psq.setAnswered(1);
@@ -326,12 +324,17 @@ public class EPaperStudentService {
326 324
         }
327 325
         paperStudent.setChecked(checked);
328 326
         ePaperStudentMapper.updateStudentPaper(paperStudent);//修改试卷信息
327
+        chandleStudentQuestionNoconvertedPic(epsid,1);//处理试卷中多张图片未合并情况
328
+    }
329
+
330
+    //处理试卷中未已提交需要合并的图片,type1代表线上2代表扫码答题卡图片
331
+    private void chandleStudentQuestionNoconvertedPic(Integer epsid,Integer type){
329 332
         List<EPaperStudentQuestion> psqlist = ePaperStudentQuestionMapper.listStuQuesitonStuAnswerPic(epsid);
330 333
         if(N_Utils.isListNotEmpty(psqlist)){
331 334
             for(EPaperStudentQuestion sq : psqlist){
332 335
                 List<String> stuanswer = JSON.parseArray(sq.getStuanswer(),String.class);
333 336
                 if(N_Utils.isListNotEmpty(stuanswer) && stuanswer.size()>1){
334
-                    convertUtil.imgMerge(sq.getEpsqid(),stuanswer,1);
337
+                    convertUtil.imgMerge(sq.getEpsqid(),stuanswer,type);
335 338
                 }
336 339
             }
337 340
         }
@@ -360,7 +363,7 @@ public class EPaperStudentService {
360 363
             //获取该试题正确答案
361 364
             PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEptqid().equals(q.getEptqid())).findFirst().orElse(null);
362 365
 
363
-            setCommitQuestion(q,anvo,2);
366
+            setCommitQuestion(q,anvo);
364 367
             if(q.getChecked() == 2){
365 368
                 checknum ++;
366 369
             }
@@ -379,6 +382,9 @@ public class EPaperStudentService {
379 382
 
380 383
         ePaperStudentQuestionMapper.updateBatchStuQuestion(sqlist);
381 384
         ePaperStudentMapper.updateStudentPaper(paperStudent);
385
+
386
+        //获取试卷中需要合并图片的试题
387
+        chandleStudentQuestionNoconvertedPic(pswvo.getEpsid(),1);
382 388
     }
383 389
 
384 390
     /**
@@ -388,24 +394,35 @@ public class EPaperStudentService {
388 394
      * @Author wn
389 395
      * @Date 2022/8/3 9:17
390 396
      **/
391
-    public void saveCommitPaperForScantron(PaperStudentWebVo pswvo){
397
+    public void saveCommitPaperForScantron(PaperStudentWebVo pswvo) throws Exception{
392 398
         //更加学生姓名和准考证号找到对应学生
399
+        Integer userid = userMapper.getUseridByExamno(pswvo.getExamno());
400
+        if(!N_Utils.isTrueInteger(userid)){
401
+            throw new Exception("考号有误");
402
+        }
403
+        //获取学生试卷
404
+        EPaperStudent ps = ePaperStudentMapper.getPaperStudentByStuidAndEpid(pswvo.getEpid(),userid);
405
+        pswvo.setEpsid(ps.getEpsid());
393 406
 
394
-        int epsid = 0;
395
-        pswvo.setEpsid(epsid);
396
-        EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(pswvo.getEpsid());
397
-        //试卷不存在或者已提交
398
-        if(ps == null || ps.getSstate() == 1){
399
-            return;
407
+        //试卷不存在
408
+        if(ps == null) {
409
+            throw new Exception("学生试卷不存在");
400 410
         }
401 411
 
402 412
         if(pswvo.getSstate() == 3){
403
-            //说明学生缺考更新状态
413
+            //说明学生缺考更新状态
404 414
             EPaperStudent paperStudent = new EPaperStudent();
405 415
             paperStudent.setEpsid(pswvo.getEpsid());
406 416
             paperStudent.setStupic(JSON.toJSONString(pswvo.getStupic()));
407 417
             paperStudent.setSstate(3);
418
+            if(!N_Utils.isEmptyInteger(pswvo.getSstate())){
419
+                paperStudent.setHasbad(0);
420
+            }else{
421
+                paperStudent.setHasbad(1);
422
+            }
423
+
408 424
             ePaperStudentMapper.updateStudentPaperState(paperStudent);
425
+            ePaperStudentQuestionMapper.updateStuQuestionChecked(pswvo.getEpsid(),userid);
409 426
         }else{
410 427
             List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
411 428
 
@@ -414,14 +431,16 @@ public class EPaperStudentService {
414 431
             Integer checknum = 0;//记录试卷中试题批阅数量
415 432
             Double paperscore = 0D;//学生试卷得分
416 433
             for(EPaperStudentQuestion q : sqlist){
434
+                q.setAnswertype(1);
417 435
 
418
-                //获取该试题正确答案
419
-                PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEptqid().equals(q.getEptqid())).findFirst().orElse(null);
436
+                //获取该试题正确答案(根据题号区分)
437
+                PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getQn().equals(q.getQn())).findFirst().orElse(null);
420 438
 
421
-                setCommitQuestion(q,anvo,2);
439
+                setCommitQuestion(q,anvo);
422 440
                 if(q.getChecked() == 2){
423 441
                     checknum ++;
424 442
                 }
443
+                q.setEpsqid(anvo.getEpsqid());
425 444
                 paperscore = ExamUtil.add(paperscore, q.getStuscore());
426 445
             }
427 446
             EPaperStudent paperStudent = new EPaperStudent();
@@ -437,6 +456,8 @@ public class EPaperStudentService {
437 456
 
438 457
             ePaperStudentQuestionMapper.updateBatchStuQuestion(sqlist);
439 458
             ePaperStudentMapper.updateStudentPaper(paperStudent);
459
+            //获取试卷中需要合并图片的试题
460
+            chandleStudentQuestionNoconvertedPic(pswvo.getEpsid(),2);
440 461
         }
441 462
     }
442 463
 

+ 2
- 2
sexam/src/main/java/com/xhkjedu/sexam/vo/paperstudent/PaperStudentWebVo.java Ver arquivo

@@ -26,10 +26,10 @@ public class PaperStudentWebVo {
26 26
 
27 27
     private Integer epid;//试卷id
28 28
 
29
-    private String stuname;//学生姓名
30
-
31 29
     private String examno;//学生准考证号
32 30
 
33 31
     private Integer sstate;//状态0未进场1已进场2已交卷3缺考
34 32
 
33
+    private Integer hasbad;//会否违规0未违规1违规
34
+
35 35
 }

+ 7
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paperstudent/PsqAnswerVo.java Ver arquivo

@@ -9,6 +9,8 @@ import lombok.Data;
9 9
  **/
10 10
 @Data
11 11
 public class PsqAnswerVo {
12
+    private Integer epsqid;//学生试题id
13
+
12 14
     private Integer eptqid;//试卷中试题id
13 15
 
14 16
     private Integer ctype;//处理题型
@@ -17,7 +19,12 @@ public class PsqAnswerVo {
17 19
 
18 20
     private String answer;//答案
19 21
 
22
+    private String qn;//题号
23
+
24
+    private Integer qorder;//试题排序
25
+
20 26
     private Integer answered;//试卷是否设置正确答案1已设置0未设置
21 27
 
22 28
     private Integer costtime;//话费时间
29
+
23 30
 }

+ 8
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Ver arquivo

@@ -169,6 +169,9 @@
169 169
     <!--更新缺考状态-->
170 170
     <update id="updateStudentPaperState">
171 171
         update e_paper_student set sstate=#{ps.sstate},checked=#{ps.checked},stupic=#{ps.stupic}
172
+        <if test="ps.ps.hasbad!=null and ps.hasbad!=0">
173
+            ,hasbad=#{ps.hasbad}
174
+        </if>
172 175
         where epsid=#{ps.epsid}
173 176
     </update>
174 177
 
@@ -177,4 +180,9 @@
177 180
         update e_paper_student ps set ps.stuscore=(SELECT SUM(IFNULL(q.stuscore,0)) FROM e_paper_student_question q
178 181
         WHERE q.epid=#{epid} and q.epsid=ps.epsid) where ps.epid=#{epid}
179 182
     </update>
183
+
184
+    <!--根据试卷id和学生id获取学生试卷信息-->
185
+    <select id="getPaperStudentByStuidAndEpid" resultType="com.xhkjedu.sexam.model.paperstudent.EPaperStudent">
186
+        select * from e_paper_student where epid=#{epid} and studentid=#{studentid} order by epsid desc limit 1
187
+    </select>
180 188
 </mapper>

+ 10
- 3
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml Ver arquivo

@@ -30,13 +30,13 @@
30 30
 
31 31
     <!--获取试卷中未合并图片-->
32 32
     <select id="listStuQuesitonStuAnswerPic" resultType="com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion">
33
-        select epsqid,stuanswer from e_paper_student_question
34
-        where epsid=#{epsid} and answertype=1 and converted=0
33
+        select epsqid,stuanswer,stupic from e_paper_student_question
34
+        where epsid=#{epsid} and answertype=1 and answered=1 and converted=0 order by qorder
35 35
     </select>
36 36
 
37 37
     <!--获取试卷中所有试题正确答案及分值-->
38 38
     <select id="listPaperQuestionsAnswer" resultType="com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo">
39
-        select distinct psq.eptqid,psq.costtime,ptq.ctype,ptq.score,ptq.answer,p.answered
39
+        select distinct psq.epsqid,psq.eptqid,psq.costtime,psq.qn,psq.qorder,ptq.ctype,ptq.score,ptq.answer,p.answered
40 40
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
41 41
         left join e_paper p on psq.epid=p.epid where psq.epsid=#{epsid} order by ptq.qorder
42 42
     </select>
@@ -128,4 +128,11 @@
128 128
             </foreach>
129 129
         </where>
130 130
     </update>
131
+
132
+    <!--更新缺考学生试题均已批阅-->
133
+    <update id="updateStuQuestionChecked">
134
+        update e_paper_student_question set q.checked=2,checktime=unix_timestamp(NOW())
135
+        where epsid=#{epsid} and studentid=#{studentid}
136
+    </update>
137
+
131 138
 </mapper>

+ 5
- 0
sexam/src/main/resources/mapper/system/UserMapper.xml Ver arquivo

@@ -41,4 +41,9 @@
41 41
         </foreach>
42 42
         group by u.userid
43 43
     </select>
44
+
45
+    <!--根据准考证号获取学生id-->
46
+    <select id="getUseridByExamno" resultType="java.lang.Integer">
47
+        select userid from t_user where examno=#{examno}
48
+    </select>
44 49
 </mapper>

Carregando…
Cancelar
Salvar