瀏覽代碼

提交试题

tags/正式版本
王宁 2 年之前
父節點
當前提交
d2739f6fea

+ 28
- 12
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java 查看文件

@@ -74,10 +74,10 @@ public class EPaperStudentController {
74 74
             Map map = ePaperStudentService.startPaperForAndroid(eps);
75 75
             return new ResultVo(0, "成功获取学生试卷", map);
76 76
         }catch (MissingParametersException e){
77
-            log.error("学生开始考试android失败:" + e.getMessage());
77
+            log.error("学生开始考试android出错:" + e.getMessage());
78 78
             return new ResultVo(1,e.getMessage());
79 79
         }catch (Exception e){
80
-            log.error("学生开始考试android失败:" + e.getMessage());
80
+            log.error("学生开始考试android出错:" + e.getMessage());
81 81
             return new ResultVo(1,e.getMessage());
82 82
         }
83 83
 
@@ -91,10 +91,10 @@ public class EPaperStudentController {
91 91
             Map map = ePaperStudentService.startPaperForAndroidNew(eps);
92 92
             return new ResultVo(0, "成功获取学生试卷", map);
93 93
         }catch (MissingParametersException e){
94
-            log.error("学生开始考试android失败:" + e.getMessage());
94
+            log.error("学生开始考试android出错:" + e.getMessage());
95 95
             return new ResultVo(1,e.getMessage());
96 96
         }catch (Exception e){
97
-            log.error("学生开始考试android失败:" + e.getMessage());
97
+            log.error("学生开始考试android出错:" + e.getMessage());
98 98
             return new ResultVo(1,e.getMessage());
99 99
         }
100 100
 
@@ -108,7 +108,7 @@ public class EPaperStudentController {
108 108
             ePaperStudentService.saveCommitQuestion(sq);
109 109
             return new ResultVo(0, "成功提交试题");
110 110
         } catch (Exception e) {
111
-            log.error("提交试题失败:" + e.getMessage());
111
+            log.error("提交android试题失败:" + e.getMessage());
112 112
             return new ResultVo(1, "提交试题失败");
113 113
         }
114 114
     }
@@ -120,7 +120,7 @@ public class EPaperStudentController {
120 120
             N_Utils.validation(new Object[]{ps.getEpsid(), "试卷id", 1});
121 121
             return ePaperStudentService.saveCommitPaper(ps);
122 122
         } catch (Exception e) {
123
-            log.error("提交android试卷失败:" + e.getMessage());
123
+            log.error("提交试卷出错:" + e.getMessage());
124 124
             return new ResultVo(1, "提交失败");
125 125
         }
126 126
     }
@@ -132,10 +132,10 @@ public class EPaperStudentController {
132 132
             Integer endTime = ePaperStudentService.updatePaperStudentState(ps.getEpsid());
133 133
             return new ResultVo(0, "操作成功", endTime);
134 134
         }catch(MissingParametersException e){
135
-            log.error("进入考场失败:" + e.getMessage());
135
+            log.error("进入考场出错:" + e.getMessage());
136 136
             return new ResultVo(1,e.getMessage());
137 137
         } catch (Exception e) {
138
-            log.error("进入考场失败:" + e.getMessage());
138
+            log.error("进入考场出错:" + e.getMessage());
139 139
             return new ResultVo(1, "操作失败");
140 140
         }
141 141
     }
@@ -154,7 +154,7 @@ public class EPaperStudentController {
154 154
             int result = ePaperStudentService.getExamstateSubjectState(ps.getEpsid());
155 155
             return new ResultVo(0, "获取成功",result);
156 156
         } catch (Exception e) {
157
-            log.error("获取考试状态失败:" + e.getMessage());
157
+            log.error("获取考试状态出错:" + e.getMessage());
158 158
             return new ResultVo(1, "获取考试状态失败");
159 159
         }
160 160
     }
@@ -167,14 +167,30 @@ public class EPaperStudentController {
167 167
             Map psvo = ePaperStudentService.startPaperForWeb(eps);
168 168
             return new ResultVo(0, "成功获取学生试卷", psvo);
169 169
         }catch (MissingParametersException e){
170
-            log.error("学生web获取试卷失败:" + e.getMessage());
170
+            log.error("学生web获取试卷出错:" + e.getMessage());
171 171
             return new ResultVo(1,e.getMessage());
172 172
         }catch (Exception e){
173
-            log.error("学生web获取试卷失败:" + e.getMessage());
173
+            log.error("学生web获取试卷出错:" + e.getMessage());
174 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 194
     //提交试卷(web)
179 195
     @PostMapping("/scpw")
180 196
     public ResultVo saveCommitPaperWeb(@RequestBody PaperStudentWebVo ps) {
@@ -186,7 +202,7 @@ public class EPaperStudentController {
186 202
             }
187 203
             return ePaperStudentService.saveCommitPaperForWeb(ps);
188 204
         } catch (Exception e) {
189
-            log.error("提交web试卷失败:" + e.getMessage());
205
+            log.error("提交web试卷出错:" + e.getMessage());
190 206
             return new ResultVo(1, "提交失败");
191 207
         }
192 208
     }

+ 54
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java 查看文件

@@ -490,6 +490,60 @@ public class EPaperStudentService {
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 548
      * @Description 提交试卷试题(网页端)
495 549
      * @Param [pswvo]

+ 5
- 53
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml 查看文件

@@ -53,59 +53,11 @@
53 53
 
54 54
     <!--批量提交试题-->
55 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 61
     </update>
110 62
 
111 63
     <!--获取试卷中指定试题作答情况-->

Loading…
取消
儲存