|
@@ -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
|
|