龚焕茏
2024-07-03 3ec909b27b3eba956aa9d00cc7a94c179bd04bbf
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -121,6 +121,7 @@
        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);
@@ -138,7 +139,10 @@
            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);
            //批量修改
@@ -167,6 +171,7 @@
            throw new RuntimeException("该试卷没有题目");
        }
        List<Question> questions = questionMapper.selectByIds(questionIds);
        //单选数量
        Integer singleChoice = questions.stream().filter(e -> e.getQuestionType() == 1).collect(Collectors.toList()).size();
        //多选数量
@@ -182,6 +187,7 @@
            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)),
@@ -217,7 +223,7 @@
                userNames.add(user.getRealName());
            }
        }
        vm.setUserId(userIds);
        vm.setUserIds(userIds);
        vm.setUserNames(userNames);
        return vm;
    }
@@ -523,9 +529,10 @@
        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<>();
            //多选