From 12b7bf2629926c8acbd451f48aa815a2fb59fa50 Mon Sep 17 00:00:00 2001
From: luohairen <3399054449@qq.com>
Date: 星期三, 13 十一月 2024 11:51:17 +0800
Subject: [PATCH] 优化错题详情

---
 src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java b/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
index acbdaf4..fcda5ea 100644
--- a/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
+++ b/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
@@ -1,18 +1,23 @@
 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.ExamPaperAnswerInfo;
 import com.ycl.jxkg.domain.entity.ExamPaperScore;
 import com.ycl.jxkg.domain.entity.User;
+import com.ycl.jxkg.domain.vo.DoQuestionVO;
 import com.ycl.jxkg.domain.vo.PaperFixQuestionVO;
 import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkNavbarVO;
 import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperScoreVO;
 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;
@@ -23,7 +28,10 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @RequiredArgsConstructor
 @RestController("StudentExamPaperAnswerController")
@@ -35,6 +43,8 @@
     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)
@@ -99,4 +109,45 @@
         return Result.ok(examPaperScoreVO);
     }
 
+
+    @RequestMapping(value = "/checkWrong", method = RequestMethod.POST)
+    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.setUserName(Objects.nonNull(user) ? user.getRealName() : "鐢ㄦ埛宸叉敞閿�");
+        examPaperScoreVO.setNavbar(JSON.parseArray(examPaperScore.getNavbar(), ExamPaperMarkNavbarVO.class));
+        examPaperScoreVO.setTitleItems(JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class));
+
+        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());
+        examPaperScoreVO.setTitleItems(collect);
+        return Result.ok(examPaperScoreVO);
+    }
+
 }

--
Gitblit v1.8.0