| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO; |
| | | import com.ycl.jxkg.domain.vo.student.wrong.CheckWrongVO; |
| | | import com.ycl.jxkg.mapper.ExamPaperMapper; |
| | | import com.ycl.jxkg.mapper.ExamPaperScoreMapper; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("StudentExamPaperAnswerController") |
| | |
| | | private final ExamPaperService examPaperService; |
| | | private final SubjectService subjectService; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | private final ExamPaperScoreMapper examPaperScoreMapper; |
| | | private final ExamPaperMapper examPaperMapper; |
| | | |
| | | |
| | | @RequestMapping(value = "/pageList", method = RequestMethod.POST) |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "/checkWrong", method = RequestMethod.POST) |
| | | public Result<ExamPaperScoreVO> checkWrong(@RequestBody @Valid DoQuestionVO model) { |
| | | ExamPaperScore examPaperScore = examPaperScoreService.getById(model.getId()); |
| | | public Result<ExamPaperScoreVO> checkWrong(@RequestBody @Valid CheckWrongVO model) { |
| | | ExamPaperScore info = new LambdaQueryChainWrapper<>(examPaperScoreMapper) |
| | | .eq(ExamPaperScore::getExamId, model.getExamId()) |
| | | .eq(ExamPaperScore::getUserId, getCurrentUser().getId()) |
| | | .one(); |
| | | |
| | | // model.setUserId(getCurrentUser().getId()); |
| | | // ExamPaperScore examPaperScore = examPaperScoreMapper.checkWrong(model); |
| | | |
| | | ExamPaperScore examPaperScore = examPaperScoreService.getById(info.getId()); |
| | | ExamPaperScoreVO examPaperScoreVO = new ExamPaperScoreVO(); |
| | | BeanUtils.copyProperties(examPaperScore, examPaperScoreVO); |
| | | User user = userService.getById(examPaperScore.getUserId()); |
| | |
| | | examPaperScoreVO.setNavbar(JSON.parseArray(examPaperScore.getNavbar(), ExamPaperMarkNavbarVO.class)); |
| | | examPaperScoreVO.setTitleItems(JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class)); |
| | | |
| | | List<PaperFixQuestionVO> titleItems = new ArrayList<>(); |
| | | List<DoQuestionVO> list = new ArrayList<>(); |
| | | List<PaperFixQuestionVO> collect = JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class).stream() |
| | | .filter(item -> item.getQuestionType() == model.getQuestionType()) |
| | | .collect(Collectors.toList()); |
| | | List<DoQuestionVO> doQuestionVOS = new ArrayList<>(); |
| | | |
| | | collect.stream().forEach(item -> { |
| | | item.getQuestionList().stream().forEach(question -> { |
| | | if (question.getId() == model.getQuestionId()) { |
| | | doQuestionVOS.add(question); |
| | | } |
| | | }); |
| | | }); |
| | | collect.stream().forEach(item -> { |
| | | item.setQuestionList(doQuestionVOS); |
| | | }); |
| | | |
| | | PaperFixQuestionVO paperFixQuestionVO = new PaperFixQuestionVO(); |
| | | paperFixQuestionVO.setQuestionType(model.getQuestionType()); |
| | | list.add(model); |
| | | paperFixQuestionVO.setQuestionList(list); |
| | | titleItems.add(paperFixQuestionVO); |
| | | examPaperScoreVO.setTitleItems(titleItems); |
| | | examPaperScoreVO.setTitleItems(collect); |
| | | return Result.ok(examPaperScoreVO); |
| | | } |
| | | |