|
@@ -131,7 +131,7 @@ public class QuestionController {
|
|
|
@RequestParam(required = false) Integer[] structIds,
|
|
|
@RequestParam(required = false) String place,
|
|
|
@RequestParam(required = false) String difficult,
|
|
|
- @RequestParam(required = false, defaultValue = "id") String order, // collect_number, correct, time, relation_score
|
|
|
+ @RequestParam(required = false) String order, // collect_number, correct, time, relation_score
|
|
|
// @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
@@ -249,14 +249,34 @@ public class QuestionController {
|
|
|
List<UserExerciseGroupDto> p = new ArrayList<>(three.size());
|
|
|
for(ExerciseStruct struct : three){
|
|
|
UserExerciseGroupDto dto = Transform.convert(struct, UserExerciseGroupDto.class);
|
|
|
+
|
|
|
+ // 获取第四层节点
|
|
|
+ List<ExerciseStruct> children = exerciseStructService.children(struct.getId(), 0);
|
|
|
+ List<ExercisePaper> paperList = exercisePaperService.listByLogic(struct.getId(), null, ExerciseLogic.NO, null);
|
|
|
+ Collection paperIds = Transform.getIds(paperList, ExercisePaper.class, "id");
|
|
|
+
|
|
|
// 获取第三层所有题目,并获取题目统计
|
|
|
- List<QuestionNo> list = questionNoService.listByStruct(StructModule.EXERCISE, struct.getId());
|
|
|
+ Collection questionNoIds = new ArrayList();
|
|
|
+ for (ExercisePaper paper : paperList){
|
|
|
+ Collections.addAll(questionNoIds, paper.getQuestionNoIds());
|
|
|
+ }
|
|
|
+ List<QuestionNo> list = questionNoService.select(questionNoIds);
|
|
|
+// if (children == null || children.size() == 0) {
|
|
|
+// list = questionNoService.listByStruct(StructModule.EXERCISE, struct.getId());
|
|
|
+// }else{
|
|
|
+// Integer[] childrenIds = new Integer[children.size()];
|
|
|
+// int index = 0;
|
|
|
+// for(ExerciseStruct childrenStruct : children){
|
|
|
+// childrenIds[index] = childrenStruct.getId();
|
|
|
+// index++;
|
|
|
+// }
|
|
|
+// list = questionNoService.listByStruct(StructModule.EXERCISE, childrenIds);
|
|
|
+// }
|
|
|
dto.setStat(questionNoService.statPaper(list));
|
|
|
dto.setQuestionNumber(list.size());
|
|
|
Map<Object, UserQuestionStat> userQuestionStatMap = null;
|
|
|
if(user != null){
|
|
|
- Collection questionNoIds = Transform.getIds(list, QuestionNo.class, "id");
|
|
|
- List<UserQuestion> userQuestionList = userQuestionService.listByQuestionNo(user.getId(), questionNoIds);
|
|
|
+ List<UserQuestion> userQuestionList = userQuestionService.listByPaper(user.getId(), PaperOrigin.EXERCISE, paperIds);
|
|
|
userQuestionStatMap = userQuestionService.statQuestionNoMap(userQuestionList);
|
|
|
|
|
|
dto.setUserStat(userQuestionService.statQuestion(userQuestionList));
|
|
@@ -280,11 +300,8 @@ public class QuestionController {
|
|
|
}
|
|
|
|
|
|
// 作文、阅读没有第4层
|
|
|
- // 获取第四层节点
|
|
|
- List<ExerciseStruct> children = exerciseStructService.children(struct.getId(), 0);
|
|
|
if (children == null || children.size() == 0){
|
|
|
// 以下属的paper作为children
|
|
|
- List<ExercisePaper> paperList = exercisePaperService.listByLogic(struct.getId(), 0, ExerciseLogic.NO, null);
|
|
|
List<UserExerciseGroupExtendDto> childrenDtos = new ArrayList<>(paperList.size());
|
|
|
|
|
|
Integer start = 0;
|
|
@@ -314,7 +331,7 @@ public class QuestionController {
|
|
|
if (!flag) minTimes = 0;
|
|
|
for(int questionNoId : child.getQuestionNoIds()){
|
|
|
UserQuestionStat stat = userQuestionStatMap.get(questionNoId);
|
|
|
- if (stat != null && stat.getUserNumber() > minTimes) userQuestionNumber += 1;
|
|
|
+ if (stat != null && stat.getUserNumber() >= minTimes) userQuestionNumber += 1;
|
|
|
}
|
|
|
extendDto.setUserNumber(userQuestionNumber);
|
|
|
extendDto.setMinTimes(minTimes);
|
|
@@ -324,15 +341,14 @@ public class QuestionController {
|
|
|
}
|
|
|
|
|
|
if (user != null){
|
|
|
- Collection ids = Transform.getIds(paperList, ExercisePaper.class, "id");
|
|
|
- List<UserPaper> userPaperList = userPaperService.listWithOrigin(user.getId(), PaperOrigin.EXERCISE, ids, null);
|
|
|
+ List<UserPaper> userPaperList = userPaperService.listWithOrigin(user.getId(), PaperOrigin.EXERCISE, paperIds, null);
|
|
|
// 绑定userPaperId,用于关联report
|
|
|
Map userPaperMap = Transform.getMap(userPaperList, UserPaper.class, "originId", "id");
|
|
|
Transform.combine(childrenDtos, userPaperMap, UserExerciseGroupExtendDto.class, "id", "userPaperId");
|
|
|
|
|
|
// 获取最后一次作业结果
|
|
|
- Collection paperIds = Transform.getIds(userPaperList, UserPaper.class, "id");
|
|
|
- List<UserReport> reportList = userReportService.listWithLast(paperIds);
|
|
|
+ Collection userPaperIds = Transform.getIds(userPaperList, UserPaper.class, "id");
|
|
|
+ List<UserReport> reportList = userReportService.listWithLast(userPaperIds);
|
|
|
Transform.combine(childrenDtos, reportList, UserExerciseGroupExtendDto.class, "userPaperId", "report", UserReport.class, "paperId", UserReportExtendDto.class);
|
|
|
}
|
|
|
dto.setChildren(childrenDtos);
|