| | |
| | | import com.qxueyou.scc.msg.service.IMsgInfoService; |
| | | |
| | | /** |
| | | * 考试管理服务层 |
| | | * 考试管理服务层 |
| | | * |
| | | * @author kevin |
| | | * @createTime 2017-11-1 |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | |
| | | 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)); |
| | |
| | | }); |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | ExamInfo examInfo = read(ExamInfo.class, param.getExamId()); |
| | | |
| | | if (examInfo == null) { |
| | | return new Result(false, "考试不存在"); |
| | | return new Result(false, "考试不存在"); |
| | | } |
| | | |
| | | TraceUtils.setUpdateTrace(examInfo); |
| | |
| | | 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 |
| | | // 删除之前的Exercise关联的group |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | //保存考试,源题目组信息 |
| | | //保存考试,源题目组信息 |
| | | String [] sourceGroupIds = param.getSourceGroupIds().split(","); |
| | | |
| | | // 保存关联练习组 |
| | | // 保存关联练习组 |
| | | if (sourceGroupIds != null && sourceGroupIds.length > 0) { |
| | | ExerciseExamReGroup reGroup = null; |
| | | for (String groupId : sourceGroupIds) { |
| | |
| | | } |
| | | |
| | | }else{ |
| | | // 删除原来的关联关系 |
| | | // 删除原来的关联关系 |
| | | String hql = "update ExamReExamPaper set deleteFlag = true where examId=? "; |
| | | this.bulkUpdate(hql, new Object[] { param.getExamId() }); |
| | | List<ExamReExamPaper> lstExamReExamPaper = param.getReExamPapers(); |
| | |
| | | |
| | | 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); |
| | |
| | | this.doExamPublishMsg(examInfo.getExamId()); |
| | | } |
| | | } else { |
| | | return new Result(false, "没有选择要发布的考试。"); |
| | | return new Result(false, "没有选择要发布的考试。"); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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, "考试马上开始了,请做好考试准备"); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | } |
| | | @Override |
| | | public ExamInfo queryReExam() { |
| | | // 查询是否有进行中的考试 |
| | | // 查询是否有进行中的考试 |
| | | ExamInfo examInfo = this.findUnique( |
| | | "from ExamInfo where maxLateMin=? and deleteFlag is false ", |
| | | CollectionUtils.newList((short)1), |
| | |
| | | } |
| | | |
| | | /** |
| | | * 开始考试 |
| | | * 开始考试 |
| | | * |
| | | * @param |
| | | * @return |
| | |
| | | //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()); |
| | |
| | | return new Result(true,"",resultData); |
| | | } |
| | | /** |
| | | * 开始补考考试 |
| | | * 开始补考考试 |
| | | * |
| | | * @param examId |
| | | * @return |
| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 判断是否是随机考试 |
| | | * 判断是否是随机考试 |
| | | * @param examType |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取考试试卷信息 |
| | | * 获取考试试卷信息 |
| | | * @param examId |
| | | * @param groupId |
| | | * @param examType |
| | |
| | | } |
| | | |
| | | /** |
| | | * 手动添加题目位置信息 |
| | | * 手动添加题目位置信息 |
| | | * @param groupId |
| | | * @param examType |
| | | * @param totalSocre |
| | |
| | | int itemCount = lstItemSets.get(i).getItemCount(); |
| | | if (itemCount>0) { |
| | | examPaperSectionInfo.setGroupId(groupId); |
| | | //设置开始结束 |
| | | //设置开始结束 |
| | | examPaperSectionInfo.setItemStartOrder((short)count); |
| | | //获取题目设置的count,下次循环用 |
| | | //获取题目设置的count,下次循环用 |
| | | count+=itemCount; |
| | | examPaperSectionInfo.setItemEndOrder((short)count); |
| | | //名称 |
| | | //名称 |
| | | examPaperSectionInfo.setSectionName(String.valueOf(lstItemSets.get(i).getItemType())); |
| | | examPaperSectionInfos.add(examPaperSectionInfo); |
| | | } |
| | |
| | | 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); |
| | |
| | | exerciseItemSet4.setItemCount(statisticsMap.get(examPaperInfo.getExamPaperId()).getFillBlanksCount()); |
| | | exerciseItemSet4.setItemType((short) 4); |
| | | lstItemSets.add(exerciseItemSet4); |
| | | //将itemSets设置成页面要用到的ExamPaperSectionInfo设置 |
| | | //将itemSets设置成页面要用到的ExamPaperSectionInfo设置 |
| | | 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,下次循环用 |
| | | //获取题目设置的count,下次循环用 |
| | | count+=itemCount; |
| | | examPaperSectionInfo.setItemEndOrder((short)count); |
| | | //名称 |
| | | //名称 |
| | | examPaperSectionInfo.setSectionName(String.valueOf(lstItemSets.get(i).getItemType())); |
| | | examPaperSectionInfos.add(examPaperSectionInfo); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户答题信息 |
| | | * 获取用户答题信息 |
| | | * @param recordId |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的考试记录,如果不存在则创建并返回 |
| | | * 获取用户的考试记录,如果不存在则创建并返回 |
| | | * @param examBatchInfo |
| | | * @param itemSets |
| | | * @param classId |
| | |
| | | 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()), |
| | |
| | | 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); |
| | |
| | | return record; |
| | | } |
| | | /** |
| | | * 创建补考考试记录 |
| | | * 创建补考考试记录 |
| | | * @param examBatchInfo |
| | | * @param itemSets |
| | | * @param studentUserId |
| | |
| | | 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); |
| | |
| | | return record; |
| | | } |
| | | |
| | | // 获取正在做试卷的学生数 |
| | | // 获取正在做试卷的学生数 |
| | | private int getCachedRecordCount(String cacheKey,String examBatchId){ |
| | | String cacheCount = stringRedisTemplate.opsForValue().get(cacheKey); |
| | | int doCount = StringUtils.isEmpty(cacheCount) ? 0 : Integer.valueOf(cacheCount); |
| | |
| | | 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())); |
| | |
| | | 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 |
| | | //不设置classID |
| | | // 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())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取补考记录集合 |
| | | * 获取补考记录集合 |
| | | * @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()), |
| | |
| | | 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){ |
| | |
| | | |
| | | @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, |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询考试关联的题目组 |
| | | * 查询考试关联的题目组 |
| | | * @param examId |
| | | * @param |
| | | * @return 题目组Map<id,> |
| | | * @return 题目组Map<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", |
| | |
| | | |
| | | |
| | | /** |
| | | * 查询考试关联的题目配置信息 |
| | | * 查询考试关联的题目配置信息 |
| | | * @param examId |
| | | * @param |
| | | * @return |