From c8ebf3038d2a7f69d9eb40f5a276dc3fa826fa9b Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 10 Aug 2021 21:42:52 +0800
Subject: [PATCH] 报名接口修改,考试计算成绩接口修改,对比答案修改为对比所有题目
---
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java | 71 ++++++++++++++++++++++++++++-------
1 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
index f8c09c8..6f122fd 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -4,22 +4,26 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
+import org.springblade.common.utils.arg;
import org.springblade.modules.exam.entity.ExamExaminationSubject;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
+import org.springblade.modules.exam.entity.ExamSubjectChoices;
+import org.springblade.modules.exam.excel.ExamScoreExcel;
import org.springblade.modules.exam.mapper.ExamScoreMapper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
-import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
+import org.springblade.modules.exam.service.ExamSubjectChoicesService;
import org.springblade.modules.exam.vo.ExamResultVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
+
+import static com.bstek.ureport.expression.model.condition.Join.and;
/**
* 考试成绩服务实现类
@@ -30,6 +34,8 @@
public class ExamScoreServiceImpl extends ServiceImpl<ExamScoreMapper, ExamScore> implements ExamScoreService {
private final ExamPaperService examPaperService;
+
+ private final ExamSubjectChoicesService examSubjectChoicesService;
/**
* 自定义分页数据
@@ -63,25 +69,25 @@
if (examScore.getExamResultVOS().size()>0){
List<ExamResultVO> examResultVOS = examScore.getExamResultVOS();
//获取试卷的内容(题号,答案)
- ExamPaper examPaper = new ExamPaper();
- examPaper.setId(examScore.getPapersId());
- List<ExamExaminationSubject> examExaminationSubjects
- = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects();
+// ExamPaper examPaper = new ExamPaper();
+// examPaper.setId(examScore.getPapersId());
+// List<ExamExaminationSubject> examExaminationSubjects
+// = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects();
+ List<ExamSubjectChoices> list = examSubjectChoicesService.list();
//比对考试结果
//声明理论得分
int theoryGrade = 0;
for (ExamResultVO examResultVO : examResultVOS) {
- for (ExamExaminationSubject examExaminationSubject : examExaminationSubjects) {
+ for (ExamSubjectChoices es: list) {
//对比题目id
- if (examResultVO.getSubjectChoicesId().equals(examExaminationSubject.getExamSubjectChoices().getId())) {
+ if (examResultVO.getSubjectChoicesId().equals(es.getId())) {
//对比答案
-
- if (examExaminationSubject.getExamSubjectChoices().getChoicesType() == 2){
+ if (es.getChoicesType() == 2 || es.getChoicesType() == 3){
//判断题逻辑
- if (examResultVO.getValue().equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) {
+ if (examResultVO.getValue().equals(es.getAnswer())) {
theoryGrade += examResultVO.getGrade();
}
- }else if(examExaminationSubject.getExamSubjectChoices().getChoicesType() == 0 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 1){
+ }else if(es.getChoicesType() == 0 || es.getChoicesType() == 1){
//处理多选题的答案排序
String[] split = examResultVO.getValue().split(",");
StringBuilder builder = new StringBuilder();
@@ -93,12 +99,12 @@
Arrays.sort(arrayCh);
String sub0 = Arrays.toString(arrayCh);
String sub = sub0.substring(1,sub0.length()-1).replaceAll(" ","");
- if (sub.equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) {
+ if (sub.equals(es.getAnswer())) {
theoryGrade += examResultVO.getGrade();
}
}
//移除当前试卷题目答案对象
- examExaminationSubjects.remove(examExaminationSubject);
+ list.remove(es);
break;
}
}
@@ -115,6 +121,8 @@
}
//保存成绩数据
int i = baseMapper.insert(examScore);
+ //修改考试状态
+
if (i>0){
//返回结果
return true;
@@ -123,4 +131,37 @@
//返回结果
return false;
}
+
+ /**
+ * 导入实操成绩
+ * @param examScoreExcelList
+ * @param isCovered 是否覆盖
+ */
+ @Override
+ public void importExamScore(List<ExamScoreExcel> examScoreExcelList, Boolean isCovered) {
+ if (examScoreExcelList.size()>0){
+ examScoreExcelList.forEach(examScoreExcel -> {
+ if (null!=examScoreExcel.getLearnGrade() && null!=examScoreExcel.getIdCardNo() && examScoreExcel.getIdCardNo()!=""){
+ ExamScore examScore = baseMapper.getExamScoreInfoByIdCardNo(examScoreExcel.getIdCardNo());
+ if (null!=examScore) {
+ examScore.setLearnGrade(examScoreExcel.getLearnGrade());
+ if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) {
+ //合格
+ examScore.setQualified(0);
+ } else {
+ //不合格
+ examScore.setQualified(1);
+ }
+ //更新成绩数据
+ baseMapper.updateById(examScore);
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public List<Map<String, Object>> scoreStatistics() {
+ return baseMapper.scoreStatistics();
+ }
}
--
Gitblit v1.9.3