| | |
| | | package com.ycl.jxkg.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.domain.entity.ExamPaperScore; |
| | | import com.ycl.jxkg.domain.entity.Question; |
| | | import com.ycl.jxkg.domain.entity.QuestionAnswerRecord; |
| | | import com.ycl.jxkg.domain.vo.DoQuestionVO; |
| | | import com.ycl.jxkg.domain.vo.PaperFixQuestionVO; |
| | | import com.ycl.jxkg.domain.vo.student.wrong.WrongPageVo; |
| | | import com.ycl.jxkg.domain.vo.student.wrong.WrongRequestVo; |
| | | import com.ycl.jxkg.domain.vo.student.wrong.WrongResponseVO; |
| | | import com.ycl.jxkg.mapper.ExamPaperScoreMapper; |
| | | import com.ycl.jxkg.mapper.QuestionAnswerRecordMapper; |
| | | import com.ycl.jxkg.mapper.QuestionMapper; |
| | | import com.ycl.jxkg.service.WrongService; |
| | | import com.ycl.jxkg.utils.JsonUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | private ExamPaperScoreMapper examPaperScoreMapper; |
| | | @Autowired |
| | | private QuestionMapper questionMapper; |
| | | @Autowired |
| | | private QuestionAnswerRecordMapper questionAnswerRecordMapper; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 分页条件查询错题 |
| | | * 条件查询错题 |
| | | * */ |
| | | @Override |
| | | public List<DoQuestionVO> page(WrongRequestVo wrongRequestVo) { |
| | | // 查询该用户的所有非随机试卷及试卷错题 |
| | | // List<ExamPaperScore> examPaperScores = examPaperScoreMapper |
| | | // .selectList(new LambdaQueryChainWrapper<>(ExamPaperScore.class) |
| | | // .eq(ExamPaperScore::getUserId,wrongRequestVo.getUserId())); |
| | | // 查询该用户的所有考试 |
| | | List<ExamPaperScore> examPaperScores = examPaperScoreMapper.selectByUserId(wrongRequestVo.getUserId()); |
| | | List<PaperFixQuestionVO> paperList = new ArrayList<>(); |
| | | List<DoQuestionVO> questions = new ArrayList<>(); |
| | | // 遍历所有考试获得考试详情 |
| | | examPaperScores.stream().forEach(examPaperScore -> { |
| | | try{ |
| | | // 解析json字符串 |
| | | List<PaperFixQuestionVO> paperFixQuestionVOS = JsonUtil.toJsonListObject(examPaperScore.getPaperContent(), PaperFixQuestionVO.class); |
| | | paperFixQuestionVOS.stream().forEach(paperFixQuestionVO -> { |
| | | List<DoQuestionVO> doQuestionVOS = paperFixQuestionVO.getQuestionList().stream() |
| | | .filter(doQuestionVO -> !doQuestionVO.getRight()) |
| | | .map(doQuestionVO -> { |
| | | // 根据id查询题干 |
| | | Question question = questionMapper.selectById(doQuestionVO.getId()); |
| | | doQuestionVO.setExamId(examPaperScore.getExamId()); |
| | | doQuestionVO.setExamName(examPaperScore.getExamName()); |
| | | doQuestionVO.setTitle(question.getTitle()); |
| | | return doQuestionVO; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | questions.addAll(doQuestionVOS); |
| | | }); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | public PageInfo<WrongResponseVO> list(WrongRequestVo wrongRequestVo) { |
| | | return PageHelper.startPage(wrongRequestVo.getPageIndex(), wrongRequestVo.getPageSize()).doSelectPageInfo(() -> { |
| | | questionAnswerRecordMapper.selectWrongQuestion(wrongRequestVo); |
| | | }); |
| | | return questions; |
| | | } |
| | | } |