1 | |
package org.kuali.student.enrollment.class2.grading.service.impl; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.kuali.rice.krad.util.GlobalVariables; |
5 | |
import org.kuali.student.common.util.UUIDHelper; |
6 | |
import org.kuali.student.enrollment.class2.grading.assembler.GradeValuesGroupAssembler; |
7 | |
import org.kuali.student.enrollment.class2.grading.service.assembler.GradeRosterAssembler; |
8 | |
import org.kuali.student.enrollment.class2.grading.service.assembler.GradeRosterEntryAssembler; |
9 | |
import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo; |
10 | |
import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService; |
11 | |
import org.kuali.student.enrollment.courseregistration.service.CourseRegistrationService; |
12 | |
import org.kuali.student.enrollment.grading.dto.GradeRosterEntryInfo; |
13 | |
import org.kuali.student.enrollment.grading.dto.GradeRosterInfo; |
14 | |
import org.kuali.student.enrollment.grading.dto.GradeValuesGroupInfo; |
15 | |
import org.kuali.student.enrollment.grading.service.GradingService; |
16 | |
import org.kuali.student.enrollment.lpr.dto.LprInfo; |
17 | |
import org.kuali.student.enrollment.lpr.service.LprService; |
18 | |
import org.kuali.student.enrollment.lrr.dto.LearningResultRecordInfo; |
19 | |
import org.kuali.student.enrollment.lrr.service.LearningResultRecordService; |
20 | |
import org.kuali.student.enrollment.lui.service.LuiService; |
21 | |
import org.kuali.student.r2.common.assembler.AssemblyException; |
22 | |
import org.kuali.student.r2.common.dto.*; |
23 | |
import org.kuali.student.r2.common.exceptions.*; |
24 | |
import org.kuali.student.r2.common.util.constants.LprServiceConstants; |
25 | |
import org.kuali.student.r2.common.util.constants.LrcServiceConstants; |
26 | |
import org.kuali.student.r2.common.util.constants.LrrServiceConstants; |
27 | |
import org.kuali.student.r2.common.util.constants.LuiServiceConstants; |
28 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo; |
29 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo; |
30 | |
import org.kuali.student.r2.lum.lrc.service.LRCService; |
31 | |
|
32 | |
import javax.jws.WebParam; |
33 | |
import java.util.*; |
34 | |
import org.kuali.student.enrollment.roster.dto.LprRosterEntryInfo; |
35 | |
import org.kuali.student.enrollment.roster.dto.LprRosterInfo; |
36 | |
import org.kuali.student.enrollment.roster.service.LprRosterService; |
37 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
38 | |
|
39 | 0 | public class GradingServiceImpl implements GradingService { |
40 | |
private LprService lprService; |
41 | |
private LprRosterService lprRosterService; |
42 | |
private CourseOfferingService courseOfferingService; |
43 | |
private LRCService lrcService; |
44 | |
private LearningResultRecordService lrrService; |
45 | |
private LuiService luiService; |
46 | |
private GradeRosterAssembler gradeRosterAssembler; |
47 | |
private GradeRosterEntryAssembler gradeRosterEntryAssembler; |
48 | |
private GradeValuesGroupAssembler gradeValuesGroupAssembler; |
49 | |
private CourseRegistrationService courseRegistrationService; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
@Override |
70 | |
public TypeInfo getGradeRosterType(@WebParam(name = "gradeRosterTypeKey") String gradeRosterTypeKey, |
71 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
72 | |
MissingParameterException, OperationFailedException { |
73 | 0 | return null; |
74 | |
} |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
@Override |
92 | |
public GradeRosterInfo getGradeRoster(@WebParam(name = "gradeRosterId") String gradeRosterId, |
93 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
94 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
95 | 0 | return null; |
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
@Override |
115 | |
public List<GradeRosterInfo> getGradeRostersByGraderAndTerm(@WebParam(name = "graderId") String graderId, |
116 | |
@WebParam(name = "termId") String termId, @WebParam(name = "context") ContextInfo context) |
117 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
118 | |
OperationFailedException, PermissionDeniedException { |
119 | 0 | return null; |
120 | |
} |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
@Override |
138 | |
public List<GradeRosterInfo> getFinalGradeRostersForCourseOffering( |
139 | |
@WebParam(name = "courseOfferingId") String courseOfferingId, |
140 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
141 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
142 | 0 | List<GradeRosterInfo> gradeRosterInfos = new ArrayList<GradeRosterInfo>(); |
143 | |
|
144 | 0 | List<LprRosterInfo> lprRosters = lprRosterService.getLprRostersByTypeAndLui(LprServiceConstants.LPRROSTER_COURSE_FINAL_GRADEROSTER_TYPE_KEY, courseOfferingId, context); |
145 | 0 | for (LprRosterInfo lprRoster : lprRosters) { |
146 | 0 | GradeRosterInfo gradeRosterInfo = assembleGradeRoster(lprRoster, context); |
147 | 0 | gradeRosterInfos.add(gradeRosterInfo); |
148 | 0 | } |
149 | |
|
150 | 0 | return gradeRosterInfos; |
151 | |
} |
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
@Override |
169 | |
public List<GradeRosterInfo> getFinalGradeRostersForActivityOffering( |
170 | |
@WebParam(name = "activityOfferingId") String activityOfferingId, |
171 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
172 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
173 | 0 | return null; |
174 | |
} |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
@Override |
192 | |
public List<GradeRosterInfo> getGradeRostersForActivityOffering( |
193 | |
@WebParam(name = "activityOfferingId") String activityOfferingId, |
194 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
195 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
196 | 0 | return null; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
@Override |
218 | |
public GradeRosterInfo buildInterimGradeRosterByType( |
219 | |
@WebParam(name = "courseOfferingId") String courseOfferingId, |
220 | |
@WebParam(name = "activityOfferingIds") List<String> activityOfferingIds, |
221 | |
@WebParam(name = "rosterTypeKey") String rosterTypeKey, @WebParam(name = "context") ContextInfo context) |
222 | |
throws AlreadyExistsException, InvalidParameterException, MissingParameterException, |
223 | |
OperationFailedException, PermissionDeniedException { |
224 | 0 | return null; |
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
@Override |
246 | |
public GradeRosterInfo updateInterimGradeRoster(@WebParam(name = "gradeRoster") GradeRosterInfo gradeRoster, |
247 | |
@WebParam(name = "context") ContextInfo context) throws DataValidationErrorException, |
248 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
249 | |
PermissionDeniedException, VersionMismatchException { |
250 | 0 | return null; |
251 | |
} |
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
@Override |
269 | |
public StatusInfo deleteInterimGradeRoster(@WebParam(name = "gradeRosterId") String gradeRosterId, |
270 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
271 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
272 | 0 | return null; |
273 | |
} |
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
@Override |
297 | |
public GradeRosterInfo updateFinalGradeRosterState(@WebParam(name = "gradeRosterId") String gradeRosterId, |
298 | |
@WebParam(name = "newStateKey") String stateKey, @WebParam(name = "context") ContextInfo context) |
299 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
300 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
301 | |
|
302 | 0 | LprRosterInfo lprRosterInfo = lprRosterService.getLprRoster(gradeRosterId,context); |
303 | 0 | lprRosterInfo.setStateKey(stateKey); |
304 | |
|
305 | |
GradeRosterInfo returnRoster; |
306 | |
try { |
307 | 0 | LprRosterInfo newRoster = lprRosterService.updateLprRoster(gradeRosterId,lprRosterInfo,context); |
308 | 0 | returnRoster = assembleGradeRoster(newRoster,context); |
309 | 0 | } catch (ReadOnlyException e) { |
310 | 0 | throw new RuntimeException(e); |
311 | 0 | } |
312 | |
|
313 | |
|
314 | 0 | List<LprRosterEntryInfo> rosterEntryInfoList = lprRosterService.getLprRosterEntriesByLprRoster(lprRosterInfo.getId(),context); |
315 | 0 | List<String> lprIds = new ArrayList(); |
316 | 0 | for (LprRosterEntryInfo entryInfo : rosterEntryInfoList) { |
317 | 0 | lprIds.add(entryInfo.getLprId()); |
318 | |
} |
319 | |
|
320 | 0 | List<LearningResultRecordInfo> learningResultRecordInfoList = lrrService.getLearningResultRecordsForLprIds(lprIds,context); |
321 | 0 | for (LearningResultRecordInfo learningResultRecordInfo : learningResultRecordInfoList) { |
322 | |
|
323 | 0 | if (StringUtils.equals(learningResultRecordInfo.getStateKey(),LrrServiceConstants.RESULT_RECORD_SAVED_STATE_KEY)){ |
324 | 0 | learningResultRecordInfo.setStateKey(LrrServiceConstants.RESULT_RECORD_SUBMITTED_STATE_KEY); |
325 | 0 | lrrService.updateLearningResultRecord(learningResultRecordInfo.getId(),learningResultRecordInfo,context); |
326 | |
} |
327 | |
} |
328 | |
|
329 | 0 | return returnRoster; |
330 | |
} |
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
@Override |
346 | |
public List<ValidationResultInfo> validateGradeRoster(@WebParam(name = "gradeRoster") GradeRosterInfo gradeRoster, |
347 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
348 | |
MissingParameterException, OperationFailedException { |
349 | 0 | return null; |
350 | |
} |
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
@Override |
368 | |
public GradeRosterEntryInfo getGradeRosterEntry(@WebParam(name = "gradeRosterEntryId") String gradeRosterEntryId, |
369 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
370 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
371 | 0 | return null; |
372 | |
} |
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
@Override |
391 | |
public List<GradeRosterEntryInfo> getGradeRosterEntriesByIds( |
392 | |
@WebParam(name = "gradeRosterEntryIds") List<String> gradeRosterEntryIds, |
393 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
394 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
395 | |
|
396 | |
|
397 | 0 | List<LprRosterEntryInfo> entries = lprRosterService.getLprRosterEntriesByIds(gradeRosterEntryIds, context); |
398 | 0 | return assembleGradeRosterEntries(entries, context); |
399 | |
} |
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
@Override |
417 | |
public List<GradeRosterEntryInfo> getGradeRosterEntriesByRosterId( |
418 | |
@WebParam(name = "gradeRosterId") String gradeRosterId, @WebParam(name = "context") ContextInfo context) |
419 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
420 | |
OperationFailedException, PermissionDeniedException { |
421 | 0 | List<LprRosterEntryInfo> entries = lprRosterService.getLprRosterEntriesByLprRoster(gradeRosterId, context); |
422 | 0 | return assembleGradeRosterEntries(entries, context); |
423 | |
} |
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
@Override |
442 | |
public GradeRosterEntryInfo getFinalGradeForStudentInCourseOffering(@WebParam(name = "studentId") String studentId, |
443 | |
@WebParam(name = "courseOfferingId") String courseOfferingId, |
444 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
445 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, DisabledIdentifierException { |
446 | |
|
447 | |
|
448 | 0 | List<LprRosterInfo> lprRosters = lprRosterService.getLprRostersByTypeAndLui(LprServiceConstants.LPRROSTER_COURSE_FINAL_GRADEROSTER_TYPE_KEY, courseOfferingId, context); |
449 | 0 | Map<String, LprRosterEntryInfo> lprIdToRosterEntryMap = new HashMap<String, LprRosterEntryInfo>(); |
450 | 0 | for (LprRosterInfo lprRoster : lprRosters) { |
451 | 0 | String rosterId = lprRoster.getId(); |
452 | 0 | List<LprRosterEntryInfo> rosterEntries = lprRosterService.getLprRosterEntriesByLprRoster(rosterId, context); |
453 | 0 | for (LprRosterEntryInfo rosterEntry : rosterEntries) { |
454 | 0 | String lprId = rosterEntry.getLprId(); |
455 | 0 | lprIdToRosterEntryMap.put(lprId, rosterEntry); |
456 | 0 | } |
457 | 0 | } |
458 | |
|
459 | 0 | List<LprInfo> lprs = lprService.getLprsByPersonAndLui(studentId, courseOfferingId, context); |
460 | 0 | LprInfo lpr = lprs.get(0); |
461 | 0 | LprRosterEntryInfo entry = lprIdToRosterEntryMap.get(lpr.getId()); |
462 | |
|
463 | 0 | return assembleGradeRosterEntry(entry, context); |
464 | |
} |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
@Override |
483 | |
public GradeRosterEntryInfo addEntrytoInterimRoster( |
484 | |
@WebParam(name = "gradeRosterEntry") GradeRosterEntryInfo gradeRosterEntry, |
485 | |
@WebParam(name = "gradeRosterId") String gradeRosterId, @WebParam(name = "context") ContextInfo context) |
486 | |
throws AlreadyExistsException, InvalidParameterException, MissingParameterException, |
487 | |
OperationFailedException, PermissionDeniedException { |
488 | 0 | return null; |
489 | |
} |
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
|
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
@Override |
508 | |
public StatusInfo removeEntryFromInterimRoster(@WebParam(name = "gradeRosterEntryId") String gradeRosterEntryId, |
509 | |
@WebParam(name = "gradeRosterId") String gradeRosterId, @WebParam(name = "context") ContextInfo context) |
510 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
511 | |
OperationFailedException, PermissionDeniedException { |
512 | 0 | return null; |
513 | |
} |
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
@Override |
535 | |
public boolean updateGrade(@WebParam(name = "gradeRosterEntryId") String gradeRosterEntryId, |
536 | |
@WebParam(name = "assignedGrade") String assignedGradeKey, @WebParam(name = "context") ContextInfo context) |
537 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
538 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
539 | |
|
540 | 0 | List<String> lprRosterEntryIds = new ArrayList(); |
541 | 0 | lprRosterEntryIds.add(gradeRosterEntryId); |
542 | |
|
543 | 0 | List<LprRosterEntryInfo> entryInfoList = lprRosterService.getLprRosterEntriesByIds(lprRosterEntryIds,context); |
544 | 0 | if (entryInfoList.isEmpty()){ |
545 | 0 | throw new DoesNotExistException("Lpr Roster Entry not exists for the id " + gradeRosterEntryId); |
546 | |
} |
547 | |
|
548 | 0 | LprRosterEntryInfo entryInfo = entryInfoList.get(0); |
549 | 0 | List<String> lprIds = new ArrayList(); |
550 | 0 | lprIds.add(entryInfo.getLprId()); |
551 | |
|
552 | 0 | List<LearningResultRecordInfo> learningResultRecordInfoList = lrrService.getLearningResultRecordsForLprIds(lprIds,context); |
553 | |
|
554 | |
|
555 | 0 | if ((learningResultRecordInfoList == null || learningResultRecordInfoList.isEmpty()) && StringUtils.isNotBlank(assignedGradeKey)){ |
556 | 0 | LearningResultRecordInfo lrrInfo = constructLearningResultRecordInfo(entryInfo, assignedGradeKey); |
557 | |
try{ |
558 | 0 | lrrService.createLearningResultRecord(lrrInfo,context); |
559 | 0 | return true; |
560 | 0 | }catch(AlreadyExistsException e){ |
561 | 0 | throw new OperationFailedException("Someone updated the grade. Please refresh to get the latest",e); |
562 | |
} |
563 | |
} |
564 | |
|
565 | 0 | for (LearningResultRecordInfo lrrInfo : learningResultRecordInfoList){ |
566 | 0 | if (StringUtils.equals(LrrServiceConstants.RESULT_RECORD_FINAL_GRADE_ASSIGNED_TYPE_KEY, lrrInfo.getTypeKey())){ |
567 | 0 | if (!StringUtils.equals(LrrServiceConstants.RESULT_RECORD_DELETED_STATE_KEY,lrrInfo.getStateKey())){ |
568 | 0 | if (StringUtils.isBlank(assignedGradeKey)){ |
569 | 0 | StatusInfo status = lrrService.deleteLearningResultRecord(lrrInfo.getId(),context); |
570 | 0 | return status.getIsSuccess(); |
571 | |
}else{ |
572 | 0 | lrrInfo.setStateKey(LrrServiceConstants.RESULT_RECORD_SAVED_STATE_KEY); |
573 | 0 | lrrInfo.setResultValueKey(assignedGradeKey); |
574 | 0 | lrrService.updateLearningResultRecord(lrrInfo.getId(),lrrInfo,context); |
575 | 0 | return true; |
576 | |
} |
577 | |
} |
578 | |
} |
579 | |
} |
580 | |
|
581 | |
|
582 | 0 | if (StringUtils.isNotBlank(assignedGradeKey)){ |
583 | 0 | LearningResultRecordInfo newLrr = constructLearningResultRecordInfo(entryInfo, assignedGradeKey); |
584 | |
try{ |
585 | 0 | lrrService.createLearningResultRecord(newLrr,context); |
586 | 0 | return true; |
587 | 0 | }catch(AlreadyExistsException e){ |
588 | 0 | throw new OperationFailedException("Someone updated the grade. Please refresh to get the latest",e); |
589 | |
} |
590 | |
} |
591 | |
|
592 | 0 | return false; |
593 | |
} |
594 | |
|
595 | |
private LearningResultRecordInfo constructLearningResultRecordInfo(LprRosterEntryInfo entryInfo, String assignedGradeKey){ |
596 | 0 | LearningResultRecordInfo lrrInfo = new LearningResultRecordInfo(); |
597 | 0 | lrrInfo.setId(UUIDHelper.genStringUUID()); |
598 | 0 | lrrInfo.setLprId(entryInfo.getLprId()); |
599 | 0 | lrrInfo.setName("LRR for " + entryInfo.getLprId()); |
600 | 0 | lrrInfo.setStateKey(LrrServiceConstants.RESULT_RECORD_SAVED_STATE_KEY); |
601 | 0 | lrrInfo.setTypeKey(LrrServiceConstants.RESULT_RECORD_FINAL_GRADE_ASSIGNED_TYPE_KEY); |
602 | |
|
603 | |
|
604 | 0 | List<String> resultSource = new ArrayList(); |
605 | 0 | resultSource.add("ResultSource-Sample1"); |
606 | 0 | lrrInfo.setResultSourceIds(resultSource); |
607 | |
|
608 | 0 | lrrInfo.setResultValueKey(assignedGradeKey); |
609 | 0 | MetaInfo meta = new MetaInfo(); |
610 | 0 | meta.setCreateId(GlobalVariables.getUserSession().getPrincipalId()); |
611 | 0 | meta.setCreateTime(new Date()); |
612 | 0 | lrrInfo.setMeta(meta); |
613 | |
|
614 | 0 | return lrrInfo; |
615 | |
} |
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
@Override |
637 | |
public boolean updateCredit(@WebParam(name = "gradeRosterEntryId") String gradeRosterEntryId, |
638 | |
@WebParam(name = "creditsEarned") String assignedGradeKey, @WebParam(name = "context") ContextInfo context) |
639 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
640 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
641 | 0 | return false; |
642 | |
} |
643 | |
|
644 | |
@Override |
645 | |
public List<GradeValuesGroupInfo> getGradeGroupsByKeyList(List<String> gradeGroupKeyList, ContextInfo context) |
646 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
647 | |
OperationFailedException, PermissionDeniedException { |
648 | |
|
649 | 0 | List<ResultValuesGroupInfo> resultValuesGroupInfos = lrcService.getResultValuesGroupsByIds(gradeGroupKeyList, context); |
650 | 0 | List<GradeValuesGroupInfo> gradeValuesGroupInfos = new ArrayList<GradeValuesGroupInfo>(); |
651 | |
|
652 | 0 | for(ResultValuesGroupInfo resultValuesGroupInfo : resultValuesGroupInfos){ |
653 | 0 | List<ResultValueInfo> resultValueInfos = lrcService.getResultValuesByIds(resultValuesGroupInfo.getResultValueKeys(),context); |
654 | |
try { |
655 | 0 | gradeValuesGroupInfos.add(gradeValuesGroupAssembler.assemble(resultValuesGroupInfo,resultValueInfos,context)); |
656 | 0 | } catch (AssemblyException e) { |
657 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
658 | 0 | } |
659 | 0 | } |
660 | |
|
661 | 0 | return gradeValuesGroupInfos; |
662 | |
} |
663 | |
|
664 | |
@Override |
665 | |
public boolean updateNumberGrade(String gradeRosterEntryId, String numberGradeValue, ContextInfo context) |
666 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
667 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
668 | |
|
669 | 0 | return false; |
670 | |
} |
671 | |
|
672 | |
private GradeRosterInfo assembleGradeRoster(LprRosterInfo lprRosterInfo, ContextInfo context) throws InvalidParameterException, MissingParameterException, DoesNotExistException, PermissionDeniedException, OperationFailedException { |
673 | 0 | Map<String, LprRosterEntryInfo> lprIdToRosterEntriesMap = new HashMap<String, LprRosterEntryInfo>(); |
674 | 0 | List<String> graderIds = new ArrayList<String>(); |
675 | 0 | List<String> lprRosterEntryIds = new ArrayList<String>(); |
676 | |
|
677 | 0 | List<LprRosterEntryInfo> lprRosterEntries = lprRosterService.getLprRosterEntriesByLprRoster(lprRosterInfo.getId(), context); |
678 | 0 | for (LprRosterEntryInfo lprRosterEntry : lprRosterEntries) { |
679 | 0 | String lprId = lprRosterEntry.getLprId(); |
680 | 0 | lprIdToRosterEntriesMap.put(lprId, lprRosterEntry); |
681 | 0 | } |
682 | |
|
683 | 0 | List<String> lprIds = new ArrayList<String>(lprIdToRosterEntriesMap.keySet()); |
684 | 0 | List<LprInfo> lprInfos = lprService.getLprsByIds(lprIds, context); |
685 | 0 | for (LprInfo lprInfo : lprInfos) { |
686 | 0 | String lprInfoType = lprInfo.getTypeKey(); |
687 | 0 | if (LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY.equals(lprInfoType)) { |
688 | 0 | graderIds.add(lprInfo.getPersonId()); |
689 | 0 | } else if (LprServiceConstants.REGISTRANT_TYPE_KEY.equals(lprInfoType)) { |
690 | 0 | LprRosterEntryInfo lprRosterEntryInfo = lprIdToRosterEntriesMap.get(lprInfo.getId()); |
691 | 0 | lprRosterEntryIds.add(lprRosterEntryInfo.getId()); |
692 | |
} |
693 | 0 | } |
694 | |
|
695 | 0 | String courseOfferingId = null; |
696 | 0 | List<String> activityOfferingIds = null; |
697 | |
|
698 | 0 | List<String> associatedLuiIds = lprRosterInfo.getAssociatedLuiIds(); |
699 | |
|
700 | 0 | if (associatedLuiIds == null || associatedLuiIds.size() == 0) { |
701 | 0 | throw new OperationFailedException("LPR Roster does not contain any associated LUI IDs."); |
702 | 0 | } else if (associatedLuiIds.size() == 1) { |
703 | 0 | CourseOfferingInfo courseOffering = courseOfferingService.getCourseOffering(associatedLuiIds.get(0), context); |
704 | 0 | courseOfferingId = courseOffering.getId(); |
705 | 0 | activityOfferingIds = new ArrayList<String>(); |
706 | 0 | } else if (associatedLuiIds.size() > 1) { |
707 | 0 | activityOfferingIds = associatedLuiIds; |
708 | |
|
709 | 0 | List<String> relatedLuis = luiService.getLuiIdsByRelatedLuiAndRelationType(activityOfferingIds.get(0), LuiServiceConstants.LUI_LUI_RELATION_DELIVEREDVIA_TYPE_KEY, context); |
710 | 0 | if (relatedLuis == null || relatedLuis.size() != 1) { |
711 | 0 | throw new OperationFailedException("The provided activity offering is not related to 1 and only 1 course offering."); |
712 | |
} |
713 | 0 | courseOfferingId = relatedLuis.get(0); |
714 | |
} |
715 | |
|
716 | 0 | GradeRosterInfo gradeRosterInfo = gradeRosterAssembler.assemble(lprRosterInfo, lprRosterEntryIds, graderIds, courseOfferingId, activityOfferingIds, context); |
717 | 0 | return gradeRosterInfo; |
718 | |
} |
719 | |
|
720 | |
private List<GradeRosterEntryInfo> assembleGradeRosterEntries(List<LprRosterEntryInfo> entries, ContextInfo context) |
721 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
722 | |
|
723 | |
|
724 | |
|
725 | 0 | final String STUDENT_ID = "studentId"; |
726 | 0 | final String ACTIVITY_OFFERING_ID = "activityOfferingId"; |
727 | 0 | final String ASSIGNED_GRADE = "assignedGrade"; |
728 | 0 | final String ADMINISTRATIVE_GRADE = "administrativeGrade"; |
729 | 0 | final String CREDITS_EARNED = "creditsEarned"; |
730 | 0 | final String CALCULATED_GRADE = "calculatedGrade"; |
731 | 0 | final String GRADING_OPTION = "gradingOption"; |
732 | |
|
733 | 0 | List<GradeRosterEntryInfo> gradeRosterEntryInfos = new ArrayList<GradeRosterEntryInfo>(); |
734 | 0 | Map<LprRosterEntryInfo, Map<String, String>> entryKeysMap = new HashMap<LprRosterEntryInfo, Map<String, String>>(); |
735 | |
|
736 | 0 | Map<String, LprRosterEntryInfo> lprIdToEntryMap = new HashMap<String, LprRosterEntryInfo>(); |
737 | 0 | for (LprRosterEntryInfo lprRosterEntryInfo : entries) { |
738 | 0 | lprIdToEntryMap.put(lprRosterEntryInfo.getLprId(), lprRosterEntryInfo); |
739 | 0 | entryKeysMap.put(lprRosterEntryInfo, new HashMap<String, String>()); |
740 | |
} |
741 | |
|
742 | 0 | List<String> lprIds = new ArrayList(lprIdToEntryMap.keySet()); |
743 | 0 | List<LprInfo> lprs = lprService.getLprsByIds(lprIds, context); |
744 | |
|
745 | 0 | Map<String,List> lprToGradeOptions = new HashMap(); |
746 | |
|
747 | 0 | for (LprInfo lpr : lprs) { |
748 | 0 | Map<String, String> entryAttributes = entryKeysMap.get(lprIdToEntryMap.get(lpr.getId())); |
749 | 0 | entryAttributes.put(STUDENT_ID, lpr.getPersonId()); |
750 | 0 | entryAttributes.put(ACTIVITY_OFFERING_ID, lpr.getLuiId()); |
751 | |
|
752 | 0 | CourseOfferingInfo courseOfferingInfo = courseOfferingService.getCourseOffering(lpr.getLuiId(),context); |
753 | |
|
754 | 0 | if (courseOfferingInfo == null){ |
755 | 0 | throw new OperationFailedException("Could not find course offering " + lpr.getLuiId()); |
756 | |
} |
757 | |
|
758 | 0 | lprToGradeOptions.put(lpr.getId(),courseOfferingInfo.getRegistrationGradingOptionIds()); |
759 | |
|
760 | 0 | } |
761 | |
|
762 | 0 | List<LearningResultRecordInfo> lrrs = lrrService.getLearningResultRecordsForLprIds(lprIds, context); |
763 | 0 | Map<LearningResultRecordInfo, String> lrrToLprIdMap = new HashMap<LearningResultRecordInfo, String>(); |
764 | 0 | List<String> resultValueKeys = new ArrayList<String>(); |
765 | 0 | List<LearningResultRecordInfo> filteredLrrs = new ArrayList(); |
766 | |
|
767 | 0 | for (LearningResultRecordInfo lrr : lrrs) { |
768 | |
|
769 | 0 | if (!StringUtils.equals(lrr.getStateKey(),LrrServiceConstants.RESULT_RECORD_DELETED_STATE_KEY)){ |
770 | 0 | lrrToLprIdMap.put(lrr, lrr.getLprId()); |
771 | 0 | if (StringUtils.isNotBlank(lrr.getResultValueKey())){ |
772 | 0 | resultValueKeys.add(lrr.getResultValueKey()); |
773 | 0 | filteredLrrs.add(lrr); |
774 | |
} |
775 | |
} |
776 | |
} |
777 | |
|
778 | 0 | List<ResultValueInfo> resultValues = lrcService.getResultValuesByIds(resultValueKeys, context); |
779 | 0 | for (int i = 0; i < resultValues.size(); i++) { |
780 | 0 | LearningResultRecordInfo lrr = filteredLrrs.get(i); |
781 | 0 | ResultValueInfo resultValue = resultValues.get(i); |
782 | 0 | String lprId = lrrToLprIdMap.get(lrr); |
783 | 0 | LprRosterEntryInfo entry = lprIdToEntryMap.get(lprId); |
784 | 0 | Map<String, String> entryAttributes = entryKeysMap.get(entry); |
785 | |
|
786 | 0 | String resultValuetypeKey = resultValue.getTypeKey(); |
787 | 0 | String entryAttributesKey = null; |
788 | 0 | if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE.equals(resultValuetypeKey)) { |
789 | 0 | entryAttributesKey = ASSIGNED_GRADE; |
790 | 0 | } else if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_ADMIN_GRADE.equals(resultValuetypeKey)) { |
791 | 0 | entryAttributesKey = ADMINISTRATIVE_GRADE; |
792 | 0 | } else if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_CREDIT.equals(resultValuetypeKey)) { |
793 | 0 | entryAttributesKey = CREDITS_EARNED; |
794 | |
} else if (false) { |
795 | |
entryAttributesKey = CALCULATED_GRADE; |
796 | |
} |
797 | |
|
798 | 0 | if (entryAttributesKey != null) { |
799 | 0 | entryAttributes.put(entryAttributesKey, resultValue.getKey()); |
800 | |
} |
801 | |
} |
802 | |
|
803 | 0 | for (LprRosterEntryInfo lprRosterEntry : entryKeysMap.keySet()) { |
804 | 0 | Map<String, String> entryAttributes = entryKeysMap.get(lprRosterEntry); |
805 | 0 | String studentId = entryAttributes.get(STUDENT_ID); |
806 | 0 | String activityOfferingId = entryAttributes.get(ACTIVITY_OFFERING_ID); |
807 | 0 | String assignedGradeKey = entryAttributes.get(ASSIGNED_GRADE); |
808 | 0 | String calculatedGradeKey = entryAttributes.get(CALCULATED_GRADE); |
809 | 0 | String administrativeGradeKey = entryAttributes.get(ADMINISTRATIVE_GRADE); |
810 | 0 | String creditsEarnedKey = entryAttributes.get(CREDITS_EARNED); |
811 | 0 | List gradingOptionKey = lprToGradeOptions.get(lprRosterEntry.getLprId()); |
812 | |
|
813 | 0 | GradeRosterEntryInfo gradeRosterEntry = gradeRosterEntryAssembler.assemble(lprRosterEntry, studentId, activityOfferingId, assignedGradeKey, calculatedGradeKey, administrativeGradeKey, creditsEarnedKey, gradingOptionKey , context); |
814 | 0 | gradeRosterEntryInfos.add(gradeRosterEntry); |
815 | 0 | } |
816 | |
|
817 | 0 | return gradeRosterEntryInfos; |
818 | |
} |
819 | |
|
820 | |
private GradeRosterEntryInfo assembleGradeRosterEntry(LprRosterEntryInfo lprRosterEntry, ContextInfo context) |
821 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
822 | |
|
823 | |
String studentId; |
824 | |
String activityOfferingId; |
825 | 0 | String assignedGradeKey = null; |
826 | 0 | String administrativeGradeKey = null; |
827 | 0 | String creditsEarnedKey = null; |
828 | 0 | String calculatedGradeKey = null; |
829 | 0 | List<String> gradingOptionKeys = new ArrayList<String>(); |
830 | |
|
831 | 0 | String lprId = lprRosterEntry.getLprId(); |
832 | 0 | LprInfo lpr = lprService.getLpr(lprId, context); |
833 | |
|
834 | 0 | studentId = lpr.getPersonId(); |
835 | 0 | activityOfferingId = lpr.getLuiId(); |
836 | |
|
837 | |
|
838 | 0 | CourseOfferingInfo courseOfferingInfo = courseOfferingService.getCourseOffering(lpr.getLuiId(),context); |
839 | 0 | gradingOptionKeys.add(courseOfferingInfo.getGradingOptionId()); |
840 | |
|
841 | 0 | List<LearningResultRecordInfo> lrrs = lrrService.getLearningResultRecordsForLpr(lprId); |
842 | 0 | List<String> resultValueKeys = new ArrayList<String>(); |
843 | |
|
844 | 0 | for (LearningResultRecordInfo lrr : lrrs) { |
845 | |
|
846 | 0 | if (StringUtils.isBlank(lrr.getResultValueKey()) || |
847 | |
StringUtils.equals(lrr.getStateKey(),LrrServiceConstants.RESULT_RECORD_DELETED_STATE_KEY)) { |
848 | 0 | lrrs.remove(lrr); |
849 | |
} else { |
850 | 0 | resultValueKeys.add(lrr.getResultValueKey()); |
851 | |
} |
852 | |
} |
853 | |
|
854 | 0 | List<ResultValueInfo> resultValues = lrcService.getResultValuesByIds(resultValueKeys, context); |
855 | 0 | for (int i = 0; i < resultValues.size(); i++) { |
856 | 0 | ResultValueInfo resultValue = resultValues.get(i); |
857 | 0 | String resultValuetypeKey = resultValue.getTypeKey(); |
858 | 0 | if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_GRADE.equals(resultValuetypeKey)) { |
859 | 0 | assignedGradeKey = resultValue.getKey(); |
860 | 0 | } else if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_ADMIN_GRADE.equals(resultValuetypeKey)) { |
861 | 0 | administrativeGradeKey = resultValue.getKey(); |
862 | 0 | } else if (LrcServiceConstants.RESULT_SCALE_TYPE_KEY_CREDIT.equals(resultValuetypeKey)) { |
863 | 0 | creditsEarnedKey = resultValue.getKey(); |
864 | |
} else if (false) { |
865 | |
calculatedGradeKey = resultValue.getKey(); |
866 | |
} |
867 | |
} |
868 | |
|
869 | 0 | GradeRosterEntryInfo gradeRosterEntry = gradeRosterEntryAssembler.assemble(lprRosterEntry, studentId, activityOfferingId, assignedGradeKey, calculatedGradeKey, administrativeGradeKey, creditsEarnedKey, gradingOptionKeys , context); |
870 | |
|
871 | 0 | return gradeRosterEntry; |
872 | |
} |
873 | |
|
874 | |
public LprRosterService getLprRosterService() { |
875 | 0 | return lprRosterService; |
876 | |
} |
877 | |
|
878 | |
public void setLprRosterService(LprRosterService lprRosterService) { |
879 | 0 | this.lprRosterService = lprRosterService; |
880 | 0 | } |
881 | |
|
882 | |
public LprService getLprService() { |
883 | 0 | return lprService; |
884 | |
} |
885 | |
|
886 | |
public void setLprService(LprService lprService) { |
887 | 0 | this.lprService = lprService; |
888 | 0 | } |
889 | |
|
890 | |
public CourseOfferingService getCourseOfferingService() { |
891 | 0 | return courseOfferingService; |
892 | |
} |
893 | |
|
894 | |
public void setCourseOfferingService(CourseOfferingService courseOfferingService) { |
895 | 0 | this.courseOfferingService = courseOfferingService; |
896 | 0 | } |
897 | |
|
898 | |
public LRCService getLrcService() { |
899 | 0 | return lrcService; |
900 | |
} |
901 | |
|
902 | |
public void setLrcService(LRCService lrcService) { |
903 | 0 | this.lrcService = lrcService; |
904 | 0 | } |
905 | |
|
906 | |
public LearningResultRecordService getLrrService() { |
907 | 0 | return lrrService; |
908 | |
} |
909 | |
|
910 | |
public void setLrrService(LearningResultRecordService lrrService) { |
911 | 0 | this.lrrService = lrrService; |
912 | 0 | } |
913 | |
|
914 | |
public LuiService getLuiService() { |
915 | 0 | return luiService; |
916 | |
} |
917 | |
|
918 | |
public void setLuiService(LuiService luiService) { |
919 | 0 | this.luiService = luiService; |
920 | 0 | } |
921 | |
|
922 | |
public GradeRosterAssembler getGradeRosterAssembler() { |
923 | 0 | return gradeRosterAssembler; |
924 | |
} |
925 | |
|
926 | |
public void setGradeRosterAssembler(GradeRosterAssembler gradeRosterAssembler) { |
927 | 0 | this.gradeRosterAssembler = gradeRosterAssembler; |
928 | 0 | } |
929 | |
|
930 | |
public GradeRosterEntryAssembler getGradeRosterEntryAssembler() { |
931 | 0 | return gradeRosterEntryAssembler; |
932 | |
} |
933 | |
|
934 | |
public void setGradeRosterEntryAssembler(GradeRosterEntryAssembler gradeRosterEntryAssembler) { |
935 | 0 | this.gradeRosterEntryAssembler = gradeRosterEntryAssembler; |
936 | 0 | } |
937 | |
|
938 | |
public GradeValuesGroupAssembler getGradeValuesGroupAssembler() { |
939 | 0 | return gradeValuesGroupAssembler; |
940 | |
} |
941 | |
|
942 | |
public void setGradeValuesGroupAssembler(GradeValuesGroupAssembler gradeValuesGroupAssembler) { |
943 | 0 | this.gradeValuesGroupAssembler = gradeValuesGroupAssembler; |
944 | 0 | } |
945 | |
|
946 | |
public CourseRegistrationService getCourseRegistrationService() { |
947 | 0 | return courseRegistrationService; |
948 | |
} |
949 | |
|
950 | |
public void setCourseRegistrationService(CourseRegistrationService courseRegistrationService) { |
951 | 0 | this.courseRegistrationService = courseRegistrationService; |
952 | 0 | } |
953 | |
} |