From 12aa6d1bbe7b386f81731d797942b6a1ac7e3a2f Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 26 六月 2024 13:49:58 +0800
Subject: [PATCH] 班级学员新增bug

---
 src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
index 3efb975..04194a2 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -146,6 +146,12 @@
         if (Objects.isNull(exam.getExamPaperId())) {
             throw new RuntimeException("鑰冭瘯鏈粦瀹氳瘯鍗�");
         }
+        if (ExamStatusEnum.NOT_START.equals(exam.getStatus())) {
+            throw new RuntimeException("鑰冭瘯杩樻湭寮�濮�");
+        }
+        if (ExamStatusEnum.FINISHED.equals(exam.getStatus())) {
+            throw new RuntimeException("鑰冭瘯宸茬粡缁撴潫");
+        }
         // 鏌ュ嚭鑰冭瘯璇曞嵎
         ExamPaper examPaper = examPaperMapper.selectById(exam.getExamPaperId());
         if (Objects.isNull(examPaper)) {
@@ -159,7 +165,6 @@
             }
             // 杞崲
             List<PaperFixQuestionVO> data = this.coverTo(examPaper);
-
             return Result.ok().data(data);
         } else if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) {
             // 鏍规嵁闅忔満璇曞嵎鐨勯厤缃紝闅忔満鐢熸垚瀵瑰簲棰樼洰
@@ -167,8 +172,13 @@
                 throw new RuntimeException("璇曞嵎閰嶇疆寮傚父锛岃鑱旂郴鑰佸笀");
             }
             List<PaperQuestionSettingDTO> paperSettingList = JSON.parseArray(examPaper.getContent(), PaperQuestionSettingDTO.class);
-            List<DoQuestionVO> questionList = new ArrayList<>(24);
+
+            // 璇曞嵎鍐呭
+            List<PaperFixQuestionVO> examData = new ArrayList<>(8);
             for (PaperQuestionSettingDTO paperSetting : paperSettingList) {
+                PaperFixQuestionVO paperFixQuestionVO = new PaperFixQuestionVO();
+                paperFixQuestionVO.setTitle(paperSetting.getTitle());
+                paperFixQuestionVO.setQuestionType(paperSetting.getQuestionType());
                 // 鎷垮埌璇剧洰涓嬫煇绫婚鍨嬬殑x閬撻殢鏈洪
                 List<Question> questions = questionMapper.getRandomQuestion(examPaper.getSubjectId(), paperSetting.getQuestionType(), paperSetting.getNum());
                 if (paperSetting.getNum() > questions.size()) {
@@ -188,16 +198,9 @@
                     doQuestionVO.setAudioFile(item.getAudioFile());
                     return doQuestionVO;
                 }).collect(Collectors.toList());
-                questionList.addAll(childQuestions);
-
+                paperFixQuestionVO.setQuestionList(childQuestions);
+                examData.add(paperFixQuestionVO);
             }
-            // 淇濇寔闅忔満璇曞嵎鍜屽浐瀹氳瘯鍗风殑鏍煎紡涓�鑷�
-            List<PaperFixQuestionVO> examData = new ArrayList<>(1);
-            PaperFixQuestionVO paperFixQuestionVO = new PaperFixQuestionVO();
-            paperFixQuestionVO.setQuestionList(questionList);
-            paperFixQuestionVO.setTitle("");
-            paperFixQuestionVO.setQuestionType(null);
-            examData.add(paperFixQuestionVO);
             return Result.ok(examData);
         }
         return Result.ok();
@@ -264,6 +267,12 @@
         return Result.ok().data(vos);
     }
 
+    /**
+     * 涓诲姩鎻愪氦璇曞嵎
+     *
+     * @param submitData 璇曞嵎鍋氶鎻愪氦鏁版嵁
+     * @return
+     */
     @Override
     public Result examSubmit(ExamSubmitVO submitData) {
         // 鏍¢獙
@@ -303,6 +312,12 @@
         return Result.ok();
     }
 
+    /**
+     * 涓存椂淇濆瓨璇曞嵎
+     *
+     * @param submitData
+     * @return
+     */
     @Override
     public Result timingSubmit(ExamSubmitVO submitData) {
         saveTempExam(submitData, ExamSubmitTempStatusEnum.TEMP);
@@ -310,7 +325,7 @@
     }
 
     /**
-     * 淇濆瓨涓存椂璇曞嵎
+     * 淇濆瓨璇曞嵎锛氬鏋滄帴鍙f槸瀹氭椂淇濆瓨閭d箞鏄复鏃惰瘯鍗枫�傚鏋滄帴鍙f槸鑷富鎻愪氦閭d箞鏄畬鎴愯瘯鍗�
      *
      * @param submitData  鍓嶇浼犻�掔殑璇曞嵎鏁版嵁
      * @param status  璇曞嵎鐨勭姸鎬�

--
Gitblit v1.8.0