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 | 91 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 83 insertions(+), 8 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 e2473ff..04194a2 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java @@ -6,6 +6,8 @@ import com.ycl.jxkg.context.WebContext; import com.ycl.jxkg.domain.entity.*; import com.ycl.jxkg.domain.exam.PaperFixQuestionDTO; +import com.ycl.jxkg.domain.exam.PaperQuestionSettingDTO; +import com.ycl.jxkg.domain.question.QuestionObject; import com.ycl.jxkg.domain.vo.*; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; import com.ycl.jxkg.enums.ExamPaperTypeEnum; @@ -144,25 +146,64 @@ 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)) { throw new RuntimeException("璇曞嵎涓嶅瓨鍦�"); } - if (StringUtils.hasText(examPaper.getContent())) { - throw new RuntimeException("璇曞嵎棰樼洰涓虹┖"); - } - // 灏嗛鐩浆鎹负鍙复鏃朵繚瀛樼殑棰樼洰缁撴瀯 + // 灏嗛鐩浆鎹负鍙复鏃朵繚瀛樼殑棰樼洰缁撴瀯銆傚浐瀹氳瘯鍗峰拰闅忓簭璇曞嵎鐨勯鐩槸鐩存帴淇濆瓨鍒癱ontent瀛楁鐨� if (ExamPaperTypeEnum.Fixed.getCode().equals(examPaper.getPaperType()) || ExamPaperTypeEnum.RandomOrder.getCode().equals(examPaper.getPaperType())) { + if (StringUtils.hasText(examPaper.getContent())) { + throw new RuntimeException("璇曞嵎棰樼洰涓虹┖"); + } // 杞崲 List<PaperFixQuestionVO> data = this.coverTo(examPaper); return Result.ok().data(data); } else if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) { - // todo 闅忔満棰樼洰鐢熸垚 + // 鏍规嵁闅忔満璇曞嵎鐨勯厤缃紝闅忔満鐢熸垚瀵瑰簲棰樼洰 + if (! StringUtils.hasText(examPaper.getContent())) { + throw new RuntimeException("璇曞嵎閰嶇疆寮傚父锛岃鑱旂郴鑰佸笀"); + } + List<PaperQuestionSettingDTO> paperSettingList = JSON.parseArray(examPaper.getContent(), PaperQuestionSettingDTO.class); + // 璇曞嵎鍐呭 + 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()) { + throw new RuntimeException("閰嶇疆鐨勯鐩暟涓嶈冻浠ョ敓鎴愯瘯鍗�"); + } + // 鎷垮埌棰樼洰鍚庣粍瑁呬负鍙复鏃朵繚瀛樼殑棰樼洰缁撴瀯 + List<DoQuestionVO> childQuestions = questions.stream().map(item -> { + DoQuestionVO doQuestionVO = new DoQuestionVO(); + doQuestionVO.setTitle(item.getTitle()); + doQuestionVO.setQuestionType(item.getQuestionType()); + if (StringUtils.hasText(item.getContent())) { + QuestionObject questionObject = JSON.parseObject(item.getContent(), QuestionObject.class); + doQuestionVO.setQuestionItemList(questionObject.getQuestionItemObjects()); + } + doQuestionVO.setId(item.getId()); + doQuestionVO.setOriginalFile(item.getOriginalFile()); + doQuestionVO.setAudioFile(item.getAudioFile()); + return doQuestionVO; + }).collect(Collectors.toList()); + paperFixQuestionVO.setQuestionList(childQuestions); + examData.add(paperFixQuestionVO); + } + return Result.ok(examData); } - return null; + return Result.ok(); } /** @@ -172,6 +213,9 @@ * @return */ private List<PaperFixQuestionVO> coverTo(ExamPaper examPaper) { + if (! StringUtils.hasText(examPaper.getContent())) { + throw new RuntimeException("璇曞嵎鏈厤缃鐩紝璇疯仈绯昏�佸笀"); + } List<PaperFixQuestionDTO> questionWarpList = JSON.parseArray(examPaper.getContent(), PaperFixQuestionDTO.class); return questionWarpList.stream().map(item -> { PaperFixQuestionVO vo = new PaperFixQuestionVO(); @@ -223,6 +267,12 @@ return Result.ok().data(vos); } + /** + * 涓诲姩鎻愪氦璇曞嵎 + * + * @param submitData 璇曞嵎鍋氶鎻愪氦鏁版嵁 + * @return + */ @Override public Result examSubmit(ExamSubmitVO submitData) { // 鏍¢獙 @@ -262,6 +312,12 @@ return Result.ok(); } + /** + * 涓存椂淇濆瓨璇曞嵎 + * + * @param submitData + * @return + */ @Override public Result timingSubmit(ExamSubmitVO submitData) { saveTempExam(submitData, ExamSubmitTempStatusEnum.TEMP); @@ -269,7 +325,7 @@ } /** - * 淇濆瓨涓存椂璇曞嵎 + * 淇濆瓨璇曞嵎锛氬鏋滄帴鍙f槸瀹氭椂淇濆瓨閭d箞鏄复鏃惰瘯鍗枫�傚鏋滄帴鍙f槸鑷富鎻愪氦閭d箞鏄畬鎴愯瘯鍗� * * @param submitData 鍓嶇浼犻�掔殑璇曞嵎鏁版嵁 * @param status 璇曞嵎鐨勭姸鎬� @@ -301,7 +357,7 @@ } @Override - public Result getMarkPaperInfo(Integer id) { + public Result getMarkResultInfo(Integer id) { Exam exam = baseMapper.selectById(id); if (Objects.isNull(exam)) { throw new RuntimeException("璇ヨ�冭瘯涓嶅瓨鍦�"); @@ -341,4 +397,23 @@ return Result.ok().data(markPaperVO); } + + @Override + public Result getMarkPaperInfo(Integer examId, Integer userId) { + ExamSubmitTemp userExam = new LambdaQueryChainWrapper<>(examSubmitTempMapper) + .eq(ExamSubmitTemp::getExamId, examId) + .eq(ExamSubmitTemp::getUserId, userId) + .one(); + if (Objects.isNull(userExam)) { + throw new RuntimeException("璇ュ鍛樿�冭瘯璁板綍涓嶅瓨鍦�"); + } + ExamSubmitVO vo = new ExamSubmitVO(); + vo.setExamId(userExam.getExamId()); + vo.setDoTime(userExam.getDoTime()); + vo.setUpdateTime(userExam.getUpdateTime()); + if (StringUtils.hasText(userExam.getExamSubmit())) { + vo.setPaperQuestionList(JSON.parseArray(userExam.getExamSubmit(), PaperFixQuestionVO.class)); + } + return Result.ok(vo); + } } -- Gitblit v1.8.0