| | |
| | | import com.qxueyou.scc.exercise.util.ExerciseUtils; |
| | | |
| | | /** |
| | | * 通知管理服务层 |
| | | * 通知管理服务层 |
| | | * |
| | | * @author kevin |
| | | * @createTime 2017-11-1 |
| | |
| | | |
| | | for (ExerciseGroup exerciseGroup : lstExerciseGroup) { |
| | | if (ExerciseGroup.STATUS_DRAFT != exerciseGroup.getStatus()) { |
| | | return new Result(false, "只有草稿状态的题库,才能发布。"); |
| | | return new Result(false, "只有草稿状态的题库,才能发布。"); |
| | | } |
| | | exerciseGroup.setStatus(ExerciseGroup.STATUS_PUBLISHED); |
| | | TraceUtils.setUpdateTrace(exerciseGroup); |
| | | save(exerciseGroup); |
| | | } |
| | | } else { |
| | | return new Result(false, "没有选择要发布的题库。"); |
| | | return new Result(false, "没有选择要发布的题库。"); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | List<ExerciseGroup> lstExerciseGroup = this.findByComplexHql(hql, pramMap, ExerciseGroup.class); |
| | | for (ExerciseGroup exerciseGroup : lstExerciseGroup) { |
| | | if (ExerciseGroup.STATUS_DRAFT != exerciseGroup.getStatus()) { |
| | | return new Result(false, "只有发布状态的题库,才能撤回。"); |
| | | return new Result(false, "只有发布状态的题库,才能撤回。"); |
| | | } |
| | | exerciseGroup.setStatus(ExerciseGroup.STATUS_DRAFT); |
| | | TraceUtils.setUpdateTrace(exerciseGroup); |
| | | save(exerciseGroup); |
| | | } |
| | | } else { |
| | | return new Result(false, "没有选择要撤回的题库。"); |
| | | return new Result(false, "没有选择要撤回的题库。"); |
| | | } |
| | | |
| | | return new Result(true); |
| | |
| | | public ExerciseGroup queryExerciseGroupDetail(String groupId,String batchId) { |
| | | ExerciseGroup exerciseGroup = this.read(ExerciseGroup.class, groupId); |
| | | if(exerciseGroup!=null){ |
| | | //根据批次ID查询考试ID |
| | | //根据批次ID查询考试ID |
| | | String hql="select r.examId from ExamBatchClassRe r where r.examBatchId=?"; |
| | | String examId = this.findUnique(hql, CollectionUtils.newList(batchId), String.class); |
| | | exerciseGroup.setItems(this.queryExerciseItemList(exerciseGroup,examId)); |
| | | } |
| | | return exerciseGroup; |
| | | } |
| | | //补考考试获取试卷设置 |
| | | //补考考试获取试卷设置 |
| | | @Override |
| | | public ExerciseGroup queryReExerciseGroupDetail(String groupId,String examId) { |
| | | ExerciseGroup exerciseGroup = this.read(ExerciseGroup.class, groupId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询练习题目list |
| | | * 查询练习题目list |
| | | * |
| | | * @param groupId |
| | | * @return |
| | |
| | | List<ExerciseItem> lstItems = boundValueOperations.get(); |
| | | |
| | | if(lstItems==null){ |
| | | // 1.查询练习题目信息 |
| | | // 1.查询练习题目信息 |
| | | StringBuffer hqlBuffer = new StringBuffer(1000); |
| | | hqlBuffer.append("select item from ExerciseItem item, ExerciseGroupItemRe re, ExerciseGroup g"); |
| | | hqlBuffer.append(" where item.exerciseId=re.exerciseItemId and re.exerciseGroupId=g.groupId"); |
| | | hqlBuffer.append(" and g.groupId = ? and item.deleteFlag is false and g.deleteFlag is false"); |
| | | //如果是题库按照题目类型排序,其他按照题目顺序排序 |
| | | //如果是题库按照题目类型排序,其他按照题目顺序排序 |
| | | if(exerciseGroup.getType() == ExerciseGroup.TYPE_EXERCISE_GROUP_LIB){ |
| | | hqlBuffer.append(" and re.deleteFlag is false order by item.type, re.itemOrder"); |
| | | }else{ |
| | |
| | | |
| | | lstItems = this.find(hqlBuffer.toString(), CollectionUtils.newList(exerciseGroup.getGroupId()), ExerciseItem.class); |
| | | |
| | | // 为空 |
| | | // 为空 |
| | | if (lstItems.isEmpty()) { |
| | | return lstItems; |
| | | } |
| | | |
| | | // 组装选项,答案,解析等信息 |
| | | // 组装选项,答案,解析等信息 |
| | | lstItems = getCommonExerItemDetail(lstItems, exerciseGroup.getGroupId()); |
| | | |
| | | boundValueOperations.setIfAbsent(lstItems); |
| | |
| | | List<ExerciseItem> lstItems = boundValueOperations.get(); |
| | | |
| | | if(true){ |
| | | // 1.查询练习题目信息 |
| | | // 1.查询练习题目信息 |
| | | StringBuffer hqlBuffer = new StringBuffer(1000); |
| | | hqlBuffer.append("select item from ExerciseItem item, ExerciseGroupItemRe re, ExerciseGroup g"); |
| | | hqlBuffer.append(" where item.exerciseId=re.exerciseItemId and re.exerciseGroupId=g.groupId"); |
| | | hqlBuffer.append(" and g.groupId = ? and item.deleteFlag is false and g.deleteFlag is false"); |
| | | //如果是题库按照题目类型排序,其他按照题目顺序排序 |
| | | //如果是题库按照题目类型排序,其他按照题目顺序排序 |
| | | if(exerciseGroup.getType() == ExerciseGroup.TYPE_EXERCISE_GROUP_LIB){ |
| | | hqlBuffer.append(" and re.deleteFlag is false order by item.type, re.itemOrder"); |
| | | }else{ |
| | |
| | | |
| | | lstItems = this.find(hqlBuffer.toString(), CollectionUtils.newList(exerciseGroup.getGroupId()), ExerciseItem.class); |
| | | |
| | | // 为空 |
| | | // 为空 |
| | | if (lstItems.isEmpty()) { |
| | | return lstItems; |
| | | } |
| | | |
| | | // 组装选项,答案,解析等信息 |
| | | // 组装选项,答案,解析等信息 |
| | | lstItems = getCommonExerItemDetail(lstItems, exerciseGroup.getGroupId(),examId); |
| | | |
| | | boundValueOperations.setIfAbsent(lstItems); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 重新组装练习题 加入分析结果 |
| | | * 重新组装练习题 加入分析结果 |
| | | * |
| | | * @param lstItems |
| | | * @param exerciseGroupId |
| | |
| | | * @return |
| | | */ |
| | | private List<ExerciseItem> getCommonExerItemDetail(List<ExerciseItem> lstItems, String exerciseGroupId) { |
| | | // 0.组装参数 |
| | | // 0.组装参数 |
| | | Map<String, Object> argsMap = new HashMap<String, Object>(); |
| | | Object[] args = new Object[lstItems.size()]; |
| | | for (int i = 0; i < lstItems.size(); i++) { |
| | | args[i] = lstItems.get(i).getExerciseId(); |
| | | } |
| | | argsMap.put("exerciseIds", args); |
| | | //查询题目得分 |
| | | //查询题目得分 |
| | | String hql_itemScores = "from ExerciseItemScore s where s.groupId=:groupId and s.exerciseItemId in (:exerciseIds) and s.deleteFlag is false order by exerciseItemId"; |
| | | List<ExerciseItemScore> lstItemScores = this.findByComplexHql(hql_itemScores, CollectionUtils.newObjectMap("groupId",exerciseGroupId,"exerciseIds",args), ExerciseItemScore.class); |
| | | Map<String, List<ExerciseItemScore>> scoresMap= new HashMap<String,List<ExerciseItemScore>>(lstItemScores.size()); |
| | | ExerciseUtils.packageExerciseItemScore(scoresMap, lstItemScores); |
| | | |
| | | // 1.查询练习题目全站分析 |
| | | // 1.查询练习题目全站分析 |
| | | String hql_analisis = "from ExerciseItemAnalisi where exerciseItemId in (:exerciseIds) and deleteFlag is false "; |
| | | List<ExerciseItemAnalisi> lstAnalisis = this.findByComplexHql(hql_analisis, argsMap, ExerciseItemAnalisi.class); |
| | | Map<String, List<ExerciseItemAnalisi>> analisiMap = new HashMap<String, List<ExerciseItemAnalisi>>(lstAnalisis.size()); |
| | |
| | | } |
| | | } |
| | | |
| | | // 2.查询练习题目答案选项 |
| | | // 2.查询练习题目答案选项 |
| | | Map<String, List<ExerciseItemOption>> optionsMap = new HashMap<String, List<ExerciseItemOption>>( |
| | | lstItems.size()); |
| | | Map<String, String> answerMap = new HashMap<String, String>(); |
| | | String hql_options = "from ExerciseItemOption where exerciseItemId in (:exerciseIds) and deleteFlag is false order by exerciseItemId, optionOrder "; |
| | | List<ExerciseItemOption> lstAllOptions = this.findByComplexHql(hql_options, argsMap, ExerciseItemOption.class); |
| | | |
| | | // 重新组装练习 |
| | | // 重新组装练习 |
| | | ExerciseUtils.packageExerciseItem(optionsMap, answerMap, lstAllOptions, null); |
| | | |
| | | String exerciseId = null; |
| | | for (ExerciseItem item : lstItems) { |
| | | |
| | | // 4.0 分析结果 |
| | | // 4.0 分析结果 |
| | | exerciseId = item.getExerciseId(); |
| | | |
| | | // 得到练习组id |
| | | // 得到练习组id |
| | | if (StringUtils.isNotBlank(exerciseGroupId)) { |
| | | item.setExerciseGroupId(exerciseGroupId); |
| | | } |
| | | |
| | | // 4.3 题目选项 |
| | | // 4.3 题目选项 |
| | | item.setOptions(optionsMap.get(exerciseId)); |
| | | |
| | | item.setAnalisisResult(null); |
| | | item.setAnalysises(null); |
| | | item.setAnalysises(analisiMap.get(exerciseId)); |
| | | |
| | | //组装练习题目 |
| | | //组装练习题目 |
| | | item.setScores(scoresMap.get(exerciseId)); |
| | | } |
| | | |
| | | return lstItems; |
| | | } |
| | | /** |
| | | * 重新组装练习题 加入分析结果 |
| | | * 重新组装练习题 加入分析结果 |
| | | * |
| | | * @param lstItems |
| | | * @param exerciseGroupId |
| | |
| | | * @return |
| | | */ |
| | | private List<ExerciseItem> getCommonExerItemDetail(List<ExerciseItem> lstItems, String exerciseGroupId,String examId) { |
| | | // 0.组装参数 |
| | | // 0.组装参数 |
| | | Map<String, Object> argsMap = new HashMap<String, Object>(); |
| | | Object[] args = new Object[lstItems.size()]; |
| | | for (int i = 0; i < lstItems.size(); i++) { |
| | |
| | | } |
| | | argsMap.put("exerciseIds", args); |
| | | |
| | | //查询题目得分 |
| | | //查询题目得分 |
| | | String hql_itemScores = "from ExerciseItemScore s where s.groupId=:groupId and s.exerciseItemId in (:exerciseIds) and s.deleteFlag is false order by exerciseItemId"; |
| | | List<ExerciseItemScore> lstItemScores = this.findByComplexHql(hql_itemScores, CollectionUtils.newObjectMap("groupId",exerciseGroupId,"exerciseIds",args), ExerciseItemScore.class); |
| | | Map<String, List<ExerciseItemScore>> scoresMap= new HashMap<String,List<ExerciseItemScore>>(); |
| | | log.error("================================================="); |
| | | List<ExerciseItemSet> exerciseItemSets=null; |
| | | if (lstItemScores==null||lstItemScores.size()<=0){ |
| | | //根据考试ID查询itemSet |
| | | //根据考试ID查询itemSet |
| | | String hql = "select r from ExerciseItemSet r where r.exerciseInfoId=?"; |
| | | exerciseItemSets = this.find(hql, CollectionUtils.newList(examId), ExerciseItemSet.class); |
| | | }else { |
| | | ExerciseUtils.packageExerciseItemScore(scoresMap, lstItemScores); |
| | | } |
| | | |
| | | // 1.查询练习题目全站分析 |
| | | // 1.查询练习题目全站分析 |
| | | String hql_analisis = "from ExerciseItemAnalisi where exerciseItemId in (:exerciseIds) and deleteFlag is false "; |
| | | List<ExerciseItemAnalisi> lstAnalisis = this.findByComplexHql(hql_analisis, argsMap, ExerciseItemAnalisi.class); |
| | | Map<String, List<ExerciseItemAnalisi>> analisiMap = new HashMap<String, List<ExerciseItemAnalisi>>(lstAnalisis.size()); |
| | |
| | | } |
| | | } |
| | | |
| | | // 2.查询练习题目答案选项 |
| | | // 2.查询练习题目答案选项 |
| | | Map<String, List<ExerciseItemOption>> optionsMap = new HashMap<String, List<ExerciseItemOption>>( |
| | | lstItems.size()); |
| | | Map<String, String> answerMap = new HashMap<String, String>(); |
| | | String hql_options = "from ExerciseItemOption where exerciseItemId in (:exerciseIds) and deleteFlag is false order by exerciseItemId, optionOrder "; |
| | | List<ExerciseItemOption> lstAllOptions = this.findByComplexHql(hql_options, argsMap, ExerciseItemOption.class); |
| | | |
| | | // 重新组装练习 |
| | | // 重新组装练习 |
| | | ExerciseUtils.packageExerciseItem(optionsMap, answerMap, lstAllOptions, null); |
| | | |
| | | String exerciseId = null; |
| | | for (ExerciseItem item : lstItems) { |
| | | |
| | | // 4.0 分析结果 |
| | | // 4.0 分析结果 |
| | | exerciseId = item.getExerciseId(); |
| | | |
| | | // 得到练习组id |
| | | // 得到练习组id |
| | | if (StringUtils.isNotBlank(exerciseGroupId)) { |
| | | item.setExerciseGroupId(exerciseGroupId); |
| | | } |
| | | |
| | | // 4.3 题目选项 |
| | | // 4.3 题目选项 |
| | | item.setOptions(optionsMap.get(exerciseId)); |
| | | |
| | | item.setAnalisisResult(null); |
| | | item.setAnalysises(null); |
| | | item.setAnalysises(analisiMap.get(exerciseId)); |
| | | //组装练习题目 |
| | | //组装练习题目 |
| | | item.setScores(scoresMap.get(exerciseId)); |
| | | //随机试题没有对应分数,需要根据考试Id从item_set里查询每种题目的分数设置 |
| | | //随机试题没有对应分数,需要根据考试Id从item_set里查询每种题目的分数设置 |
| | | if (exerciseItemSets != null ) { |
| | | //遍历每个item |
| | | //遍历每个item |
| | | short type = item.getType(); |
| | | //遍历itemset,每个item根据type获取对应类型的分数设置 |
| | | //遍历itemset,每个item根据type获取对应类型的分数设置 |
| | | for (ExerciseItemSet exerciseItemSet : exerciseItemSets) { |
| | | if (exerciseItemSet.getItemType() == type) { |
| | | /** |
| | |
| | | @Override |
| | | public int doCopyExerciseGroupItem(ExerciseGroup sourceGroup, ExerciseGroup targetGroup,Short[] itemTypes, int startOrder) |
| | | throws IllegalAccessException, InvocationTargetException { |
| | | //参数判断 |
| | | //参数判断 |
| | | if(sourceGroup==null || targetGroup==null || ArrayUtils.isEmpty(itemTypes)){ |
| | | return 0; |
| | | } |
| | | |
| | | //查询题目组与题目关联关系,需要过滤掉在目标题目组中已拷贝过的题目 |
| | | //查询题目组与题目关联关系,需要过滤掉在目标题目组中已拷贝过的题目 |
| | | String hql = "select r1 from ExerciseGroupItemRe r1,ExerciseItem i where r1.exerciseItemId = i.exerciseId and i.type in(:itemTypes) and r1.deleteFlag is false and r1.exerciseGroupId = :sourceGroupId " |
| | | + " and not exists (select 1 from ExerciseGroupItemRe r2 where r2.deleteFlag is false and r2.exerciseItemId = r1.exerciseItemId and r2.exerciseGroupId = :targetGroupId ) order by r1.itemOrder ASC "; |
| | | |
| | |
| | | queryParamMap.put("itemTypes", itemTypes); |
| | | List<ExerciseGroupItemRe> lstSourceGroupRe = this.findByComplexHql(hql,queryParamMap,ExerciseGroupItemRe.class); |
| | | |
| | | //查询题目组关联的得分信息,只关联获取没初化过的 |
| | | //查询题目组关联的得分信息,只关联获取没初化过的 |
| | | String hql_itemScores = "select s1 from ExerciseItemScore s1,ExerciseItem i where s1.exerciseItemId = i.exerciseId and i.type in(:itemTypes) and s1.groupId=:sourceGroupId and s1.deleteFlag is false and not exists (" |
| | | + " select 1 from ExerciseItemScore s2 where s2.deleteFlag is false and s2.exerciseItemId = s1.exerciseItemId and s2.groupId =:targetGroupId ) order by s1.exerciseItemId"; |
| | | List<ExerciseItemScore> lstItemScores = this.findByComplexHql(hql_itemScores,queryParamMap, ExerciseItemScore.class); |
| | |
| | | |
| | | int copyItemSize=0; |
| | | if(lstSourceGroupRe!=null && lstSourceGroupRe.size()>0){ |
| | | //更新item的顺序号 |
| | | //更新item的顺序号 |
| | | this.bulkUpdate("update ExerciseGroupItemRe r set r.itemOrder=r.itemOrder+"+lstSourceGroupRe.size() |
| | | +" where r.exerciseGroupId=? and r.itemOrder>? and r.deleteFlag is false ", new Object[]{targetGroup.getGroupId(),startOrder}); |
| | | |
| | | //拷贝item |
| | | //拷贝item |
| | | copyItemSize=lstSourceGroupRe.size(); |
| | | int itemOrder = startOrder; |
| | | ExerciseItemScore objItemScore = null; |
| | |
| | | ojbItemRe.setExerciseGroupId(targetGroup.getGroupId()); |
| | | lstTargetItemRe.add(ojbItemRe); |
| | | |
| | | //复制题目分数信息 |
| | | //复制题目分数信息 |
| | | List<ExerciseItemScore> scores = scoresMap.get(it.getExerciseItemId()); |
| | | if(scores!=null && scores.size()>0){ |
| | | for(int i=0;i<scores.size();i++){ |
| | |
| | | @Override |
| | | public int doCopyExerciseGroupItem(ExerciseGroup sourceGroup, ExerciseGroup targetGroup,String[] exerciseItemIds, int startOrder) |
| | | throws IllegalAccessException, InvocationTargetException { |
| | | //参数判断 |
| | | //参数判断 |
| | | if(sourceGroup==null || targetGroup==null || ArrayUtils.isEmpty(exerciseItemIds)){ |
| | | return 0; |
| | | } |
| | | |
| | | //查询题目组与题目关联关系,需要过滤掉在目标题目组中已拷贝过的题目 |
| | | //查询题目组与题目关联关系,需要过滤掉在目标题目组中已拷贝过的题目 |
| | | String hql = "select r1 from ExerciseGroupItemRe r1 where r1.exerciseItemId in(:exerciseItemIds) and r1.deleteFlag is false and r1.exerciseGroupId = :sourceGroupId " |
| | | + " and not exists (select 1 from ExerciseGroupItemRe r2 where r2.deleteFlag is false and r2.exerciseItemId = r1.exerciseItemId and r2.exerciseGroupId = :targetGroupId ) order by r1.itemOrder ASC "; |
| | | |
| | |
| | | queryParamMap.put("exerciseItemIds", exerciseItemIds); |
| | | List<ExerciseGroupItemRe> lstSourceGroupRe = this.findByComplexHql(hql,queryParamMap,ExerciseGroupItemRe.class); |
| | | |
| | | //查询题目组关联的得分信息,只关联获取没初化过的 |
| | | //查询题目组关联的得分信息,只关联获取没初化过的 |
| | | String hql_itemScores = "select s1 from ExerciseItemScore s1 where s1.exerciseItemId in (:exerciseItemIds) and s1.groupId=:sourceGroupId and s1.deleteFlag is false and not exists (" |
| | | + " select 1 from ExerciseItemScore s2 where s2.deleteFlag is false and s2.exerciseItemId = s1.exerciseItemId and s2.groupId =:targetGroupId ) order by s1.exerciseItemId"; |
| | | List<ExerciseItemScore> lstItemScores = this.findByComplexHql(hql_itemScores,queryParamMap, ExerciseItemScore.class); |
| | |
| | | |
| | | int copyItemSize=0; |
| | | if(lstSourceGroupRe!=null && lstSourceGroupRe.size()>0){ |
| | | //更新item的顺序号 |
| | | //更新item的顺序号 |
| | | this.bulkUpdate("update ExerciseGroupItemRe r set r.itemOrder=r.itemOrder+"+lstSourceGroupRe.size() |
| | | +" where r.exerciseGroupId=? and r.itemOrder>? and r.deleteFlag is false ", new Object[]{targetGroup.getGroupId(),startOrder}); |
| | | |
| | | //拷贝item |
| | | //拷贝item |
| | | copyItemSize=lstSourceGroupRe.size(); |
| | | int itemOrder = startOrder; |
| | | ExerciseItemScore objItemScore = null; |
| | |
| | | ojbItemRe.setExerciseGroupId(targetGroup.getGroupId()); |
| | | lstTargetItemRe.add(ojbItemRe); |
| | | |
| | | //复制题目分数信息 |
| | | //复制题目分数信息 |
| | | List<ExerciseItemScore> scores = scoresMap.get(it.getExerciseItemId()); |
| | | if(scores!=null && scores.size()>0){ |
| | | for(int i=0;i<scores.size();i++){ |
| | |
| | | queryParams.put("groupId", groupId); |
| | | queryParams.put("exerciseItemIds", new String[] { exerciseItemId1, exerciseItemId2 }); |
| | | List<ExerciseGroupItemRe> lstItemRe = this.findByComplexHql(hql, queryParams, ExerciseGroupItemRe.class); |
| | | // 交换顺序号 |
| | | // 交换顺序号 |
| | | int tempOrder = lstItemRe.get(0).getItemOrder(); |
| | | lstItemRe.get(0).setItemOrder(lstItemRe.get(1).getItemOrder()); |
| | | lstItemRe.get(1).setItemOrder(tempOrder); |
| | |
| | | |
| | | for (ExerciseGroup exerciseGroup : lstExerciseLibs) { |
| | | if (ExerciseGroup.STATUS_DRAFT != exerciseGroup.getStatus()) { |
| | | return new Result(false, "只有草稿状态的题库,才能发布。"); |
| | | return new Result(false, "只有草稿状态的题库,才能发布。"); |
| | | } |
| | | //判断题库中是否有题,有题目的题库才能发布 |
| | | //判断题库中是否有题,有题目的题库才能发布 |
| | | if(exerciseGroup.getAllCount()==null || exerciseGroup.getAllCount().intValue()<=0){ |
| | | return new Result(false, "只有已经配置题目的题库,才能发布。"); |
| | | return new Result(false, "只有已经配置题目的题库,才能发布。"); |
| | | } |
| | | exerciseGroup.setStatus(ExerciseGroup.STATUS_PUBLISHED); |
| | | TraceUtils.setUpdateTrace(exerciseGroup); |
| | | save(exerciseGroup); |
| | | } |
| | | } else { |
| | | return new Result(false, "没有选择要发布的题库。"); |
| | | return new Result(false, "没有选择要发布的题库。"); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | |
| | | for (ExerciseGroup exerciseGroup : lstExerciseLibs) { |
| | | if (ExerciseGroup.STATUS_PUBLISHED != exerciseGroup.getStatus()) { |
| | | return new Result(false, "只有发布状态的题库,才能撤回。"); |
| | | return new Result(false, "只有发布状态的题库,才能撤回。"); |
| | | } |
| | | exerciseGroup.setStatus(ExerciseGroup.STATUS_DRAFT); |
| | | TraceUtils.setUpdateTrace(exerciseGroup); |
| | | save(exerciseGroup); |
| | | } |
| | | } else { |
| | | return new Result(false, "没有选择要撤回的题库。"); |
| | | return new Result(false, "没有选择要撤回的题库。"); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 创建考试题目 |
| | | * 创建考试题目 |
| | | * |
| | | * @param groupIds |
| | | * @return |
| | | */ |
| | | private Result doCreateRandomExerciseItem(String[] groupIds, List<ExerciseItemSet> lstExerciseItemSet) { |
| | | if (groupIds.length == 0 || lstExerciseItemSet == null || lstExerciseItemSet.size() == 0) { |
| | | return new Result(false, "参数错误"); |
| | | return new Result(false, "参数错误"); |
| | | } |
| | | |
| | | List<Map<String, Object>> lstExerciseItem = new ArrayList<Map<String, Object>>(); |
| | | |
| | | //按照题型(单选题(1),多选题(2),判断题(3), 填空题(8),简答题(4))排序lstExerciseItemSet |
| | | //按照题型(单选题(1),多选题(2),判断题(3), 填空题(8),简答题(4))排序lstExerciseItemSet |
| | | Collections.sort(lstExerciseItemSet, new Comparator<ExerciseItemSet>(){ |
| | | @Override |
| | | public int compare(ExerciseItemSet o1, ExerciseItemSet o2) { |
| | |
| | | CollectionUtils.newObjectMap("exerciseGroupId", paramGroupIds, "type", itemSet.getItemType())); |
| | | |
| | | if (lstItem.size() < itemSet.getItemCount()) { |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数"); |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数"); |
| | | } |
| | | |
| | | lstExerciseItem.addAll(this.getRandomList(lstItem, itemSet.getItemCount())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 随机获取List中若干数据 |
| | | * 随机获取List中若干数据 |
| | | * |
| | | * @param paramList |
| | | * @param count |
| | |
| | | List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); |
| | | int temp = 0; |
| | | for (int i = 0; i < count; i++) { |
| | | temp = random.nextInt(paramList.size());// 将产生的随机数作为被抽list的索引 |
| | | temp = random.nextInt(paramList.size());// 将产生的随机数作为被抽list的索引 |
| | | if (!tempList.contains(temp)) { |
| | | tempList.add(temp); |
| | | newList.add(paramList.get(temp)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取题库中各种题型的数量 |
| | | * 获取题库中各种题型的数量 |
| | | * @param groupIds |
| | | * @return |
| | | */ |