Browse Source

提交试题

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

+ 28
- 12
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java View File

74
             Map map = ePaperStudentService.startPaperForAndroid(eps);
74
             Map map = ePaperStudentService.startPaperForAndroid(eps);
75
             return new ResultVo(0, "成功获取学生试卷", map);
75
             return new ResultVo(0, "成功获取学生试卷", map);
76
         }catch (MissingParametersException e){
76
         }catch (MissingParametersException e){
77
-            log.error("学生开始考试android失败:" + e.getMessage());
77
+            log.error("学生开始考试android出错:" + e.getMessage());
78
             return new ResultVo(1,e.getMessage());
78
             return new ResultVo(1,e.getMessage());
79
         }catch (Exception e){
79
         }catch (Exception e){
80
-            log.error("学生开始考试android失败:" + e.getMessage());
80
+            log.error("学生开始考试android出错:" + e.getMessage());
81
             return new ResultVo(1,e.getMessage());
81
             return new ResultVo(1,e.getMessage());
82
         }
82
         }
83
 
83
 
91
             Map map = ePaperStudentService.startPaperForAndroidNew(eps);
91
             Map map = ePaperStudentService.startPaperForAndroidNew(eps);
92
             return new ResultVo(0, "成功获取学生试卷", map);
92
             return new ResultVo(0, "成功获取学生试卷", map);
93
         }catch (MissingParametersException e){
93
         }catch (MissingParametersException e){
94
-            log.error("学生开始考试android失败:" + e.getMessage());
94
+            log.error("学生开始考试android出错:" + e.getMessage());
95
             return new ResultVo(1,e.getMessage());
95
             return new ResultVo(1,e.getMessage());
96
         }catch (Exception e){
96
         }catch (Exception e){
97
-            log.error("学生开始考试android失败:" + e.getMessage());
97
+            log.error("学生开始考试android出错:" + e.getMessage());
98
             return new ResultVo(1,e.getMessage());
98
             return new ResultVo(1,e.getMessage());
99
         }
99
         }
100
 
100
 
108
             ePaperStudentService.saveCommitQuestion(sq);
108
             ePaperStudentService.saveCommitQuestion(sq);
109
             return new ResultVo(0, "成功提交试题");
109
             return new ResultVo(0, "成功提交试题");
110
         } catch (Exception e) {
110
         } catch (Exception e) {
111
-            log.error("提交试题失败:" + e.getMessage());
111
+            log.error("提交android试题失败:" + e.getMessage());
112
             return new ResultVo(1, "提交试题失败");
112
             return new ResultVo(1, "提交试题失败");
113
         }
113
         }
114
     }
114
     }
120
             N_Utils.validation(new Object[]{ps.getEpsid(), "试卷id", 1});
120
             N_Utils.validation(new Object[]{ps.getEpsid(), "试卷id", 1});
121
             return ePaperStudentService.saveCommitPaper(ps);
121
             return ePaperStudentService.saveCommitPaper(ps);
122
         } catch (Exception e) {
122
         } catch (Exception e) {
123
-            log.error("提交android试卷失败:" + e.getMessage());
123
+            log.error("提交试卷出错:" + e.getMessage());
124
             return new ResultVo(1, "提交失败");
124
             return new ResultVo(1, "提交失败");
125
         }
125
         }
126
     }
126
     }
132
             Integer endTime = ePaperStudentService.updatePaperStudentState(ps.getEpsid());
132
             Integer endTime = ePaperStudentService.updatePaperStudentState(ps.getEpsid());
133
             return new ResultVo(0, "操作成功", endTime);
133
             return new ResultVo(0, "操作成功", endTime);
134
         }catch(MissingParametersException e){
134
         }catch(MissingParametersException e){
135
-            log.error("进入考场失败:" + e.getMessage());
135
+            log.error("进入考场出错:" + e.getMessage());
136
             return new ResultVo(1,e.getMessage());
136
             return new ResultVo(1,e.getMessage());
137
         } catch (Exception e) {
137
         } catch (Exception e) {
138
-            log.error("进入考场失败:" + e.getMessage());
138
+            log.error("进入考场出错:" + e.getMessage());
139
             return new ResultVo(1, "操作失败");
139
             return new ResultVo(1, "操作失败");
140
         }
140
         }
141
     }
141
     }
154
             int result = ePaperStudentService.getExamstateSubjectState(ps.getEpsid());
154
             int result = ePaperStudentService.getExamstateSubjectState(ps.getEpsid());
155
             return new ResultVo(0, "获取成功",result);
155
             return new ResultVo(0, "获取成功",result);
156
         } catch (Exception e) {
156
         } catch (Exception e) {
157
-            log.error("获取考试状态失败:" + e.getMessage());
157
+            log.error("获取考试状态出错:" + e.getMessage());
158
             return new ResultVo(1, "获取考试状态失败");
158
             return new ResultVo(1, "获取考试状态失败");
159
         }
159
         }
160
     }
160
     }
167
             Map psvo = ePaperStudentService.startPaperForWeb(eps);
167
             Map psvo = ePaperStudentService.startPaperForWeb(eps);
168
             return new ResultVo(0, "成功获取学生试卷", psvo);
168
             return new ResultVo(0, "成功获取学生试卷", psvo);
169
         }catch (MissingParametersException e){
169
         }catch (MissingParametersException e){
170
-            log.error("学生web获取试卷失败:" + e.getMessage());
170
+            log.error("学生web获取试卷出错:" + e.getMessage());
171
             return new ResultVo(1,e.getMessage());
171
             return new ResultVo(1,e.getMessage());
172
         }catch (Exception e){
172
         }catch (Exception e){
173
-            log.error("学生web获取试卷失败:" + e.getMessage());
173
+            log.error("学生web获取试卷出错:" + e.getMessage());
174
             return new ResultVo(1,"获取试卷失败");
174
             return new ResultVo(1,"获取试卷失败");
175
         }
175
         }
176
     }
176
     }
177
 
177
 
178
+    //提交试题(web:一次提交可能多可客观题或一个主观题)
179
+    @PostMapping("/scqw")
180
+    public ResultVo saveCommitQuestionWeb(@RequestBody PaperStudentWebVo ps) {
181
+        try {
182
+            N_Utils.validation(new Object[]{ps.getEpsid(), "试卷id", 1});
183
+            List<EPaperStudentQuestion> qlist = ps.getQuestions();
184
+            if (N_Utils.isListEmpty(qlist)) {
185
+                return new ResultVo(1, "试题不能为空");
186
+            }
187
+            return ePaperStudentService.saveCommitQuestionForWeb(ps);
188
+        } catch (Exception e) {
189
+            log.error("提交web试题出错:" + e.getMessage());
190
+            return new ResultVo(1, "提交失败");
191
+        }
192
+    }
193
+
178
     //提交试卷(web)
194
     //提交试卷(web)
179
     @PostMapping("/scpw")
195
     @PostMapping("/scpw")
180
     public ResultVo saveCommitPaperWeb(@RequestBody PaperStudentWebVo ps) {
196
     public ResultVo saveCommitPaperWeb(@RequestBody PaperStudentWebVo ps) {
186
             }
202
             }
187
             return ePaperStudentService.saveCommitPaperForWeb(ps);
203
             return ePaperStudentService.saveCommitPaperForWeb(ps);
188
         } catch (Exception e) {
204
         } catch (Exception e) {
189
-            log.error("提交web试卷失败:" + e.getMessage());
205
+            log.error("提交web试卷出错:" + e.getMessage());
190
             return new ResultVo(1, "提交失败");
206
             return new ResultVo(1, "提交失败");
191
         }
207
         }
192
     }
208
     }

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

490
         }
490
         }
491
     }
491
     }
492
 
492
 
493
+    /**
494
+     * @Description 网页端提交试题
495
+     * @Param [pswvo]
496
+     * @Return com.xhkjedu.vo.ResultVo
497
+     * @Author wn
498
+     * @Date 2022/11/23 14:43
499
+     **/
500
+    public ResultVo saveCommitQuestionForWeb(PaperStudentWebVo pswvo) {
501
+        List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
502
+        //获取试卷中所有试题答案及分值
503
+        List<PsqAnswerVo> anvolist = ePaperStudentQuestionMapper.listPaperQuestionsAnswer(pswvo.getEpsid());
504
+        Integer checknum = 0;//记录试卷中试题批阅数量
505
+        Double paperscore = 0D;//学生试卷得分
506
+        List<EPaperStudentQuestion> saveQlist = new ArrayList<>();//提交有值试题
507
+        for (EPaperStudentQuestion q : sqlist) {
508
+
509
+            //获取该试题正确答案
510
+            PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEpsqid().equals(q.getEpsqid())).findFirst().orElse(null);
511
+
512
+            setCommitQuestion(q, anvo);
513
+            if (q.getChecked() == 2) {
514
+                checknum++;
515
+            }
516
+            paperscore = ExamUtil.add(paperscore, q.getStuscore());
517
+
518
+            if(N_Utils.isTrueInteger(q.getAnswered())){
519
+                saveQlist.add(q);
520
+            }
521
+        }
522
+        EPaperStudent paperStudent = new EPaperStudent();
523
+        paperStudent.setEpsid(pswvo.getEpsid());
524
+        int timestamp = N_Utils.getSecondTimestamp();
525
+        paperStudent.setEndtime(timestamp);
526
+        paperStudent.setSstate(2);
527
+        paperStudent.setStuscore(paperscore);
528
+        paperStudent.setDevice(pswvo.getDevice());
529
+        paperStudent.setSubmittype(pswvo.getSubmittype());
530
+        if(N_Utils.isTrueInteger(pswvo.getCosttime())){
531
+            paperStudent.setCosttime(pswvo.getCosttime());
532
+        }else{
533
+            paperStudent.setCosttime(0);
534
+        }
535
+
536
+        int checked = 0;
537
+        if (checknum == saveQlist.size()) {
538
+            checked = 2;
539
+        }
540
+        paperStudent.setChecked(checked);
541
+        if(N_Utils.isListNotEmpty(saveQlist)){
542
+            ePaperStudentQuestionMapper.updateBatchStuQuestion(saveQlist);
543
+        }
544
+        return new ResultVo(0,"提交成功");
545
+    }
546
+
493
     /**
547
     /**
494
      * @Description 提交试卷试题(网页端)
548
      * @Description 提交试卷试题(网页端)
495
      * @Param [pswvo]
549
      * @Param [pswvo]

+ 5
- 53
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml View File

53
 
53
 
54
     <!--批量提交试题-->
54
     <!--批量提交试题-->
55
     <update id="updateBatchStuQuestion">
55
     <update id="updateBatchStuQuestion">
56
-        update e_paper_student_question
57
-        <trim prefix="set" suffixOverrides=",">
58
-            <trim prefix="answered = case" suffix="end,">
59
-                <foreach collection="list" item="q">
60
-                    when epsqid=#{q.epsqid} then #{q.answered}
61
-                </foreach>
62
-            </trim>
63
-            <trim prefix="answertype = case" suffix="end,">
64
-                <foreach collection="list" item="q">
65
-                    when epsqid=#{q.epsqid} then #{q.answertype}
66
-                </foreach>
67
-            </trim>
68
-            <trim prefix="stuanswer = case" suffix="end,">
69
-                <foreach collection="list" item="q">
70
-                    when epsqid=#{q.epsqid} then #{q.stuanswer}
71
-                </foreach>
72
-            </trim>
73
-            <trim prefix="stuanswertxt = case" suffix="end,">
74
-                <foreach collection="list" item="q">
75
-                    when epsqid=#{q.epsqid} then #{q.stuanswertxt}
76
-                </foreach>
77
-            </trim>
78
-            <trim prefix="converted = case" suffix="end,">
79
-                <foreach collection="list" item="q">
80
-                    when epsqid=#{q.epsqid} then #{q.converted}
81
-                </foreach>
82
-            </trim>
83
-            <trim prefix="answertime = case" suffix="end,">
84
-                <foreach collection="list" item="q">
85
-                    when epsqid=#{q.epsqid} then #{q.answertime}
86
-                </foreach>
87
-            </trim>
88
-            <trim prefix="stuscore = case" suffix="end,">
89
-                <foreach collection="list" item="q">
90
-                    when epsqid=#{q.epsqid} then #{q.stuscore}
91
-                </foreach>
92
-            </trim>
93
-            <trim prefix="checked = case" suffix="end,">
94
-                <foreach collection="list" item="q">
95
-                    when epsqid=#{q.epsqid} then #{q.checked}
96
-                </foreach>
97
-            </trim>
98
-            <trim prefix="checktime = case" suffix="end,">
99
-                <foreach collection="list" item="q">
100
-                    when epsqid=#{q.epsqid} then #{q.checktime}
101
-                </foreach>
102
-            </trim>
103
-        </trim>
104
-        <where>
105
-            <foreach collection="list" item="q" separator="or">
106
-                epsqid=#{q.epsqid}
107
-            </foreach>
108
-        </where>
56
+        <foreach collection="list" item="q" separator=";">
57
+            update e_paper_student_question set answered=#{q.answered},answertype=#{q.answertype},stuanswer=#{q.stuanswer}
58
+            ,stuanswertxt=#{q.stuanswertxt},converted=#{q.converted},answertime=#{q.answertime},stuscore=#{q.stuscore}
59
+            ,checked=#{q.checked},checktime=#{q.checktime} where epsqid=#{q.epsqid}
60
+        </foreach>
109
     </update>
61
     </update>
110
 
62
 
111
     <!--获取试卷中指定试题作答情况-->
63
     <!--获取试卷中指定试题作答情况-->

Loading…
Cancel
Save