|
@@ -146,82 +146,86 @@ public class PaperClassService {
|
146
|
146
|
, LinkedHashMap::new, Collectors.toList()));
|
147
|
147
|
List<Integer> studentids = groups.stream().map(m -> (Integer) m.get("studentid")).distinct().collect(Collectors.toList());
|
148
|
148
|
|
149
|
|
- List<Map> users = paperClassMapper.listUserByIds(studentids);
|
150
|
|
- Map<Integer, Map> userMap = users.stream().collect(Collectors.toMap(m -> (Integer) m.get("userid"), m -> m));
|
151
|
|
- if (papertype == 3) {//靶向作业
|
152
|
|
- List<QuestionVo> questions = paperClassMapper.listPaperQuestions(paperid);
|
153
|
|
- for (QuestionVo question : questions) {
|
154
|
|
- String qstemtxt = question.getQstemtxt();
|
155
|
|
- if(N_Utils.isNotEmpty(qstemtxt)){
|
156
|
|
- List<Map> sonqlist=JSON.parseArray(qstemtxt, Map.class);
|
157
|
|
- question.setSonqlist(sonqlist);
|
158
|
|
- }
|
159
|
|
- question.setQstemtxt(null);
|
160
|
|
- List<PointVo> points = JSON.parseArray(question.getSource(), PointVo.class);
|
161
|
|
- question.setPoints(points);
|
162
|
|
- question.setSource(null);
|
163
|
|
- }
|
164
|
|
- paper.put("questions", questions);
|
165
|
|
- List<String> questionids = questions.stream().map(QuestionVo::getQuestionid).collect(Collectors.toList());
|
166
|
|
- List<Map> stuQuestions = paperClassMapper.listStuQuestion(questionids, studentids);
|
167
|
|
- for (Integer studentid : studentids) {
|
168
|
|
- List<String> stuQuestionIds = new ArrayList<>();//学生未收到或未得满分的试题ids
|
169
|
|
- Double paperscore = 0.0;//试卷总分
|
|
149
|
+ List<Map> classes = new ArrayList<>();
|
|
150
|
+
|
|
151
|
+ if(N_Utils.isListNotEmpty(studentids)){
|
|
152
|
+ List<Map> users = paperClassMapper.listUserByIds(studentids);
|
|
153
|
+ Map<Integer, Map> userMap = users.stream().collect(Collectors.toMap(m -> (Integer) m.get("userid"), m -> m));
|
|
154
|
+ if (papertype == 3) {//靶向作业
|
|
155
|
+ List<QuestionVo> questions = paperClassMapper.listPaperQuestions(paperid);
|
170
|
156
|
for (QuestionVo question : questions) {
|
171
|
|
- String questionid = question.getQuestionid();
|
172
|
|
- boolean anyMatch = stuQuestions.stream().anyMatch(m -> m.get("studentid").equals(studentid)
|
173
|
|
- && m.get("questionid").equals(questionid));
|
174
|
|
- if (!anyMatch) {
|
175
|
|
- stuQuestionIds.add(questionid);
|
176
|
|
- paperscore = ArithUtil.add(paperscore, question.getScore());
|
|
157
|
+ String qstemtxt = question.getQstemtxt();
|
|
158
|
+ if(N_Utils.isNotEmpty(qstemtxt)){
|
|
159
|
+ List<Map> sonqlist=JSON.parseArray(qstemtxt, Map.class);
|
|
160
|
+ question.setSonqlist(sonqlist);
|
177
|
161
|
}
|
|
162
|
+ question.setQstemtxt(null);
|
|
163
|
+ List<PointVo> points = JSON.parseArray(question.getSource(), PointVo.class);
|
|
164
|
+ question.setPoints(points);
|
|
165
|
+ question.setSource(null);
|
178
|
166
|
}
|
179
|
|
- Map stuQue = userMap.get(studentid);
|
180
|
|
- stuQue.put("questionids", stuQuestionIds);
|
181
|
|
- stuQue.put("paperscore", paperscore);
|
182
|
|
- userMap.put(studentid, stuQue);
|
183
|
|
- }
|
184
|
|
- }
|
185
|
|
- List<Map> classes = new ArrayList<>();
|
186
|
|
- for (Map.Entry<Integer, List<Map>> entry : classList.entrySet()) {
|
187
|
|
- Integer classid = entry.getKey();
|
188
|
|
- List<Map> groupList = entry.getValue();
|
189
|
|
- Map gMap = groupList.get(0);
|
190
|
|
- Map c = new HashMap();
|
191
|
|
- c.put("classid", classid);
|
192
|
|
- c.put("gradeid", gMap.get("gradeid"));
|
193
|
|
- c.put("classname", gMap.get("classname"));
|
194
|
|
- LinkedHashMap<Integer, List<Map>> groupCollect = groupList.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("groupid")
|
195
|
|
- , LinkedHashMap::new, Collectors.toList()));
|
196
|
|
- List<Map> groups2 = new ArrayList<>();
|
197
|
|
- for (Map.Entry<Integer, List<Map>> gentry : groupCollect.entrySet()) {
|
198
|
|
- List<Map> studentList = gentry.getValue();
|
199
|
|
- Map sMap = studentList.get(0);
|
200
|
|
- Map g = new HashMap();
|
201
|
|
- g.put("groupid", gentry.getKey());
|
202
|
|
- g.put("groupname", sMap.get("groupname"));
|
203
|
|
- g.put("groupnum", sMap.get("groupnum"));
|
204
|
|
- g.put("grouptype", sMap.get("grouptype"));
|
205
|
|
- List<Map> students = new ArrayList<>();
|
206
|
|
- for (Map map : studentList) {
|
207
|
|
- Map s = new HashMap();
|
208
|
|
- Object studentid = map.get("studentid");
|
209
|
|
- s.put("studentid", studentid);
|
210
|
|
- Map stuMap = userMap.get(studentid);
|
211
|
|
- s.put("studentname", stuMap.get("username"));
|
212
|
|
- s.put("questionids", stuMap.get("questionids"));
|
213
|
|
- s.put("paperscore", stuMap.get("paperscore"));
|
214
|
|
- s.put("headpic", stuMap.get("headpic"));
|
215
|
|
- students.add(s);
|
|
167
|
+ paper.put("questions", questions);
|
|
168
|
+ List<String> questionids = questions.stream().map(QuestionVo::getQuestionid).collect(Collectors.toList());
|
|
169
|
+ List<Map> stuQuestions = paperClassMapper.listStuQuestion(questionids, studentids);
|
|
170
|
+ for (Integer studentid : studentids) {
|
|
171
|
+ List<String> stuQuestionIds = new ArrayList<>();//学生未收到或未得满分的试题ids
|
|
172
|
+ Double paperscore = 0.0;//试卷总分
|
|
173
|
+ for (QuestionVo question : questions) {
|
|
174
|
+ String questionid = question.getQuestionid();
|
|
175
|
+ boolean anyMatch = stuQuestions.stream().anyMatch(m -> m.get("studentid").equals(studentid)
|
|
176
|
+ && m.get("questionid").equals(questionid));
|
|
177
|
+ if (!anyMatch) {
|
|
178
|
+ stuQuestionIds.add(questionid);
|
|
179
|
+ paperscore = ArithUtil.add(paperscore, question.getScore());
|
|
180
|
+ }
|
|
181
|
+ }
|
|
182
|
+ Map stuQue = userMap.get(studentid);
|
|
183
|
+ stuQue.put("questionids", stuQuestionIds);
|
|
184
|
+ stuQue.put("paperscore", paperscore);
|
|
185
|
+ userMap.put(studentid, stuQue);
|
216
|
186
|
}
|
|
187
|
+ }
|
217
|
188
|
|
218
|
|
- students = students.stream().sorted(Comparator.comparing(m -> m.get("studentname").toString()))
|
219
|
|
- .collect(Collectors.toList());
|
220
|
|
- g.put("students", students);
|
221
|
|
- groups2.add(g);
|
|
189
|
+ for (Map.Entry<Integer, List<Map>> entry : classList.entrySet()) {
|
|
190
|
+ Integer classid = entry.getKey();
|
|
191
|
+ List<Map> groupList = entry.getValue();
|
|
192
|
+ Map gMap = groupList.get(0);
|
|
193
|
+ Map c = new HashMap();
|
|
194
|
+ c.put("classid", classid);
|
|
195
|
+ c.put("gradeid", gMap.get("gradeid"));
|
|
196
|
+ c.put("classname", gMap.get("classname"));
|
|
197
|
+ LinkedHashMap<Integer, List<Map>> groupCollect = groupList.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("groupid")
|
|
198
|
+ , LinkedHashMap::new, Collectors.toList()));
|
|
199
|
+ List<Map> groups2 = new ArrayList<>();
|
|
200
|
+ for (Map.Entry<Integer, List<Map>> gentry : groupCollect.entrySet()) {
|
|
201
|
+ List<Map> studentList = gentry.getValue();
|
|
202
|
+ Map sMap = studentList.get(0);
|
|
203
|
+ Map g = new HashMap();
|
|
204
|
+ g.put("groupid", gentry.getKey());
|
|
205
|
+ g.put("groupname", sMap.get("groupname"));
|
|
206
|
+ g.put("groupnum", sMap.get("groupnum"));
|
|
207
|
+ g.put("grouptype", sMap.get("grouptype"));
|
|
208
|
+ List<Map> students = new ArrayList<>();
|
|
209
|
+ for (Map map : studentList) {
|
|
210
|
+ Map s = new HashMap();
|
|
211
|
+ Object studentid = map.get("studentid");
|
|
212
|
+ s.put("studentid", studentid);
|
|
213
|
+ Map stuMap = userMap.get(studentid);
|
|
214
|
+ s.put("studentname", stuMap.get("username"));
|
|
215
|
+ s.put("questionids", stuMap.get("questionids"));
|
|
216
|
+ s.put("paperscore", stuMap.get("paperscore"));
|
|
217
|
+ s.put("headpic", stuMap.get("headpic"));
|
|
218
|
+ students.add(s);
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+ students = students.stream().sorted(Comparator.comparing(m -> m.get("studentname").toString()))
|
|
222
|
+ .collect(Collectors.toList());
|
|
223
|
+ g.put("students", students);
|
|
224
|
+ groups2.add(g);
|
|
225
|
+ }
|
|
226
|
+ c.put("groups", groups2);
|
|
227
|
+ classes.add(c);
|
222
|
228
|
}
|
223
|
|
- c.put("groups", groups2);
|
224
|
|
- classes.add(c);
|
225
|
229
|
}
|
226
|
230
|
|
227
|
231
|
paper.put("classes", classes);
|