Browse Source

优化试卷返回值

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

+ 143
- 153
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java View File

67
         return ePaperStudentMapper.listExamPapersForStudent(eps.getStudentid());
67
         return ePaperStudentMapper.listExamPapersForStudent(eps.getStudentid());
68
     }
68
     }
69
 
69
 
70
-    public Map getExamSubjectPaperByEpsid(Integer epsid){
70
+    public Map getExamSubjectPaperByEpsid(Integer epsid) {
71
         Map map = ePaperStudentMapper.getExamSubjectPaperByEpsid(epsid);
71
         Map map = ePaperStudentMapper.getExamSubjectPaperByEpsid(epsid);
72
         Long times = null;
72
         Long times = null;
73
-        if(map.get("sdate")!=null && map.get("begintime")!=null && map.get("endtime")!=null){
73
+        if (map.get("sdate") != null && map.get("begintime") != null && map.get("endtime") != null) {
74
             long bg = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("begintime").toString() + ":00");
74
             long bg = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("begintime").toString() + ":00");
75
             long ed = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("endtime").toString() + ":00");
75
             long ed = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("endtime").toString() + ":00");
76
-            times = ExamUtil.subtract(ed,bg);
76
+            times = ExamUtil.subtract(ed, bg);
77
         }
77
         }
78
-        map.put("times",times);
78
+        map.put("times", times);
79
         return map;
79
         return map;
80
     }
80
     }
81
 
81
 
125
                 questions = ePaperStudentMapper.listStuPaperFjQuestionsForAndroid(epsid);
125
                 questions = ePaperStudentMapper.listStuPaperFjQuestionsForAndroid(epsid);
126
             }
126
             }
127
         }
127
         }
128
-        if(ptype == 2){
128
+        if (ptype == 2) {
129
             List<Map> files = ePaperFileMapper.listPaperFiles(psvo.getEpid());
129
             List<Map> files = ePaperFileMapper.listPaperFiles(psvo.getEpid());
130
-            map.put("files",files);
130
+            map.put("files", files);
131
         }
131
         }
132
 
132
 
133
-        ePaperStudentMapper.updateStuStartime(epsid,N_Utils.getSecondTimestamp());
134
-        map.put("paper",psvo);
135
-        map.put("questions",questions);
133
+        ePaperStudentMapper.updateStuStartime(epsid, N_Utils.getSecondTimestamp());
134
+        map.put("paper", psvo);
135
+        map.put("questions", questions);
136
         return map;
136
         return map;
137
     }
137
     }
138
 
138
 
200
             }
200
             }
201
         }
201
         }
202
 
202
 
203
-        if(ptype==2){
203
+        if (ptype == 2) {
204
             List<Map> files = ePaperFileMapper.listPaperFiles(psvo.getEpid());
204
             List<Map> files = ePaperFileMapper.listPaperFiles(psvo.getEpid());
205
             psvo.setFiles(files);
205
             psvo.setFiles(files);
206
         }
206
         }
207
         psvo.setQtypelist(questions);
207
         psvo.setQtypelist(questions);
208
-        ePaperStudentMapper.updateStuStartime(epsid,N_Utils.getSecondTimestamp());
208
+        ePaperStudentMapper.updateStuStartime(epsid, N_Utils.getSecondTimestamp());
209
         return psvo;
209
         return psvo;
210
     }
210
     }
211
 
211
 
220
         try {
220
         try {
221
             //学生作答提交时先判断试卷是否设置的正确答案
221
             //学生作答提交时先判断试卷是否设置的正确答案
222
             PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
222
             PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
223
-            setCommitQuestion(psq,answerVo);
223
+            setCommitQuestion(psq, answerVo);
224
             ePaperStudentQuestionMapper.updateStuAnswer(psq);
224
             ePaperStudentQuestionMapper.updateStuAnswer(psq);
225
-        }catch (Exception e){
226
-            log.error("提交试题失败:"+e.getMessage());
225
+        } catch (Exception e) {
226
+            log.error("提交试题失败:" + e.getMessage());
227
             throw new Exception("提交试题失败");
227
             throw new Exception("提交试题失败");
228
         }
228
         }
229
 
229
 
230
     }
230
     }
231
 
231
 
232
     //判断单道题情况
232
     //判断单道题情况
233
-    private void setCommitQuestion(EPaperStudentQuestion psq,PsqAnswerVo answerVo){
233
+    private void setCommitQuestion(EPaperStudentQuestion psq, PsqAnswerVo answerVo) {
234
         int timestamp = N_Utils.getSecondTimestamp();
234
         int timestamp = N_Utils.getSecondTimestamp();
235
         psq.setAnswertime(timestamp);
235
         psq.setAnswertime(timestamp);
236
         int coverted = 1;//是否转换0未转换1已转换2转换失败
236
         int coverted = 1;//是否转换0未转换1已转换2转换失败
238
         List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
238
         List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
239
         Double stuscore = 0D;
239
         Double stuscore = 0D;
240
 
240
 
241
-        if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
242
-                && N_Utils.isEmpty(psq.getStuanswertxt())){
241
+        if (N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
242
+                && N_Utils.isEmpty(psq.getStuanswertxt())) {
243
             psq.setStuscore(stuscore);
243
             psq.setStuscore(stuscore);
244
             psq.setChecked(2);
244
             psq.setChecked(2);
245
             psq.setChecktime(timestamp);
245
             psq.setChecktime(timestamp);
246
             psq.setAnswered(0);
246
             psq.setAnswered(0);
247
-        }else{
247
+        } else {
248
             //试卷已经设置了正确答案
248
             //试卷已经设置了正确答案
249
-            if (answerVo.getAnswered() == 1){
249
+            if (answerVo.getAnswered() == 1) {
250
                 String qanswer = answerVo.getAnswer();
250
                 String qanswer = answerVo.getAnswer();
251
-                List<String> qanswers = JSON.parseArray(qanswer,String.class);
251
+                List<String> qanswers = JSON.parseArray(qanswer, String.class);
252
                 int ctype = answerVo.getCtype();
252
                 int ctype = answerVo.getCtype();
253
-                if(psq.getAnswertype() == 1){
254
-                    if(N_Utils.isObjectiveQuestion(ctype)){
253
+                if (psq.getAnswertype() == 1) {
254
+                    if (N_Utils.isObjectiveQuestion(ctype)) {
255
                         //客观题进行批阅
255
                         //客观题进行批阅
256
-                        if(ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6){
256
+                        if (ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6) {
257
                             //单选、判断
257
                             //单选、判断
258
-                            if(stuanswer.equalsIgnoreCase(qanswer)) {
258
+                            if (stuanswer.equalsIgnoreCase(qanswer)) {
259
                                 stuscore = answerVo.getScore();
259
                                 stuscore = answerVo.getScore();
260
                             }
260
                             }
261
-                        }else if(ctype == 2){//多选
261
+                        } else if (ctype == 2) {//多选
262
                             //多选、选错不得分
262
                             //多选、选错不得分
263
-                            if(stuanswers.get(0).length() <= qanswer.length()){
263
+                            if (stuanswers.get(0).length() <= qanswer.length()) {
264
                                 String[] qanswerList = qanswers.get(0).split("");
264
                                 String[] qanswerList = qanswers.get(0).split("");
265
                                 String[] stuanswerList = stuanswers.get(0).split("");
265
                                 String[] stuanswerList = stuanswers.get(0).split("");
266
                                 int rightNum = 0;//选对个数
266
                                 int rightNum = 0;//选对个数
267
-                                for(String sa : stuanswerList){
267
+                                for (String sa : stuanswerList) {
268
                                     int right = 0;
268
                                     int right = 0;
269
-                                    for(String qa : qanswerList){
270
-                                        if(qa.equals(sa)){
269
+                                    for (String qa : qanswerList) {
270
+                                        if (qa.equals(sa)) {
271
                                             right = 1;
271
                                             right = 1;
272
-                                            rightNum ++;
272
+                                            rightNum++;
273
                                         }
273
                                         }
274
                                     }
274
                                     }
275
-                                    if(right == 0){//说明选错
275
+                                    if (right == 0) {//说明选错
276
                                         rightNum = 0;
276
                                         rightNum = 0;
277
                                         break;
277
                                         break;
278
                                     }
278
                                     }
279
                                 }
279
                                 }
280
-                                if(rightNum>0){
281
-                                    if(qanswerList.length == rightNum){
280
+                                if (rightNum > 0) {
281
+                                    if (qanswerList.length == rightNum) {
282
                                         //全选对
282
                                         //全选对
283
                                         stuscore = answerVo.getScore();
283
                                         stuscore = answerVo.getScore();
284
-                                    }else if (qanswerList.length > rightNum){
284
+                                    } else if (qanswerList.length > rightNum) {
285
                                         //少选得半分
285
                                         //少选得半分
286
-                                        stuscore = ExamUtil.div(answerVo.getScore(),2,1);
286
+                                        stuscore = ExamUtil.div(answerVo.getScore(), 2, 1);
287
                                     }
287
                                     }
288
                                 }
288
                                 }
289
                             }
289
                             }
290
-                        }else if(ctype == 7 || ctype == 8 || ctype == 10){
290
+                        } else if (ctype == 7 || ctype == 8 || ctype == 10) {
291
                             //完形填空、阅读理解、任务型阅读
291
                             //完形填空、阅读理解、任务型阅读
292
-                            Double qscore = ExamUtil.div(answerVo.getScore(),qanswers.size());
292
+                            Double qscore = ExamUtil.div(answerVo.getScore(), qanswers.size());
293
                             Double stuScoreDouble = 0d;
293
                             Double stuScoreDouble = 0d;
294
-                            for(int i=0;i<qanswers.size();i++){
295
-                                if(qanswers.get(i).equalsIgnoreCase(stuanswers.get(i))){
296
-                                    stuScoreDouble = ExamUtil.add(stuScoreDouble,qscore);
294
+                            for (int i = 0; i < qanswers.size(); i++) {
295
+                                if (qanswers.get(i).equalsIgnoreCase(stuanswers.get(i))) {
296
+                                    stuScoreDouble = ExamUtil.add(stuScoreDouble, qscore);
297
                                 }
297
                                 }
298
                             }
298
                             }
299
-                            stuscore = ExamUtil.round(stuScoreDouble,1);
299
+                            stuscore = ExamUtil.round(stuScoreDouble, 1);
300
                         }
300
                         }
301
-                        if(stuscore.compareTo(answerVo.getScore()) == 1){
301
+                        if (stuscore.compareTo(answerVo.getScore()) == 1) {
302
                             stuscore = answerVo.getScore();
302
                             stuscore = answerVo.getScore();
303
                         }
303
                         }
304
 
304
 
305
                         psq.setChecked(2);
305
                         psq.setChecked(2);
306
                         psq.setChecktime(timestamp);
306
                         psq.setChecktime(timestamp);
307
-                    }else{
308
-                        if(stuanswers.size() > 1){
307
+                    } else {
308
+                        if (stuanswers.size() > 1) {
309
                             coverted = 0;//上传的多张图片设为0未转换
309
                             coverted = 0;//上传的多张图片设为0未转换
310
                         }
310
                         }
311
                         psq.setChecked(0);
311
                         psq.setChecked(0);
312
                     }
312
                     }
313
-                }else{
313
+                } else {
314
                     psq.setChecked(0);
314
                     psq.setChecked(0);
315
                 }
315
                 }
316
-            }else{
316
+            } else {
317
                 psq.setStuscore(stuscore);
317
                 psq.setStuscore(stuscore);
318
                 psq.setChecked(0);
318
                 psq.setChecked(0);
319
             }
319
             }
320
         }
320
         }
321
         psq.setStuscore(stuscore);
321
         psq.setStuscore(stuscore);
322
         Integer costtime = answerVo.getCosttime();
322
         Integer costtime = answerVo.getCosttime();
323
-        if(costtime == null){
323
+        if (costtime == null) {
324
             costtime = 0;
324
             costtime = 0;
325
         }
325
         }
326
-        if(psq.getCosttime() == null){
326
+        if (psq.getCosttime() == null) {
327
             psq.setCosttime(costtime);
327
             psq.setCosttime(costtime);
328
-        }else{
328
+        } else {
329
             psq.setCosttime(psq.getCosttime());
329
             psq.setCosttime(psq.getCosttime());
330
         }
330
         }
331
 
331
 
340
      * @Date 2022/7/28 16:59
340
      * @Date 2022/7/28 16:59
341
      **/
341
      **/
342
     @Transactional(rollbackFor = Exception.class)
342
     @Transactional(rollbackFor = Exception.class)
343
-    public void saveCommitPaper(Integer epsid){
343
+    public void saveCommitPaper(Integer epsid) {
344
         EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(epsid);
344
         EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(epsid);
345
-        if(ps == null || ps.getSstate() == 2){
345
+        if (ps == null || ps.getSstate() == 2) {
346
             return;
346
             return;
347
         }
347
         }
348
         EPaperStudent paperStudent = new EPaperStudent();
348
         EPaperStudent paperStudent = new EPaperStudent();
355
         //获取试卷中未批阅试题数量
355
         //获取试卷中未批阅试题数量
356
         int noCheckNum = ePaperStudentQuestionMapper.getStuQuestionNoCheckNum(epsid);
356
         int noCheckNum = ePaperStudentQuestionMapper.getStuQuestionNoCheckNum(epsid);
357
         int checked = 0;
357
         int checked = 0;
358
-        if(noCheckNum == 0){
358
+        if (noCheckNum == 0) {
359
             checked = 2;//试卷中所有试题都批完后标识试卷已批改
359
             checked = 2;//试卷中所有试题都批完后标识试卷已批改
360
         }
360
         }
361
         paperStudent.setChecked(checked);
361
         paperStudent.setChecked(checked);
362
         ePaperStudentMapper.updateStudentPaper(paperStudent);//修改试卷信息
362
         ePaperStudentMapper.updateStudentPaper(paperStudent);//修改试卷信息
363
-        chandleStudentQuestionNoconvertedPic(epsid,1);//处理试卷中多张图片未合并情况
363
+        chandleStudentQuestionNoconvertedPic(epsid, 1);//处理试卷中多张图片未合并情况
364
     }
364
     }
365
 
365
 
366
     //处理试卷中未已提交需要合并的图片,type1代表线上2代表扫码答题卡图片
366
     //处理试卷中未已提交需要合并的图片,type1代表线上2代表扫码答题卡图片
367
-    private void chandleStudentQuestionNoconvertedPic(Integer epsid,Integer type){
367
+    private void chandleStudentQuestionNoconvertedPic(Integer epsid, Integer type) {
368
         List<EPaperStudentQuestion> psqlist = ePaperStudentQuestionMapper.listStuQuesitonStuAnswerPic(epsid);
368
         List<EPaperStudentQuestion> psqlist = ePaperStudentQuestionMapper.listStuQuesitonStuAnswerPic(epsid);
369
-        if(N_Utils.isListNotEmpty(psqlist)){
370
-            for(EPaperStudentQuestion sq : psqlist){
371
-                List<String> stuanswer = JSON.parseArray(sq.getStuanswer(),String.class);
372
-                if(N_Utils.isListNotEmpty(stuanswer) && stuanswer.size()>1){
373
-                    convertUtil.imgMerge(sq.getEpsqid(),stuanswer,type);
369
+        if (N_Utils.isListNotEmpty(psqlist)) {
370
+            for (EPaperStudentQuestion sq : psqlist) {
371
+                List<String> stuanswer = JSON.parseArray(sq.getStuanswer(), String.class);
372
+                if (N_Utils.isListNotEmpty(stuanswer) && stuanswer.size() > 1) {
373
+                    convertUtil.imgMerge(sq.getEpsqid(), stuanswer, type);
374
                 }
374
                 }
375
             }
375
             }
376
         }
376
         }
383
      * @Author wn
383
      * @Author wn
384
      * @Date 2022/7/28 19:18
384
      * @Date 2022/7/28 19:18
385
      **/
385
      **/
386
-    public void saveCommitPaperForWeb(PaperStudentWebVo pswvo){
386
+    public void saveCommitPaperForWeb(PaperStudentWebVo pswvo) {
387
         List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
387
         List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
388
         EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(pswvo.getEpsid());
388
         EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(pswvo.getEpsid());
389
         //试卷不存在或者已提交
389
         //试卷不存在或者已提交
390
-        if(ps == null || ps.getSstate() == 2){
390
+        if (ps == null || ps.getSstate() == 2) {
391
             return;
391
             return;
392
         }
392
         }
393
         //获取试卷中所有试题答案及分值
393
         //获取试卷中所有试题答案及分值
394
         List<PsqAnswerVo> anvolist = ePaperStudentQuestionMapper.listPaperQuestionsAnswer(pswvo.getEpsid());
394
         List<PsqAnswerVo> anvolist = ePaperStudentQuestionMapper.listPaperQuestionsAnswer(pswvo.getEpsid());
395
         Integer checknum = 0;//记录试卷中试题批阅数量
395
         Integer checknum = 0;//记录试卷中试题批阅数量
396
         Double paperscore = 0D;//学生试卷得分
396
         Double paperscore = 0D;//学生试卷得分
397
-        for(EPaperStudentQuestion q : sqlist){
397
+        for (EPaperStudentQuestion q : sqlist) {
398
 
398
 
399
             //获取该试题正确答案
399
             //获取该试题正确答案
400
             PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEpsqid().equals(q.getEpsqid())).findFirst().orElse(null);
400
             PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEpsqid().equals(q.getEpsqid())).findFirst().orElse(null);
401
 
401
 
402
-            setCommitQuestion(q,anvo);
403
-            if(q.getChecked() == 2){
404
-                checknum ++;
402
+            setCommitQuestion(q, anvo);
403
+            if (q.getChecked() == 2) {
404
+                checknum++;
405
             }
405
             }
406
             paperscore = ExamUtil.add(paperscore, q.getStuscore());
406
             paperscore = ExamUtil.add(paperscore, q.getStuscore());
407
         }
407
         }
411
         paperStudent.setSstate(2);
411
         paperStudent.setSstate(2);
412
         paperStudent.setStuscore(paperscore);
412
         paperStudent.setStuscore(paperscore);
413
         int checked = 0;
413
         int checked = 0;
414
-        if(checknum == sqlist.size()){
414
+        if (checknum == sqlist.size()) {
415
             checked = 2;
415
             checked = 2;
416
         }
416
         }
417
         paperStudent.setChecked(checked);
417
         paperStudent.setChecked(checked);
420
         ePaperStudentMapper.updateStudentPaper(paperStudent);
420
         ePaperStudentMapper.updateStudentPaper(paperStudent);
421
 
421
 
422
         //获取试卷中需要合并图片的试题
422
         //获取试卷中需要合并图片的试题
423
-        chandleStudentQuestionNoconvertedPic(pswvo.getEpsid(),1);
423
+        chandleStudentQuestionNoconvertedPic(pswvo.getEpsid(), 1);
424
     }
424
     }
425
 
425
 
426
     /**
426
     /**
431
      * @Date 2022/8/3 9:17
431
      * @Date 2022/8/3 9:17
432
      **/
432
      **/
433
     @Transactional(rollbackFor = Exception.class)
433
     @Transactional(rollbackFor = Exception.class)
434
-    public void saveCommitPaperForScantron(PaperStudentWebVo pswvo) throws Exception{
434
+    public void saveCommitPaperForScantron(PaperStudentWebVo pswvo) throws Exception {
435
 
435
 
436
         //扫描一次扫描数量+1
436
         //扫描一次扫描数量+1
437
         eScanbatchMapper.updateScannum(pswvo.getBatchid());
437
         eScanbatchMapper.updateScannum(pswvo.getBatchid());
473
     }
473
     }
474
 
474
 
475
     //更新扫描出错信息
475
     //更新扫描出错信息
476
-    private void updateScanErrorInfo(Integer errortype,PaperStudentWebVo pswvo){
476
+    private void updateScanErrorInfo(Integer errortype, PaperStudentWebVo pswvo) {
477
         //识别出错
477
         //识别出错
478
         EScanerror er = new EScanerror();
478
         EScanerror er = new EScanerror();
479
         er.setBatchid(pswvo.getBatchid());
479
         er.setBatchid(pswvo.getBatchid());
507
      * @Author wn
507
      * @Author wn
508
      * @Date 2022/8/12 10:45
508
      * @Date 2022/8/12 10:45
509
      **/
509
      **/
510
-    public Map getStudentPaperScore(Integer epsid){
510
+    public Map getStudentPaperScore(Integer epsid) {
511
         Map paper = ePaperStudentMapper.getStudentPaperScore(epsid);
511
         Map paper = ePaperStudentMapper.getStudentPaperScore(epsid);
512
         Integer ptype = Integer.parseInt(paper.get("ptype").toString());
512
         Integer ptype = Integer.parseInt(paper.get("ptype").toString());
513
         Integer epid = Integer.parseInt(paper.get("epid").toString());
513
         Integer epid = Integer.parseInt(paper.get("epid").toString());
514
         List<Map> qtypeques = null;
514
         List<Map> qtypeques = null;
515
-        if(ptype == 1){
515
+        if (ptype == 1) {
516
             qtypeques = ePaperStudentQuestionMapper.listQStuQuestionScore(epsid);
516
             qtypeques = ePaperStudentQuestionMapper.listQStuQuestionScore(epsid);
517
             setQuestionsForPaper(qtypeques);
517
             setQuestionsForPaper(qtypeques);
518
-        }else{
518
+        } else {
519
             qtypeques = ePaperStudentQuestionMapper.listFjStuQuestionScore(epsid);
519
             qtypeques = ePaperStudentQuestionMapper.listFjStuQuestionScore(epsid);
520
             List<Map> files = ePaperFileMapper.listPaperFiles(epid);
520
             List<Map> files = ePaperFileMapper.listPaperFiles(epid);
521
-            paper.put("files",files);
521
+            paper.put("files", files);
522
         }
522
         }
523
-        paper.put("qtypes",qtypeques);
523
+        paper.put("qtypes", qtypeques);
524
         return paper;
524
         return paper;
525
     }
525
     }
526
 
526
 
527
-    private void setQuestionsForPaper(List<Map> qtypes){
528
-        for(Map mt : qtypes){
529
-            Integer ctype = Integer.parseInt(mt.get("ctype").toString());
530
-            List<Map> mqlist = new ArrayList<>();
531
-            if(ctype == 11 || ctype == 16 || ctype == 17){
532
-                //符合题、完形填空、任务型阅读
533
-                List<Map> questions = (List<Map>) mt.get("questions");
534
-                Map<String,List<Map>> quemap = questions.stream().collect(Collectors.groupingBy(o -> o.get("questionpid").toString()));
535
-
536
-                for(Map.Entry<String,List<Map>> entry : quemap.entrySet()){
537
-                    List<Map> sonqlst = entry.getValue();
538
-                    Double sontotalsocre = sonqlst.stream().mapToDouble(o -> Double.parseDouble(o.get("score").toString())).sum();
539
-                    Double stuscore = sonqlst.stream().mapToDouble(o -> Double.parseDouble(o.get("stuscore").toString())).sum();
540
-                    Map sque = sonqlst.get(0);
541
-                    Map mque = new HashMap();
542
-                    mque.put("questionid",sque.get("mquestionid").toString());
543
-                    mque.put("qlevel",2);
544
-                    mque.put("qstem",sque.get("mqstem").toString());
545
-                    mque.put("ctype",Integer.parseInt(sque.get("mctype").toString()));
546
-                    mque.put("qtypeid",sque.get("mqtypeid").toString());
547
-                    mque.put("qtypename",sque.get("mqtypename").toString());
548
-                    mque.put("qorder",sque.get("qorder").toString());
549
-                    mque.put("qn",sque.get("qn").toString());
550
-                    mque.put("snum",Integer.parseInt(sque.get("snum").toString()));
551
-                    Integer hashear = Integer.parseInt(sque.get("mhashear").toString());
552
-                    mque.put("hashear",hashear);
553
-                    if(ctype == 12 && hashear==1){
554
-                        mque.put("hearfile",sque.get("mhearfile").toString());
555
-                    }else{
556
-                        mque.put("hearfile","");
557
-                    }
558
-                    mque.put("score",sontotalsocre);
559
-                    mque.put("sonques",sonqlst);
560
-                    mque.put("stuscore",stuscore);
561
-                    mqlist.add(mque);
562
-                }
563
-            }else if(ctype == 12){
564
-                //听力题,包含单题和复合题
565
-                List<Map> questions = (List<Map>) mt.get("questions");
566
-                List<String> questionpids = new ArrayList<>();
567
-                for(Map q : questions){
568
-                    Integer qlevel = Integer.parseInt(q.get("qlevel").toString());
569
-                    if(qlevel == 1){
570
-                        mqlist.add(q);
571
-                    }else{
572
-                        String questionpid = q.get("questionpid").toString();
573
-                        if(!questionpids.contains(questionpid)){
574
-                            questionpids.add(questionpid);
575
-
576
-                            List<Map> sonques = questions.stream().filter(s -> qlevel.equals(Integer.parseInt(s.get("qlevel").toString())) && questionpid.equals(s.get("questionpid").toString())).collect(Collectors.toList());
577
-                            Double sontotalsocre = sonques.stream().mapToDouble(o -> Double.parseDouble(o.get("score").toString())).sum();
578
-                            Double stuscore = sonques.stream().mapToDouble(o -> Double.parseDouble(o.get("stuscore").toString())).sum();
579
-                            Map mque = new HashMap();
580
-                            mque.put("questionid",questionpid);
581
-                            mque.put("qlevel",2);
582
-                            mque.put("qstem",q.get("mqstem").toString());
583
-                            mque.put("ctype",Integer.parseInt(q.get("mctype").toString()));
584
-                            mque.put("qtypeid",q.get("mqtypeid").toString());
585
-                            mque.put("qtypename",q.get("mqtypename").toString());
586
-                            mque.put("qorder",q.get("qorder").toString());
587
-                            mque.put("qn",q.get("qn").toString());
588
-                            mque.put("snum",Integer.parseInt(q.get("snum").toString()));
589
-                            Integer hashear = Integer.parseInt(q.get("mhashear").toString());
590
-                            mque.put("hashear",hashear);
591
-                            if(ctype == 12 && hashear == 1){
592
-                                mque.put("hearfile",q.get("mhearfile").toString());
593
-                            }else{
594
-                                mque.put("hearfile","");
595
-                            }
596
-                            mque.put("score",sontotalsocre);
597
-                            mque.put("stuscore",stuscore);
598
-                            mque.put("sonques",sonques);
599
-                            mqlist.add(mque);
527
+    //这只试卷中母子题
528
+    private void setQuestionsForPaper(List<Map> qtypes) {
529
+        for (Map mt : qtypes) {
530
+            List<Map> questions = (List<Map>) mt.get("questions");
531
+            List<Map> mqlist = new ArrayList<>();//存放母子题结构试题
532
+            List<String> mtquestionids = new ArrayList<>();//存放母题的id
533
+            for (Map qmap : questions) {
534
+                Integer qlevel = Integer.parseInt(qmap.get("qlevel").toString());
535
+                if (qlevel == 1) {
536
+                    //单题
537
+                    qmap.remove("mqstem");
538
+                    qmap.remove("mqoption");
539
+                    qmap.remove("msum");
540
+                    qmap.remove("mqtypeid");
541
+                    qmap.remove("mqtypename");
542
+                    qmap.remove("mhashear");
543
+                    qmap.remove("mhearfile");
544
+                    qmap.remove("mquestionid");
545
+                    qmap.remove("mctype");
546
+                    qmap.remove("questionpid");
547
+
548
+                    mqlist.add(qmap);
549
+                } else {
550
+                    //子题
551
+                    String questionpid = qmap.get("questionpid").toString();
552
+                    if (!mtquestionids.contains(questionpid)) {
553
+                        mtquestionids.add(questionpid);
554
+                        List<Map> sonqueslist =
555
+                                questions.stream().filter(s -> qlevel.equals(Integer.parseInt(s.get("qlevel").toString())) && questionpid.equals(s.get("questionpid").toString())).collect(Collectors.toList());
556
+
557
+                        Double sontotalsocre = sonqueslist.stream().mapToDouble(o -> Double.parseDouble(o.get("score").toString())).sum();
558
+                        Double stuscore = sonqueslist.stream().mapToDouble(o -> Double.parseDouble(o.get("stuscore").toString())).sum();
559
+                        Map sque = sonqueslist.get(0);
560
+                        Map mque = new HashMap();
561
+                        mque.put("questionid", sque.get("mquestionid").toString());
562
+                        mque.put("qlevel", 2);
563
+                        mque.put("qstem", sque.get("mqstem").toString());
564
+                        mque.put("ctype", Integer.parseInt(sque.get("mctype").toString()));
565
+                        mque.put("qtypeid", sque.get("mqtypeid").toString());
566
+                        mque.put("qtypename", sque.get("mqtypename").toString());
567
+                        mque.put("qorder", sque.get("qorder").toString());
568
+                        mque.put("qn", sque.get("qn").toString());
569
+                        mque.put("snum", Integer.parseInt(sque.get("snum").toString()));
570
+                        Integer hashear = Integer.parseInt(sque.get("mhashear").toString());
571
+                        mque.put("hashear", hashear);
572
+                        if (hashear == 1) {
573
+                            mque.put("hearfile", sque.get("mhearfile").toString());
574
+                        } else {
575
+                            mque.put("hearfile", "");
576
+                        }
577
+                        mque.put("score", sontotalsocre);
578
+                        mque.put("stuscore", stuscore);
579
+
580
+                        for(Map sonquem : sonqueslist){
581
+                            sonquem.remove("mqstem");
582
+                            sonquem.remove("mqoption");
583
+                            sonquem.remove("msum");
584
+                            sonquem.remove("mqtypeid");
585
+                            sonquem.remove("mqtypename");
586
+                            sonquem.remove("mhashear");
587
+                            sonquem.remove("mhearfile");
588
+                            sonquem.remove("mquestionid");
589
+                            sonquem.remove("mctype");
590
+                            sonquem.remove("hashear");
591
+                            sonquem.remove("hearfile");
600
                         }
592
                         }
593
+                        mque.put("sonques", sonqueslist);
594
+                        mqlist.add(mque);
601
                     }
595
                     }
602
                 }
596
                 }
603
-
604
-            }else{
605
-                List<Map> questions = (List<Map>) mt.get("questions");
606
-                mqlist.addAll(questions);
607
             }
597
             }
608
             mt.put("questions",mqlist);
598
             mt.put("questions",mqlist);
609
         }
599
         }
719
             }
709
             }
720
             q.setEpsqid(anvo.getEpsqid());
710
             q.setEpsqid(anvo.getEpsqid());
721
             paperscore = ExamUtil.add(paperscore, q.getStuscore());
711
             paperscore = ExamUtil.add(paperscore, q.getStuscore());
722
-            if(N_Utils.isObjectiveQuestion(q.getCtype()) && q.getAnswered()!=null && q.getAnswered()==1){
712
+            if (N_Utils.isObjectiveQuestion(q.getCtype()) && q.getAnswered() != null && q.getAnswered() == 1) {
723
                 rtnanswernum++;
713
                 rtnanswernum++;
724
             }
714
             }
725
         }
715
         }
782
     @Transactional(rollbackFor = Exception.class)
772
     @Transactional(rollbackFor = Exception.class)
783
     public void qkConfirm(List<PaperStudentWebVo> list) throws Exception {
773
     public void qkConfirm(List<PaperStudentWebVo> list) throws Exception {
784
         List<EPaperStudent> pslist = new ArrayList<>();
774
         List<EPaperStudent> pslist = new ArrayList<>();
785
-        for(PaperStudentWebVo objvo : list){
775
+        for (PaperStudentWebVo objvo : list) {
786
             EPaperStudent ps = new EPaperStudent();
776
             EPaperStudent ps = new EPaperStudent();
787
             ps.setEpsid(objvo.getEpsid());
777
             ps.setEpsid(objvo.getEpsid());
788
             ps.setSstate(objvo.getSstate());
778
             ps.setSstate(objvo.getSstate());

+ 30
- 41
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportStudentService.java View File

1
 package com.xhkjedu.sexam.service.report;
1
 package com.xhkjedu.sexam.service.report;
2
 
2
 
3
 import com.alibaba.fastjson.JSON;
3
 import com.alibaba.fastjson.JSON;
4
+import com.sun.org.apache.xml.internal.utils.QName;
4
 import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
5
 import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
5
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
6
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
6
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
7
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
180
         List<Map> list = null;
181
         List<Map> list = null;
181
         if (ptype == 1) {
182
         if (ptype == 1) {
182
             list = eRstudentMapper.listStudentQuestionsTk(epid, studentid);
183
             list = eRstudentMapper.listStudentQuestionsTk(epid, studentid);
183
-            setPaperQuestionForTK(list);
184
+            list = setPaperQuestionForTK(list);
184
         } else {
185
         } else {
185
             list = eRstudentMapper.listStudentQuestionsFj(epid, studentid);
186
             list = eRstudentMapper.listStudentQuestionsFj(epid, studentid);
186
             for (Map qmap : list) {
187
             for (Map qmap : list) {
203
             Integer qlevel = Integer.parseInt(q.get("qlevel").toString());
204
             Integer qlevel = Integer.parseInt(q.get("qlevel").toString());
204
             if (qlevel == 1) {
205
             if (qlevel == 1) {
205
                 //代表单题
206
                 //代表单题
206
-                Map map = new HashMap();
207
-                map.put("epsqid", Integer.parseInt(q.get("epsqid").toString()));
208
-                map.put("eptqid", Integer.parseInt(q.get("eptqid").toString()));
209
-                map.put("ctype", Integer.parseInt(q.get("ctype").toString()));
210
-                map.put("qn", q.get("qn").toString());
211
-                map.put("qorder", Integer.parseInt(q.get("qorder").toString()));
212
                 Double stuscore = Double.parseDouble(q.get("stuscore").toString());
207
                 Double stuscore = Double.parseDouble(q.get("stuscore").toString());
213
                 Double pscore = Double.parseDouble(q.get("qscore").toString());
208
                 Double pscore = Double.parseDouble(q.get("qscore").toString());
214
-                map.put("qscore", pscore);
215
-                map.put("stuscore", stuscore);
216
-                map.put("answered", Integer.parseInt(q.get("answered").toString()));
217
-                map.put("answertype", Integer.parseInt(q.get("answertype").toString()));
218
-                map.put("stuanswer", q.get("stuanswer").toString());
219
-                map.put("stuanswertxt", q.get("stuanswertxt").toString());
220
-                map.put("answer", q.get("answer").toString());
221
-                map.put("qstem", q.get("qstem").toString());
222
-                if (N_Utils.isNotEmpty(q.get("qoption"))) {
223
-                    map.put("qoption", q.get("qoption").toString());
224
-                } else {
225
-                    map.put("qoption", "");
226
-                }
227
-                if (N_Utils.isNotEmpty(q.get("qanalyze"))) {
228
-                    map.put("qanalyze", q.get("qanalyze").toString());
229
-                } else {
230
-                    map.put("qanalyze", "");
231
-                }
232
-
233
-                Integer hashear = Integer.parseInt(q.get("hashear").toString());
234
-                map.put("hashear", hashear);
235
-                if (hashear == 1) {
236
-                    map.put("hearfile", q.get("hearfile").toString());
237
-                }
209
+                q.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));//得分率
238
 
210
 
239
-                map.put("qlevel", qlevel);
240
-                map.put("classavgscore", Double.parseDouble(q.get("classavgscore").toString()));
241
-                map.put("gradeavgscore", Double.parseDouble(q.get("gradeavgscore").toString()));
242
-                map.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));//得分率
243
-
244
-                if (q.get("points") != null) {
245
-                    List<Map> points = (List<Map>) q.get("points");
246
-                    map.put("points", points);
247
-                }
248
-                rtnlist.add(map);
211
+                q.remove("mqstem");
212
+                q.remove("mqoption");
213
+                q.remove("msum");
214
+                q.remove("mqtypeid");
215
+                q.remove("mqtypename");
216
+                q.remove("mhashear");
217
+                q.remove("mhearfile");
218
+                q.remove("mquestionid");
219
+                q.remove("mctype");
220
+                q.remove("questionpid");
221
+                rtnlist.add(q);
249
             } else {
222
             } else {
250
                 //母题
223
                 //母题
251
                 String questionpid = q.get("questionpid").toString();
224
                 String questionpid = q.get("questionpid").toString();
288
 
261
 
289
                     Double stuscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("stuscore").toString())).sum();
262
                     Double stuscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("stuscore").toString())).sum();
290
                     Double pscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("qscore").toString())).sum();
263
                     Double pscore = sonqueslist.stream().mapToDouble(s -> Double.parseDouble(s.get("qscore").toString())).sum();
264
+                    mq.put("qscore",pscore);
265
+                    mq.put("stuscore",stuscore);
291
                     mq.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));
266
                     mq.put("srate", N_Utils.getDoubleDivideAndMulitiply(stuscore, pscore));
267
+                    for(Map sonmap : sonqueslist){
268
+                        sonmap.remove("mqstem");
269
+                        sonmap.remove("msum");
270
+                        sonmap.remove("mqoption");
271
+                        sonmap.remove("mqtypeid");
272
+                        sonmap.remove("mqtypename");
273
+                        sonmap.remove("mhashear");
274
+                        sonmap.remove("mhearfile");
275
+                        sonmap.remove("mquestionid");
276
+                        sonmap.remove("mctype");
277
+                        sonmap.remove("points");
278
+                        sonmap.remove("hashear");
279
+                        sonmap.remove("hearfile");
280
+                    }
292
                     mq.put("sonques", sonqueslist);
281
                     mq.put("sonques", sonqueslist);
293
                     rtnlist.add(mq);
282
                     rtnlist.add(mq);
294
                 }
283
                 }

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

164
             <result column="qtypename" property="qtypename"></result>
164
             <result column="qtypename" property="qtypename"></result>
165
             <result column="qctype" property="ctype"></result>
165
             <result column="qctype" property="ctype"></result>
166
             <result column="hashear" property="hashear"></result>
166
             <result column="hashear" property="hashear"></result>
167
-            <result column="qctype" property="ctype"></result>
168
             <result column="hearfile" property="hearfile"></result>
167
             <result column="hearfile" property="hearfile"></result>
169
             <result column="qoption" property="qoption"></result>
168
             <result column="qoption" property="qoption"></result>
169
+            <result column="qstem" property="qstem"></result>
170
             <result column="qlevel" property="qlevel"></result>
170
             <result column="qlevel" property="qlevel"></result>
171
             <result column="sorder" property="sorder"></result>
171
             <result column="sorder" property="sorder"></result>
172
             <result column="snum" property="snum"></result>
172
             <result column="snum" property="snum"></result>

Loading…
Cancel
Save