演示
系统是考试系统的改进版增加了了自动组卷功能 ,原来是将用的选的题目类型 /参数/难度拿到后台后,
生成随机数,从题库中随机获取题目。
实现的代码
@AutowiredQuestionService questionService;/*自动生成试卷*/@RequestMapping(value = "/edit", method = RequestMethod.POST)public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody Map map) {System.out.print(map);Integer difficulty = (Integer) map.get("difficulty");Integer multipleChoice = (Integer) map.get("multipleChoice");Integer shortAnswer = (Integer) map.get("shortAnswer");Integer trueFalse = (Integer) map.get("trueFalse");ExamPaperEditRequestVM model = new ExamPaperEditRequestVM();Instant instant = Instant.now();String timestamp = String.valueOf(instant.toEpochMilli());model.setLevel(1);model.setPaperType(1);model.setSubjectId(1);model.setName("自动生成试卷"+timestamp);model.setSuggestTime(30);model.setScore("100");ArrayList<ExamPaperTitleItemVM> titleitems = new ArrayList<ExamPaperTitleItemVM>();ExamPaperTitleItemVM examPaperTitleItemVM = new ExamPaperTitleItemVM();examPaperTitleItemVM.setName("智能试卷"+timestamp );ArrayList<QuestionEditRequestVM> questionEditRequestVMS = new ArrayList<>();List<Question> page = questionMapper.page(new QuestionPageRequestVM());ArrayList<Integer> integers = new ArrayList<>();Random random = new Random();List<Integer> ids1 = page.stream().filter(question -> question.getQuestionType() == 1) // 过滤指定类型的题目.filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目.map(Question::getId) // 获取题目的ID.limit(multipleChoice).collect(Collectors.toList());// 转换为列表List<Integer> ids3 = page.stream().filter(question -> question.getQuestionType() == 3) // 过滤指定类型的题目.filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目.map(Question::getId) // 获取题目的ID.distinct() // 去重.limit(shortAnswer).collect(Collectors.toList());// 转换为列表List<Integer> ids5 = page.stream().filter(question -> question.getQuestionType() == 5) // 过滤指定类型的题目.filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目.map(Question::getId) // 获取题目的ID.distinct() // 去重.limit(trueFalse).collect(Collectors.toList());// 转换为列表// 创建一个新的ArrayList用于合并List<Integer> mergedList = new ArrayList<>();mergedList.addAll(ids1);mergedList.addAll(ids3);mergedList.addAll(ids5);for (Integer id : mergedList) {QuestionEditRequestVM questionEditRequestVM = questionService.getQuestionEditRequestVM(id);questionEditRequestVMS.add(questionEditRequestVM);}examPaperTitleItemVM.setQuestionItems(questionEditRequestVMS);titleitems.add(examPaperTitleItemVM);model.setTitleItems(titleitems);ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser());ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId());return RestResponse.ok(newVM);}@Autowired QuestionService questionService; /*自动生成试卷*/ @RequestMapping(value = "/edit", method = RequestMethod.POST) public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody Map map) { System.out.print(map); Integer difficulty = (Integer) map.get("difficulty"); Integer multipleChoice = (Integer) map.get("multipleChoice"); Integer shortAnswer = (Integer) map.get("shortAnswer"); Integer trueFalse = (Integer) map.get("trueFalse"); ExamPaperEditRequestVM model = new ExamPaperEditRequestVM(); Instant instant = Instant.now(); String timestamp = String.valueOf(instant.toEpochMilli()); model.setLevel(1); model.setPaperType(1); model.setSubjectId(1); model.setName("自动生成试卷"+timestamp); model.setSuggestTime(30); model.setScore("100"); ArrayList<ExamPaperTitleItemVM> titleitems = new ArrayList<ExamPaperTitleItemVM>(); ExamPaperTitleItemVM examPaperTitleItemVM = new ExamPaperTitleItemVM(); examPaperTitleItemVM.setName("智能试卷"+timestamp ); ArrayList<QuestionEditRequestVM> questionEditRequestVMS = new ArrayList<>(); List<Question> page = questionMapper.page(new QuestionPageRequestVM()); ArrayList<Integer> integers = new ArrayList<>(); Random random = new Random(); List<Integer> ids1 = page.stream() .filter(question -> question.getQuestionType() == 1) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .limit(multipleChoice) .collect(Collectors.toList());// 转换为列表 List<Integer> ids3 = page.stream() .filter(question -> question.getQuestionType() == 3) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .distinct() // 去重 .limit(shortAnswer) .collect(Collectors.toList());// 转换为列表 List<Integer> ids5 = page.stream() .filter(question -> question.getQuestionType() == 5) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .distinct() // 去重 .limit(trueFalse) .collect(Collectors.toList());// 转换为列表 // 创建一个新的ArrayList用于合并 List<Integer> mergedList = new ArrayList<>(); mergedList.addAll(ids1); mergedList.addAll(ids3); mergedList.addAll(ids5); for (Integer id : mergedList) { QuestionEditRequestVM questionEditRequestVM = questionService.getQuestionEditRequestVM(id); questionEditRequestVMS.add(questionEditRequestVM); } examPaperTitleItemVM.setQuestionItems(questionEditRequestVMS); titleitems.add(examPaperTitleItemVM); model.setTitleItems(titleitems); ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser()); ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); return RestResponse.ok(newVM); }@Autowired QuestionService questionService; /*自动生成试卷*/ @RequestMapping(value = "/edit", method = RequestMethod.POST) public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody Map map) { System.out.print(map); Integer difficulty = (Integer) map.get("difficulty"); Integer multipleChoice = (Integer) map.get("multipleChoice"); Integer shortAnswer = (Integer) map.get("shortAnswer"); Integer trueFalse = (Integer) map.get("trueFalse"); ExamPaperEditRequestVM model = new ExamPaperEditRequestVM(); Instant instant = Instant.now(); String timestamp = String.valueOf(instant.toEpochMilli()); model.setLevel(1); model.setPaperType(1); model.setSubjectId(1); model.setName("自动生成试卷"+timestamp); model.setSuggestTime(30); model.setScore("100"); ArrayList<ExamPaperTitleItemVM> titleitems = new ArrayList<ExamPaperTitleItemVM>(); ExamPaperTitleItemVM examPaperTitleItemVM = new ExamPaperTitleItemVM(); examPaperTitleItemVM.setName("智能试卷"+timestamp ); ArrayList<QuestionEditRequestVM> questionEditRequestVMS = new ArrayList<>(); List<Question> page = questionMapper.page(new QuestionPageRequestVM()); ArrayList<Integer> integers = new ArrayList<>(); Random random = new Random(); List<Integer> ids1 = page.stream() .filter(question -> question.getQuestionType() == 1) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .limit(multipleChoice) .collect(Collectors.toList());// 转换为列表 List<Integer> ids3 = page.stream() .filter(question -> question.getQuestionType() == 3) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .distinct() // 去重 .limit(shortAnswer) .collect(Collectors.toList());// 转换为列表 List<Integer> ids5 = page.stream() .filter(question -> question.getQuestionType() == 5) // 过滤指定类型的题目 .filter(question -> question.getDifficult() == difficulty) // 过滤指定类型的题目 .map(Question::getId) // 获取题目的ID .distinct() // 去重 .limit(trueFalse) .collect(Collectors.toList());// 转换为列表 // 创建一个新的ArrayList用于合并 List<Integer> mergedList = new ArrayList<>(); mergedList.addAll(ids1); mergedList.addAll(ids3); mergedList.addAll(ids5); for (Integer id : mergedList) { QuestionEditRequestVM questionEditRequestVM = questionService.getQuestionEditRequestVM(id); questionEditRequestVMS.add(questionEditRequestVM); } examPaperTitleItemVM.setQuestionItems(questionEditRequestVMS); titleitems.add(examPaperTitleItemVM); model.setTitleItems(titleitems); ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser()); ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); return RestResponse.ok(newVM); }
修改密码
智能组卷
效果演示视频
【智能组卷系统的实现】 https://www.bilibili.com/video/BV16m411B7yV/?share_source=copy_web&vd_source=df4184718591e6cbac58f83db35ea5fe
源码下载
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
- 最新
- 最热
只看作者