|
@@ -12,6 +12,7 @@ import com.xhkjedu.sexam.utils.ExamUtil;
|
12
|
12
|
import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
|
13
|
13
|
import com.xhkjedu.sexam.vo.paperstudent.PsqAnswerVo;
|
14
|
14
|
import com.xhkjedu.utils.N_Utils;
|
|
15
|
+import lombok.extern.slf4j.Slf4j;
|
15
|
16
|
import org.springframework.stereotype.Service;
|
16
|
17
|
|
17
|
18
|
import javax.annotation.Resource;
|
|
@@ -25,6 +26,7 @@ import java.util.Map;
|
25
|
26
|
* Date 2022/7/26 14:00
|
26
|
27
|
**/
|
27
|
28
|
@Service
|
|
29
|
+@Slf4j
|
28
|
30
|
public class EPaperStudentService {
|
29
|
31
|
@Resource
|
30
|
32
|
private EPaperStudentMapper ePaperStudentMapper;
|
|
@@ -153,75 +155,127 @@ public class EPaperStudentService {
|
153
|
155
|
return psvo;
|
154
|
156
|
}
|
155
|
157
|
|
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;
|
|
158
|
+ /**
|
|
159
|
+ * @Description 提交单题
|
|
160
|
+ * @Param [psq]
|
|
161
|
+ * @Return void
|
|
162
|
+ * @Author wn
|
|
163
|
+ * @Date 2022/7/28 13:47
|
|
164
|
+ **/
|
|
165
|
+ public void saveCommitQuestion(EPaperStudentQuestion psq) throws Exception {
|
|
166
|
+ try {
|
|
167
|
+ //学生作答提交时先判断试卷是否设置的正确答案
|
|
168
|
+ PsqAnswerVo answerVo = ePaperStudentQuestionMapper.getPaperQuestionAnswer(psq.getEpsqid());
|
|
169
|
+ int timestamp = N_Utils.getSecondTimestamp();
|
|
170
|
+ psq.setAnswertime(timestamp);
|
164
|
171
|
int coverted = 1;//是否转换0未转换1已转换2转换失败
|
165
|
172
|
String stuanswer = psq.getStuanswer();
|
166
|
173
|
List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
|
167
|
|
- String qanswer = answerVo.getAnswer();
|
168
|
|
- List<String> qanswers = JSON.parseArray(qanswer,String.class);
|
|
174
|
+ Double stuscore = 0.0;
|
|
175
|
+
|
169
|
176
|
if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
|
170
|
177
|
&& N_Utils.isEmpty(psq.getStuanswertxt())){
|
171
|
178
|
psq.setStuscore(stuscore);
|
172
|
|
- psq.setChecked(1);
|
|
179
|
+ psq.setChecked(2);
|
173
|
180
|
psq.setChecktime(timestamp);
|
174
|
181
|
psq.setAnswered(0);
|
175
|
182
|
}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
|
|
- //全选对
|
|
183
|
+ //试卷已经设置了正确答案
|
|
184
|
+ if (answerVo.getAnswered() == 1){
|
|
185
|
+ String qanswer = answerVo.getAnswer();
|
|
186
|
+ List<String> qanswers = JSON.parseArray(qanswer,String.class);
|
|
187
|
+ if(N_Utils.isListEmpty(stuanswers) && N_Utils.isEmpty(psq.getStuanswertxt())
|
|
188
|
+ && N_Utils.isEmpty(psq.getStuanswertxt())){
|
|
189
|
+ psq.setStuscore(stuscore);
|
|
190
|
+ psq.setChecked(1);
|
|
191
|
+ psq.setChecktime(timestamp);
|
|
192
|
+ psq.setAnswered(0);
|
|
193
|
+ }else{
|
|
194
|
+ int ctype = answerVo.getCtype();
|
|
195
|
+ if(N_Utils.isObjectiveQuestion(ctype)){
|
|
196
|
+ //客观题进行批阅
|
|
197
|
+ if(ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6){
|
|
198
|
+ //单选、判断
|
|
199
|
+ if(stuanswer.equalsIgnoreCase(qanswer)) {
|
206
|
200
|
stuscore = answerVo.getScore();
|
207
|
|
- }else if (qanswerList.length > rightNum){
|
208
|
|
- //少选得半分
|
209
|
|
- stuscore = ExamUtil.div(answerVo.getScore(),2,1);
|
210
|
201
|
}
|
|
202
|
+ }else if(ctype == 2){//多选
|
|
203
|
+ //多选、选错不得分
|
|
204
|
+ if(stuanswers.get(0).length() <= qanswer.length()){
|
|
205
|
+ String[] qanswerList = qanswers.get(0).split("");
|
|
206
|
+ String[] stuanswerList = stuanswers.get(0).split("");
|
|
207
|
+ int rightNum = 0;//选对个数
|
|
208
|
+ for(String sa : stuanswerList){
|
|
209
|
+ int right = 0;
|
|
210
|
+ for(String qa : qanswerList){
|
|
211
|
+ if(qa.equals(sa)){
|
|
212
|
+ right = 1;
|
|
213
|
+ rightNum ++;
|
|
214
|
+ }
|
|
215
|
+ }
|
|
216
|
+ if(right == 0){//说明选错
|
|
217
|
+ rightNum = 0;
|
|
218
|
+ break;
|
|
219
|
+ }
|
|
220
|
+ }
|
|
221
|
+ if(rightNum>0){
|
|
222
|
+ if(qanswerList.length == rightNum){
|
|
223
|
+ //全选对
|
|
224
|
+ stuscore = answerVo.getScore();
|
|
225
|
+ }else if (qanswerList.length > rightNum){
|
|
226
|
+ //少选得半分
|
|
227
|
+ stuscore = ExamUtil.div(answerVo.getScore(),2,1);
|
|
228
|
+ }
|
|
229
|
+ }
|
|
230
|
+ }
|
|
231
|
+ }else if(ctype == 7 || ctype == 8 || ctype == 10){
|
|
232
|
+ //完形填空、阅读理解、任务型阅读
|
|
233
|
+ Double qscore = ExamUtil.div(answerVo.getScore(),qanswers.size());
|
|
234
|
+ Double stuScoreDouble = 0d;
|
|
235
|
+ for(int i=0;i<qanswers.size();i++){
|
|
236
|
+ if(qanswers.get(i).equalsIgnoreCase(stuanswers.get(i))){
|
|
237
|
+ stuScoreDouble = ExamUtil.add(stuScoreDouble,qscore);
|
|
238
|
+ }
|
|
239
|
+ }
|
|
240
|
+ stuscore = ExamUtil.round(stuScoreDouble,1);
|
|
241
|
+ }
|
|
242
|
+ if(stuscore.compareTo(answerVo.getScore()) == 1){
|
|
243
|
+ stuscore = answerVo.getScore();
|
|
244
|
+ }
|
|
245
|
+ psq.setStuscore(stuscore);
|
|
246
|
+ psq.setChecked(2);
|
|
247
|
+ psq.setChecktime(timestamp);
|
|
248
|
+ }else{
|
|
249
|
+
|
|
250
|
+ if(stuanswers.size() > 0){
|
|
251
|
+ coverted = 0;//上传的多张图片设为0未转换
|
211
|
252
|
}
|
212
|
253
|
}
|
|
254
|
+ psq.setAnswered(1);
|
213
|
255
|
}
|
214
|
|
-
|
215
|
|
- }else{
|
216
|
|
-
|
217
|
256
|
}
|
218
|
|
- psq.setAnswered(1);
|
219
|
257
|
}
|
220
|
258
|
|
221
|
|
-
|
|
259
|
+ Integer costtime = answerVo.getCosttime();
|
|
260
|
+ if(costtime == null){
|
|
261
|
+ costtime = 0;
|
|
262
|
+ }
|
|
263
|
+ psq.setCosttime(psq.getCosttime() + costtime);
|
|
264
|
+ psq.setConverted(coverted);
|
|
265
|
+ ePaperStudentQuestionMapper.updateStuAnswer(psq);
|
|
266
|
+ }catch (Exception e){
|
|
267
|
+ log.error("提交试题失败:"+e.getMessage());
|
|
268
|
+ throw new Exception("提交试题失败");
|
222
|
269
|
}
|
223
|
270
|
|
224
|
271
|
}
|
225
|
272
|
|
|
273
|
+ public int saveCommitPaper(Integer epsid){
|
|
274
|
+ EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(epsid);
|
|
275
|
+ if(ps == null || ps.getSstate() == 1){
|
|
276
|
+ return 1;
|
|
277
|
+ }
|
|
278
|
+ return 1;
|
|
279
|
+ }
|
226
|
280
|
|
227
|
281
|
}
|