|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.xhkjedu.sexam.service.paperstudent;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
3
|
4
|
import com.xhkjedu.sexam.mapper.paper.EPaperQtypeMapper;
|
4
|
5
|
import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
|
5
|
6
|
import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
|
|
@@ -7,12 +8,14 @@ import com.xhkjedu.sexam.model.paper.EPaperQtype;
|
7
|
8
|
import com.xhkjedu.sexam.model.paper.EPaperQtypeQuestion;
|
8
|
9
|
import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
|
9
|
10
|
import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
|
|
11
|
+import com.xhkjedu.sexam.utils.ExamUtil;
|
10
|
12
|
import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
|
|
13
|
+import com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo;
|
|
14
|
+import com.xhkjedu.utils.N_Utils;
|
11
|
15
|
import org.springframework.stereotype.Service;
|
12
|
16
|
|
13
|
17
|
import javax.annotation.Resource;
|
14
|
18
|
import java.util.ArrayList;
|
15
|
|
-import java.util.HashMap;
|
16
|
19
|
import java.util.List;
|
17
|
20
|
import java.util.Map;
|
18
|
21
|
|
|
@@ -31,24 +34,26 @@ public class EPaperStudentService {
|
31
|
34
|
private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
|
32
|
35
|
|
33
|
36
|
/**
|
34
|
|
- * @Description 学生进行中考试列表
|
|
37
|
+ * @Description 学生进行中考试列表
|
35
|
38
|
* @Param [eps]
|
36
|
39
|
* @Return java.util.List<java.util.Map>
|
37
|
40
|
* @Author wn
|
38
|
41
|
* @Date 2022/7/27 10:35
|
39
|
42
|
**/
|
40
|
|
- public List<Map> listExamPapersForStudent(EPaperStudent eps){
|
|
43
|
+ public List<Map> listExamPapersForStudent(EPaperStudent eps) {
|
41
|
44
|
return ePaperStudentMapper.listExamPapersForStudent(eps.getStudentid());
|
42
|
45
|
}
|
43
|
46
|
|
44
|
|
- /** 学生已结束考试列表
|
|
47
|
+ /**
|
|
48
|
+ * 学生已结束考试列表
|
|
49
|
+ *
|
45
|
50
|
* @Description
|
46
|
51
|
* @Param [eps]
|
47
|
52
|
* @Return java.util.List<java.util.Map>
|
48
|
53
|
* @Author wn
|
49
|
54
|
* @Date 2022/7/27 11:34
|
50
|
55
|
**/
|
51
|
|
- public List<Map> listExamsEndForStudent(EPaperStudent eps){
|
|
56
|
+ public List<Map> listExamsEndForStudent(EPaperStudent eps) {
|
52
|
57
|
return ePaperStudentMapper.listExamsEndForStudent(eps.getStudentid());
|
53
|
58
|
}
|
54
|
59
|
|
|
@@ -59,28 +64,28 @@ public class EPaperStudentService {
|
59
|
64
|
* @Author wn
|
60
|
65
|
* @Date 2022/7/27 11:48
|
61
|
66
|
**/
|
62
|
|
- public List<Map> startPaperForAndroid(EPaperStudent eps){
|
|
67
|
+ public List<Map> startPaperForAndroid(EPaperStudent eps) {
|
63
|
68
|
Integer epsid = eps.getEpsid();
|
64
|
69
|
//获取试卷基本信息
|
65
|
70
|
EPaperStudentVo psvo = ePaperStudentMapper.getExamSubjectByEpsid(epsid);
|
66
|
71
|
Integer ptype = psvo.getPtype();
|
67
|
72
|
|
68
|
73
|
List<Map> questions = null;
|
69
|
|
- if(ptype == 1){
|
|
74
|
+ if (ptype == 1) {
|
70
|
75
|
//题库试卷试题
|
71
|
76
|
questions = ePaperStudentMapper.listStuPaperQuestionsForAndroid(epsid);
|
72
|
|
- }else{
|
|
77
|
+ } else {
|
73
|
78
|
questions = ePaperStudentMapper.listStuPaperFjQuestionsForAndroid(epsid);
|
74
|
79
|
}
|
75
|
80
|
//判断是否生成学生试卷,未生成则需要生成,如果已生成直接返回
|
76
|
|
- if(questions == null || questions.size() == 0){
|
|
81
|
+ if (questions == null || questions.size() == 0) {
|
77
|
82
|
|
78
|
83
|
//保存试卷关联信息
|
79
|
84
|
savePaperStudentQuestion(psvo);
|
80
|
85
|
//保存后重新获取返回
|
81
|
|
- if(ptype == 1){
|
|
86
|
+ if (ptype == 1) {
|
82
|
87
|
questions = ePaperStudentMapper.listStuPaperQuestionsForAndroid(epsid);
|
83
|
|
- }else{
|
|
88
|
+ } else {
|
84
|
89
|
questions = ePaperStudentMapper.listStuPaperFjQuestionsForAndroid(epsid);
|
85
|
90
|
}
|
86
|
91
|
}
|
|
@@ -88,12 +93,12 @@ public class EPaperStudentService {
|
88
|
93
|
}
|
89
|
94
|
|
90
|
95
|
//保存学生试卷关联信息
|
91
|
|
- private void savePaperStudentQuestion(EPaperStudentVo psvo){
|
|
96
|
+ private void savePaperStudentQuestion(EPaperStudentVo psvo) {
|
92
|
97
|
//生成学生试卷
|
93
|
98
|
List<EPaperQtypeQuestion> pqlist = ePaperQtypeMapper.listQuestionsByEpid(psvo.getEpid());
|
94
|
99
|
|
95
|
100
|
List<EPaperStudentQuestion> psqlist = new ArrayList<>();
|
96
|
|
- for(EPaperQtypeQuestion q : pqlist){
|
|
101
|
+ for (EPaperQtypeQuestion q : pqlist) {
|
97
|
102
|
EPaperStudentQuestion sq = new EPaperStudentQuestion();
|
98
|
103
|
sq.setClassid(psvo.getClassid());
|
99
|
104
|
sq.setStudentid(psvo.getStudentid());
|
|
@@ -120,27 +125,27 @@ public class EPaperStudentService {
|
120
|
125
|
* @Author wn
|
121
|
126
|
* @Date 2022/7/27 15:36
|
122
|
127
|
**/
|
123
|
|
- public EPaperStudentVo startPaperForWeb(EPaperStudent eps){
|
|
128
|
+ public EPaperStudentVo startPaperForWeb(EPaperStudent eps) {
|
124
|
129
|
Integer epsid = eps.getEpsid();
|
125
|
130
|
//获取试卷基本信息
|
126
|
131
|
EPaperStudentVo psvo = ePaperStudentMapper.getExamSubjectByEpsid(epsid);
|
127
|
132
|
Integer ptype = psvo.getPtype();
|
128
|
133
|
|
129
|
134
|
List<EPaperQtype> questions = null;
|
130
|
|
- if(ptype == 1){
|
|
135
|
+ if (ptype == 1) {
|
131
|
136
|
//题库试卷试题
|
132
|
137
|
questions = ePaperStudentMapper.listStuPaperQuestionsForWeb(epsid);
|
133
|
|
- }else{
|
|
138
|
+ } else {
|
134
|
139
|
questions = ePaperStudentMapper.listStuPaperFjQuestionsForWeb(epsid);
|
135
|
140
|
}
|
136
|
141
|
//判断是否生成学生试卷,未生成则需要生成,如果已生成直接返回
|
137
|
|
- if(questions == null || questions.size() == 0){
|
|
142
|
+ if (questions == null || questions.size() == 0) {
|
138
|
143
|
//保存试卷关联信息
|
139
|
144
|
savePaperStudentQuestion(psvo);
|
140
|
145
|
//保存后重新获取返回
|
141
|
|
- if(ptype == 1){
|
|
146
|
+ if (ptype == 1) {
|
142
|
147
|
questions = ePaperStudentMapper.listStuPaperQuestionsForWeb(epsid);
|
143
|
|
- }else{
|
|
148
|
+ } else {
|
144
|
149
|
questions = ePaperStudentMapper.listStuPaperFjQuestionsForWeb(epsid);
|
145
|
150
|
}
|
146
|
151
|
}
|
|
@@ -148,4 +153,75 @@ public class EPaperStudentService {
|
148
|
153
|
return psvo;
|
149
|
154
|
}
|
150
|
155
|
|
|
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;
|
|
164
|
+ int coverted = 1;//是否转换0未转换1已转换2转换失败
|
|
165
|
+ String stuanswer = psq.getStuanswer();
|
|
166
|
+ List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
|
|
167
|
+ String qanswer = answerVo.getAnswer();
|
|
168
|
+ List<String> qanswers = JSON.parseArray(qanswer,String.class);
|
|
169
|
+ if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
|
|
170
|
+ && N_Utils.isEmpty(psq.getStuanswertxt())){
|
|
171
|
+ psq.setStuscore(stuscore);
|
|
172
|
+ psq.setChecked(1);
|
|
173
|
+ psq.setChecktime(timestamp);
|
|
174
|
+ psq.setAnswered(0);
|
|
175
|
+ }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
|
+ //全选对
|
|
206
|
+ stuscore = answerVo.getScore();
|
|
207
|
+ }else if (qanswerList.length > rightNum){
|
|
208
|
+ //少选得半分
|
|
209
|
+ stuscore = ExamUtil.div(answerVo.getScore(),2,1);
|
|
210
|
+ }
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ }else{
|
|
216
|
+
|
|
217
|
+ }
|
|
218
|
+ psq.setAnswered(1);
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+ }
|
|
223
|
+
|
|
224
|
+ }
|
|
225
|
+
|
|
226
|
+
|
151
|
227
|
}
|