| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | ExamPaper examPaper = new ExamPaper(); |
| | | examPaper.setId(examScore.getPapersId()); |
| | | List<ExamExaminationSubject> examExaminationSubjects |
| | | = examPaperService.queryPagerSubject(examPaper).getExamExaminationSubjects(); |
| | | = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects(); |
| | | //比对考试结果 |
| | | //声明理论得分 |
| | | int theoryGrade = 0; |
| | | for (int i = 0; i < examResultVOS.size(); i++) { |
| | | if (examResultVOS.get(i).getValue().equals(examExaminationSubjects.get(i).getExamSubjectChoices().getAnswer())){ |
| | | theoryGrade += examResultVOS.get(i).getGrade(); |
| | | for (ExamResultVO examResultVO : examResultVOS) { |
| | | for (ExamExaminationSubject examExaminationSubject : examExaminationSubjects) { |
| | | //对比题目id |
| | | if (examResultVO.getSubjectChoicesId().equals(examExaminationSubject.getExamSubjectChoices().getId())) { |
| | | //对比答案 |
| | | |
| | | if (examExaminationSubject.getExamSubjectChoices().getChoicesType() == 2){ |
| | | //判断题逻辑 |
| | | if (examResultVO.getValue().equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) { |
| | | theoryGrade += examResultVO.getGrade(); |
| | | } |
| | | }else if(examExaminationSubject.getExamSubjectChoices().getChoicesType() == 0 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 1){ |
| | | //处理多选题的答案排序 |
| | | String[] split = examResultVO.getValue().split(","); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String s : split) { |
| | | builder.append(s); |
| | | } |
| | | char[] arrayCh = builder.toString().toCharArray(); |
| | | //利用数组帮助类自动排序 |
| | | Arrays.sort(arrayCh); |
| | | String sub0 = Arrays.toString(arrayCh); |
| | | String sub = sub0.substring(1,sub0.length()-1).replaceAll(" ",""); |
| | | if (sub.equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) { |
| | | theoryGrade += examResultVO.getGrade(); |
| | | } |
| | | } |
| | | //移除当前试卷题目答案对象 |
| | | examExaminationSubjects.remove(examExaminationSubject); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //设置理论得分 |
| | | examScore.setTheoryGrade(theoryGrade); |
| | | //计算总成绩 |
| | | examScore.setAllGrade(theoryGrade + examScore.getLearnGrade()); |
| | | //计算总成绩,此时没有实操成绩,总成绩为实操成绩和理论成绩和的一半 |
| | | examScore.setAllGrade(Math.round(theoryGrade/2)); |
| | | //设置状态 |
| | | if (theoryGrade>=60){ |
| | | examScore.setQualified(2); |
| | | }else { |
| | | examScore.setQualified(1); |
| | | } |
| | | //保存成绩数据 |
| | | int i = baseMapper.insert(examScore); |
| | | if (i>0){ |