Browse Source

Merge remote-tracking branch 'origin/master' into ywx

tags/正式版本
雍文秀 2 years ago
parent
commit
7964026c23

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

4
 import com.github.pagehelper.PageInfo;
4
 import com.github.pagehelper.PageInfo;
5
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
5
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
6
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
6
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
7
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
7
 import com.xhkjedu.sexam.service.paperstudent.EPaperStudentService;
8
 import com.xhkjedu.sexam.service.paperstudent.EPaperStudentService;
8
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
9
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
9
 import com.xhkjedu.utils.N_Utils;
10
 import com.xhkjedu.utils.N_Utils;
64
         return new ResultVo(0,"成功获取学生试卷",psvo);
65
         return new ResultVo(0,"成功获取学生试卷",psvo);
65
     }
66
     }
66
 
67
 
68
+    //提交单题
69
+    @PostMapping("/scq")
70
+    public ResultVo saveCommitQuestion(@RequestBody EPaperStudentQuestion sq){
71
+       try {
72
+           N_Utils.validation(new Object[]{sq.getEpsqid(),"试题id",1});
73
+           ePaperStudentService.saveCommitQuestion(sq);
74
+           return new ResultVo(0,"成功提交试题");
75
+       }catch (Exception e){
76
+           return new ResultVo(1,"提交试题失败");
77
+       }
78
+    }
79
+
80
+
81
+
67
 
82
 
68
 }
83
 }

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

17
 
17
 
18
     //根据学生试题id获取试题正确答案
18
     //根据学生试题id获取试题正确答案
19
     PsqAnswerVo getPaperQuestionAnswer(@Param("epsqid")Integer epsqid);
19
     PsqAnswerVo getPaperQuestionAnswer(@Param("epsqid")Integer epsqid);
20
+
21
+    //提交单题
22
+    void updateStuAnswer(@Param("q")EPaperStudentQuestion q);
20
 }
23
 }

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

40
     private Integer answered;
40
     private Integer answered;
41
 
41
 
42
     //答案类型1选择题、图片2纯文本
42
     //答案类型1选择题、图片2纯文本
43
-    private Integer ansertype;
43
+    private Integer answertype;
44
 
44
 
45
     //学生答案(选项、图片)
45
     //学生答案(选项、图片)
46
     private String stuanswer;
46
     private String stuanswer;

+ 3
- 22
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java View File

83
         }
83
         }
84
 
84
 
85
         //更加试卷状态是否需要生成分析和更改科目状态
85
         //更加试卷状态是否需要生成分析和更改科目状态
86
-        if(espVo.getExammode() == 2 && paper.getPstate()!=null && paper.getPstate() == 1){
86
+        if(espVo.getExammode() == 1 && paper.getPstate()!=null && paper.getPstate() == 1){
87
             //如果提交试卷,更改科目状态
87
             //如果提交试卷,更改科目状态
88
             eSubjectMapper.updateExamSubjectState(1,espVo.getEsid());
88
             eSubjectMapper.updateExamSubjectState(1,espVo.getEsid());
89
         }
89
         }
112
         paper.setCreatetime(timestamp);
112
         paper.setCreatetime(timestamp);
113
         paper.setHandletime(timestamp);
113
         paper.setHandletime(timestamp);
114
         paper.setHandleid(paper.getCreateid());
114
         paper.setHandleid(paper.getCreateid());
115
+        paper.setCorrecttype(0);
115
         if(paper.getPtype() == 1){
116
         if(paper.getPtype() == 1){
116
             paper.setAnswered(1);//题库已设置正确答案
117
             paper.setAnswered(1);//题库已设置正确答案
117
         }else{
118
         }else{
398
         }
399
         }
399
 
400
 
400
         //更加试卷状态是否需要生成分析和更改科目状态
401
         //更加试卷状态是否需要生成分析和更改科目状态
401
-        if(paper.getPstate()!=null && paper.getPstate() == 1){
402
+        if(espVo.getExammode() == 1 && paper.getPstate()!=null && paper.getPstate() == 1){
402
             //如果提交试卷,更改科目状态
403
             //如果提交试卷,更改科目状态
403
             eSubjectMapper.updateExamSubjectState(1,espVo.getEsid());
404
             eSubjectMapper.updateExamSubjectState(1,espVo.getEsid());
404
         }
405
         }
568
     @Transactional(rollbackFor = Exception.class)
569
     @Transactional(rollbackFor = Exception.class)
569
     public void savePaperScan(EPaper paper){
570
     public void savePaperScan(EPaper paper){
570
         List<EPaperQtypeQuestion> questions = paper.getQuestions();
571
         List<EPaperQtypeQuestion> questions = paper.getQuestions();
571
-        for(EPaperQtypeQuestion q : questions){
572
-            List<String> coorlist = q.getCoordlist();
573
-            if(q.getCtype() == 3 || q.getCtype() == 14 || q.getCtype() == 15){
574
-                if(coorlist.size() > 1){
575
-                    //有多个坐标,合并为一个
576
-                    List<List> savecoor = new ArrayList<>();
577
-                    for(String str : coorlist){
578
-                        List lst = JSON.parseArray(str);
579
-                        for(int i=0;i<lst.size();i++){
580
-                            savecoor.add((List)lst.get(i));
581
-                        }
582
-                    }
583
-                    q.setCoord(JSON.toJSONString(savecoor));
584
-                }else{
585
-                    q.setCoord(coorlist.get(0));
586
-                }
587
-            }else{
588
-                q.setCoord(coorlist.get(0));
589
-            }
590
-        }
591
         ePaperMapper.updatePaperScantron(paper);
572
         ePaperMapper.updatePaperScantron(paper);
592
         ePaperQtypeMapper.updateBatchQuestionForScan(questions);
573
         ePaperQtypeMapper.updateBatchQuestionForScan(questions);
593
         if(paper.getPstate() == 1){
574
         if(paper.getPstate() == 1){

+ 103
- 49
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java View File

12
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
12
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
13
 import com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo;
13
 import com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo;
14
 import com.xhkjedu.utils.N_Utils;
14
 import com.xhkjedu.utils.N_Utils;
15
+import lombok.extern.slf4j.Slf4j;
15
 import org.springframework.stereotype.Service;
16
 import org.springframework.stereotype.Service;
16
 
17
 
17
 import javax.annotation.Resource;
18
 import javax.annotation.Resource;
25
  * Date 2022/7/26 14:00
26
  * Date 2022/7/26 14:00
26
  **/
27
  **/
27
 @Service
28
 @Service
29
+@Slf4j
28
 public class EPaperStudentService {
30
 public class EPaperStudentService {
29
     @Resource
31
     @Resource
30
     private EPaperStudentMapper ePaperStudentMapper;
32
     private EPaperStudentMapper ePaperStudentMapper;
153
         return psvo;
155
         return psvo;
154
     }
156
     }
155
 
157
 
156
-    public void saveCommitQuestion(EPaperStudentQuestion psq) {
157
-        //学生作答提交时先判断试卷是否设置的正确答案
158
-        PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
159
-        int timestamp = N_Utils.getSecondTimestamp();
160
-        psq.setAnswertime(timestamp);
161
-        //试卷已经设置了正确答案
162
-        if (answerVo.getAnswered() == 1){
163
-            Double stuscore = 0.0;
158
+    /**
159
+     * @Description 提交单题
160
+     * @Param [psq]
161
+     * @Return void
162
+     * @Author wn
163
+     * @Date 2022/7/28 13:47
164
+     **/
165
+    public void saveCommitQuestion(EPaperStudentQuestion psq) throws Exception {
166
+        try {
167
+            //学生作答提交时先判断试卷是否设置的正确答案
168
+            PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
169
+            int timestamp = N_Utils.getSecondTimestamp();
170
+            psq.setAnswertime(timestamp);
164
             int coverted = 1;//是否转换0未转换1已转换2转换失败
171
             int coverted = 1;//是否转换0未转换1已转换2转换失败
165
             String stuanswer = psq.getStuanswer();
172
             String stuanswer = psq.getStuanswer();
166
             List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
173
             List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
167
-            String qanswer = answerVo.getAnswer();
168
-            List<String> qanswers = JSON.parseArray(qanswer,String.class);
174
+            Double stuscore = 0.0;
175
+
169
             if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
176
             if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
170
                     && N_Utils.isEmpty(psq.getStuanswertxt())){
177
                     && N_Utils.isEmpty(psq.getStuanswertxt())){
171
                 psq.setStuscore(stuscore);
178
                 psq.setStuscore(stuscore);
172
-                psq.setChecked(1);
179
+                psq.setChecked(2);
173
                 psq.setChecktime(timestamp);
180
                 psq.setChecktime(timestamp);
174
                 psq.setAnswered(0);
181
                 psq.setAnswered(0);
175
             }else{
182
             }else{
176
-
177
-                int ctype = answerVo.getCtype();
178
-                if(N_Utils.isObjectiveQuestion(ctype)){
179
-                    //客观题进行批阅
180
-                    if(ctype == 1){//单选
181
-                        if(stuanswer.equalsIgnoreCase(qanswer)) {
182
-                            stuscore = answerVo.getScore();
183
-                        }
184
-                    }else if(ctype == 2){//多选
185
-                        //多选、选错不得分
186
-                        if(stuanswers.get(0).length() <= qanswer.length()){
187
-                            String[] qanswerList = qanswers.get(0).split("");
188
-                            String[] stuanswerList = stuanswers.get(0).split("");
189
-                            int rightNum = 0;//选对个数
190
-                            for(String sa : stuanswerList){
191
-                               int right = 0;
192
-                               for(String qa : qanswerList){
193
-                                   if(qa.equals(sa)){
194
-                                       right = 1;
195
-                                       rightNum ++;
196
-                                   }
197
-                               }
198
-                               if(right == 0){//说明选错
199
-                                   rightNum = 0;
200
-                                   break;
201
-                               }
202
-                            }
203
-                            if(rightNum>0){
204
-                                if(qanswerList.length == rightNum){
205
-                                    //全选对
183
+                //试卷已经设置了正确答案
184
+                if (answerVo.getAnswered() == 1){
185
+                    String qanswer = answerVo.getAnswer();
186
+                    List<String> qanswers = JSON.parseArray(qanswer,String.class);
187
+                    if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
188
+                            && N_Utils.isEmpty(psq.getStuanswertxt())){
189
+                        psq.setStuscore(stuscore);
190
+                        psq.setChecked(1);
191
+                        psq.setChecktime(timestamp);
192
+                        psq.setAnswered(0);
193
+                    }else{
194
+                        int ctype = answerVo.getCtype();
195
+                        if(N_Utils.isObjectiveQuestion(ctype)){
196
+                            //客观题进行批阅
197
+                            if(ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6){
198
+                                //单选、判断
199
+                                if(stuanswer.equalsIgnoreCase(qanswer)) {
206
                                     stuscore = answerVo.getScore();
200
                                     stuscore = answerVo.getScore();
207
-                                }else if (qanswerList.length > rightNum){
208
-                                    //少选得半分
209
-                                    stuscore = ExamUtil.div(answerVo.getScore(),2,1);
210
                                 }
201
                                 }
202
+                            }else if(ctype == 2){//多选
203
+                                //多选、选错不得分
204
+                                if(stuanswers.get(0).length() <= qanswer.length()){
205
+                                    String[] qanswerList = qanswers.get(0).split("");
206
+                                    String[] stuanswerList = stuanswers.get(0).split("");
207
+                                    int rightNum = 0;//选对个数
208
+                                    for(String sa : stuanswerList){
209
+                                        int right = 0;
210
+                                        for(String qa : qanswerList){
211
+                                            if(qa.equals(sa)){
212
+                                                right = 1;
213
+                                                rightNum ++;
214
+                                            }
215
+                                        }
216
+                                        if(right == 0){//说明选错
217
+                                            rightNum = 0;
218
+                                            break;
219
+                                        }
220
+                                    }
221
+                                    if(rightNum>0){
222
+                                        if(qanswerList.length == rightNum){
223
+                                            //全选对
224
+                                            stuscore = answerVo.getScore();
225
+                                        }else if (qanswerList.length > rightNum){
226
+                                            //少选得半分
227
+                                            stuscore = ExamUtil.div(answerVo.getScore(),2,1);
228
+                                        }
229
+                                    }
230
+                                }
231
+                            }else if(ctype == 7 || ctype == 8 || ctype == 10){
232
+                                //完形填空、阅读理解、任务型阅读
233
+                                Double qscore = ExamUtil.div(answerVo.getScore(),qanswers.size());
234
+                                Double stuScoreDouble = 0d;
235
+                                for(int i=0;i<qanswers.size();i++){
236
+                                    if(qanswers.get(i).equalsIgnoreCase(stuanswers.get(i))){
237
+                                        stuScoreDouble = ExamUtil.add(stuScoreDouble,qscore);
238
+                                    }
239
+                                }
240
+                                stuscore = ExamUtil.round(stuScoreDouble,1);
241
+                            }
242
+                            if(stuscore.compareTo(answerVo.getScore()) == 1){
243
+                                stuscore = answerVo.getScore();
244
+                            }
245
+                            psq.setStuscore(stuscore);
246
+                            psq.setChecked(2);
247
+                            psq.setChecktime(timestamp);
248
+                        }else{
249
+
250
+                            if(stuanswers.size() > 0){
251
+                                coverted = 0;//上传的多张图片设为0未转换
211
                             }
252
                             }
212
                         }
253
                         }
254
+                        psq.setAnswered(1);
213
                     }
255
                     }
214
-
215
-                }else{
216
-
217
                 }
256
                 }
218
-                psq.setAnswered(1);
219
             }
257
             }
220
 
258
 
221
-
259
+            Integer costtime = answerVo.getCosttime();
260
+            if(costtime == null){
261
+                costtime = 0;
262
+            }
263
+            psq.setCosttime(psq.getCosttime() + costtime);
264
+            psq.setConverted(coverted);
265
+            ePaperStudentQuestionMapper.updateStuAnswer(psq);
266
+        }catch (Exception e){
267
+            log.error("提交试题失败:"+e.getMessage());
268
+            throw new Exception("提交试题失败");
222
         }
269
         }
223
 
270
 
224
     }
271
     }
225
 
272
 
273
+    public int saveCommitPaper(Integer epsid){
274
+        EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(epsid);
275
+        if(ps == null || ps.getSstate() == 1){
276
+            return 1;
277
+        }
278
+        return 1;
279
+    }
226
 
280
 
227
 }
281
 }

+ 55
- 0
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java View File

45
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
45
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
46
         return b1.divide(b2, scale, BigDecimal.ROUND_DOWN).doubleValue();
46
         return b1.divide(b2, scale, BigDecimal.ROUND_DOWN).doubleValue();
47
     }
47
     }
48
+
49
+    /**
50
+     * 提供精确的加法运算。
51
+     *
52
+     * @param v1 被加数
53
+     * @param v2 加数
54
+     * @return 两个参数的和
55
+     */
56
+    public static double add(double v1, double v2) {
57
+        BigDecimal b1 = new BigDecimal(Double.toString(v1));
58
+        BigDecimal b2 = new BigDecimal(Double.toString(v2));
59
+        return b1.add(b2).doubleValue();
60
+    }
61
+
62
+    /**
63
+     * 提供精确的小数位四舍五入处理。
64
+     *
65
+     * @param v     需要四舍五入的数字
66
+     * @param scale 小数点后保留几位
67
+     * @return 四舍五入后的结果
68
+     */
69
+    public static double round(double v, int scale) {
70
+        if (scale < 0) {
71
+            throw new IllegalArgumentException("The   scale   must   be   a   positive   integer   or   zero");
72
+        }
73
+        BigDecimal b = new BigDecimal(Double.toString(v));
74
+        BigDecimal one = new BigDecimal("1");
75
+        return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
76
+    }
77
+
78
+    /**
79
+     * 提供精确的减法运算。
80
+     *
81
+     * @param v1 被减数
82
+     * @param v2 减数
83
+     * @return 两个参数的差
84
+     */
85
+    public static double sub(double v1, double v2) {
86
+        BigDecimal b1 = new BigDecimal(Double.toString(v1));
87
+        BigDecimal b2 = new BigDecimal(Double.toString(v2));
88
+        return b1.subtract(b2).doubleValue();
89
+    }
90
+
91
+    /**
92
+     * 提供精确的乘法运算。
93
+     *
94
+     * @param v1 被乘数
95
+     * @param v2 乘数
96
+     * @return 两个参数的积
97
+     */
98
+    public static double mul(double v1, double v2) {
99
+        BigDecimal b1 = new BigDecimal(Double.toString(v1));
100
+        BigDecimal b2 = new BigDecimal(Double.toString(v2));
101
+        return b1.multiply(b2).doubleValue();
102
+    }
48
 }
103
 }

+ 2
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paperstudent/PsqAnswerVo.java View File

18
     private String answer;//答案
18
     private String answer;//答案
19
 
19
 
20
     private Integer answered;//试卷是否设置正确答案1已设置0未设置
20
     private Integer answered;//试卷是否设置正确答案1已设置0未设置
21
+
22
+    private Integer costtime;//话费时间
21
 }
23
 }

+ 0
- 2
sexam/src/main/resources/mapper/paper/EPaperMapper.xml View File

99
         from e_subject es left join e_paper ep on es.esid=ep.esid
99
         from e_subject es left join e_paper ep on es.esid=ep.esid
100
         left join e_base e on es.examid=e.examid where es.esid=#{esid}
100
         left join e_base e on es.examid=e.examid where es.esid=#{esid}
101
     </select>
101
     </select>
102
-
103
-    <select id="getExamState"></select>
104
 </mapper>
102
 </mapper>

+ 9
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml View File

4
 
4
 
5
     <!--根据学生试题id获取试题正确答案-->
5
     <!--根据学生试题id获取试题正确答案-->
6
     <select id="getPaperQuestionAnswer" resultType="com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo">
6
     <select id="getPaperQuestionAnswer" resultType="com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo">
7
-        select psq.eptqid,ptq.ctype,ptq.score,ptq.answer,p.answered
7
+        select psq.eptqid,psq.costtime,ptq.ctype,ptq.score,ptq.answer,p.answered
8
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
8
         from e_paper_student_question psq left join e_paper_qtype_question ptq on psq.eptqid=ptq.eptqid
9
         left join e_paper p on psq.epid=p.epid where psq.epsqid=#{epsqid}
9
         left join e_paper p on psq.epid=p.epid where psq.epsqid=#{epsqid}
10
     </select>
10
     </select>
11
+
12
+    <!--提交单题-->
13
+    <update id="updateStuAnswer">
14
+        update e_paper_student_question set answered=#{q.answered},answertype=#{q.answertype},
15
+        stuanswer=#{q.stuanswer},stuanswertxt=#{q.stuanswertxt},converted=#{q.converted},
16
+        answertime=#{q.answertime},costtime=#{q.costtime},stuscore=#{q.stuscore},
17
+        checked=#{q.checked},checkid=#{q.checkid},checktime=#{q.checktime} where epsqid=#{q.epsqid}
18
+    </update>
11
 </mapper>
19
 </mapper>

Loading…
Cancel
Save