|
@@ -1,13 +1,14 @@
|
1
|
1
|
package com.xhkjedu.smarking.service.paper;
|
2
|
2
|
|
3
|
3
|
import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
|
4
|
|
-import com.xhkjedu.smarking.mapper.paper.MsPaperBlockMapper;
|
5
|
|
-import com.xhkjedu.smarking.mapper.paper.MsPaperBlockQuestionMapper;
|
6
|
|
-import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
|
7
|
|
-import com.xhkjedu.smarking.model.paper.MsPaper;
|
|
4
|
+import com.xhkjedu.smarking.mapper.paper.*;
|
|
5
|
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentBlockMapper;
|
|
6
|
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
|
8
|
7
|
import com.xhkjedu.smarking.model.paper.MsPaperBlock;
|
9
|
8
|
import com.xhkjedu.smarking.model.paper.MsPaperBlockQuestion;
|
|
9
|
+import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion;
|
10
|
10
|
import com.xhkjedu.smarking.vo.paper.MsPaperParams;
|
|
11
|
+import com.xhkjedu.smarking.vo.paper.PExamSubjectVo;
|
11
|
12
|
import com.xhkjedu.utils.N_Utils;
|
12
|
13
|
import org.springframework.stereotype.Service;
|
13
|
14
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -31,6 +32,12 @@ public class MsPaperBlockService {
|
31
|
32
|
private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
|
32
|
33
|
@Resource
|
33
|
34
|
private MsSubjectMapper msSubjectMapper;
|
|
35
|
+ @Resource
|
|
36
|
+ private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
|
|
37
|
+ @Resource
|
|
38
|
+ private MsPaperStudentBlockMapper msPaperStudentBlockMapper;
|
|
39
|
+ @Resource
|
|
40
|
+ private MsPaperStudentMapper msPaperStudentMapper;
|
34
|
41
|
|
35
|
42
|
/*
|
36
|
43
|
* @Description 获取试卷所有题块
|
|
@@ -54,23 +61,59 @@ public class MsPaperBlockService {
|
54
|
61
|
**/
|
55
|
62
|
@Transactional(rollbackFor = Exception.class)
|
56
|
63
|
public Integer save(MsPaperParams params){
|
57
|
|
- MsPaper paper = msPaperMapper.getPaperBaseByMsid(params.getMsid());
|
|
64
|
+ PExamSubjectVo paper = msPaperMapper.getPaperAndMxammodeByMsid(params.getMsid());
|
58
|
65
|
Integer mpid = paper.getMpid();
|
59
|
|
- //先删除已存在题块
|
60
|
|
- msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
|
61
|
66
|
|
62
|
|
- Integer createid = paper.getCreateid();
|
|
67
|
+ Integer createid = params.getCreateid();
|
63
|
68
|
Integer timestamp = N_Utils.getSecondTimestamp();
|
|
69
|
+ List<MsPaperBlockQuestion> questions = new ArrayList<>();//保存的题块下试题
|
|
70
|
+ int papernum = 0;//试卷中试题总数量
|
|
71
|
+ if(paper.getExammode() == 3){
|
|
72
|
+ //线上考试,删除所有题块
|
|
73
|
+ msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,null);
|
|
74
|
+ //保存客观题相关题块
|
|
75
|
+ List<MsPaperQtypeQuestion> objQues = msPaperQtypeQuestionMapper.listObjectiveQuestionByMpid(mpid,N_Utils.objectiveList);
|
|
76
|
+ papernum = objQues.size();
|
|
77
|
+ Double bqscore = objQues.stream().mapToDouble(MsPaperQtypeQuestion::getQscore).sum();
|
|
78
|
+ MsPaperBlock obBlock = new MsPaperBlock();
|
|
79
|
+ obBlock.setMpid(mpid);
|
|
80
|
+ obBlock.setBlockname("客观题题块1");
|
|
81
|
+ obBlock.setBlocktype(1);
|
|
82
|
+ obBlock.setBlockorder(objQues.get(0).getQorder());
|
|
83
|
+ obBlock.setBqnum(papernum);
|
|
84
|
+ obBlock.setBqscore(bqscore);
|
|
85
|
+ obBlock.setCreateid(createid);
|
|
86
|
+ obBlock.setCreatetime(timestamp);
|
|
87
|
+ msPaperBlockMapper.insertUseGeneratedKeys(obBlock);
|
|
88
|
+ Integer mblockid = obBlock.getId();
|
|
89
|
+ for(MsPaperQtypeQuestion q : objQues){
|
|
90
|
+ MsPaperBlockQuestion bq = new MsPaperBlockQuestion();
|
|
91
|
+ bq.setMblockid(mblockid);
|
|
92
|
+ bq.setMpid(mpid);
|
|
93
|
+ bq.setMbqtype(1);
|
|
94
|
+ bq.setMptqid(q.getMptqid());
|
|
95
|
+ bq.setBqn(q.getQn());
|
|
96
|
+ bq.setBqscore(q.getQscore());
|
|
97
|
+ bq.setBqorder(q.getQorder());
|
|
98
|
+ bq.setCreateid(createid);
|
|
99
|
+ bq.setCreatetime(timestamp);
|
|
100
|
+ questions.add(bq);
|
|
101
|
+ }
|
|
102
|
+ }else{
|
|
103
|
+ //先删除已存在主观题题块
|
|
104
|
+ msPaperBlockMapper.deleteObjByMpidAndBlocktype(mpid,2);
|
|
105
|
+ }
|
|
106
|
+
|
64
|
107
|
List<MsPaperBlock> blocks = params.getBlocks();
|
65
|
108
|
for(MsPaperBlock block : blocks){
|
66
|
109
|
block.setBlocktype(2);
|
67
|
110
|
block.setMpid(mpid);
|
68
|
111
|
block.setCreateid(createid);
|
69
|
112
|
block.setCreatetime(timestamp);
|
|
113
|
+ papernum += block.getBqnum();
|
70
|
114
|
}
|
71
|
115
|
msPaperBlockMapper.insertList(blocks);
|
72
|
|
-
|
73
|
|
- List<MsPaperBlockQuestion> questions = new ArrayList<>();
|
|
116
|
+ //保存题块下试题
|
74
|
117
|
for(MsPaperBlock block : blocks){
|
75
|
118
|
List<MsPaperBlockQuestion> bqs = block.getQuestions();
|
76
|
119
|
for(MsPaperBlockQuestion bq : bqs){
|
|
@@ -83,9 +126,17 @@ public class MsPaperBlockService {
|
83
|
126
|
}
|
84
|
127
|
|
85
|
128
|
msPaperBlockQuestionMapper.insertList(questions);
|
|
129
|
+ int pbsate = 1;
|
|
130
|
+ if(paper.getExammode() == 3){
|
|
131
|
+ pbsate = 2;//线上考试,设置完题块,科目题块状态变为已完成;线下考试需要为题块框选
|
|
132
|
+ }
|
86
|
133
|
//更改科目题块框选状态
|
87
|
|
- msSubjectMapper.updatePbstateByMpid(mpid,1);//题块状态变成设置中
|
|
134
|
+ msSubjectMapper.updatePbstateByMpid(mpid,pbsate);//题块状态变成设置中
|
|
135
|
+ //修改试卷中合并后试题数量
|
|
136
|
+ msPaperMapper.updaePaperMeregpnumByMpid(mpid,papernum);
|
|
137
|
+ msPaperStudentMapper.updatePaperMergepnumByMpid(mpid, papernum);
|
88
|
138
|
//保存完题块后,需要清除之前已经生产的学生答案、批阅信息之类的数据,
|
|
139
|
+ msPaperStudentBlockMapper.updateStudentBlockQuestionByMpid(mpid);
|
89
|
140
|
//知识点,难易度关联需要重新处理;新的题块试题需要绑定知识点,难度度如何处理?
|
90
|
141
|
|
91
|
142
|
return mpid;
|