| | |
| | | Integer totalStudy = studyRecord.getTotalStudy(); |
| | | studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); |
| | | studyRecord = studyService.studySchedule(studyRecord, week); |
| | | // 数据库保存的是已完成的学习进度,返回前端时需要转换为剩余学习进度 |
| | | Integer look = studyRecord.getLook(); |
| | | if (look != 100 && look != -1) { |
| | | studyRecord.setLook(100 - look); |
| | | } |
| | | Integer pair = studyRecord.getPair(); |
| | | if (pair != 100 && pair != -1) { |
| | | studyRecord.setPair(100 - pair); |
| | | } |
| | | Integer answer = studyRecord.getAnswer(); |
| | | if (answer != 100 && answer != -1) { |
| | | studyRecord.setAnswer(100 - answer); |
| | | } |
| | | Integer induction = studyRecord.getInduction(); |
| | | if (induction != 100 && induction != -1) { |
| | | studyRecord.setInduction(100 - induction); |
| | | } |
| | | Integer listen = studyRecord.getListen(); |
| | | if (listen != 100 && listen != -1) { |
| | | studyRecord.setListen(100 - listen); |
| | | } |
| | | } |
| | | return R.ok(studyRecord); |
| | | } |
| | |
| | | // 返回结果 |
| | | SubjectRecordResultVO result; |
| | | if (null != subjectRecord) { |
| | | subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 1) |
| | | .eq(TSubjectRecord::getId, subjectRecord.getId()).update(); |
| | | // 题组id |
| | | /*// 题组id |
| | | List<Integer> teamIds = Arrays.stream(subjectRecord.getBeforeSubject().split(",")).map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | // 题目id |
| | | List<Integer> topicIds = Arrays.stream(subjectRecord.getCompleteSubject().split(",")).map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | result = new SubjectRecordResultVO(teamIds, topicIds, subjectRecord.getAnswerNumber(), subjectRecord.getCorrectNumber()); |
| | | .collect(Collectors.toList());*/ |
| | | result = new SubjectRecordResultVO(null, null, subjectRecord.getAnswerNumber(), subjectRecord.getCorrectNumber(), subjectRecord.getSchedule()); |
| | | } else { |
| | | result = null; |
| | | } |
| | |
| | | if (null == loginStudy) { |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | // 退出学习如果已经存在中途学习记录,则删除记录,保存新学习记录 |
| | | Integer userid = loginStudy.getUserid(); |
| | | TSubjectRecord subjectRecord = subjectRecordService.lambdaQuery() |
| | | .eq(TSubjectRecord::getUserId, userid) |
| | | .eq(TSubjectRecord::getWeek, exitLearn.getWeek()) |
| | | .eq(TSubjectRecord::getDay, exitLearn.getDay()) |
| | | .eq(TSubjectRecord::getType, exitLearn.getType()) |
| | | .eq(TSubjectRecord::getDisabled, 0) |
| | | .one(); |
| | | if (null != subjectRecord) { |
| | | subjectRecordService.removeById(subjectRecord); |
| | | } |
| | | // 判断当前week和day是否已完成学习 |
| | | TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | |
| | | Integer quarter = exitLearn.getQuarter(); |
| | | Integer week = exitLearn.getWeek(); |
| | | Integer day = exitLearn.getDay(); |
| | | int schedule = exitLearn.getSchedule() == null ? 0 : exitLearn.getSchedule(); |
| | | int schedule = exitLearn.getSchedule() - 1; |
| | | if (userStudy.getWeek().equals(exitLearn.getWeek()) && userStudy.getDay().equals(exitLearn.getDay())) { |
| | | // 计算完成率 |
| | | Integer type = exitLearn.getType(); |
| | | // 更新用户学习完成率 |
| | | if (Constants.ONE.equals(type)) { |
| | | if (1 == exitLearn.getSchedule()) { |
| | | userStudy.setListen(Constants.BURDEN_ONE); |
| | | } else { |
| | | // 听音选图 |
| | | List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day); |
| | | int item = 0; |
| | |
| | | if (i > userStudy.getListen()) { |
| | | userStudy.setListen(i); |
| | | } |
| | | } |
| | | } else if (Constants.TWO.equals(type)) { |
| | | if (1 == exitLearn.getSchedule()) { |
| | | userStudy.setLook(Constants.BURDEN_ONE); |
| | | } else { |
| | | // 看图选音 |
| | | List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day); |
| | | int item = 0; |
| | | for (TStudyLook studyLook : lookList) { |
| | | item += studyLook.getSubject().split(",").length; |
| | | } |
| | | if (!lookList.isEmpty()) { |
| | | int item = lookList.size(); |
| | | int i = (int) (((double) schedule / item) * 100); |
| | | if (i > userStudy.getLook()) { |
| | | userStudy.setLook(i); |
| | | } |
| | | } |
| | | } |
| | | } else if (Constants.THREE.equals(type)) { |
| | | if (1 == exitLearn.getSchedule()) { |
| | | userStudy.setInduction(Constants.BURDEN_ONE); |
| | | } else { |
| | | // 归纳排除 |
| | | List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); |
| | | if (!inductionList.isEmpty()) { |
| | |
| | | userStudy.setInduction(i); |
| | | } |
| | | } |
| | | } |
| | | } else if (Constants.FOUR.equals(type)) { |
| | | if (1 == exitLearn.getSchedule()) { |
| | | userStudy.setAnswer(Constants.BURDEN_ONE); |
| | | } else { |
| | | // 有问有答 |
| | | List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); |
| | | if (answerList.size() % Constants.TWO == Constants.ZERO) { |
| | |
| | | userStudy.setAnswer(i); |
| | | } |
| | | } |
| | | } |
| | | } else if (Constants.FIVE.equals(type)) { |
| | | if (1 == exitLearn.getSchedule()) { |
| | | userStudy.setPair(Constants.BURDEN_ONE); |
| | | } else { |
| | | // 音图相配 |
| | | List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); |
| | | if (!pairList.isEmpty()) { |
| | | int item = pairList.size(); |
| | | int i = (int) (((double) schedule / item) * 100); |
| | | if (i > userStudy.getPair()) { |
| | | userStudy.setPair(i); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // 学习时长更新 |
| | |
| | | // 登录用户id |
| | | Integer userId = userStudy.getUserid(); |
| | | // 判断是否已完成该题组 |
| | | boolean update = true; |
| | | boolean update; |
| | | // 清除中途退出记录 |
| | | TSubjectRecord subjectRecord = subjectRecordService.lambdaQuery() |
| | | .eq(TSubjectRecord::getUserId, userId) |
| | | .eq(TSubjectRecord::getWeek, completeStudy.getWeek()) |
| | | .eq(TSubjectRecord::getDay, completeStudy.getDay()) |
| | | .eq(TSubjectRecord::getType, completeStudy.getType()) |
| | | .eq(TSubjectRecord::getDisabled, 0) |
| | | .one(); |
| | | if (null != subjectRecord) { |
| | | subjectRecordService.removeById(subjectRecord); |
| | | } |
| | | List<String> studyIds = Arrays.stream(completeStudy.getStudyIds().split(",")) |
| | | .collect(Collectors.toList()); |
| | | Integer type = completeStudy.getType(); |
| | |
| | | } else { |
| | | throw new GlobalException("该次游戏积分计算异常!"); |
| | | } |
| | | Integer accuracy = completeStudy.getAccuracy(); |
| | | if (accuracy >= 100) { |
| | | accuracy = 100; |
| | | } |
| | | int gameAvailableIntegral = (int) (integral * ((double) completeStudy.getAccuracy() / 100)); |
| | | Integer availableIntegral = gameService.countIntegral(userid, game, completeStudy, gameAvailableIntegral, integralRecordList); |
| | | // 游戏测试记录 |
| | |
| | | if (null == accuracy) { |
| | | throw new GlobalException("自主故事-看图配音正确率异常!"); |
| | | } |
| | | if (accuracy >= 100) { |
| | | accuracy = 100; |
| | | } |
| | | // 看图配音模式,也需要根据游戏正确率计算积分 |
| | | double d = (double) accuracy / 100; |
| | | int integral = (int) (storyListen.getLookIntegral() * d); |