From b4876fa189c28f0d31f069e66db7953cfd625aa6 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 4 Dec 2020 20:10:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E8=AF=BE=E7=A8=8B=E3=80=81?= =?UTF-8?q?=E8=80=83=E8=AF=95=E6=97=B6=EF=BC=9A=E5=A6=82=E6=9E=9C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=B8=8B=E6=9C=89=E8=AF=95=E5=8D=B7=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=88=90=E8=AF=95=E5=8D=B7=EF=BC=9B=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=AF=95=E5=8D=B7=EF=BC=8C=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=AF=95=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/ExamService.java | 7 ++ .../joylink/rtss/services/IExamService.java | 23 ++-- .../joylink/rtss/services/LessonService.java | 113 +++++++++--------- 3 files changed, 75 insertions(+), 68 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index 6d056782c..4ad37c1b5 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -536,6 +536,13 @@ public class ExamService implements IExamService{ // } } + @Override + public List findEntities(Long lessonId) { + ExamDefinitionExample example = new ExamDefinitionExample(); + example.createCriteria().andLessonIdEqualTo(lessonId); + return examDefinitionDAO.selectByExample(example); + } + private List findEntityByLessonIdList(ArrayList lessonIdList) { ExamDefinitionExample example = new ExamDefinitionExample(); example.createCriteria().andLessonIdIn(lessonIdList); diff --git a/src/main/java/club/joylink/rtss/services/IExamService.java b/src/main/java/club/joylink/rtss/services/IExamService.java index 4846c3ac4..6dbd24a9a 100644 --- a/src/main/java/club/joylink/rtss/services/IExamService.java +++ b/src/main/java/club/joylink/rtss/services/IExamService.java @@ -1,7 +1,11 @@ package club.joylink.rtss.services; +import club.joylink.rtss.entity.ExamDefinition; import club.joylink.rtss.vo.UserVO; -import club.joylink.rtss.vo.client.*; +import club.joylink.rtss.vo.client.ExamDefinitionQueryVO; +import club.joylink.rtss.vo.client.ExamDefinitionVO; +import club.joylink.rtss.vo.client.ExamsLessonVO; +import club.joylink.rtss.vo.client.PageVO; import java.util.List; import java.util.Map; @@ -26,14 +30,11 @@ public interface IExamService { /** * 查询课程所属产品下有实训的实训类型 - * @param lessonId - * @return */ List queryTrainingTypes(Long lessonId); /** * 查询试题定义的详细信息 - * @param examId */ ExamDefinitionVO queryExamInfo(Long examId); @@ -59,32 +60,28 @@ public interface IExamService { /** * 根据课程和实训类型查询实训数量 - * @param lessonId - * @param trainingType - * @return */ Long queryTrainingNum(Long lessonId, String trainingType, String operateType); /** * 试题上线 - * @param id - * @param userVO */ void onLine(Long id, UserVO userVO); /** * 试题下线 - * @param id - * @param userVO */ void offLine(Long id, UserVO userVO); /** * 更新试题 - * @param id - * @param examDefinitionVO */ void update(Long id, ExamDefinitionVO examDefinitionVO); void copy(Map lessonRelationMap, UserVO user); + + /** + * 根据课程id查询考试 + */ + List findEntities(Long lessonId); } diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index e3d105e4d..e3a96e811 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -619,7 +619,7 @@ public class LessonService implements ILessonService { if (Objects.nonNull(existedDefaultLesson)) { lesson.setId(existedDefaultLesson.getId()); lessonDAO.updateByPrimaryKey(lesson); - //存在默认课程删除旧版本、章节、考试及关联实训数据 + //存在默认课程删除旧版本、章节、章节关联的实训 LsLessonVersionExample versionExample = new LsLessonVersionExample(); versionExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId()); lessonVersionDAO.deleteByExample(versionExample); @@ -632,21 +632,21 @@ public class LessonService implements ILessonService { chapterExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId()); lessonChapterDAO.deleteByExample(chapterExample); - ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample(); - examDefinitionExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId()); - List examDefinitions = examDefinitionDAO.selectByExample(examDefinitionExample); - if (!CollectionUtils.isEmpty(examDefinitions)) { - List list = examDefinitions.stream().map(ExamDefinition::getId).collect(Collectors.toList()); - ExamDefinitionRulesExample rulesExample = new ExamDefinitionRulesExample(); - rulesExample.createCriteria().andExamIdIn(list); - definitionRulesDAO.deleteByExample(rulesExample); - examDefinitionDAO.deleteByExample(examDefinitionExample); - } +// ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample(); +// examDefinitionExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId()); +// List examDefinitions = examDefinitionDAO.selectByExample(examDefinitionExample); +// if (!CollectionUtils.isEmpty(examDefinitions)) { +// List list = examDefinitions.stream().map(ExamDefinition::getId).collect(Collectors.toList()); +// ExamDefinitionRulesExample rulesExample = new ExamDefinitionRulesExample(); +// rulesExample.createCriteria().andExamIdIn(list); +// definitionRulesDAO.deleteByExample(rulesExample); +// examDefinitionDAO.deleteByExample(examDefinitionExample); +// } } else { lessonDAO.insert(lesson); } - //版本0.0 + //课程版本0.0 LsLessonVersion lessonVersion = new LsLessonVersion(); lessonVersion.setLessonId(lesson.getId()); lessonVersion.setCreatorId(lesson.getCreatorId()); @@ -654,6 +654,7 @@ public class LessonService implements ILessonService { lessonVersion.setVersion(BusinessConsts.Lesson.Version.originalVersion); lessonVersionDAO.insert(lessonVersion); + //生成课程的章节 List examTrainings = new ArrayList<>(20); int orderNum = 1; Random random = new Random(); @@ -687,49 +688,51 @@ public class LessonService implements ILessonService { } }); } - //试卷定义 - if (CollectionUtils.isEmpty(examTrainings)) { - return; - } - ExamDefinition examDefinition = new ExamDefinition(); - examDefinition.setLessonId(lesson.getId()); - examDefinition.setName(lesson.getName() + "试卷"); - examDefinition.setDuration(1800); - examDefinition.setCreatorId(userVO.getId()); - examDefinition.setCreateTime(LocalDateTime.now()); - examDefinition.setRemarks(examDefinition.getName() + "-默认试卷"); - examDefinition.setStatus("1"); - examDefinition.setTrial(true); - //试卷规则 取20道题,每中实训类型取一道 - if (examTrainings.size() < 20) { - examDefinition.setFullPoint(examTrainings.size() * 5); - examDefinition.setPassingPoint(Double.valueOf(examDefinition.getFullPoint() * 0.6).intValue()); - examDefinitionDAO.insert(examDefinition); - examTrainings.forEach(training -> { - ExamDefinitionRules examRules = new ExamDefinitionRules(); - examRules.setExamId(examDefinition.getId()); - examRules.setNum(1); - examRules.setPoint(5); - examRules.setTrainingType(training.getType()); - examRules.setOperateType(training.getOperateType()); - definitionRulesDAO.insert(examRules); - }); - - } else { - examDefinition.setFullPoint(100); - examDefinition.setPassingPoint(60); - examDefinitionDAO.insert(examDefinition); - int i = 1; - do { - ExamDefinitionRules examRules = new ExamDefinitionRules(); - examRules.setExamId(examDefinition.getId()); - examRules.setNum(1); - examRules.setPoint(5); - Training training = examTrainings.remove(random.nextInt(examTrainings.size())); - examRules.setTrainingType(training.getType()); - examRules.setOperateType(training.getOperateType()); - definitionRulesDAO.insert(examRules); - } while (i++ < 20); + List exams = iExamService.findEntities(lesson.getId()); + if (CollectionUtils.isEmpty(exams)) { + //试卷定义 + if (CollectionUtils.isEmpty(examTrainings)) { + return; + } + ExamDefinition examDefinition = new ExamDefinition(); + examDefinition.setLessonId(lesson.getId()); + examDefinition.setName(lesson.getName() + "试卷"); + examDefinition.setDuration(1800); + examDefinition.setCreatorId(userVO.getId()); + examDefinition.setCreateTime(LocalDateTime.now()); + examDefinition.setRemarks(examDefinition.getName() + "-默认试卷"); + examDefinition.setStatus("1"); + examDefinition.setTrial(true); + //试卷规则 取20道题,每中实训类型取一道 + if (examTrainings.size() < 20) { + examDefinition.setFullPoint(examTrainings.size() * 5); + examDefinition.setPassingPoint(Double.valueOf(examDefinition.getFullPoint() * 0.6).intValue()); + examDefinitionDAO.insert(examDefinition); + examTrainings.forEach(training -> { + ExamDefinitionRules examRules = new ExamDefinitionRules(); + examRules.setExamId(examDefinition.getId()); + examRules.setNum(1); + examRules.setPoint(5); + examRules.setTrainingType(training.getType()); + examRules.setOperateType(training.getOperateType()); + definitionRulesDAO.insert(examRules); + }); + } else { + examDefinition.setFullPoint(100); + examDefinition.setPassingPoint(60); + examDefinitionDAO.insert(examDefinition); + int i = 1; + do { + ExamDefinitionRules examRules = new ExamDefinitionRules(); + examRules.setExamId(examDefinition.getId()); + examRules.setNum(1); + examRules.setPoint(5); + Training training = examTrainings.remove(random.nextInt(examTrainings.size())); + examRules.setTrainingType(training.getType()); + examRules.setOperateType(training.getOperateType()); + definitionRulesDAO.insert(examRules); + } while (i++ < 20); + } } } }