| | |
| | | private final UserDepartmentMapper userDepartmentMapper; |
| | | private final DepartmentService departmentService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { |
| | | super(examPaperMapper); |
| | |
| | | examPaper.setCreateTime(now); |
| | | examPaper.setCreateUser(user.getId()); |
| | | examPaper.setDeleted(false); |
| | | examPaper.setUserIds(examPaperEditRequestVM.getMenuIds()); |
| | | examPaperFromVM(examPaperEditRequestVM, examPaper, titleItemsVM); |
| | | examPaperMapper.insertSelective(examPaper); |
| | | |
| | |
| | | ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(id); |
| | | ExamPaperEditRequestVM vm = modelMapper.map(examPaper, ExamPaperEditRequestVM.class); |
| | | vm.setLevel(examPaper.getGradeLevel()); |
| | | vm.setMenuIds(examPaper.getUserIds()); |
| | | TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId()); |
| | | List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class); |
| | | List<Integer> questionIds = examPaperTitleItemObjects.stream() |
| | |
| | | keys.remove(index); |
| | | } |
| | | } |
| | | |
| | | if (!values.isEmpty()) { |
| | | int index = random.nextInt(values.size()); |
| | | int score = values.get(index); |
| | |
| | | * @param titleItemsVM title |
| | | */ |
| | | private void randomQuestionType(ExamPaperEditRequestVM examPaperEditRequestVM, List<ExamPaperTitleItemObject> frameTextContentList, List<ExamPaperTitleItemVM> titleItemsVM) throws QuestionException { |
| | | |
| | | |
| | | //单选 |
| | | Integer singleChoice = examPaperEditRequestVM.getQuestionTypeVMS().stream().mapToInt(QuestionTypeVM::getSingleChoice).sum(); |
| | | //多选 |
| | | Integer multipleChoice = examPaperEditRequestVM.getQuestionTypeVMS().stream().mapToInt(QuestionTypeVM::getMultipleChoice).sum(); |
| | | //判断 |
| | | Integer judgment = examPaperEditRequestVM.getQuestionTypeVMS().stream().mapToInt(QuestionTypeVM::getTrueFalse).sum(); |
| | | if ((singleChoice * 2 + multipleChoice * 2 + judgment * 2) != new Integer(20)) { |
| | | |
| | | |
| | | if ((singleChoice * 2 + multipleChoice * 2 + judgment * 2) != new Integer(10)) { |
| | | throw new QuestionException(); |
| | | } |
| | | |
| | |
| | | Map<Integer, Integer> multipleMap = list.stream() |
| | | .filter(e -> e.getQuestionType().equals(QuestionTypeEnum.MultipleChoice.getCode())) |
| | | .collect(Collectors.toMap(Question::getId, Question::getScore)); |
| | | Integer multipleSource = questionTypeVM.getMultipleChoice() * 5; |
| | | Integer multipleSource = questionTypeVM.getMultipleChoice() * 2; |
| | | selectRandomScores(multiple, multipleMap, questionTypeVM.getMultipleChoice(), multipleSource); |
| | | |
| | | |
| | | //判断 |
| | | Map<Integer, Integer> judgmentMap = list.stream() |
| | | .filter(e -> e.getQuestionType().equals(QuestionTypeEnum.TrueFalse.getCode())) |
| | | .collect(Collectors.toMap(Question::getId, Question::getScore)); |
| | | Integer trueFalse = questionTypeVM.getTrueFalse() * 2; |
| | | List<Question> collect1 = list.stream().filter(e -> e.getQuestionType().equals(QuestionTypeEnum.TrueFalse.getCode())).collect(Collectors.toList()); |
| | | Map<Integer, Integer> judgmentMap = collect1.stream().collect(Collectors.toMap(Question::getId, Question::getScore)); |
| | | Integer trueFalse1 = questionTypeVM.getTrueFalse(); |
| | | Integer trueFalse = trueFalse1 * 2; |
| | | selectRandomScores(multiple, judgmentMap, questionTypeVM.getTrueFalse(), trueFalse); |
| | | |
| | | //单选分数 |