| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.ExamPaperAnswerInfo; |
| | | import com.ycl.jxkg.domain.entity.ExamPaperScore; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperReadVO; |
| | | import com.ycl.jxkg.domain.vo.PaperFixQuestionVO; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkNavbarVO; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperScoreVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | | import com.ycl.jxkg.service.UserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Objects; |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("StudentExamPaperAnswerController") |
| | |
| | | public class ExamPaperAnswerController extends BaseApiController { |
| | | |
| | | private final ExamPaperScoreService examPaperScoreService; |
| | | private final UserService userService; |
| | | private final ExamPaperService examPaperService; |
| | | private final SubjectService subjectService; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/read/{id}", method = RequestMethod.POST) |
| | | public Result<ExamPaperReadVO> read(@PathVariable Integer id) { |
| | | public Result<ExamPaperScoreVO> read(@PathVariable Integer id) { |
| | | ExamPaperScore examPaperScore = examPaperScoreService.getById(id); |
| | | ExamPaperReadVO vm = new ExamPaperReadVO(); |
| | | ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperScore.getPaperId()); |
| | | ExamPaperSubmitVO answer = examPaperScoreService.examPaperAnswerToVM(examPaperScore.getId()); |
| | | vm.setPaper(paper); |
| | | vm.setAnswer(answer); |
| | | return Result.ok(vm); |
| | | ExamPaperScoreVO examPaperScoreVO = new ExamPaperScoreVO(); |
| | | BeanUtils.copyProperties(examPaperScore, examPaperScoreVO); |
| | | User user = userService.getById(examPaperScore.getUserId()); |
| | | examPaperScoreVO.setUserName(Objects.nonNull(user) ? user.getRealName() : "用户已注销"); |
| | | examPaperScoreVO.setNavbar(JSON.parseArray(examPaperScore.getNavbar(), ExamPaperMarkNavbarVO.class)); |
| | | examPaperScoreVO.setTitleItems(JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class)); |
| | | return Result.ok(examPaperScoreVO); |
| | | } |
| | | |
| | | |
| | | } |