| | |
| | | import com.mindskip.xzs.domain.exam.ExamPaperQuestionItemObject; |
| | | import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.vo.ExamTemplatesVO; |
| | | import com.mindskip.xzs.domain.vo.PaperExcelVO; |
| | | import com.mindskip.xzs.domain.vo.UserVO; |
| | | import com.mindskip.xzs.repository.ExamPaperAnswerMapper; |
| | | import com.mindskip.xzs.repository.ExamPaperMapper; |
| | | import com.mindskip.xzs.repository.QuestionMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | |
| | | String frameTextContentStr = JsonUtil.toJsonStr(frameTextContentList); |
| | | |
| | | ExamPaper examPaper; |
| | | Integer[] userIds = examPaperEditRequestVM.getUserIds(); |
| | | if (actionEnum == ActionEnum.ADD) { |
| | | examPaper = modelMapper.map(examPaperEditRequestVM, ExamPaper.class); |
| | | TextContent frameTextContent = new TextContent(frameTextContentStr, now); |
| | |
| | | TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId()); |
| | | frameTextContent.setContent(frameTextContentStr); |
| | | textContentService.updateByIdFilter(frameTextContent); |
| | | examPaperEditRequestVM.setScore(null); |
| | | examPaperEditRequestVM.setUserIds(null); |
| | | modelMapper.map(examPaperEditRequestVM, examPaper); |
| | | examPaperEditRequestVM.setUserIds(userIds); |
| | | examPaperFromVM(examPaperEditRequestVM, examPaper, titleItemsVM); |
| | | examPaperMapper.updateByPrimaryKeySelective(examPaper); |
| | | //批量修改 |
| | |
| | | .flatMap(t -> t.getQuestionItems().stream() |
| | | .map(q -> q.getId())) |
| | | .collect(Collectors.toList()); |
| | | if (ObjectUtils.isEmpty(questionIds)) { |
| | | throw new RuntimeException("该试卷没有题目"); |
| | | } |
| | | List<Question> questions = questionMapper.selectByIds(questionIds); |
| | | |
| | | //单选数量 |
| | | Integer singleChoice = questions.stream().filter(e -> e.getQuestionType() == 1).collect(Collectors.toList()).size(); |
| | | //多选数量 |
| | |
| | | List<ExamQuestionVO> questionItemsVM = t.getQuestionItems().stream().map(i -> { |
| | | Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get(); |
| | | ExamQuestionVO questionEditRequestVM = questionService.getQuestionEditRequestVM(question); |
| | | |
| | | questionEditRequestVM.setTitle("(" + QuestionTypeEnum.fromCode(questionEditRequestVM.getQuestionType()).getName() + ") " + questionEditRequestVM.getTitle()); |
| | | questionEditRequestVM.setItemOrder(generateRandomNumber(questionEditRequestVM.getQuestionType() == 1 ? 0 : ((questionEditRequestVM.getQuestionType() == 2 ? singleChoice : multipleChoice + singleChoice)), |
| | | questionEditRequestVM.getQuestionType() == 1 ? singleChoice : ((questionEditRequestVM.getQuestionType() == 2 ? multipleChoice + singleChoice : trueFalse + multipleChoice + singleChoice)), |
| | |
| | | vm.setDepartmentIds(examPaperDepartmentService.getByExamPaperId(examPaper.getId()) |
| | | .stream().map(ExamPaperDepartment::getDepartmentId).toArray(Integer[]::new)); |
| | | List<ExamPaperUser> examPaperUsers = examPaperUserService.getByExamPaperId(examPaper.getId()); |
| | | Integer[][] userIds = new Integer[examPaperUsers.size()][2]; |
| | | List<Integer> userIds = new ArrayList(); |
| | | List<String> userNames = new ArrayList(); |
| | | for (int i = 0; i < examPaperUsers.size(); i++) { |
| | | Integer[] userId = {userService.getUserById(examPaperUsers.get(i).getUserId()).getUserLevel(), examPaperUsers.get(i).getUserId()}; |
| | | userIds[i] = userId; |
| | | User user = userService.getUserById(examPaperUsers.get(i).getUserId()); |
| | | if (ObjectUtils.isNotEmpty(user)) { |
| | | Integer userId = examPaperUsers.get(i).getUserId(); |
| | | userIds.add(userId); |
| | | userNames.add(user.getRealName()); |
| | | } |
| | | } |
| | | vm.setUserId(userIds); |
| | | vm.setUserIds(userIds); |
| | | vm.setUserNames(userNames); |
| | | return vm; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public Integer selectAllCount() { |
| | | return examPaperMapper.selectAllCount(); |
| | | public Integer selectAllCount(List<Integer> deptIds) { |
| | | return examPaperMapper.selectAllCount(deptIds); |
| | | } |
| | | |
| | | @Override |
| | |
| | | Integer order = 0; |
| | | for (QuestionTypeVM questionTypeVM : questionTypeVMList) { |
| | | |
| | | List<Integer> questions = questionSubjectService.getSubject(questionTypeVM.getSubjectId()) |
| | | List<Integer> questions = questionSubjectService.getSubjectBySubjectIds(examPaperEditRequestVM.getSubjectId()) |
| | | .stream().map(QuestionSubject::getQuestionId).collect(Collectors.toList()); |
| | | List<Question> list = questionService.selectByIds(questions); |
| | | // List<Question> list = questionService.getAll(); |
| | | |
| | | Map<Integer, Integer> multiple = new HashMap<>(); |
| | | //多选 |
| | |
| | | } |
| | | // 根据考试id将选择的补考考生的考试成绩设置为无效 |
| | | examPaperAnswerMapper.setMissExam(model); |
| | | |
| | | // 补考时将没有选择的并且没有参加过考试的考生增加一条零分考试记录,否则没有参加过考试的即使不被选择也可以参加补考 |
| | | examPaperAnswerMapper.insertDefault(model); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void missExamByTemplateId(ExamTemplatesVO model) { |
| | | List<Integer> id = examPaperMapper.getExamPaperByTemplateId(model); |
| | | model.setPaperIds(id); |
| | | // 根据考试id将选择的补考考生的考试成绩设置为无效 |
| | | examPaperAnswerMapper.setMissExamByTemplate(model); |
| | | } |
| | | |
| | | @Override |
| | | public List<ExamPaper> list(List<Integer> deptIds) { |
| | | List<ExamPaper> list = examPaperMapper.list(deptIds); |
| | | List<ExamPaper> template = examPaperMapper.template(deptIds); |
| | | list.addAll(template); |
| | | return list.stream().sorted(Comparator.comparing(ExamPaper::getCreateTime).reversed()).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<UserVO> selectStudent(UserVO userVO, List<Integer> adminDeptIds) { |
| | | userVO.setDeptIds(ObjectUtils.isNotEmpty(userVO.getDeptIds()) ? userVO.getDeptIds() : adminDeptIds); |
| | | return PageHelper.startPage(userVO.getPageIndex(), userVO.getPageSize()).doSelectPageInfo(() -> |
| | | examPaperMapper.selectStudent(userVO)); |
| | | } |
| | | |
| | | @Override |
| | | public List<ExamPaper> queryCondition() { |
| | | List<ExamPaper> examPaperList = examPaperMapper.getExamPaper(); |
| | | List<ExamPaper> templateList = examPaperMapper.getTemplate(); |
| | | examPaperList.addAll(templateList); |
| | | return examPaperList.stream().sorted(Comparator.comparing(ExamPaper::getCreateTime).reversed()).collect(Collectors.toList()); |
| | | } |
| | | } |