|
@@ -3,8 +3,12 @@ package com.xhkjedu.sexam.service.paper;
|
3
|
3
|
import com.alibaba.fastjson.JSON;
|
4
|
4
|
import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
|
5
|
5
|
import com.xhkjedu.sexam.mapper.paper.*;
|
|
6
|
+import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
|
|
7
|
+import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
|
6
|
8
|
import com.xhkjedu.sexam.mapper.system.UserBasketMapper;
|
7
|
9
|
import com.xhkjedu.sexam.model.paper.*;
|
|
10
|
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
|
|
11
|
+import com.xhkjedu.sexam.utils.ExamUtil;
|
8
|
12
|
import com.xhkjedu.sexam.vo.paper.*;
|
9
|
13
|
import com.xhkjedu.utils.N_Utils;
|
10
|
14
|
import com.xhkjedu.vo.ResultVo;
|
|
@@ -12,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
12
|
16
|
import org.springframework.beans.BeanUtils;
|
13
|
17
|
import org.springframework.stereotype.Service;
|
14
|
18
|
import org.springframework.transaction.annotation.Transactional;
|
|
19
|
+import org.w3c.dom.stylesheets.LinkStyle;
|
15
|
20
|
|
16
|
21
|
import javax.annotation.Resource;
|
17
|
22
|
import java.util.*;
|
|
@@ -40,6 +45,10 @@ public class EPaperQtypeService {
|
40
|
45
|
private EPaperFileMapper ePaperFileMapper;
|
41
|
46
|
@Resource
|
42
|
47
|
private UserBasketMapper userBasketMapper;
|
|
48
|
+ @Resource
|
|
49
|
+ private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
|
|
50
|
+ @Resource
|
|
51
|
+ private EPaperStudentMapper ePaperStudentMapper;
|
43
|
52
|
|
44
|
53
|
|
45
|
54
|
/**
|
|
@@ -517,9 +526,101 @@ public class EPaperQtypeService {
|
517
|
526
|
ePaperQtypeMapper.updateBatchQuestionAnswer(questions);
|
518
|
527
|
ePaper.setAnswered(1);
|
519
|
528
|
ePaperMapper.updateEPaperAnswered(ePaper);
|
|
529
|
+ //设置完答案进行匹配
|
|
530
|
+ }
|
|
531
|
+
|
|
532
|
+ private void setChangeQuestionAnswer(List<EPaperQtypeQuestion> questions,Integer epid){
|
520
|
533
|
//获取考试对应的状态,如果考试状态未进行中或者已结束,则需要更改学生已提交试卷中对应试题的答案
|
521
|
|
- Map map = ePaperMapper.getExamPaperAndSubject(ePaper.getEpid());
|
|
534
|
+ Map map = ePaperMapper.getExamPaperAndSubject(epid);
|
522
|
535
|
Integer examstate = Integer.parseInt(map.get("examstate").toString());
|
|
536
|
+ if(examstate > 0){
|
|
537
|
+ //获取试卷中原试题答案
|
|
538
|
+ List<EPaperQtypeQuestion> yqlist = ePaperQtypeMapper.listQuestionsByEpid(epid);
|
|
539
|
+ List<EPaperQtypeQuestion> changeQs = new ArrayList<>();//改变答案的试题
|
|
540
|
+ for(EPaperQtypeQuestion tq : questions){
|
|
541
|
+ EPaperQtypeQuestion yq = yqlist.stream().filter(y -> y.getEptqid().equals(tq.getEptqid())).findFirst().orElse(null);
|
|
542
|
+ if(!tq.getAnswer().equalsIgnoreCase(yq.getAnswer())){
|
|
543
|
+ //说明新设置的答案和原设置的答案不一致,则为变动的
|
|
544
|
+ tq.setCtype(yq.getCtype());
|
|
545
|
+ tq.setScore(yq.getScore());
|
|
546
|
+ changeQs.add(tq);
|
|
547
|
+ }
|
|
548
|
+ }
|
|
549
|
+ if(changeQs.size()>0){
|
|
550
|
+ //说明有试题答案变更,则更改学生试卷试题表中原批改内容
|
|
551
|
+ List<Integer> eptqids = changeQs.stream().map(EPaperQtypeQuestion::getEptqid).collect(Collectors.toList());
|
|
552
|
+ //学生试卷试题情况
|
|
553
|
+ List<EPaperStudentQuestion> psqlist = ePaperStudentQuestionMapper.listPaperStudentQuestionByeptqid(epid,eptqids);
|
|
554
|
+ if(N_Utils.isListNotEmpty(psqlist)){
|
|
555
|
+ List<EPaperStudentQuestion> uplist = new ArrayList<>();//要更新的
|
|
556
|
+ for(EPaperQtypeQuestion q : changeQs){
|
|
557
|
+ List<String> qanswers = JSON.parseArray(q.getAnswer(),String.class);
|
|
558
|
+ //处理指定试题
|
|
559
|
+ List<EPaperStudentQuestion> cqlist = psqlist.stream().filter(s -> s.getEptqid().equals(q.getEptqid())).collect(Collectors.toList());
|
|
560
|
+ for(EPaperStudentQuestion cq : cqlist){
|
|
561
|
+ Double stuscore = 0D;
|
|
562
|
+ List<String> stuanswers = JSON.parseArray(cq.getStuanswer(),String.class);
|
|
563
|
+ if(N_Utils.isListEmpty(stuanswers)){
|
|
564
|
+ break;
|
|
565
|
+ }else{
|
|
566
|
+ if(q.getCtype() == 1 || q.getCtype() == 4 || q.getCtype() == 5 || q.getCtype() == 6){
|
|
567
|
+ if(q.getAnswer().equalsIgnoreCase(cq.getStuanswer())){
|
|
568
|
+ stuscore = q.getScore();
|
|
569
|
+ }
|
|
570
|
+ }else if(q.getCtype() == 2){
|
|
571
|
+ if(stuanswers.get(0).length() <= qanswers.get(0).length()){
|
|
572
|
+ String[] qanswerList = qanswers.get(0).split("");
|
|
573
|
+ String[] stuanswerList = stuanswers.get(0).split("");
|
|
574
|
+ int rightNum = 0;//选对个数
|
|
575
|
+ for(String sa : stuanswerList){
|
|
576
|
+ int right = 0;
|
|
577
|
+ for(String qa : qanswerList){
|
|
578
|
+ if(qa.equals(sa)){
|
|
579
|
+ right = 1;
|
|
580
|
+ rightNum ++;
|
|
581
|
+ }
|
|
582
|
+ }
|
|
583
|
+ if(right == 0){//说明选错
|
|
584
|
+ rightNum = 0;
|
|
585
|
+ break;
|
|
586
|
+ }
|
|
587
|
+ }
|
|
588
|
+ if(rightNum>0){
|
|
589
|
+ if(qanswerList.length == rightNum){
|
|
590
|
+ //全选对
|
|
591
|
+ stuscore = q.getScore();
|
|
592
|
+ }else if (qanswerList.length > rightNum){
|
|
593
|
+ //少选得半分
|
|
594
|
+ stuscore = ExamUtil.div(q.getScore(), 2, 1);
|
|
595
|
+ }
|
|
596
|
+ }
|
|
597
|
+ }
|
|
598
|
+ }else if(q.getCtype() == 7 || q.getCtype() == 8 || q.getCtype() == 10){
|
|
599
|
+ //完形填空、阅读理解、任务型阅读
|
|
600
|
+ Double qscore = ExamUtil.div(q.getScore(),qanswers.size());
|
|
601
|
+ Double stuScoreDouble = 0d;
|
|
602
|
+ for(int i=0;i<qanswers.size();i++){
|
|
603
|
+ if(qanswers.get(i).equalsIgnoreCase(stuanswers.get(i))){
|
|
604
|
+ stuScoreDouble = ExamUtil.add(stuScoreDouble,qscore);
|
|
605
|
+ }
|
|
606
|
+ }
|
|
607
|
+ stuscore = ExamUtil.round(stuScoreDouble,1);
|
|
608
|
+ }
|
|
609
|
+ cq.setStuscore(stuscore);
|
|
610
|
+ uplist.add(cq);
|
|
611
|
+ }
|
|
612
|
+ }
|
|
613
|
+ }
|
|
614
|
+
|
|
615
|
+ if(N_Utils.isListNotEmpty(uplist)){
|
|
616
|
+ //批量更新学生试题分值
|
|
617
|
+ ePaperStudentQuestionMapper.updateBatchStuQuestionScore(uplist);
|
|
618
|
+ //更新学生试卷分值
|
|
619
|
+ ePaperStudentMapper.updateBathStudentPaperScoreByEpid(epid);
|
|
620
|
+ }
|
|
621
|
+ }
|
|
622
|
+ }
|
|
623
|
+ }
|
523
|
624
|
}
|
524
|
625
|
|
525
|
626
|
/**
|