From fe29db7a08e9da70ca3c78db27a11e48fa5f6f43 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 15 五月 2024 22:24:47 +0800
Subject: [PATCH] springboot静态文件配置。删除dist

---
 src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java |   91 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
index a197e18..82a7cd6 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -1,14 +1,15 @@
 package com.mindskip.xzs.service.impl;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.mindskip.xzs.domain.*;
 import com.mindskip.xzs.domain.enums.ExamPaperAnswerStatusEnum;
 import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
 import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
 import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject;
-import com.mindskip.xzs.domain.other.KeyValue;
 import com.mindskip.xzs.domain.other.ExamPaperAnswerUpdate;
+import com.mindskip.xzs.domain.other.KeyValue;
 import com.mindskip.xzs.domain.task.TaskItemAnswerObject;
-import com.mindskip.xzs.repository.*;
 import com.mindskip.xzs.repository.ExamPaperAnswerMapper;
 import com.mindskip.xzs.repository.ExamPaperMapper;
 import com.mindskip.xzs.repository.QuestionMapper;
@@ -19,19 +20,16 @@
 import com.mindskip.xzs.utility.DateTimeUtil;
 import com.mindskip.xzs.utility.ExamUtil;
 import com.mindskip.xzs.utility.JsonUtil;
+import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM;
+import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradeQuery;
 import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
 import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM;
 import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.mindskip.xzs.domain.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -220,13 +218,17 @@
         QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
         switch (questionTypeEnum) {
             case SingleChoice:
+                examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent());
+                examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent()));
+                examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
+                break;
             case TrueFalse:
                 examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent());
                 examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent()));
                 examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
                 break;
             case MultipleChoice:
-                String customerAnswer = ExamUtil.contentToString(customerQuestionAnswer.getContentArray());
+                String customerAnswer = customerQuestionAnswer.getContent() ==null ? ExamUtil.contentToString(customerQuestionAnswer.getContentArray()) : customerQuestionAnswer.getContent();
                 examPaperQuestionCustomerAnswer.setAnswer(customerAnswer);
                 examPaperQuestionCustomerAnswer.setDoRight(customerAnswer.equals(question.getCorrect()));
                 examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
@@ -275,4 +277,75 @@
         return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "user_score desc").doSelectPageInfo(() ->
                 examPaperAnswerMapper.adminPage(requestVM));
     }
+
+    @Override
+    public ExamPaperAnswer getById(Integer id) {
+        return examPaperAnswerMapper.getById(id);
+    }
+
+    @Override
+    public List<ExamPaperAnswer> selectByPaperName(String paperName) {
+        return examPaperAnswerMapper.selectByPaperName(paperName);
+    }
+
+    @Override
+    public List<ExamPaperAnswer> getByExamPaperIdAndUserId(List<ExamTemplatesUserCount> examTemplatesUserCount) {
+        return examPaperAnswerMapper.getByExamPaperIdAndUserId(examTemplatesUserCount);
+    }
+
+    @Override
+    public PageInfo<ExamPaperAnswer> adminPageByGrade(ExamPaperGradePageRequestVM grade) {
+        return PageHelper.startPage(grade.getPageIndex(), grade.getPageSize(), "id desc").doSelectPageInfo(() ->
+                examPaperAnswerMapper.adminPageByGrade(grade));
+    }
+
+    @Override
+    public List<ExamPaperAnswer> getByScorePaperIdAndUserId(List<ScoreTemplatesUserCount> scoreTemplatesUserCounts) {
+        return examPaperAnswerMapper.getByScorePaperIdAndUserId(scoreTemplatesUserCounts);
+    }
+
+    @Override
+    public PageInfo<ExamPaperAnswer> getByCreatUser(ExamPaperGradeQuery query) {
+        query.setFullTime();
+        return PageHelper.startPage(query.getPageIndex(), query.getPageSize(), "id desc").doSelectPageInfo(() ->
+                examPaperAnswerMapper.getByCreatUser(query));
+    }
+
+    @Override
+    public Map<String, Object> statistic(String examPaperId, String departmentId) {
+        // 鑾峰彇鍘熷鏁版嵁
+        Map<String, Object> histogram = examPaperAnswerMapper.histogram(examPaperId, departmentId);
+        Map<String, Object> pieChart = examPaperAnswerMapper.pieChart(examPaperId, departmentId);
+        // 鍒濆鍖栫粨鏋滃鍣�
+        HashMap<String, Object> map = new HashMap<>();
+        List<Map<String, Object>> score = new ArrayList<>();
+        List<Map<String, Object>> age = new ArrayList<>();
+        List<Map<String, Object>> examPeopleNum = new ArrayList<>();
+        // 澶勭悊鎴愮哗涓庡勾榫勫垎甯�
+        histogram.forEach((k, v) -> {
+            Map<String, Object> hashMap = new HashMap<>();
+            hashMap.put(k, v);
+            if (k.contains("score")) {
+                score.add(hashMap);
+            }
+            if (k.contains("age")) {
+                age.add(hashMap);
+            }
+        });
+        // 澶勭悊鍙傝�冧汉鏁帮紙鍑哄腑涓庣己甯級
+        pieChart.forEach((k, v) -> {
+            Map<String, Object> hashMap = new HashMap<>();
+            hashMap.put(k, v);
+            if ("totalAttended".equals(k)) {
+                examPeopleNum.add(hashMap);
+            }
+            if ("totalAbsent".equals(k)) {
+                examPeopleNum.add(hashMap);
+            }
+        });
+        map.put("score", score);
+        map.put("age", age);
+        map.put("examPeopleNum", examPeopleNum);
+        return map;
+    }
 }

--
Gitblit v1.8.0