| | |
| | | import com.mindskip.xzs.event.UserEvent; |
| | | import com.mindskip.xzs.service.ExamPaperAnswerService; |
| | | import com.mindskip.xzs.service.ExamPaperService; |
| | | import com.mindskip.xzs.service.ExamPaperSubjectService; |
| | | import com.mindskip.xzs.service.SubjectService; |
| | | import com.mindskip.xzs.utility.DateTimeUtil; |
| | | import com.mindskip.xzs.utility.ExamUtil; |
| | |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController("StudentExamPaperAnswerController") |
| | | @RequestMapping(value = "/api/student/exampaper/answer") |
| | |
| | | private final ExamPaperService examPaperService; |
| | | private final SubjectService subjectService; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | private final ExamPaperSubjectService examPaperSubjectService; |
| | | |
| | | @Autowired |
| | | public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher) { |
| | | public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher, ExamPaperSubjectService examPaperSubjectService) { |
| | | this.examPaperAnswerService = examPaperAnswerService; |
| | | this.examPaperService = examPaperService; |
| | | this.subjectService = subjectService; |
| | | this.eventPublisher = eventPublisher; |
| | | this.examPaperSubjectService = examPaperSubjectService; |
| | | } |
| | | |
| | | |
| | |
| | | PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model); |
| | | PageInfo<ExamPaperAnswerPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamPaperAnswerPageResponseVM vm = modelMapper.map(e, ExamPaperAnswerPageResponseVM.class); |
| | | Subject subject = subjectService.selectById(vm.getSubjectId()); |
| | | ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(vm.getId()); |
| | | Integer[] ids = examPaperSubjectService.getByExamPaperId(examPaperAnswer.getExamPaperId()) |
| | | .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new); |
| | | String name = ""; |
| | | if(ids.length>0){ |
| | | name = subjectService.selectByIds(ids) |
| | | .stream().map(Subject::getName).collect(Collectors.joining(",")); |
| | | } |
| | | vm.setDoTime(ExamUtil.secondToVM(e.getDoTime())); |
| | | vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); |
| | | vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); |
| | | vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); |
| | | vm.setSubjectName(subject.getName()); |
| | | vm.setSubjectName(name); |
| | | vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vm; |
| | | }); |
| | |
| | | userEventLog.setContent(content); |
| | | eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo)); |
| | | eventPublisher.publishEvent(new UserEvent(userEventLog)); |
| | | |
| | | return RestResponse.ok(scoreVm); |
| | | } |
| | | |