luohairen
2024-11-12 f18c0b3336a10bc36a9e5ca34a03b6d19c34569b
优化错题详情
3个文件已修改
1个文件已添加
59 ■■■■ 已修改文件
src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/vo/student/wrong/CheckWrongVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/vo/student/wrong/WrongResponseVO.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QuestionAnswerRecordMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
@@ -1,6 +1,7 @@
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;
@@ -14,6 +15,8 @@
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.ExamPaperScoreMapper;
import com.ycl.jxkg.service.ExamPaperScoreService;
import com.ycl.jxkg.service.ExamPaperService;
import com.ycl.jxkg.service.SubjectService;
@@ -27,6 +30,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@RequiredArgsConstructor
@RestController("StudentExamPaperAnswerController")
@@ -38,6 +42,7 @@
    private final ExamPaperService examPaperService;
    private final SubjectService subjectService;
    private final ApplicationEventPublisher eventPublisher;
    private final ExamPaperScoreMapper examPaperScoreMapper;
    @RequestMapping(value = "/pageList", method = RequestMethod.POST)
@@ -104,8 +109,12 @@
    @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();
        ExamPaperScore examPaperScore = examPaperScoreService.getById(info.getId());
        ExamPaperScoreVO examPaperScoreVO = new ExamPaperScoreVO();
        BeanUtils.copyProperties(examPaperScore, examPaperScoreVO);
        User user = userService.getById(examPaperScore.getUserId());
@@ -113,14 +122,25 @@
        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);
    }
src/main/java/com/ycl/jxkg/domain/vo/student/wrong/CheckWrongVO.java
New file
@@ -0,0 +1,14 @@
package com.ycl.jxkg.domain.vo.student.wrong;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CheckWrongVO {
    private Integer examId;
    private Integer questionType;
    private Integer questionId;
}
src/main/java/com/ycl/jxkg/domain/vo/student/wrong/WrongResponseVO.java
@@ -15,7 +15,8 @@
@AllArgsConstructor
@NoArgsConstructor
public class WrongResponseVO {
    private Integer paperId;
    private Integer examId;
    private Integer questionId;
    private String title;
    private Integer questionType;
    private BigDecimal score;
src/main/resources/mapper/QuestionAnswerRecordMapper.xml
@@ -14,7 +14,8 @@
    </resultMap>
    <resultMap id="WrongResultMap" type="com.ycl.jxkg.domain.vo.student.wrong.WrongResponseVO">
        <result property="paperId" column="paper_id" />
        <result property="examId" column="exam_id" />
        <result property="questionId" column="question_id" />
        <result property="title" column="title" />
        <result property="questionType" column="question_type" />
        <result property="difficult" column="difficult" />
@@ -25,7 +26,8 @@
    <select id="selectWrongQuestion" resultMap="WrongResultMap">
        SELECT
            qar.paper_id,
            e.id AS exam_id,
            q.id AS question_id,
            q.title,
            q.question_type,
            q.difficult,