|
@@ -91,23 +91,64 @@ public class IssueService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分别加载各个模块的试题,并返回符合前端展示的格式
|
|
|
+ * @param paper 试题
|
|
|
+ * @return 题目列表
|
|
|
+ */
|
|
|
public List<Issue> listAll(IssuePaper paper) {
|
|
|
Long subjectId = paper.getSubjectId();
|
|
|
List<Long> chapterIds = Arrays.stream(paper.getChapterIds().split(",")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
List<Issue> list1 = listWithOption(subjectId, chapterIds);
|
|
|
+ list1.sort(Comparator.comparingLong(Issue::getId));
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ Issue issue = list1.get(i);
|
|
|
+ issue.setNumber(i + 1);
|
|
|
+ }
|
|
|
|
|
|
List<Issue> list2 = listWithOption(subjectId, paper.getGrade(), 2);
|
|
|
+ list2.sort(Comparator.comparingLong(Issue::getNumber));
|
|
|
|
|
|
List<Issue> list3 = listWithLite(subjectId, paper.getGrade(), 3);
|
|
|
+ list3.sort(Comparator.comparingLong(Issue::getNumber));
|
|
|
+ list3 = convertIssue(list3);
|
|
|
|
|
|
List<Issue> result = new ArrayList<>();
|
|
|
result.addAll(list1);
|
|
|
result.addAll(list2);
|
|
|
result.addAll(list3);
|
|
|
+// result.forEach(it -> {
|
|
|
+// it.setAnswer(null);
|
|
|
+// it.setCorrectNum(null);
|
|
|
+// });
|
|
|
return result;
|
|
|
// return issueDao.findBySubjectIdAndGrade(subjectId, grade);
|
|
|
}
|
|
|
|
|
|
+ private List<Issue> convertIssue(List<Issue> list) {
|
|
|
+ List<Issue> result = new ArrayList<>();
|
|
|
+ for (Issue issue : list) {
|
|
|
+ List<IssueLite> lites = issue.getLites();
|
|
|
+ List<Issue> issues = lites.stream().map(it -> convertIssue(it, issue)).collect(Collectors.toList());
|
|
|
+ result.addAll(issues);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Issue convertIssue(IssueLite lite, Issue old) {
|
|
|
+ Issue issue = new Issue();
|
|
|
+ issue.setMaterial(old.getContent());
|
|
|
+ issue.setContent(lite.getContent());
|
|
|
+ issue.setAnswer(lite.getAnswer());
|
|
|
+ issue.setOptions(lite.getOptions());
|
|
|
+ issue.setCorrectNum(lite.getCorrectNum());
|
|
|
+ issue.setNumber(lite.getNumber());
|
|
|
+ issue.setGrade(old.getGrade());
|
|
|
+ issue.setSection(old.getSection());
|
|
|
+ issue.setSubjectId(old.getSubjectId());
|
|
|
+ return issue;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取模块一题目列表
|
|
|
*
|
|
@@ -159,7 +200,7 @@ public class IssueService {
|
|
|
Map<Long, List<IssueLite>> group = lites.stream().collect(Collectors.groupingBy(IssueLite::getIssueId));
|
|
|
for (Issue issue : list) {
|
|
|
List<IssueLite> liteGroup = group.getOrDefault(issue.getId(), new ArrayList<>());
|
|
|
- liteGroup.forEach(it -> it.setNumber((it.getNumber() - 1) % liteGroup.size() + 1));
|
|
|
+// liteGroup.forEach(it -> it.setNumber((it.getNumber() - 1) % liteGroup.size() + 1));
|
|
|
issue.setLites(liteGroup);
|
|
|
}
|
|
|
return list;
|