| | |
| | | |
| | | /** |
| | | * 考试 |
| | | * |
| | | * |
| | | * @author lihanqi |
| | | * |
| | | */ |
| | |
| | | |
| | | @Autowired |
| | | IHandoutService handoutService; |
| | | |
| | | |
| | | @Autowired |
| | | IMsgInfoService msgInfoService; |
| | | |
| | | |
| | | @Autowired |
| | | IExerciseCompleteService exerciseCompleteService; |
| | | |
| | | |
| | | @Autowired |
| | | IExerciseGroupService exerciseGroupService; |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseInfo> list(String keyword,String classId,Short status,Integer pageSize,Integer pageNum) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseInfo e where e.name like ? and e.createId =? "); |
| | | List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); |
| | | |
| | | |
| | | if(status!=null){ |
| | | hql.append(" and e.status = ? "); |
| | | params.add(status); |
| | | } |
| | | |
| | | |
| | | if(StringUtils.isNotEmpty(classId)){ |
| | | hql.append(" and exists(select 1 from ExerciseExamReClass r where e.exerciseInfoId=r.examId and r.classId = ? and r.deleteFlag is false)"); |
| | | params.add(classId); |
| | | } |
| | | |
| | | |
| | | hql.append(" and e.deleteFlag is false order by e.createTime desc"); |
| | | return findList(hql.toString(),new Pager(pageSize, pageNum),params, ExerciseInfo.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int listCount(String keyword,String classId, Short status) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseInfo e where e.name like ? and e.createId =? "); |
| | | List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); |
| | | |
| | | |
| | | if(status!=null){ |
| | | hql.append(" and e.status = ? "); |
| | | params.add(status); |
| | | } |
| | | |
| | | |
| | | if(StringUtils.isNotEmpty(classId)){ |
| | | hql.append(" and exists(select 1 from ExerciseExamReClass r where e.exerciseInfoId=r.examId and r.classId = ? and r.deleteFlag is false)"); |
| | | params.add(classId); |
| | | } |
| | | |
| | | |
| | | hql.append(" and e.deleteFlag is false "); |
| | | return findCount(hql.toString(),params); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存作业 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public Result insertExerciseInfo(ExerciseInfo exerciseInfo) { |
| | | String[] classIds = QBeanUtils.listPropertyVal(exerciseInfo.getReClasses(), "classId").toArray(new String[exerciseInfo.getReClasses().size()]); |
| | | |
| | | |
| | | String exerciseInfoId = UUIDUtils.generateUUID().replace("-", ""); |
| | | exerciseInfo.setExerciseInfoId(exerciseInfoId); |
| | | exerciseInfo.setOrgId(ClientUtils.getOrgId()); |
| | |
| | | // 保存题目类型 |
| | | List<ExerciseItemSet> lstExerciseItemSet = exerciseInfo.getExerciseItemSets(); |
| | | this.saveExerciseItemSet(exerciseInfoId,lstExerciseItemSet); |
| | | |
| | | |
| | | //生成作业题目信息 |
| | | String[] sourceGroupIds = QBeanUtils.listPropertyVal(exerciseInfo.getReGroups(), "groupId").toArray(new String[exerciseInfo.getReGroups().size()]); |
| | | |
| | | |
| | | String newGroupId = this.exerciseGroupService.doCreateRandomExerciseGroup( |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,sourceGroupIds,lstExerciseItemSet); |
| | | |
| | | |
| | | if(StringUtils.isEmpty(newGroupId)){ |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数",exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | this.saveExerciseExamReGroup(exerciseInfoId,new String[]{newGroupId},EXAM_TYPES[0],ExerciseExamReGroup.GROUP_TYPE_EXAM); |
| | | |
| | | |
| | | // 保存关联题库信息 |
| | | this.saveExerciseExamReGroup(exerciseInfoId,sourceGroupIds,null,ExerciseExamReGroup.GROUP_TYPE_SOURCE); |
| | | } |
| | | |
| | | |
| | | // 保存关联班级 |
| | | this.saveExerciseExamReClass(exerciseInfoId, classIds); |
| | | |
| | | |
| | | return new Result(true, "", exerciseInfoId); |
| | | } |
| | | |
| | | /** |
| | | * 修改练习 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public Result updateExerciseInfo(ExerciseInfo exerciseInfo) { |
| | | String[] classIds = QBeanUtils.listPropertyVal(exerciseInfo.getReClasses(), "classId").toArray(new String[exerciseInfo.getReClasses().size()]); |
| | | |
| | | |
| | | String exerciseInfoId = exerciseInfo.getExerciseInfoId(); |
| | | |
| | | |
| | | ExerciseInfo newExerciseInfo = this.read(ExerciseInfo.class, exerciseInfoId); |
| | | newExerciseInfo.setScore(exerciseInfo.getScore()); |
| | | newExerciseInfo.setClassCount(classIds == null ? 0 : classIds.length); |
| | |
| | | newExerciseInfo.setCommitUploadType(exerciseInfo.getCommitUploadType()); |
| | | TraceUtils.setUpdateTrace(newExerciseInfo); |
| | | this.save(newExerciseInfo); |
| | | |
| | | |
| | | //清理旧关系数据 |
| | | this.doClearExerciseExamReData(exerciseInfoId); |
| | | |
| | | |
| | | // 答题作业默认按照统一卷生成作业题目 |
| | | |
| | | |
| | | if (newExerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_ANSWER) { |
| | | |
| | | |
| | | // 保存题目类型 |
| | | List<ExerciseItemSet> lstExerciseItemSet = exerciseInfo.getExerciseItemSets(); |
| | | |
| | | |
| | | saveExerciseItemSet(exerciseInfoId,lstExerciseItemSet); |
| | | |
| | | |
| | | //生成作业题目信息 |
| | | String[] groupIds = QBeanUtils.listPropertyVal(exerciseInfo.getReGroups(), "groupId").toArray(new String[exerciseInfo.getReGroups().size()]); |
| | | String newGroupId = this.exerciseGroupService.doCreateRandomExerciseGroup( |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,groupIds, lstExerciseItemSet); |
| | | |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,groupIds, lstExerciseItemSet); |
| | | |
| | | if(StringUtils.isEmpty(newGroupId)){ |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数"); |
| | | } |
| | | |
| | | |
| | | this.saveExerciseExamReGroup(exerciseInfoId,new String[]{newGroupId},EXAM_TYPES[0],ExerciseExamReGroup.GROUP_TYPE_EXAM); |
| | | |
| | | |
| | | // 保存关联题库信息 |
| | | this.saveExerciseExamReGroup(exerciseInfoId,groupIds,null,ExerciseExamReGroup.GROUP_TYPE_SOURCE); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | // 保存关联班级 |
| | | this.saveExerciseExamReClass(exerciseInfoId, classIds); |
| | | |
| | | |
| | | return new Result(true, "", exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | //清除之前的练习关联关系数据 |
| | | private void doClearExerciseExamReData(String exerciseInfoId){ |
| | | this.bulkUpdate("update ExerciseExamReGroup set deleteFlag = 1 where examId = ?",new Object[]{exerciseInfoId}); |
| | | this.bulkUpdate("update ExerciseExamReClass set deleteFlag = 1 where examId = ?",new Object[] {exerciseInfoId}); |
| | | this.bulkUpdate("update ExerciseItemSet set deleteFlag = 1 where exerciseInfoId = ?",new Object[]{exerciseInfoId}); |
| | | } |
| | | |
| | | |
| | | private void saveExerciseExamReClass(String exerciseInfoId,String[] classIds){ |
| | | ExerciseExamReClass reClass = null; |
| | | for (String classId : classIds) { |
| | |
| | | reClass.setDeleteFlag(false); |
| | | reClass.setExamId(exerciseInfoId); |
| | | TraceUtils.setCreateTrace(reClass); |
| | | this.save(reClass); |
| | | this.save(reClass); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void saveExerciseExamReGroup(String exerciseInfoId, String [] groupIds,String examType,short reType){ |
| | | ExerciseExamReGroup reGroup = null; |
| | | for (String groupId : groupIds) { |
| | |
| | | reGroup.setExamId(exerciseInfoId); |
| | | TraceUtils.setCreateTrace(reGroup); |
| | | this.save(reGroup); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void saveExerciseItemSet(String exerciseInfoId,List<ExerciseItemSet> lstExerciseItemSet){ |
| | | for (ExerciseItemSet itemSet : lstExerciseItemSet) { |
| | | itemSet.setExerciseInfoId(exerciseInfoId); |
| | |
| | | |
| | | /** |
| | | * 删除作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | @Override |
| | | public String queryExerciseInfoRelatedGroupId(String exerciseInfoId) { |
| | | return this.findUnique("select groupId from ExerciseExamReGroup where examId=? and type=? and deleteFlag is false ", |
| | | CollectionUtils.newList(exerciseInfoId, ExerciseExamReGroup.GROUP_TYPE_EXAM),String.class); |
| | | return this.findUnique("select groupId from ExerciseExamReGroup where examId=? and type=? and deleteFlag is false ", |
| | | CollectionUtils.newList(exerciseInfoId, ExerciseExamReGroup.GROUP_TYPE_EXAM),String.class); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseItemSet> queryExerciseItemSet(String exerciseInfoId){ |
| | | return this.find("from ExerciseItemSet where exerciseInfoId=? and deleteFlag is false order by itemType ASC", |
| | | return this.find("from ExerciseItemSet where exerciseInfoId=? and deleteFlag is false order by itemType ASC", |
| | | CollectionUtils.newList(exerciseInfoId), ExerciseItemSet.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseResultV> queryStuExerciselist(String keyword,String exerciseInfoId,String userId,String subjectId,Short status,Integer pageSize,Integer pageNum) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseResultV where exerciseStatus=?"); |
| | | List<Object> params = CollectionUtils.newList(ExerciseInfo.EXERCISE_STATUS_PUBLISHED); |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(userId)){ |
| | | hql.append(" and userId=? "); |
| | | params.add(userId); |
| | | params.add(userId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(exerciseInfoId)){ |
| | | hql.append(" and id.exerciseInfoId=?"); |
| | | params.add(exerciseInfoId); |
| | | params.add(exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(keyword)){ |
| | | hql.append(" and studentName like ?"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and subjectId=?"); |
| | | params.add(subjectId); |
| | | } |
| | | |
| | | |
| | | //默认全部,0待完成,1已提交 ,2:已批阅,3需重写,4:逾期未交 |
| | | if(status!=null){ |
| | | Date nowTime = new Date(); |
| | |
| | | params.add(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | } |
| | | } |
| | | |
| | | |
| | | hql.append(" order by startTime desc"); |
| | | |
| | | |
| | | return this.findList(hql.toString(),new Pager(pageSize, pageNum),params, ExerciseResultV.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int queryStuExerciseListCount(String keyword,String exerciseInfoId,String userId,String subjectId,Short status) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseResultV where exerciseStatus=?"); |
| | | List<Object> params = CollectionUtils.newList(ExerciseInfo.EXERCISE_STATUS_PUBLISHED); |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(userId)){ |
| | | hql.append(" and userId=? "); |
| | | params.add(userId); |
| | | params.add(userId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(exerciseInfoId)){ |
| | | hql.append(" and id.exerciseInfoId=?"); |
| | | params.add(exerciseInfoId); |
| | | params.add(exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(keyword)){ |
| | | hql.append(" and studentName like ?"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and subjectId=?"); |
| | | params.add(subjectId); |
| | | } |
| | | |
| | | |
| | | //默认全部,0待完成,1已提交 ,2:已批阅,3需重写,4:逾期未交 |
| | | if(status!=null){ |
| | | Date nowTime = new Date(); |
| | |
| | | params.add(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | } |
| | | } |
| | | |
| | | return this.findCount(hql.toString(), params); |
| | | |
| | | return this.findCount(hql.toString(), params); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化平均成绩和最高成绩 |
| | | * |
| | | * |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 题目得分详情 |
| | | * |
| | | * |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开始题目作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | this.doStartAnswerExercise(exerciseInfo, clsClass, studentUserId) |
| | | : |
| | | this.doStartOtherExercise(exerciseInfo, clsClass, studentUserId); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 开始题目作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | // 查询学生考试总分 |
| | | result.addData("studentScore", record.getScore()); |
| | | result.addData("objStudentScore", record.getObjScore()==null?BigDecimal.ZERO:record.getObjScore()); |
| | | |
| | | |
| | | ExerciseCompleteInfo completeInfo = doGetOrCreateExerciseCompleteInfo(exerciseInfo.getExerciseInfoId(),clsClass.getClassId() , studentUserId); |
| | | |
| | | |
| | | if(completeInfo!=null){ |
| | | result.addData("exerciseCompleteId", completeInfo.getExerciseCompleteId()); |
| | | } |
| | | |
| | | |
| | | result.addData("itemSet", exerciseInfo.getExerciseItemSets()); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | private ExerciseCompleteInfo doGetOrCreateExerciseCompleteInfo(String exerciseInfoId,String classId,String studentUserId){ |
| | | // 判断是否已经初始化 |
| | | ExerciseCompleteInfo completeInfo = exerciseCompleteService.queryCompleteInfo(exerciseInfoId,classId , studentUserId); |
| | | |
| | | if(completeInfo==null){ |
| | | String hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName," |
| | | + " c.classId as classId,c.name as className from StuStudent s ,ClsClass c,ExerciseExamReClass r " |
| | | + " where r.examId=:exerciseInfoId and r.classId =c.classId and c.classId= s.classId and s.userId=:userId" |
| | | + " and s.classId=:classId and r.examId=:exerciseInfoId and r.deleteFlag is false and s.deleteFlag is false and c.deleteFlag is false"; |
| | | |
| | | List<Map<String, Object>> resultMap = this.findListWithMapByHql(hql, |
| | | // 判断是否已经初始化 |
| | | ExerciseCompleteInfo completeInfo = exerciseCompleteService.queryCompleteInfo(exerciseInfoId,classId , studentUserId); |
| | | |
| | | if(completeInfo==null){ |
| | | String hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName," |
| | | + " c.classId as classId,c.name as className from StuStudent s ,ClsClass c,ExerciseExamReClass r " |
| | | + " where r.examId=:exerciseInfoId and r.classId =c.classId and c.classId= s.classId and s.userId=:userId" |
| | | + " and s.classId=:classId and r.examId=:exerciseInfoId and r.deleteFlag is false and s.deleteFlag is false and c.deleteFlag is false"; |
| | | |
| | | List<Map<String, Object>> resultMap = this.findListWithMapByHql(hql, |
| | | CollectionUtils.newObjectMap("userId",studentUserId,"classId",classId,"exerciseInfoId",exerciseInfoId)); |
| | | |
| | | if(resultMap!=null && resultMap.get(0)!=null){ |
| | | Map<String, Object> map = resultMap.get(0); |
| | | |
| | | completeInfo = new ExerciseCompleteInfo(); |
| | | TraceUtils.setCreateTrace(completeInfo); |
| | | completeInfo.setStudentId((String) map.get("studentId")); |
| | | completeInfo.setStudentNo((String) map.get("studentNo")); |
| | | completeInfo.setStudentUserId((String) map.get("studentUserId")); |
| | | completeInfo.setStudentUserName((String) map.get("studentName")); |
| | | completeInfo.setClassId((String) map.get("classId")); |
| | | completeInfo.setClassName((String) map.get("className")); |
| | | completeInfo.setExerciseInfoId(exerciseInfoId); |
| | | completeInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | this.save(completeInfo); |
| | | } |
| | | |
| | | if(resultMap!=null && resultMap.get(0)!=null){ |
| | | Map<String, Object> map = resultMap.get(0); |
| | | |
| | | completeInfo = new ExerciseCompleteInfo(); |
| | | TraceUtils.setCreateTrace(completeInfo); |
| | | completeInfo.setStudentId((String) map.get("studentId")); |
| | | completeInfo.setStudentNo((String) map.get("studentNo")); |
| | | completeInfo.setStudentUserId((String) map.get("studentUserId")); |
| | | completeInfo.setStudentUserName((String) map.get("studentName")); |
| | | completeInfo.setClassId((String) map.get("classId")); |
| | | completeInfo.setClassName((String) map.get("className")); |
| | | completeInfo.setExerciseInfoId(exerciseInfoId); |
| | | completeInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | this.save(completeInfo); |
| | | } |
| | | |
| | | return completeInfo; |
| | | } |
| | | |
| | | return completeInfo; |
| | | } |
| | | |
| | | |
| | | private Map<String,Object> insertExerRecord(ExerciseInfo exerciseInfo,String groupId) { |
| | | ExerciseRecord record = new ExerciseRecord(); |
| | | record.setDeleteFlag(false); |
| | |
| | | record.setUserId(ClientUtils.getUserId()); |
| | | record.setOrgId(ClientUtils.getOrgId()); |
| | | TraceUtils.setCreateTrace(record); |
| | | |
| | | |
| | | //获取考试题目统计信息,并保存 |
| | | Map<String,Object> result = this.queryItemStatics(exerciseInfo.getExerciseItemSets()); |
| | | record.setTotalScore(new BigDecimal(exerciseInfo.getScore())); |
| | |
| | | record.setObjTotalScore((BigDecimal)result.get("objTotalScore")); |
| | | record.setSubItemCount((int)result.get("subItemCount")); |
| | | record.setObjItemCount((int)result.get("objItemCount")); |
| | | |
| | | |
| | | TraceUtils.setCreateTrace(record); |
| | | this.save(record); |
| | | |
| | | |
| | | Map<String,Object> resultMap = new HashMap<String, Object>(3); |
| | | resultMap.put("exerciseRecordId", record.getRecordId()); |
| | | resultMap.put("updateTime", DateTimeUtils.getCurrDateTime(record.getUpdateTime())); |
| | | resultMap.put("exerciseGroupId", groupId); |
| | | resultMap.put("record", record); |
| | | |
| | | |
| | | return resultMap; |
| | | } |
| | | |
| | | |
| | | private Map<String,Object> queryItemStatics(List<ExerciseItemSet> itemSets){ |
| | | float subTotalScore = 0,objTotalScore=0; |
| | | int subItemCount=0,objItemCount=0; |
| | | |
| | | |
| | | //如果是随机组卷 |
| | | if(itemSets!=null && itemSets.size()>0){ |
| | | for(ExerciseItemSet s:itemSets){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Map<String,Object> result = new HashMap<String,Object>(); |
| | | result.put("subTotalScore", new BigDecimal(subTotalScore)); |
| | | result.put("objTotalScore", new BigDecimal(objTotalScore)); |
| | | result.put("subItemCount", subItemCount); |
| | | result.put("objItemCount", objItemCount); |
| | | |
| | | |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 开始文件和写作作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | // 查询是否已经存在做题记录,如果不存在需要新建 |
| | | ExerciseCompleteInfo exerciseCompleteInfo = exerciseCompleteService.doCheckAndCreateExerciseCompleteInfo( |
| | | exerciseInfo.getExerciseInfoId(), clsClass.getClassId(), studentUserId); |
| | | |
| | | |
| | | exerciseCompleteInfo.setCommitUploadType(exerciseInfo.getCommitUploadType()); |
| | | exerciseCompleteInfo.setRemind(exerciseInfo.getRemind()); |
| | | exerciseCompleteInfo.setExerciseType(exerciseInfo.getType()); |
| | |
| | | exerciseCompleteInfo |
| | | .setPreviewPath(StringUtils.isNotEmpty(video.getAndroidHD()) ? video.getAndroidHD() |
| | | : StringUtils.isNotEmpty(video.getAndroidSD()) ? video.getAndroidSD() |
| | | : video.getAndroidLD()); |
| | | : video.getAndroidLD()); |
| | | } else { |
| | | exerciseCompleteInfo.setTransStatus(ExerciseCompleteInfo.PREVIEW_STATUS_NO); |
| | | } |
| | |
| | | .getOrgText(exerciseCompleteInfo.getExerciseCompleteId(), OrgText.TABLE_WRITING_EXERCISE) |
| | | .getContent()); |
| | | } |
| | | |
| | | |
| | | exerciseCompleteInfo.setTotalScore(exerciseInfo.getScore()); |
| | | |
| | | return new Result(true,"",CollectionUtils.newObjectMap("exerciseCompleteInfo", exerciseCompleteInfo)); |
| | |
| | | |
| | | @Override |
| | | public Result doSubmitOtherExerciseInfo(String exerciseCompleteInfoId, String content, String fileId, |
| | | String filePath, short submitType) { |
| | | String filePath, short submitType) { |
| | | Result result = new Result(true); |
| | | ExerciseCompleteInfo exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteInfoId); |
| | | ExerciseInfo exerciseInfo = this.read(ExerciseInfo.class, exerciseCompleteInfo.getExerciseInfoId()); |
| | | |
| | | |
| | | if (exerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_WRITING) { |
| | | result = this.doSubmitWritingExerciseInfo(exerciseCompleteInfoId, content, submitType); |
| | | } else if (exerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_FILE) { |
| | |
| | | |
| | | /** |
| | | * 提交写作作业 |
| | | * |
| | | * |
| | | * @param exerciseInfoId |
| | | * @param content |
| | | * @param submitType |
| | |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_COMMIT); |
| | | exerciseCompleteInfo.setCreator(ClientUtils.getUserName()); |
| | | } |
| | | |
| | | |
| | | this.save(exerciseCompleteInfo); |
| | | return new Result(true); |
| | | } |
| | | |
| | | /** |
| | | * 提交文件作业 |
| | | * |
| | | * |
| | | * @param exerciseCompleteInfoId |
| | | * @param content |
| | | * @param fileId |
| | |
| | | * @return |
| | | */ |
| | | private Result doSubmitFileExerciseInfo(String exerciseCompleteInfoId, String content, String fileId, |
| | | String filePath, short submitType) { |
| | | String filePath, short submitType) { |
| | | ExerciseCompleteInfo exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteInfoId); |
| | | ExerciseInfo exerciseInfo = this.read(ExerciseInfo.class, exerciseCompleteInfo.getExerciseInfoId()); |
| | | |
| | |
| | | ResFile resFile = this.read(ResFile.class, fileId); |
| | | exerciseCompleteInfo.setFileId(fileId); |
| | | exerciseCompleteInfo.setFilePath(filePath); |
| | | exerciseCompleteInfo.setOrgiFileName(resFile.getFileName()); |
| | | exerciseCompleteInfo.setOrgiFileName(ClientUtils.getUserName()+"的作业"); |
| | | } |
| | | |
| | | exerciseCompleteInfo.setUploadDesc(content); |
| | |
| | | |
| | | return new Result(false, "提交数据异常"); |
| | | } |
| | | |
| | | |
| | | ExerciseRecord record = this.read(ExerciseRecord.class, initRecordId); |
| | | |
| | | //计算得分 |
| | | double studentScore = this.doCalculateExerciseScores(answerData, exerciseInfo.getExerciseItemSets()); |
| | | |
| | | |
| | | // 提交试卷答案 |
| | | answerData.setScore(new BigDecimal(studentScore)); |
| | | Map<String, Object> resultMap = exerciseVerService.doOperExerciseAnswerData(answerData); |
| | |
| | | // 更新得分记录及状态 |
| | | exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteId); |
| | | resultMap.put("studentScore", studentScore); |
| | | |
| | | |
| | | |
| | | |
| | | // 更新完成得分 |
| | | if (ExerciseRecord.STATUS_SUBMIT.equals(answerData.getStatus())) { |
| | | resultMap.put("objScore", studentScore); |
| | | exerciseCompleteInfo.setSubmitTime(new Date()); |
| | | |
| | | |
| | | if(record.getSubItemCount()==0){ |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_CHECKED); |
| | | }else{ |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_COMMIT); |
| | | } |
| | | |
| | | |
| | | this.bulkUpdate( |
| | | "update ExerciseRecord set status=1 , score=" + studentScore + ",objScore=" + studentScore |
| | | + " where deleteFlag is false and recordId=?", |
| | |
| | | + " where deleteFlag is false and recordId=? ", |
| | | new Object[] { resultMap.get("recordId") }); |
| | | } |
| | | exerciseCompleteInfo.setStudentScore(new BigDecimal(studentScore)); |
| | | |
| | | exerciseCompleteInfo.setStudentScore(new BigDecimal(studentScore)); |
| | | |
| | | this.save(exerciseCompleteInfo); |
| | | |
| | | |
| | | // 记录提交的数据日志 |
| | | exerciseVerService.doSaveExerciseDataSubmitLog(JSON.toJSONString(answerData), initRecordId, |
| | | ExerciseDataSubmitLog.TYPE_SUBMIT_ANSWER, ExerciseDataSubmitLog.STATUS_SUCCESS, |
| | |
| | | private double doCalculateExerciseScores(ExerciseSubmitAnswerData answerData, List<ExerciseItemSet> lstItemSet) { |
| | | //获取填空题答案信息 |
| | | Map<String,String> exerciseFillItemMap= null; |
| | | List<Object[]> lstObj = this.find("select i.exerciseId,i.answer from ExerciseGroupItemRe r, ExerciseItem i where r.exerciseItemId=i.exerciseId and r.exerciseGroupId=? and r.deleteFlag is false and i.type=? and i.deleteFlag is false", |
| | | List<Object[]> lstObj = this.find("select i.exerciseId,i.answer from ExerciseGroupItemRe r, ExerciseItem i where r.exerciseItemId=i.exerciseId and r.exerciseGroupId=? and r.deleteFlag is false and i.type=? and i.deleteFlag is false", |
| | | CollectionUtils.newList(answerData.getExerciseGroupId(),ExerciseItem.TYPE_FILL_BLANKS), Object[].class); |
| | | if(lstObj!=null && lstObj.size()>0){ |
| | | exerciseFillItemMap = new HashMap<String,String>(lstObj.size()); |
| | | for(Object[] arrObj : lstObj){ |
| | | exerciseFillItemMap.put((String)arrObj[0],(String)arrObj[1]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Map<String, Double> scoreMap = new HashMap<String, Double>(); |
| | | for (int i = 0; i < lstItemSet.size(); i++) { |
| | | if (lstItemSet.get(i).getItemType() == ExerciseItem.TYPE_SINGLE_SELECT) { |
| | |
| | | scoreMap.put("fill_right", lstItemSet.get(i).getRightScore()); |
| | | scoreMap.put("fill_wrong", lstItemSet.get(i).getWrongScore()); |
| | | scoreMap.put("fill_noanswer", lstItemSet.get(i).getBlankScore()); |
| | | } |
| | | } |
| | | } |
| | | double totalScore = 0.00; |
| | | String tempRightAnswer =null; |
| | |
| | | |
| | | return totalScore; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result doPublishExercise(String[] exerciseIds) { |
| | | // 更新作业状态 |
| | |
| | | for (String exerciseId : exerciseIds) { |
| | | // 判断是否已经初始化,如果已经初始化则继续 -> TODO:需要处理新加入班级学生 |
| | | int count = this.findCount("from ExerciseCompleteInfo f where f.deleteFlag is false and f.exerciseInfoId=?",CollectionUtils.newList(exerciseId)); |
| | | |
| | | |
| | | if (count == 0) { |
| | | hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName,c.classId as classId,c.name as className " |
| | | + " from StuStudent s ,ClsClass c,ExerciseExamReClass r where r.examId=:exerciseInfoId " |
| | |
| | | this.saveOrUpdateAll(lstCompleteInfos); |
| | | } |
| | | } |
| | | |
| | | |
| | | //发布作业消息 |
| | | this.doExercisePublishMsg(exerciseId); |
| | | } |
| | | |
| | | |
| | | return new Result(true); |
| | | } |
| | | |
| | | |
| | | private void doExercisePublishMsg(String exerciseInfoId){ |
| | | ExerciseInfo exerciseInfo= this.read(ExerciseInfo.class, exerciseInfoId); |
| | | |
| | | List<String> lstUserIds = this.find("select userId from ExerciseResultV where id.exerciseInfoId=?", |
| | | CollectionUtils.newList(exerciseInfoId), String.class); |
| | | |
| | | |
| | | List<String> lstUserIds = this.find("select userId from ExerciseResultV where id.exerciseInfoId=?", |
| | | CollectionUtils.newList(exerciseInfoId), String.class); |
| | | |
| | | if(lstUserIds!=null && lstUserIds.size()>0){ |
| | | Map<String,String> attrs = CollectionUtils.newStringMap("exerciseInfoId",exerciseInfoId,"exerciseName",exerciseInfo.getName(), |
| | | "subjectId",exerciseInfo.getSubjectId(),"subjectName",exerciseInfo.getSubject().getName()); |
| | | |
| | | msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]), |
| | | MsgInfo.TYPE_EXERCISE," 发布了作业 ", attrs); |
| | | "subjectId",exerciseInfo.getSubjectId(),"subjectName",exerciseInfo.getSubject().getName()); |
| | | |
| | | msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]), |
| | | MsgInfo.TYPE_EXERCISE," 发布了作业 ", attrs); |
| | | } |
| | | } |
| | | |
| | |
| | | this.bulkUpdateInLoop("update ExerciseInfo set status=" + ExerciseInfo.EXERCISE_STATUS_DRAFT + " WHERE exerciseInfoId=?",exerciseIds); |
| | | // 清除作业完成情况 |
| | | this.bulkUpdateInLoop("update ExerciseCompleteInfo set deleteFlag= true WHERE exerciseInfoId=?", exerciseIds); |
| | | |
| | | |
| | | return new Result(true); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取完成的作业个数 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @param userId |
| | | * @return |
| | |
| | | CollectionUtils.newObjectMap("classId", classId, "status", ExerciseInfo.EXERCISE_STATUS_PUBLISHED)); |
| | | return exerciseCount; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询作业列表-教师端 |
| | | * |
| | | * |
| | | * @param pageSize |
| | | * @param keyword |
| | | * @param classId |
| | |
| | | public List<Map<String, Object>> teacherExerciseInfoList(Integer pageSize,String keyword,String classId,Integer pageNum) { |
| | | QHomeworkScoreV qHomeworkScoreV = QHomeworkScoreV.homeworkScoreV; |
| | | QExerciseInfo qExerciseInfo = QExerciseInfo.exerciseInfo; |
| | | |
| | | |
| | | Expression<Integer> cases = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.isNull()).then(1) |
| | | .otherwise(0).sum().as("homeworkNoSubmitCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.isNull()).then(1) |
| | | .otherwise(0).sum().as("homeworkNoSubmitCount"); |
| | | |
| | | Expression<Integer> cases2 = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_CHECKED))).then(1) |
| | | .otherwise(0).sum().as("homeworkToAuditCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_CHECKED))).then(1) |
| | | .otherwise(0).sum().as("homeworkToAuditCount"); |
| | | |
| | | Expression<Integer> cases3 = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_COMMIT))).then(1) |
| | | .otherwise(0).sum().as("homeworkHasAuditCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_COMMIT))).then(1) |
| | | .otherwise(0).sum().as("homeworkHasAuditCount"); |
| | | |
| | | return this.getQueryFactory().select(cases,cases2,cases3, qExerciseInfo.name.max(), |
| | | qExerciseInfo.startTime.max(), qExerciseInfo.endTime.max(), qExerciseInfo.type.max()).from(qHomeworkScoreV, qExerciseInfo) |
| | | .where(qHomeworkScoreV.classId.eq(classId) |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String,Integer> queryResultStatusCount(List<String> lstExerciseIds) { |
| | | if(lstExerciseIds== null || lstExerciseIds.size()==0){ |
| | | return null; |
| | | } |
| | | |
| | | |
| | | String hql = "select id.exerciseInfoId||'-'||completeStatus ,count(1) from ExerciseResultV " |
| | | + "where id.exerciseInfoId in(:exerciseIds) group by id.exerciseInfoId,completeStatus"; |
| | | |
| | | List<Object[]> lstResult = this.findByComplexHql(hql, |
| | | + "where id.exerciseInfoId in(:exerciseIds) group by id.exerciseInfoId,completeStatus"; |
| | | |
| | | List<Object[]> lstResult = this.findByComplexHql(hql, |
| | | CollectionUtils.newObjectMap("exerciseIds",lstExerciseIds.toArray(new String[lstExerciseIds.size()])), Object[].class); |
| | | |
| | | Map<String,Integer> resultMap = new HashMap<String,Integer>(lstResult.size()); |
| | | |
| | | |
| | | Map<String,Integer> resultMap = new HashMap<String,Integer>(lstResult.size()); |
| | | |
| | | for(Object[] o:lstResult){ |
| | | resultMap.put((String)o[0],((Long)o[1]).intValue()); |
| | | } |