From 247cb86585a1d1894596ed18a6c93efecb992946 Mon Sep 17 00:00:00 2001
From: luohairen <3399054449@qq.com>
Date: 星期四, 14 十一月 2024 10:34:27 +0800
Subject: [PATCH] 班级成绩图表分析

---
 src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 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 4e35021..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,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,9 @@
 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;
@@ -27,6 +31,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @RequiredArgsConstructor
 @RestController("StudentExamPaperAnswerController")
@@ -38,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)
@@ -104,8 +111,16 @@
 
 
     @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());
@@ -113,14 +128,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);
     }
 

--
Gitblit v1.8.0