From 0e62c15e4b010ffa2d5cff9474f3fd389e369338 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期五, 24 十一月 2023 14:31:46 +0800 Subject: [PATCH] 优化作业、考试、试卷、题库 --- src/main/java/com/qxueyou/scc/exam/service/impl/ExamService.java | 204 ++++++++++++++++++++++++++------------------------ 1 files changed, 106 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/exam/service/impl/ExamService.java b/src/main/java/com/qxueyou/scc/exam/service/impl/ExamService.java index f2f6045..65c0a84 100644 --- a/src/main/java/com/qxueyou/scc/exam/service/impl/ExamService.java +++ b/src/main/java/com/qxueyou/scc/exam/service/impl/ExamService.java @@ -31,7 +31,7 @@ import com.qxueyou.scc.msg.service.IMsgInfoService; /** - * 考试管理服务层 + * 鑰冭瘯绠$悊鏈嶅姟灞� * * @author kevin * @createTime 2017-11-1 @@ -62,9 +62,13 @@ @Override public List<ExamInfo> list(String keyword,String classId,String subjectId,Short status, Integer pageSize,Integer pageNum) { StringBuffer hql = new StringBuffer(500); - hql.append("from ExamInfo e where e.examName like ? and e.createId=? "); - List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); - + String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId(); + hql.append("from ExamInfo e where e.examName like ? "); + List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%'); + if (StringUtils.isNotBlank(teacherId)) { + hql.append(" and e.createId=?"); + params.add(teacherId); + } if(status!=null){ hql.append(" and e.examStatus = ? "); params.add(status); @@ -87,9 +91,13 @@ @Override public int listCount(String keyword,String classId,String subjectId,Short status) { StringBuffer hql = new StringBuffer(500); - hql.append("from ExamInfo e where e.examName like ? and e.createId=? "); - List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); - + String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId(); + hql.append("from ExamInfo e where e.examName like ? "); + List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%'); + if (StringUtils.isNotBlank(teacherId)) { + hql.append(" and e.createId=?"); + params.add(teacherId); + } if(status!=null){ hql.append(" and e.examStatus = ? "); params.add(status); @@ -174,7 +182,7 @@ params.put("subjectId", subjectId); } - //根据状态查询:1未开始,2未交卷,3已交卷,4逾期未交,5已批阅 + //鏍规嵁鐘舵�佹煡璇細1鏈紑濮嬶紝2鏈氦鍗凤紝3宸蹭氦鍗凤紝4閫炬湡鏈氦,5宸叉壒闃� if(status != null) { switch(status){ case 1:hql.append(" and v.status is null") ;break; @@ -214,7 +222,7 @@ params.put("subjectId", subjectId); } - //根据状态查询:1未开始,2未交卷,3已交卷,4逾期未交,5已批阅 + //鏍规嵁鐘舵�佹煡璇細1鏈紑濮嬶紝2鏈氦鍗凤紝3宸蹭氦鍗凤紝4閫炬湡鏈氦,5宸叉壒闃� if(status != null) { switch(status){ case 1:hql.append(" and v.status is null") ;break; @@ -230,32 +238,32 @@ @Override public void addRemedy(String examId,Date startTime,Date endTime) { - //根据考试ID获取考试信息 + //鏍规嵁鑰冭瘯ID鑾峰彇鑰冭瘯淇℃伅 ExamInfo examInfo = queryExamDetail(examId); - //根据考试ID获取对应的批次信息 + //鏍规嵁鑰冭瘯ID鑾峰彇瀵瑰簲鐨勬壒娆′俊鎭� String hql = "from ExamBatchInfo where examId=? and deleteFlag is false"; List<ExamBatchInfo> list = this.find(hql, CollectionUtils.newList(examId), ExamBatchInfo.class); List<ExamBatchInfo> remedylist = new ArrayList<>(list.size()); - //根据考试ID获取对应的题目设置 + //鏍规嵁鑰冭瘯ID鑾峰彇瀵瑰簲鐨勯鐩缃� List<ExerciseItemSet> exerciseItemSets = queryExerciseItemSet(examId); List<ExerciseItemSet> exerciseItemSetses = new ArrayList<>(exerciseItemSets.size()); //... List<ExamReExamPaper> reExamPapers = examInfo.getReExamPapers(); List<ExamReExamPaper> reExamPaperses = new ArrayList<>(reExamPapers.size()); - //复制信息 + //澶嶅埗淇℃伅 ExamInfo examInfo1=new ExamInfo(); - //重新指向一个对象并复制属性 + //閲嶆柊鎸囧悜涓�涓璞″苟澶嶅埗灞炴�� BeanUtils.copyProperties(examInfo,examInfo1); - //设置考试名称 - examInfo1.setExamName(examInfo1.getExamName()+"(补考"+new Date().getTime()+")"); - //设置新指向批次集合 + //璁剧疆鑰冭瘯鍚嶇О + examInfo1.setExamName(examInfo1.getExamName()+"(琛ヨ��"+new Date().getTime()+")"); + //璁剧疆鏂版寚鍚戞壒娆¢泦鍚� examInfo1.setExamBatchInfos(remedylist); examInfo1.setExerciseItemSets(exerciseItemSetses); - //设置新指向试卷集合 + //璁剧疆鏂版寚鍚戣瘯鍗烽泦鍚� reExamPapers.forEach(reExamPaper -> reExamPaperses.add(reExamPaper)); examInfo1.setReExamPapers(reExamPaperses); String examremedyId = addExam(examInfo1); - //设置新指向题目设置集合并复制添加 + //璁剧疆鏂版寚鍚戦鐩缃泦鍚堝苟澶嶅埗娣诲姞 exerciseItemSets.forEach(exerciseItemSet -> { ExerciseItemSet exerciseItemSet1 = new ExerciseItemSet(); BeanUtils.copyProperties(exerciseItemSet,exerciseItemSet1); @@ -264,28 +272,28 @@ this.insert(exerciseItemSet1); exerciseItemSetses.add(exerciseItemSet1); }); - //根据考试ID获取题库关联信息 + //鏍规嵁鑰冭瘯ID鑾峰彇棰樺簱鍏宠仈淇℃伅 String ql = "from ExerciseExamReGroup where examId=? and deleteFlag is false"; List<ExerciseExamReGroup> exerciseExamReGroups = this.find(ql, CollectionUtils.newList(examId), ExerciseExamReGroup.class); exerciseExamReGroups.forEach(exerciseExamReGroup -> { ExerciseExamReGroup exerciseExamReGroup1 = new ExerciseExamReGroup(); BeanUtils.copyProperties(exerciseExamReGroup,exerciseExamReGroup1); - //设置考试ID保存信息 + //璁剧疆鑰冭瘯ID淇濆瓨淇℃伅 exerciseExamReGroup1.setExamId(examremedyId); TraceUtils.setCreateTrace(exerciseExamReGroup1); this.insert(exerciseExamReGroup1); }); - //循环复制批次 + //寰幆澶嶅埗鎵规 for (ExamBatchInfo examBatchInfo : list) { String remedyExamBatchId = UUIDUtils.generateSpecialUuid(32); List<ExamBatchClassRe> reClasses = examBatchInfo.getReClasses(); List<ExamBatchClassRe> examBatchClassRes = new ArrayList<>(); reClasses.forEach(reClass -> { - //新建bean + //鏂板缓bean ExamBatchClassRe examBatchClassRe = new ExamBatchClassRe(); - //复制属性 + //澶嶅埗灞炴�� BeanUtils.copyProperties(reClass,examBatchClassRe); - //修改考试ID以及批次ID + //淇敼鑰冭瘯ID浠ュ強鎵规ID examBatchClassRe.setExamId(examremedyId); examBatchClassRe.setExamBatchId(remedyExamBatchId); examBatchClassRe.setExamClassReId(UUIDUtils.generateSpecialUuid(32)); @@ -293,14 +301,14 @@ }); ExamBatchInfo examBatchInfo1 = new ExamBatchInfo(); BeanUtils.copyProperties(examBatchInfo,examBatchInfo1); - //设置批次考试ID为补考的ID + //璁剧疆鎵规鑰冭瘯ID涓鸿ˉ鑰冪殑ID examBatchInfo1.setExamId(examremedyId); - //设置开始结束时间 + //璁剧疆寮�濮嬬粨鏉熸椂闂� examBatchInfo1.setStartTime(startTime); examBatchInfo1.setEndTime(endTime); examBatchInfo1.setExamBatchId(remedyExamBatchId); examBatchInfo1.setReClasses(examBatchClassRes); - //添加批次 + //娣诲姞鎵规 examBatchService.addExamBatch(examBatchInfo1); remedylist.add(examBatchInfo1); } @@ -319,13 +327,13 @@ Result result = new Result(true); if (examIds != null && examIds.length > 0) { String hql = "update ExamInfo set deleteFlag = true where examId=?"; - //判断ID里是否包含补考考试 + //鍒ゆ柇ID閲屾槸鍚﹀寘鍚ˉ鑰冭�冭瘯 ExamInfo examInfo = queryReExam(); if (examInfo!=null) { for (String examId : examIds) { if (examId.equals(examInfo.getExamId())){ result.setSuccess(false); - result.setMsg("含有补考考试,不可删除"); + result.setMsg("鍚湁琛ヨ�冭�冭瘯锛屼笉鍙垹闄�"); return result; } } @@ -340,7 +348,7 @@ ExamInfo examInfo = read(ExamInfo.class, param.getExamId()); if (examInfo == null) { - return new Result(false, "考试不存在"); + return new Result(false, "鑰冭瘯涓嶅瓨鍦�"); } TraceUtils.setUpdateTrace(examInfo); @@ -365,16 +373,16 @@ examInfo.setTotalScore(param.getTotalScore()); examInfo.setPassingScore(param.getPassingScore()); - //如果是随机组卷 + //濡傛灉鏄殢鏈虹粍鍗� if(ExamInfo.EXAM_TYPE_RANDOM==examInfo.getExamType()||ExamInfo.EXAM_TYPE_RANDOM_BY_GROUP==examInfo.getExamType()){ - // 删除之前的Exercise关联的group + // 鍒犻櫎涔嬪墠鐨凟xercise鍏宠仈鐨刧roup this.bulkUpdate("update ExerciseExamReGroup set deleteFlag = 1 where examId = ?",new Object[] { param.getExamId()}); List<ExerciseItemSet> lstExerciseItemSet = param.getExerciseItemSets(); - // 保存题目类型 + // 淇濆瓨棰樼洰绫诲瀷 if (lstExerciseItemSet != null && lstExerciseItemSet.size() > 0) { - // 删除历史数据 + // 鍒犻櫎鍘嗗彶鏁版嵁 this.bulkUpdate("update ExerciseItemSet set deleteFlag = 1 where deleteFlag is false and exerciseInfoId = ?", new Object[] { param.getExamId()}); for (ExerciseItemSet itemSet : lstExerciseItemSet) { @@ -384,10 +392,10 @@ } } - //保存考试,源题目组信息 + //淇濆瓨鑰冭瘯锛屾簮棰樼洰缁勪俊鎭� String [] sourceGroupIds = param.getSourceGroupIds().split(","); - // 保存关联练习组 + // 淇濆瓨鍏宠仈缁冧範缁� if (sourceGroupIds != null && sourceGroupIds.length > 0) { ExerciseExamReGroup reGroup = null; for (String groupId : sourceGroupIds) { @@ -402,7 +410,7 @@ } }else{ - // 删除原来的关联关系 + // 鍒犻櫎鍘熸潵鐨勫叧鑱斿叧绯� String hql = "update ExamReExamPaper set deleteFlag = true where examId=? "; this.bulkUpdate(hql, new Object[] { param.getExamId() }); List<ExamReExamPaper> lstExamReExamPaper = param.getReExamPapers(); @@ -432,7 +440,7 @@ for (ExamInfo examInfo : lstExamInfo) { if (ExamInfo.STATUS_DRAFT != examInfo.getExamStatus()) { - return new Result(false, "只有草稿状态的考试,才能发布。"); + return new Result(false, "鍙湁鑽夌鐘舵�佺殑鑰冭瘯,鎵嶈兘鍙戝竷銆�"); } examInfo.setExamStatus(ExamInfo.STATUS_PUBLISH); TraceUtils.setUpdateTrace(examInfo); @@ -442,7 +450,7 @@ this.doExamPublishMsg(examInfo.getExamId()); } } else { - return new Result(false, "没有选择要发布的考试。"); + return new Result(false, "娌℃湁閫夋嫨瑕佸彂甯冪殑鑰冭瘯銆�"); } return new Result(true); } @@ -459,14 +467,14 @@ Map<String,String> attrs = CollectionUtils.newStringMap("examId",examId,"examName",examInfo.getExamName(), "subjectId",examInfo.getSubjectId(),"subjectName",examInfo.getSubject().getName(), "examBatchId",(String)temp.get("examBatchId"),"classId",(String)temp.get("classId"),"recordId",(String)temp.get("recordId")); - msgInfoService.doSendTextMsgToUsers(new String[]{(String)temp.get("userId")},MsgInfo.TYPE_EXAM, "发布了考试", attrs); + msgInfoService.doSendTextMsgToUsers(new String[]{(String)temp.get("userId")},MsgInfo.TYPE_EXAM, "鍙戝竷浜嗚�冭瘯", attrs); } } } @Scheduled(cron = " 0 0/5 * * * ?") protected void doTimer() { -// System.out.println("执行考试提醒定时器"); +// System.out.println("鎵ц鑰冭瘯鎻愰啋瀹氭椂鍣�"); Calendar cal =Calendar.getInstance(); cal.add(Calendar.HOUR, 1); Date beginDate = cal.getTime(); @@ -477,12 +485,12 @@ String hql = "select b.examBatchId from ExamBatchInfo b ,ExamInfo f where b.examId = f.examId " + " and b.startTime>=? and b.startTime<? and f.examStatus=? and f.deleteFlag is false and b.deleteFlag is false order by b.startTime desc"; - //查询1小时内将开始的直播 + //鏌ヨ1灏忔椂鍐呭皢寮�濮嬬殑鐩存挱 List<String> lstBatchIds = this.find(hql,CollectionUtils.newList(beginDate,endDate,ExamInfo.STATUS_PUBLISH), String.class); if(lstBatchIds!=null && lstBatchIds.size()>0){ for(String batchId:lstBatchIds){ - this.doExamRemindMsg(batchId,MsgInfo.TYPE_REMIND, "考试马上开始了,请做好考试准备"); + this.doExamRemindMsg(batchId,MsgInfo.TYPE_REMIND, "鑰冭瘯椹笂寮�濮嬩簡锛岃鍋氬ソ鑰冭瘯鍑嗗"); } } } @@ -510,14 +518,14 @@ List<ExamInfo> lstExamInfo = this.findByComplexHql(hql, pramMap, ExamInfo.class); for (ExamInfo examInfo : lstExamInfo) { if (ExamInfo.STATUS_PUBLISH != examInfo.getExamStatus()) { - return new Result(false, "只有发布状态的考试,才能撤回"); + return new Result(false, "鍙湁鍙戝竷鐘舵�佺殑鑰冭瘯,鎵嶈兘鎾ゅ洖"); } examInfo.setExamStatus(ExamInfo.STATUS_DRAFT); TraceUtils.setUpdateTrace(examInfo); save(examInfo); } } else { - return new Result(false, "没有选择要撤回的考试"); + return new Result(false, "娌℃湁閫夋嫨瑕佹挙鍥炵殑鑰冭瘯"); } return new Result(true); } @@ -537,7 +545,7 @@ } @Override public ExamInfo queryReExam() { - // 查询是否有进行中的考试 + // 鏌ヨ鏄惁鏈夎繘琛屼腑鐨勮�冭瘯 ExamInfo examInfo = this.findUnique( "from ExamInfo where maxLateMin=? and deleteFlag is false ", CollectionUtils.newList((short)1), @@ -547,7 +555,7 @@ } /** - * 开始考试 + * 寮�濮嬭�冭瘯 * * @param * @return @@ -565,17 +573,17 @@ //TODO "remainingSeconds",record.getRemainingSeconds(),"itemSet", lstItemSets,"subjectName", examInfo.getSubject().getName()); - // 如果已提交就查询用户答案信息 - //TODO 暂时不可以查看考试答案,已提交就不可以进入 - if (Integer.valueOf(record.getStatus())> 0) { - resultData.put("studentScore", record.getScore()); - resultData.put("objStudentScore", record.getObjScore()==null?BigDecimal.ZERO:record.getObjScore()); - return new Result(false,"考试已提交"); - } - //获取考试 + // 濡傛灉宸叉彁浜ゅ氨鏌ヨ鐢ㄦ埛绛旀淇℃伅 + //TODO 鏆傛椂涓嶅彲浠ユ煡鐪嬭�冭瘯绛旀锛屽凡鎻愪氦灏变笉鍙互杩涘叆 +// if (Integer.valueOf(record.getStatus())> 0) { +// resultData.put("studentScore", record.getScore()); +// resultData.put("objStudentScore", record.getObjScore()==null?BigDecimal.ZERO:record.getObjScore()); +// return new Result(false,"鑰冭瘯宸叉彁浜�"); +// } + //鑾峰彇鑰冭瘯 String ql="select i from ExamInfo i , ExamBatchClassRe r where i.deleteFlag is false and r.examBatchId=? and r.examId=i.examId"; ExamInfo exam = this.findUnique(ql, CollectionUtils.newList(examBatchId), ExamInfo.class); - //添加考试总时长 + //娣诲姞鑰冭瘯鎬绘椂闀� resultData.put("durationMin",exam.getDurationMin()); resultData.put("groupId", record.getExerciseGroupId()); resultData.put("totalScore", examInfo.getTotalScore()); @@ -585,7 +593,7 @@ return new Result(true,"",resultData); } /** - * 开始补考考试 + * 寮�濮嬭ˉ鑰冭�冭瘯 * * @param examId * @return @@ -601,7 +609,7 @@ Map<String,Object> resultData = CollectionUtils.newObjectMap("exerciseRecordId", record.getRecordId(),"submitTime",record.getSubmitTime(), //TODO "remainingSeconds",record.getRemainingSeconds(),"itemSet", lstItemSets,"subjectName", examInfo.getSubject().getName()); - //添加考试总时长 + //娣诲姞鑰冭瘯鎬绘椂闀� resultData.put("durationMin",examInfo.getDurationMin()); resultData.put("groupId", record.getExerciseGroupId()); resultData.put("totalScore", examInfo.getTotalScore()); @@ -612,7 +620,7 @@ } /** - * 判断是否是随机考试 + * 鍒ゆ柇鏄惁鏄殢鏈鸿�冭瘯 * @param examType * @return */ @@ -621,7 +629,7 @@ } /** - * 获取考试试卷信息 + * 鑾峰彇鑰冭瘯璇曞嵎淇℃伅 * @param examId * @param groupId * @param examType @@ -645,7 +653,7 @@ } /** - * 手动添加题目位置信息 + * 鎵嬪姩娣诲姞棰樼洰浣嶇疆淇℃伅 * @param groupId * @param examType * @param totalSocre @@ -669,12 +677,12 @@ int itemCount = lstItemSets.get(i).getItemCount(); if (itemCount>0) { examPaperSectionInfo.setGroupId(groupId); - //设置开始结束 + //璁剧疆寮�濮嬬粨鏉� examPaperSectionInfo.setItemStartOrder((short)count); - //获取题目设置的count,下次循环用 + //鑾峰彇棰樼洰璁剧疆鐨刢ount,涓嬫寰幆鐢� count+=itemCount; examPaperSectionInfo.setItemEndOrder((short)count); - //名称 + //鍚嶇О examPaperSectionInfo.setSectionName(String.valueOf(lstItemSets.get(i).getItemType())); examPaperSectionInfos.add(examPaperSectionInfo); } @@ -685,21 +693,21 @@ examPaperInfo = examPaperService.queryExamPaperDetail(examPaperInfo.getExamPaperId()); List<ExamPaperSectionInfo> examPaperSectionInfos = new ArrayList<>(); int count=0; - //获取试卷里的各种题数量设置 + //鑾峰彇璇曞嵎閲岀殑鍚勭棰樻暟閲忚缃� Map<String, ExamPaperInfo> statisticsMap = examPaperService.queryExamPaperItemsStatistic(new String[]{examPaperInfo.getExamPaperId()}); - //把设置封装成itemSets + //鎶婅缃皝瑁呮垚itemSets lstItemSets=new ArrayList<ExerciseItemSet>(); - //单选 + //鍗曢�� ExerciseItemSet exerciseItemSet1 = new ExerciseItemSet(); exerciseItemSet1.setItemCount(statisticsMap.get(examPaperInfo.getExamPaperId()).getSingleSelectCount()); exerciseItemSet1.setItemType((short) 1); lstItemSets.add(exerciseItemSet1); - //多选 + //澶氶�� ExerciseItemSet exerciseItemSet2 = new ExerciseItemSet(); exerciseItemSet2.setItemCount(statisticsMap.get(examPaperInfo.getExamPaperId()).getMultiSelectCount()); exerciseItemSet2.setItemType((short) 2); lstItemSets.add(exerciseItemSet2); - //判断 + //鍒ゆ柇 ExerciseItemSet exerciseItemSet3 = new ExerciseItemSet(); exerciseItemSet3.setItemCount(statisticsMap.get(examPaperInfo.getExamPaperId()).getJudgeCount()); exerciseItemSet3.setItemType((short) 3); @@ -714,18 +722,18 @@ exerciseItemSet4.setItemCount(statisticsMap.get(examPaperInfo.getExamPaperId()).getFillBlanksCount()); exerciseItemSet4.setItemType((short) 4); lstItemSets.add(exerciseItemSet4); - //将itemSets设置成页面要用到的ExamPaperSectionInfo设置 + //灏唅temSets璁剧疆鎴愰〉闈㈣鐢ㄥ埌鐨凟xamPaperSectionInfo璁剧疆 for (int i=0;i<lstItemSets.size();i++) { ExamPaperSectionInfo examPaperSectionInfo=new ExamPaperSectionInfo(); int itemCount = lstItemSets.get(i).getItemCount(); if (itemCount>0) { examPaperSectionInfo.setGroupId(groupId); - //设置开始结束 + //璁剧疆寮�濮嬬粨鏉� examPaperSectionInfo.setItemStartOrder((short)count); - //获取题目设置的count,下次循环用 + //鑾峰彇棰樼洰璁剧疆鐨刢ount,涓嬫寰幆鐢� count+=itemCount; examPaperSectionInfo.setItemEndOrder((short)count); - //名称 + //鍚嶇О examPaperSectionInfo.setSectionName(String.valueOf(lstItemSets.get(i).getItemType())); examPaperSectionInfos.add(examPaperSectionInfo); } @@ -736,7 +744,7 @@ } /** - * 获取用户答题信息 + * 鑾峰彇鐢ㄦ埛绛旈淇℃伅 * @param recordId * @return */ @@ -748,7 +756,7 @@ } /** - * 获取用户的考试记录,如果不存在则创建并返回 + * 鑾峰彇鐢ㄦ埛鐨勮�冭瘯璁板綍锛屽鏋滀笉瀛樺湪鍒欏垱寤哄苟杩斿洖 * @param examBatchInfo * @param itemSets * @param classId @@ -763,7 +771,7 @@ short examType = examBatchInfo.getExamInfo().getExamType(); int remainingSeconds = examBatchInfo.getExamInfo().getDurationMin()*60; - // 查询是否有进行中的考试 + // 鏌ヨ鏄惁鏈夎繘琛屼腑鐨勮�冭瘯 ExerciseRecord record = this.findUnique( "from ExerciseRecord where examBatchId=? and classId=? and userId = ? and deleteFlag is false ", CollectionUtils.newList(examBatchId,classId,StringUtils.isNotEmpty(studentUserId) ? studentUserId : ClientUtils.getUserId()), @@ -774,10 +782,10 @@ String cacheKey = "EXAM_DO_COUNT_".concat(examBatchId); int doCount = this.getCachedRecordCount(cacheKey,examBatchId); - //随机创建题目组 + //闅忔満鍒涘缓棰樼洰缁� if(checkIsRandomExam(examType)){ - String newGroupName = examId+"-"+examBatchNo+"-随机试卷题库-"+(++doCount); - //查题库 + String newGroupName = examId+"-"+examBatchNo+"-闅忔満璇曞嵎棰樺簱-"+(++doCount); + //鏌ラ搴� List<ExerciseGroup> lstSourceGroup = queryExamGroups(examId, ExerciseExamReGroup.GROUP_TYPE_SOURCE); String[] sourceGroupIds = QBeanUtils.listPropertyVal(lstSourceGroup, "groupId").toArray(new String[lstSourceGroup.size()]); groupId = this.exerciseGroupService.doCreateRandomExerciseGroup(newGroupName,ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,sourceGroupIds,itemSets); @@ -791,7 +799,7 @@ return record; } /** - * 创建补考考试记录 + * 鍒涘缓琛ヨ�冭�冭瘯璁板綍 * @param examBatchInfo * @param itemSets * @param studentUserId @@ -805,15 +813,15 @@ short examType = examInfo.getExamType(); int remainingSeconds = examInfo.getDurationMin()*60; - //创建考试记录 + //鍒涘缓鑰冭瘯璁板綍 String groupId = null; String cacheKey = "EXAM_DO_COUNT_".concat(examId); int doCount = this.getCachedRecordCount(cacheKey,examId); - //随机创建题目组 + //闅忔満鍒涘缓棰樼洰缁� if(checkIsRandomExam(examType)){ - String newGroupName = examId+"-"+UUIDUtils.generateSpecialUuid(4)+"-随机试卷题库-"+(++doCount); - //查题库 + String newGroupName = examId+"-"+UUIDUtils.generateSpecialUuid(4)+"-闅忔満璇曞嵎棰樺簱-"+(++doCount); + //鏌ラ搴� List<ExerciseGroup> lstSourceGroup = queryExamGroups(examId, ExerciseExamReGroup.GROUP_TYPE_SOURCE); String[] sourceGroupIds = QBeanUtils.listPropertyVal(lstSourceGroup, "groupId").toArray(new String[lstSourceGroup.size()]); groupId = this.exerciseGroupService.doCreateRandomExerciseGroup(newGroupName,ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,sourceGroupIds,itemSets); @@ -826,7 +834,7 @@ return record; } - // 获取正在做试卷的学生数 + // 鑾峰彇姝e湪鍋氳瘯鍗风殑瀛︾敓鏁� private int getCachedRecordCount(String cacheKey,String examBatchId){ String cacheCount = stringRedisTemplate.opsForValue().get(cacheKey); int doCount = StringUtils.isEmpty(cacheCount) ? 0 : Integer.valueOf(cacheCount); @@ -854,7 +862,7 @@ record.setUserId(ClientUtils.getUserId()); record.setOrgId(ClientUtils.getOrgId()); - //获取考试题目统计信息,并保存 + //鑾峰彇鑰冭瘯棰樼洰缁熻淇℃伅锛屽苟淇濆瓨 Map<String,Object> result = this.queryItemStatics(itemSets, groupId); record.setTotalScore(new BigDecimal(examInfo.getTotalScore())); record.setPassingScore(new BigDecimal(examInfo.getPassingScore())); @@ -868,27 +876,27 @@ return record; } - //设置补考考试记录 + //璁剧疆琛ヨ�冭�冭瘯璁板綍 private ExerciseRecord insertReExerRecord(ExamInfo examInfo,List<ExerciseItemSet> itemSets,String groupId,int remainingSeconds) { // ExamInfo examInfo = examBatchInfo.getExamInfo(); ExerciseRecord record = new ExerciseRecord(); record.setDeleteFlag(false); record.setExerciseGroupId(groupId); - //因为没有批次,所有时间所有人都可以考,所以这里将批次ID设置成考试ID + //鍥犱负娌℃湁鎵规锛屾墍鏈夋椂闂存墍鏈変汉閮藉彲浠ヨ�冿紝鎵�浠ヨ繖閲屽皢鎵规ID璁剧疆鎴愯�冭瘯ID record.setExamBatchId(examInfo.getExamId()); record.setDoCount(BigInteger.ZERO); record.setCorrectCount(BigInteger.ZERO); record.setTitleMaxNumber("0"); record.setStatus("0"); - //不设置classID + //涓嶈缃甤lassID // record.setClassId(classId); record.setRemainingSeconds(remainingSeconds); record.setScore(BigDecimal.ZERO); record.setUserId(ClientUtils.getUserId()); record.setOrgId(ClientUtils.getOrgId()); - //获取考试题目统计信息,并保存 + //鑾峰彇鑰冭瘯棰樼洰缁熻淇℃伅锛屽苟淇濆瓨 Map<String,Object> result = this.queryItemStatics(itemSets, groupId); record.setTotalScore(new BigDecimal(examInfo.getTotalScore())); record.setPassingScore(new BigDecimal(examInfo.getPassingScore())); @@ -903,14 +911,14 @@ } /** - * 获取补考记录集合 + * 鑾峰彇琛ヨ�冭褰曢泦鍚� * @param examId * @param userId * @return */ @Override public Result getReExamRecordList(String examId, String userId) { - // 查询是否有进行中的考试 + // 鏌ヨ鏄惁鏈夎繘琛屼腑鐨勮�冭瘯 List<ExerciseRecord> exerciseRecords = this.find( "from ExerciseRecord where examBatchId=? and userId = ? and deleteFlag is false ", CollectionUtils.newList(examId, StringUtils.isNotEmpty(userId) ? userId : ClientUtils.getUserId()), @@ -922,7 +930,7 @@ float subTotalScore = 0,objTotalScore=0; int subItemCount=0,objItemCount=0; - //如果是随机组卷 + //濡傛灉鏄殢鏈虹粍鍗� if(itemSets!=null && itemSets.size()>0){ for(ExerciseItemSet s:itemSets){ if(s.getItemType()==ExerciseItem.TYPE_ESSAY_QUESTION){ @@ -963,7 +971,7 @@ @Override public int getExamCount(String classId, String userId) { - // 查询记录数 + // 鏌ヨ璁板綍鏁� String hqlCount = "from ExamInfo i, ExamBatchInfo b,ExamBatchClassRe r WHERE " + " i.examId=b.examId and b.examBatchId = r.examBatchId AND r.classId =:classId AND i.examStatus=:examStatus AND b.deleteFlag is false AND r.deleteFlag is false "; int examCount = findCountByComplexHql(hqlCount, @@ -972,10 +980,10 @@ } /** - * 查询考试关联的题目组 + * 鏌ヨ鑰冭瘯鍏宠仈鐨勯鐩粍 * @param examId * @param - * @return 题目组Map<id,> + * @return 棰樼洰缁凪ap<id锛�> */ private List<ExerciseGroup> queryExamGroups(String examId,Short reType){ return this.find( "select p from ExerciseExamReGroup g,ExerciseGroup p where g.groupId = p.groupId and g.examId=? and g.type=? and g.deleteFlag is false", @@ -984,7 +992,7 @@ /** - * 查询考试关联的题目配置信息 + * 鏌ヨ鑰冭瘯鍏宠仈鐨勯鐩厤缃俊鎭� * @param examId * @param * @return -- Gitblit v1.8.0