src/main/java/com/ycl/jxkg/controller/admin/DashboardController.java
@@ -19,8 +19,8 @@ private final ExamPaperService examPaperService; private final QuestionService questionService; private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService; private final ExamPaperScoreService examPaperScoreService; private final ExamPaperScoreDetailService examPaperScoreDetailService; private final UserEventLogService userEventLogService; @RequestMapping(value = "/index", method = RequestMethod.POST) @@ -29,8 +29,8 @@ Integer examPaperCount = examPaperService.selectAllCount(); Integer questionCount = questionService.selectAllCount(); Integer doExamPaperCount = examPaperAnswerService.selectAllCount(); Integer doQuestionCount = examPaperQuestionCustomerAnswerService.selectAllCount(); Integer doExamPaperCount = examPaperScoreService.selectAllCount(); Integer doQuestionCount = examPaperScoreDetailService.selectAllCount(); vm.setExamPaperCount(examPaperCount); vm.setQuestionCount(questionCount); @@ -38,7 +38,7 @@ vm.setDoQuestionCount(doQuestionCount); List<Integer> mothDayUserActionValue = userEventLogService.selectMothCount(); List<Integer> mothDayDoExamQuestionValue = examPaperQuestionCustomerAnswerService.selectMothCount(); List<Integer> mothDayDoExamQuestionValue = examPaperScoreDetailService.selectMothCount(); vm.setMothDayUserActionValue(mothDayUserActionValue); vm.setMothDayDoExamQuestionValue(mothDayDoExamQuestionValue); src/main/java/com/ycl/jxkg/controller/admin/ExamController.java
@@ -5,6 +5,7 @@ import com.ycl.jxkg.domain.form.ExamForm; import com.ycl.jxkg.domain.form.ForceSubmitForm; import com.ycl.jxkg.domain.query.ExamQuery; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkVO; import com.ycl.jxkg.group.Add; import com.ycl.jxkg.group.Update; import com.ycl.jxkg.service.ExamService; @@ -95,6 +96,11 @@ public Result getMarkPaperInfo(@PathVariable("examId") Integer examId, @PathVariable("userId") Integer userId) { return examService.getMarkPaperInfo(examId, userId); } @PostMapping("/mark/paper") @ApiOperation(value = "提交批改", notes = "提交批改") public Result submitMarkPaper(@RequestBody ExamPaperMarkVO examPaperMark) { return examService.submitMarkPaper(examPaperMark); } @GetMapping("/monitor/list") @PreAuthorize("hasAuthority('exam:monitor:list')") src/main/java/com/ycl/jxkg/controller/admin/ExamPaperScoreController.java
File was renamed from src/main/java/com/ycl/jxkg/controller/admin/ExamPaperAnswerController.java @@ -3,14 +3,14 @@ import com.github.pagehelper.PageInfo; import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperReadVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerExportVO; import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; import com.ycl.jxkg.service.ExamPaperAnswerService; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.utils.ExcelUtils; import lombok.RequiredArgsConstructor; @@ -23,34 +23,34 @@ @RequiredArgsConstructor @RestController("AdminExamPaperAnswerController") @RequestMapping(value = "/api/admin/examPaperAnswer") public class ExamPaperAnswerController extends BaseApiController { public class ExamPaperScoreController extends BaseApiController { private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperScoreService examPaperScoreService; private final ExamPaperService examPaperService; @PostMapping("/pageExamPaper") public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageExamPaper(@RequestBody ExamPaperAnswerPageRequestVO model) { return Result.ok(examPaperAnswerService.pageExamPaper(model)); return Result.ok(examPaperScoreService.pageExamPaper(model)); } @RequestMapping(value = "/page", method = RequestMethod.POST) public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageJudgeList(@RequestBody ExamPaperAnswerPageRequestVO model) { return Result.ok(examPaperAnswerService.adminPage(model)); return Result.ok(examPaperScoreService.adminPage(model)); } @RequestMapping(value = "/exportExcel", method = RequestMethod.POST) @SneakyThrows public void exportExcel(ExamPaperAnswerPageRequestVO model, HttpServletResponse response) { List<ExamPaperAnswerPageResponseVO> list = examPaperAnswerService.list(model); List<ExamPaperAnswerPageResponseVO> list = examPaperScoreService.list(model); ExcelUtils.exportExcelToTarget(response, "", "成绩列表", list, ExamPaperAnswerExportVO.class); } @PostMapping("/read/{id}") public Result<ExamPaperReadVO> read(@PathVariable Integer id) { ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(id); ExamPaperScore examPaperScore = examPaperScoreService.getById(id); ExamPaperReadVO vm = new ExamPaperReadVO(); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId()); ExamPaperSubmitVO answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId()); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperScore.getPaperId()); ExamPaperSubmitVO answer = examPaperScoreService.examPaperAnswerToVM(examPaperScore.getId()); vm.setPaper(paper); vm.setAnswer(answer); return Result.ok(vm); src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
@@ -3,15 +3,14 @@ import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.*; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.Subject; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.domain.entity.UserEventLog; import com.ycl.jxkg.domain.vo.ExamSubmitVO; import com.ycl.jxkg.enums.ExamPaperAnswerStatusEnum; import com.ycl.jxkg.event.CalculateExamPaperAnswerCompleteEvent; import com.ycl.jxkg.event.UserEvent; import com.ycl.jxkg.service.ExamPaperAnswerService; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.service.SubjectService; import com.ycl.jxkg.utils.DateTimeUtil; @@ -26,7 +25,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.context.ApplicationEventPublisher; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -37,7 +35,7 @@ @RequestMapping(value = "/api/student/exampaper/answer") public class ExamPaperAnswerController extends BaseApiController { private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperScoreService examPaperScoreService; private final ExamPaperService examPaperService; private final SubjectService subjectService; private final ApplicationEventPublisher eventPublisher; @@ -46,17 +44,17 @@ @RequestMapping(value = "/pageList", method = RequestMethod.POST) public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@RequestBody @Valid ExamPaperAnswerPageVO model) { model.setCreateUser(getCurrentUser().getId()); PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model); PageInfo<ExamPaperScore> pageInfo = examPaperScoreService.studentPage(model); PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); BeanUtils.copyProperties(e, vo); Subject subject = subjectService.getById(vo.getSubjectId()); vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); vo.setSubjectName(subject.getName()); vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); // BeanUtils.copyProperties(e, vo); // Subject subject = subjectService.getById(vo.getSubjectId()); // vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); // vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); // vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); // vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); // vo.setSubjectName(subject.getName()); // vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); return vo; }); return Result.ok(page); @@ -66,50 +64,51 @@ @RequestMapping(value = "/answerSubmit", method = RequestMethod.POST) public Result answerSubmit(@RequestBody @Valid ExamPaperSubmitVO examPaperSubmitVO) { User user = getCurrentUser(); ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVO, user); ExamPaperAnswerInfo examPaperAnswerInfo = examPaperScoreService.calculateExamPaperAnswer(examPaperSubmitVO, user); if (null == examPaperAnswerInfo) { return Result.fail(2, "试卷不能重复做"); } ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer(); Integer userScore = examPaperAnswer.getUserScore(); String scoreVm = ExamUtil.scoreToVM(userScore); UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName() + " 得分:" + scoreVm + " 耗时:" + ExamUtil.secondToVM(examPaperAnswer.getDoTime()); userEventLog.setContent(content); eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo)); eventPublisher.publishEvent(new UserEvent(userEventLog)); return Result.ok(scoreVm); // ExamPaperScore examPaperScore = examPaperAnswerInfo.getExamPaperScore(); // Integer userScore = examPaperScore.getUserScore(); // String scoreVm = ExamUtil.scoreToVM(userScore); // UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); // String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName() // + " 得分:" + scoreVm // + " 耗时:" + ExamUtil.secondToVM(examPaperScore.getDoTime()); // userEventLog.setContent(content); // eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo)); // eventPublisher.publishEvent(new UserEvent(userEventLog)); // return Result.ok(scoreVm); return Result.ok(); } @RequestMapping(value = "/edit", method = RequestMethod.POST) public Result edit(@RequestBody @Valid ExamPaperSubmitVO examPaperSubmitVO) { boolean notJudge = examPaperSubmitVO.getAnswerItems().stream().anyMatch(i -> i.getDoRight() == null && i.getScore() == null); if (notJudge) { return Result.fail(2, "有未批改题目"); } ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(examPaperSubmitVO.getId()); ExamPaperAnswerStatusEnum examPaperAnswerStatusEnum = ExamPaperAnswerStatusEnum.fromCode(examPaperAnswer.getStatus()); if (examPaperAnswerStatusEnum == ExamPaperAnswerStatusEnum.Complete) { return Result.fail(3, "试卷已完成"); } String score = examPaperAnswerService.judge(examPaperSubmitVO); User user = getCurrentUser(); UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); String content = user.getUserName() + " 批改试卷:" + examPaperAnswer.getPaperName() + " 得分:" + score; userEventLog.setContent(content); eventPublisher.publishEvent(new UserEvent(userEventLog)); // boolean notJudge = examPaperSubmitVO.getAnswerItems().stream().anyMatch(i -> i.getDoRight() == null && i.getScore() == null); // if (notJudge) { // return Result.fail(2, "有未批改题目"); // } // // ExamPaperScore examPaperScore = examPaperScoreService.getById(examPaperSubmitVO.getId()); // ExamPaperAnswerStatusEnum examPaperAnswerStatusEnum = ExamPaperAnswerStatusEnum.fromCode(examPaperScore.getStatus()); // if (examPaperAnswerStatusEnum == ExamPaperAnswerStatusEnum.Complete) { // return Result.fail(3, "试卷已完成"); // } String score = examPaperScoreService.judge(examPaperSubmitVO); // User user = getCurrentUser(); // UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); // String content = user.getUserName() + " 批改试卷:" + examPaperScore.get() + " 得分:" + score; // userEventLog.setContent(content); // eventPublisher.publishEvent(new UserEvent(userEventLog)); return Result.ok(score); } @RequestMapping(value = "/read/{id}", method = RequestMethod.POST) public Result<ExamPaperReadVO> read(@PathVariable Integer id) { ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(id); ExamPaperScore examPaperScore = examPaperScoreService.getById(id); ExamPaperReadVO vm = new ExamPaperReadVO(); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId()); ExamPaperSubmitVO answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId()); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperScore.getPaperId()); ExamPaperSubmitVO answer = examPaperScoreService.examPaperAnswerToVM(examPaperScore.getId()); vm.setPaper(paper); vm.setAnswer(answer); return Result.ok(vm); src/main/java/com/ycl/jxkg/controller/student/ExamPaperController.java
@@ -3,7 +3,7 @@ import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.service.ExamPaperAnswerService; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.PageInfoHelper; @@ -24,7 +24,7 @@ public class ExamPaperController extends BaseApiController { private final ExamPaperService examPaperService; private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperScoreService examPaperScoreService; private final ApplicationEventPublisher eventPublisher; @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) src/main/java/com/ycl/jxkg/controller/student/MeetController.java
@@ -37,7 +37,7 @@ } @GetMapping("/{id}") @ApiOperation(value = "详情", notes = "详情") @ApiOperation(value = "学生上课", notes = "学生上课") public Result detail(@PathVariable("id") Integer id) { return meetService.detail(id); } src/main/java/com/ycl/jxkg/controller/student/QuestionAnswerController.java
@@ -2,11 +2,10 @@ import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.entity.Subject; import com.ycl.jxkg.domain.entity.TextContent; import com.ycl.jxkg.domain.question.QuestionObject; import com.ycl.jxkg.service.ExamPaperQuestionCustomerAnswerService; import com.ycl.jxkg.service.ExamPaperScoreDetailService; import com.ycl.jxkg.service.QuestionService; import com.ycl.jxkg.service.SubjectService; import com.ycl.jxkg.service.TextContentService; @@ -29,7 +28,7 @@ @RequestMapping(value = "/api/student/question/answer") public class QuestionAnswerController extends BaseApiController { private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService; private final ExamPaperScoreDetailService examPaperScoreDetailService; private final QuestionService questionService; private final TextContentService textContentService; private final SubjectService subjectService; @@ -37,7 +36,7 @@ @RequestMapping(value = "/page", method = RequestMethod.POST) public Result<PageInfo<QuestionPageStudentResponseVO>> pageList(@RequestBody QuestionPageStudentRequestVO model) { model.setCreateUser(getCurrentUser().getId()); PageInfo<ExamPaperQuestionCustomerAnswer> pageInfo = examPaperQuestionCustomerAnswerService.studentPage(model); PageInfo<ExamPaperScoreDetail> pageInfo = examPaperScoreDetailService.studentPage(model); PageInfo<QuestionPageStudentResponseVO> page = PageInfoHelper.copyMap(pageInfo, q -> { Subject subject = subjectService.getById(q.getSubjectId()); QuestionPageStudentResponseVO vo = new QuestionPageStudentResponseVO(); @@ -56,9 +55,9 @@ @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public Result<QuestionAnswerVO> select(@PathVariable Integer id) { QuestionAnswerVO vm = new QuestionAnswerVO(); ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = examPaperQuestionCustomerAnswerService.getById(id); ExamPaperSubmitItemVO questionAnswerVM = examPaperQuestionCustomerAnswerService.examPaperQuestionCustomerAnswerToVM(examPaperQuestionCustomerAnswer); QuestionEditRequestVO questionVM = questionService.getQuestionEditRequestVM(examPaperQuestionCustomerAnswer.getQuestionId()); ExamPaperScoreDetail examPaperScoreDetail = examPaperScoreDetailService.getById(id); ExamPaperSubmitItemVO questionAnswerVM = examPaperScoreDetailService.examPaperQuestionCustomerAnswerToVM(examPaperScoreDetail); QuestionEditRequestVO questionVM = questionService.getQuestionEditRequestVM(examPaperScoreDetail.getQuestionId()); vm.setQuestionVM(questionVM); vm.setQuestionAnswerVM(questionAnswerVM); return Result.ok(vm); src/main/java/com/ycl/jxkg/controller/wx/student/ExamPaperAnswerController.java
@@ -3,14 +3,14 @@ import com.ycl.jxkg.base.Result; import com.ycl.jxkg.controller.wx.BaseWXApiController; import com.ycl.jxkg.domain.*; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.Subject; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.domain.entity.UserEventLog; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.event.CalculateExamPaperAnswerCompleteEvent; import com.ycl.jxkg.event.UserEvent; import com.ycl.jxkg.service.ExamPaperAnswerService; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.service.SubjectService; import com.ycl.jxkg.utils.DateTimeUtil; @@ -40,7 +40,7 @@ @ResponseBody public class ExamPaperAnswerController extends BaseWXApiController { private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperScoreService examPaperScoreService; private final SubjectService subjectService; private final ApplicationEventPublisher eventPublisher; private final ExamPaperService examPaperService; @@ -48,15 +48,15 @@ @RequestMapping(value = "/pageList", method = RequestMethod.POST) public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@Valid ExamPaperAnswerPageVO model) { model.setCreateUser(getCurrentUser().getId()); PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model); PageInfo<ExamPaperScore> pageInfo = examPaperScoreService.studentPage(model); PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); BeanUtils.copyProperties(e, vo); Subject subject = subjectService.getById(vo.getSubjectId()); vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); // vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); // vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); // vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); vo.setSubjectName(subject.getName()); vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); return vo; @@ -67,23 +67,24 @@ @RequestMapping(value = "/answerSubmit", method = RequestMethod.POST) public Result answerSubmit(HttpServletRequest request) { ExamPaperSubmitVO examPaperSubmitVO = requestToExamPaperSubmitVM(request); User user = getCurrentUser(); ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVO, user); if (null == examPaperAnswerInfo) { return Result.fail(2, "试卷不能重复做"); } ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer(); Integer userScore = examPaperAnswer.getUserScore(); String scoreVm = ExamUtil.scoreToVM(userScore); UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName() + " 得分:" + scoreVm + " 耗时:" + ExamUtil.secondToVM(examPaperAnswer.getDoTime()); userEventLog.setContent(content); eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo)); eventPublisher.publishEvent(new UserEvent(userEventLog)); return Result.ok(scoreVm); //TODO:answer ExamPaperSubmitVO examPaperSubmitVO = requestToExamPaperSubmitVM(request); // User user = getCurrentUser(); // ExamPaperAnswerInfo examPaperAnswerInfo = examPaperScoreService.calculateExamPaperAnswer(examPaperSubmitVO, user); // if (null == examPaperAnswerInfo) { // return Result.fail(2, "试卷不能重复做"); // } // ExamPaperScore examPaperScore = examPaperAnswerInfo.getExamPaperScore(); // Integer userScore = examPaperScore.getUserScore(); // String scoreVm = ExamUtil.scoreToVM(userScore); // UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); // String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName() // + " 得分:" + scoreVm // + " 耗时:" + ExamUtil.secondToVM(examPaperScore.getDoTime()); // userEventLog.setContent(content); // eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo)); // eventPublisher.publishEvent(new UserEvent(userEventLog)); // return Result.ok(scoreVm); return Result.ok(); } private ExamPaperSubmitVO requestToExamPaperSubmitVM(HttpServletRequest request) { @@ -123,9 +124,9 @@ @PostMapping(value = "/read/{id}") public Result<ExamPaperReadVO> read(@PathVariable Integer id) { ExamPaperReadVO vm = new ExamPaperReadVO(); ExamPaperAnswer examPaperAnswer = examPaperAnswerService.getById(id); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId()); ExamPaperSubmitVO answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId()); ExamPaperScore examPaperScore = examPaperScoreService.getById(id); ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperScore.getPaperId()); ExamPaperSubmitVO answer = examPaperScoreService.examPaperAnswerToVM(examPaperScore.getId()); vm.setPaper(paper); vm.setAnswer(answer); return Result.ok(vm); src/main/java/com/ycl/jxkg/domain/ExamPaperAnswerInfo.java
@@ -2,8 +2,8 @@ import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import lombok.Data; import java.util.List; @@ -13,8 +13,8 @@ public ExamPaper examPaper; public ExamPaperAnswer examPaperAnswer; public ExamPaperScore examPaperScore; public List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers; public List<ExamPaperScoreDetail> examPaperScoreDetails; } src/main/java/com/ycl/jxkg/domain/entity/ExamPaper.java
@@ -78,7 +78,7 @@ private BigDecimal deductTypeScore; /** * 多选评分分数 * 题目格式 * */ @TableField("content") private String content; src/main/java/com/ycl/jxkg/domain/entity/ExamPaperScore.java
File was renamed from src/main/java/com/ycl/jxkg/domain/entity/ExamPaperAnswer.java @@ -7,50 +7,42 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; @Data @TableName("t_exam_paper_answer") public class ExamPaperAnswer extends AbsEntity { @TableField("exam_paper_id") private Integer examPaperId; @TableName("t_exam_paper_score") public class ExamPaperScore extends AbsEntity { /** * 试卷名称 * 考试id */ @TableField("paper_name") private String paperName; @TableField("exam_id") private Integer examId; /** * 试卷类型( 1固定试卷 4.时段试卷 6.任务试卷) * 考试名称 */ @TableField("exam_name") private String examName; @TableField("paper_id") private Integer paperId; /** * 试卷类型( 1固定试卷 2随机试卷 3随序试卷) */ @TableField("paper_type") private Integer paperType; /** * 学科 */ @TableField("subject_id") private Integer subjectId; /** * 系统判定得分 */ @TableField("system_score") private Integer systemScore; /** * 最终得分(千分制) * 最终得分 */ @TableField("user_score") private Integer userScore; private BigDecimal userScore; /** * 试卷总分 */ @TableField("paper_score") private Integer paperScore; private BigDecimal paperScore; /** * 做对题目数量 @@ -83,12 +75,25 @@ private Integer createUser; /** * 提交时间 * 批改人 */ @TableField("judge_user") private Integer judgeUser; /** * 批改时间 */ @TableField(value = "create_time", fill = FieldFill.INSERT) private Date createTime; @TableField("task_exam_id") private Integer taskExamId; /** * 交卷时间 */ @TableField(value = "answer_time") private Date answerTime; /** * 试卷内容 */ @TableField(value = "paper_content") private String paperContent; } src/main/java/com/ycl/jxkg/domain/entity/ExamPaperScoreDetail.java
File was renamed from src/main/java/com/ycl/jxkg/domain/entity/ExamPaperQuestionCustomerAnswer.java @@ -10,8 +10,8 @@ import java.util.Date; @Data @TableName("t_exam_paper_question_customer_answer") public class ExamPaperQuestionCustomerAnswer extends AbsEntity { @TableName("t_exam_paper_score_detail") public class ExamPaperScoreDetail extends AbsEntity { /** * 题目Id src/main/java/com/ycl/jxkg/domain/vo/DoQuestionVO.java
@@ -1,6 +1,5 @@ package com.ycl.jxkg.domain.vo; import com.ycl.jxkg.domain.base.AbsVo; import com.ycl.jxkg.domain.question.QuestionItemObject; import lombok.Data; @@ -46,6 +45,7 @@ /** 音频原始名 */ private String originalFile; private Integer itemOrder; /** 题目选项 */ private List<QuestionItemObject> questionItemList; } src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamPaperMarkAnswerVO.java
New file @@ -0,0 +1,9 @@ package com.ycl.jxkg.domain.vo.admin.exam; import lombok.Data; @Data public class ExamPaperMarkAnswerVO { private Boolean right; private Integer itemOrder; } src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamPaperMarkVO.java
New file @@ -0,0 +1,42 @@ package com.ycl.jxkg.domain.vo.admin.exam; import com.fasterxml.jackson.annotation.JsonFormat; import com.ycl.jxkg.domain.vo.PaperFixQuestionVO; import lombok.Data; import java.math.BigDecimal; import java.util.Date; import java.util.List; @Data public class ExamPaperMarkVO { /** 考试id */ private Integer examId; /** 考试名 */ private String examName; /** 试卷id */ private Integer paperId; /** 试卷类型 */ private Integer paperType; /** 答题学生id */ private Integer userId; /** 答题学生名 */ private String userName; /** 做题时长 */ private Integer doTime; /** 交卷时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date submitTime; /** 得分 */ private String score; /** 试卷总分 */ private String totalScore; /** 多选扣分类型 */ private Integer deductType; /** 多选扣分参数 */ private BigDecimal deductScore; /** 题目 */ private List<PaperFixQuestionVO> titleItems; /** 答案集合(用于前端跳转对应题目) */ private List<ExamPaperMarkAnswerVO> answers; } src/main/java/com/ycl/jxkg/domain/vo/student/exam/ExamPaperSubmitItemVO.java
@@ -5,25 +5,26 @@ import javax.validation.constraints.NotNull; import java.util.List; /** 答题 */ @Data public class ExamPaperSubmitItemVO { private Integer id; @NotNull /** 问题id */ private Integer questionId; /** 是否正确 */ private Boolean doRight; /** 作答内容 */ private String content; /** 排序 */ private Integer itemOrder; /** 多选、填空作答数组 */ private List<String> contentArray; /** 这个题的得分 */ private String score; /** 这个题的总分 */ private String questionScore; } src/main/java/com/ycl/jxkg/domain/vo/student/exam/ExamPaperSubmitVO.java
@@ -13,9 +13,10 @@ @NotNull private Integer id; /** 做题时长 */ @NotNull private Integer doTime; /** 总得分 */ private String score; @NotNull src/main/java/com/ycl/jxkg/enums/general/ExamSubmitTempStatusEnum.java
@@ -12,8 +12,8 @@ @Getter public enum ExamSubmitTempStatusEnum { TEMP("temp", "临时"), FINISH("finish", "完成"), temp("temp", "临时"), finish("finish", "完成"), ; @EnumValue src/main/java/com/ycl/jxkg/listener/CalculateExamPaperAnswerListener.java
@@ -2,14 +2,14 @@ import com.ycl.jxkg.domain.*; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.entity.TextContent; import com.ycl.jxkg.enums.ExamPaperTypeEnum; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.event.CalculateExamPaperAnswerCompleteEvent; import com.ycl.jxkg.service.ExamPaperAnswerService; import com.ycl.jxkg.service.ExamPaperQuestionCustomerAnswerService; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperScoreDetailService; import com.ycl.jxkg.service.TaskExamCustomerAnswerService; import com.ycl.jxkg.service.TextContentService; import org.springframework.beans.factory.annotation.Autowired; @@ -30,23 +30,23 @@ @Component public class CalculateExamPaperAnswerListener implements ApplicationListener<CalculateExamPaperAnswerCompleteEvent> { private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService; private final ExamPaperScoreService examPaperScoreService; private final ExamPaperScoreDetailService examPaperScoreDetailService; private final TextContentService textContentService; private final TaskExamCustomerAnswerService examCustomerAnswerService; /** * Instantiates a new Calculate exam paper answer listener. * * @param examPaperAnswerService the exam paper answer service * @param examPaperQuestionCustomerAnswerService the exam paper question customer answer service * @param examPaperScoreService the exam paper answer service * @param examPaperScoreDetailService the exam paper question customer answer service * @param textContentService the text content service * @param examCustomerAnswerService the exam customer answer service */ @Autowired public CalculateExamPaperAnswerListener(ExamPaperAnswerService examPaperAnswerService, ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService, TextContentService textContentService, TaskExamCustomerAnswerService examCustomerAnswerService) { this.examPaperAnswerService = examPaperAnswerService; this.examPaperQuestionCustomerAnswerService = examPaperQuestionCustomerAnswerService; public CalculateExamPaperAnswerListener(ExamPaperScoreService examPaperScoreService, ExamPaperScoreDetailService examPaperScoreDetailService, TextContentService textContentService, TaskExamCustomerAnswerService examCustomerAnswerService) { this.examPaperScoreService = examPaperScoreService; this.examPaperScoreDetailService = examPaperScoreDetailService; this.textContentService = textContentService; this.examCustomerAnswerService = examCustomerAnswerService; } @@ -58,11 +58,11 @@ ExamPaperAnswerInfo examPaperAnswerInfo = (ExamPaperAnswerInfo) calculateExamPaperAnswerCompleteEvent.getSource(); ExamPaper examPaper = examPaperAnswerInfo.getExamPaper(); ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer(); List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperAnswerInfo.getExamPaperQuestionCustomerAnswers(); ExamPaperScore examPaperScore = examPaperAnswerInfo.getExamPaperScore(); List<ExamPaperScoreDetail> examPaperScoreDetails = examPaperAnswerInfo.getExamPaperScoreDetails(); examPaperAnswerService.save(examPaperAnswer); examPaperQuestionCustomerAnswers.stream().filter(a -> QuestionTypeEnum.needSaveTextContent(a.getQuestionType())).forEach(d -> { examPaperScoreService.save(examPaperScore); examPaperScoreDetails.stream().filter(a -> QuestionTypeEnum.needSaveTextContent(a.getQuestionType())).forEach(d -> { TextContent textContent = new TextContent(); textContent.setContent(d.getAnswer()); textContent.setCreateTime(now); @@ -70,14 +70,14 @@ d.setTextContentId(textContent.getId()); d.setAnswer(null); }); examPaperQuestionCustomerAnswers.forEach(d -> { d.setExamPaperAnswerId(examPaperAnswer.getId()); examPaperScoreDetails.forEach(d -> { d.setExamPaperAnswerId(examPaperScore.getId()); }); examPaperQuestionCustomerAnswerService.insertList(examPaperQuestionCustomerAnswers); examPaperScoreDetailService.insertList(examPaperScoreDetails); switch (ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { case RandomOrder: { examCustomerAnswerService.insertOrUpdate(examPaper, examPaperAnswer, now); examCustomerAnswerService.insertOrUpdate(examPaper, examPaperScore, now); break; } default: src/main/java/com/ycl/jxkg/mapper/ExamPaperScoreDetailMapper.java
File was renamed from src/main/java/com/ycl/jxkg/mapper/ExamPaperQuestionCustomerAnswerMapper.java @@ -1,7 +1,7 @@ package com.ycl.jxkg.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.vo.student.question.answer.QuestionPageStudentRequestVO; @@ -12,13 +12,13 @@ import java.util.List; @Mapper public interface ExamPaperQuestionCustomerAnswerMapper extends BaseMapper<ExamPaperQuestionCustomerAnswer> { public interface ExamPaperScoreDetailMapper extends BaseMapper<ExamPaperScoreDetail> { List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id); List<ExamPaperScoreDetail> selectListByPaperAnswerId(Integer id); List<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVO requestVM); List<ExamPaperScoreDetail> studentPage(QuestionPageStudentRequestVO requestVM); int insertList(List<ExamPaperQuestionCustomerAnswer> list); int insertList(List<ExamPaperScoreDetail> list); Integer selectAllCount(); src/main/java/com/ycl/jxkg/mapper/ExamPaperScoreMapper.java
File was renamed from src/main/java/com/ycl/jxkg/mapper/ExamPaperAnswerMapper.java @@ -1,7 +1,7 @@ package com.ycl.jxkg.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; @@ -13,15 +13,15 @@ import java.util.List; @Mapper public interface ExamPaperAnswerMapper extends BaseMapper<ExamPaperAnswer> { public interface ExamPaperScoreMapper extends BaseMapper<ExamPaperScore> { List<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVO requestVM); List<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM); Integer selectAllCount(); List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime); ExamPaperAnswer getByPidUid(@Param("pid") Integer paperId, @Param("uid") Integer uid); ExamPaperScore getByPidUid(@Param("pid") Integer paperId, @Param("uid") Integer uid); List<ExamPaperAnswerPageResponseVO> adminPage(ExamPaperAnswerPageRequestVO requestVM); src/main/java/com/ycl/jxkg/mapper/MeetMapper.java
@@ -1,12 +1,10 @@ package com.ycl.jxkg.mapper; import com.ycl.jxkg.domain.entity.Meet; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.jxkg.domain.entity.Meet; import com.ycl.jxkg.domain.query.MeetQuery; import com.ycl.jxkg.domain.vo.MeetVO; import com.ycl.jxkg.domain.form.MeetForm; import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; src/main/java/com/ycl/jxkg/service/ExamPaperQuestionCustomerAnswerService.java
File was deleted src/main/java/com/ycl/jxkg/service/ExamPaperScoreDetailService.java
New file @@ -0,0 +1,39 @@ package com.ycl.jxkg.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitItemVO; import com.ycl.jxkg.domain.vo.student.question.answer.QuestionPageStudentRequestVO; import com.github.pagehelper.PageInfo; import java.util.List; public interface ExamPaperScoreDetailService extends IService<ExamPaperScoreDetail> { PageInfo<ExamPaperScoreDetail> studentPage(QuestionPageStudentRequestVO requestVM); List<ExamPaperScoreDetail> selectListByPaperAnswerId(Integer id); /** * 试卷提交答案入库 * * @param examPaperScoreDetails List<ExamPaperQuestionCustomerAnswer> */ void insertList(List<ExamPaperScoreDetail> examPaperScoreDetails); /** * 试卷问题答题信息转成ViewModel 传给前台 * * @param qa ExamPaperQuestionCustomerAnswer * @return ExamPaperSubmitItemVM */ ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperScoreDetail qa); Integer selectAllCount(); List<Integer> selectMothCount(); int updateScore(List<ExamPaperAnswerUpdate> examPaperAnswerUpdates); } src/main/java/com/ycl/jxkg/service/ExamPaperScoreService.java
File was renamed from src/main/java/com/ycl/jxkg/service/ExamPaperAnswerService.java @@ -3,7 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.pagehelper.PageInfo; import com.ycl.jxkg.domain.ExamPaperAnswerInfo; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; @@ -12,7 +12,7 @@ import java.util.List; public interface ExamPaperAnswerService extends IService<ExamPaperAnswer> { public interface ExamPaperScoreService extends IService<ExamPaperScore> { /** * 学生考试记录分页 @@ -20,7 +20,7 @@ * @param requestVM 过滤条件 * @return PageInfo<ExamPaperAnswer> */ PageInfo<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVO requestVM); PageInfo<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM); /** * 计算试卷提交结果(不入库) src/main/java/com/ycl/jxkg/service/ExamService.java
@@ -8,6 +8,7 @@ import com.ycl.jxkg.domain.form.ForceSubmitForm; import com.ycl.jxkg.domain.query.ExamQuery; import com.ycl.jxkg.domain.vo.ExamSubmitVO; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkVO; import com.ycl.jxkg.domain.vo.StartExamVO; import java.util.List; @@ -118,6 +119,14 @@ Result getMarkPaperInfo(Integer examId, Integer userId); /** * 提交阅卷 * * @param examPaperMark * @return */ Result submitMarkPaper(ExamPaperMarkVO examPaperMark); /** * 根据考试id获取监控列表 * @param query 考试id * @return 监控列表 @@ -139,4 +148,7 @@ * @return */ Result forceSubmit(ForceSubmitForm form); } src/main/java/com/ycl/jxkg/service/TaskExamCustomerAnswerService.java
@@ -2,7 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.TaskExamCustomerAnswer; import java.util.Date; @@ -10,7 +10,7 @@ public interface TaskExamCustomerAnswerService extends IService<TaskExamCustomerAnswer> { void insertOrUpdate(ExamPaper examPaper, ExamPaperAnswer examPaperAnswer, Date now); void insertOrUpdate(ExamPaper examPaper, ExamPaperScore examPaperScore, Date now); TaskExamCustomerAnswer selectByTUid(Integer tid, Integer uid); src/main/java/com/ycl/jxkg/service/impl/ExamPaperAnswerServiceImpl.java
File was deleted src/main/java/com/ycl/jxkg/service/impl/ExamPaperScoreDetailServiceImpl.java
File was renamed from src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionCustomerAnswerServiceImpl.java @@ -1,13 +1,13 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScoreDetail; import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.entity.TextContent; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.mapper.ExamPaperQuestionCustomerAnswerMapper; import com.ycl.jxkg.service.ExamPaperQuestionCustomerAnswerService; import com.ycl.jxkg.mapper.ExamPaperScoreDetailMapper; import com.ycl.jxkg.service.ExamPaperScoreDetailService; import com.ycl.jxkg.service.TextContentService; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.ExamUtil; @@ -25,32 +25,32 @@ @Service @RequiredArgsConstructor public class ExamPaperQuestionCustomerAnswerServiceImpl extends ServiceImpl<ExamPaperQuestionCustomerAnswerMapper, ExamPaperQuestionCustomerAnswer> implements ExamPaperQuestionCustomerAnswerService { public class ExamPaperScoreDetailServiceImpl extends ServiceImpl<ExamPaperScoreDetailMapper, ExamPaperScoreDetail> implements ExamPaperScoreDetailService { private final ExamPaperQuestionCustomerAnswerMapper examPaperQuestionCustomerAnswerMapper; private final ExamPaperScoreDetailMapper examPaperScoreDetailMapper; private final TextContentService textContentService; @Override public PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVO requestVM) { public PageInfo<ExamPaperScoreDetail> studentPage(QuestionPageStudentRequestVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> examPaperQuestionCustomerAnswerMapper.studentPage(requestVM) examPaperScoreDetailMapper.studentPage(requestVM) ); } @Override public List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id) { return examPaperQuestionCustomerAnswerMapper.selectListByPaperAnswerId(id); public List<ExamPaperScoreDetail> selectListByPaperAnswerId(Integer id) { return examPaperScoreDetailMapper.selectListByPaperAnswerId(id); } @Override public void insertList(List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers) { examPaperQuestionCustomerAnswerMapper.insertList(examPaperQuestionCustomerAnswers); public void insertList(List<ExamPaperScoreDetail> examPaperScoreDetails) { examPaperScoreDetailMapper.insertList(examPaperScoreDetails); } @Override public ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa) { public ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperScoreDetail qa) { ExamPaperSubmitItemVO examPaperSubmitItemVO = new ExamPaperSubmitItemVO(); examPaperSubmitItemVO.setId(qa.getId()); examPaperSubmitItemVO.setQuestionId(qa.getQuestionId()); @@ -64,14 +64,14 @@ @Override public Integer selectAllCount() { return examPaperQuestionCustomerAnswerMapper.selectAllCount(); return examPaperScoreDetailMapper.selectAllCount(); } @Override public List<Integer> selectMothCount() { Date startTime = DateTimeUtil.getMonthStartDay(); Date endTime = DateTimeUtil.getMonthEndDay(); List<KeyValue> mouthCount = examPaperQuestionCustomerAnswerMapper.selectCountByDate(startTime, endTime); List<KeyValue> mouthCount = examPaperScoreDetailMapper.selectCountByDate(startTime, endTime); List<String> mothStartToNowFormat = DateTimeUtil.MothStartToNowFormat(); return mothStartToNowFormat.stream().map(md -> { KeyValue keyValue = mouthCount.stream().filter(kv -> kv.getName().equals(md)).findAny().orElse(null); @@ -81,27 +81,27 @@ @Override public int updateScore(List<ExamPaperAnswerUpdate> examPaperAnswerUpdates) { return examPaperQuestionCustomerAnswerMapper.updateScore(examPaperAnswerUpdates); return examPaperScoreDetailMapper.updateScore(examPaperAnswerUpdates); } private void setSpecialToVM(ExamPaperSubmitItemVO examPaperSubmitItemVO, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) { QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType()); private void setSpecialToVM(ExamPaperSubmitItemVO examPaperSubmitItemVO, ExamPaperScoreDetail examPaperScoreDetail) { QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperScoreDetail.getQuestionType()); switch (questionTypeEnum) { case MultipleChoice: examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer()); examPaperSubmitItemVO.setContentArray(ExamUtil.contentToArray(examPaperQuestionCustomerAnswer.getAnswer())); examPaperSubmitItemVO.setContent(examPaperScoreDetail.getAnswer()); examPaperSubmitItemVO.setContentArray(ExamUtil.contentToArray(examPaperScoreDetail.getAnswer())); break; case GapFilling: TextContent textContent = textContentService.getById(examPaperQuestionCustomerAnswer.getTextContentId()); TextContent textContent = textContentService.getById(examPaperScoreDetail.getTextContentId()); List<String> correctAnswer = JsonUtil.toJsonListObject(textContent.getContent(), String.class); examPaperSubmitItemVO.setContentArray(correctAnswer); break; default: if (QuestionTypeEnum.needSaveTextContent(examPaperQuestionCustomerAnswer.getQuestionType())) { TextContent content = textContentService.getById(examPaperQuestionCustomerAnswer.getTextContentId()); if (QuestionTypeEnum.needSaveTextContent(examPaperScoreDetail.getQuestionType())) { TextContent content = textContentService.getById(examPaperScoreDetail.getTextContentId()); examPaperSubmitItemVO.setContent(content.getContent()); } else { examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer()); examPaperSubmitItemVO.setContent(examPaperScoreDetail.getAnswer()); } break; } src/main/java/com/ycl/jxkg/service/impl/ExamPaperScoreServiceImpl.java
New file @@ -0,0 +1,284 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ycl.jxkg.domain.ExamPaperAnswerInfo; import com.ycl.jxkg.domain.entity.*; import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitItemVO; 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.enums.ExamPaperAnswerStatusEnum; import com.ycl.jxkg.enums.ExamPaperTypeEnum; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.mapper.ExamPaperScoreMapper; import com.ycl.jxkg.mapper.ExamPaperMapper; import com.ycl.jxkg.mapper.QuestionMapper; import com.ycl.jxkg.mapper.TaskExamCustomerAnswerMapper; import com.ycl.jxkg.service.ExamPaperScoreService; import com.ycl.jxkg.service.ExamPaperScoreDetailService; import com.ycl.jxkg.service.TextContentService; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.ExamUtil; import com.ycl.jxkg.utils.JsonUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class ExamPaperScoreServiceImpl extends ServiceImpl<ExamPaperScoreMapper, ExamPaperScore> implements ExamPaperScoreService { private final ExamPaperScoreMapper examPaperScoreMapper; private final ExamPaperMapper examPaperMapper; private final TextContentService textContentService; private final QuestionMapper questionMapper; private final ExamPaperScoreDetailService examPaperScoreDetailService; private final TaskExamCustomerAnswerMapper taskExamCustomerAnswerMapper; @Override public PageInfo<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> examPaperScoreMapper.studentPage(requestVM)); } @Override public ExamPaperAnswerInfo calculateExamPaperAnswer(ExamPaperSubmitVO examPaperSubmitVO, User user) { ExamPaperAnswerInfo examPaperAnswerInfo = new ExamPaperAnswerInfo(); Date now = new Date(); ExamPaper examPaper = examPaperMapper.selectById(examPaperSubmitVO.getId()); ExamPaperTypeEnum paperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType()); //任务试卷只能做一次 if (paperTypeEnum == ExamPaperTypeEnum.RandomOrder) { ExamPaperScore examPaperScore = examPaperScoreMapper.getByPidUid(examPaperSubmitVO.getId(), user.getId()); if (null != examPaperScore) return null; } //TODO:待完成 // String frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()).getContent(); // List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class); // List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList()); // List<Question> questions = questionMapper.selectByIds(questionIds); // //将题目结构的转化为题目答案 // List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperTitleItemObjects.stream() // .flatMap(t -> t.getQuestionItems().stream() // .map(q -> { // Question question = questions.stream().filter(tq -> tq.getId().equals(q.getId())).findFirst().get(); // ExamPaperSubmitItemVO customerQuestionAnswer = examPaperSubmitVO.getAnswerItems().stream() // .filter(tq -> tq.getQuestionId().equals(q.getId())) // .findFirst() // .orElse(null); // return ExamPaperQuestionCustomerAnswerFromVM(question, customerQuestionAnswer, examPaper, q.getItemOrder(), user, now); // }) // ).collect(Collectors.toList()); // // ExamPaperAnswer examPaperAnswer = ExamPaperAnswerFromVM(examPaperSubmitVO, examPaper, examPaperQuestionCustomerAnswers, user, now); // examPaperAnswerInfo.setExamPaper(examPaper); // examPaperAnswerInfo.setExamPaperAnswer(examPaperAnswer); // examPaperAnswerInfo.setExamPaperQuestionCustomerAnswers(examPaperQuestionCustomerAnswers); return examPaperAnswerInfo; } @Override @Transactional public String judge(ExamPaperSubmitVO examPaperSubmitVO) { // ExamPaperScore examPaperScore = examPaperScoreMapper.selectById(examPaperSubmitVO.getId()); // List<ExamPaperSubmitItemVO> judgeItems = examPaperSubmitVO.getAnswerItems().stream().filter(d -> d.getDoRight() == null).collect(Collectors.toList()); // List<ExamPaperAnswerUpdate> examPaperAnswerUpdates = new ArrayList<>(judgeItems.size()); // Integer customerScore = examPaperScore.getUserScore(); // Integer questionCorrect = examPaperScore.getQuestionCorrect(); // for (ExamPaperSubmitItemVO d : judgeItems) { // ExamPaperAnswerUpdate examPaperAnswerUpdate = new ExamPaperAnswerUpdate(); // examPaperAnswerUpdate.setId(d.getId()); // examPaperAnswerUpdate.setCustomerScore(ExamUtil.scoreFromVM(d.getScore())); // boolean doRight = examPaperAnswerUpdate.getCustomerScore().equals(ExamUtil.scoreFromVM(d.getQuestionScore())); // examPaperAnswerUpdate.setDoRight(doRight); // examPaperAnswerUpdates.add(examPaperAnswerUpdate); // customerScore += examPaperAnswerUpdate.getCustomerScore(); // if (examPaperAnswerUpdate.getDoRight()) { // ++questionCorrect; // } // } // examPaperScore.setUserScore(customerScore); // examPaperScore.setQuestionCorrect(questionCorrect); // examPaperScore.setStatus(ExamPaperAnswerStatusEnum.Complete.getCode()); // examPaperScoreMapper.updateById(examPaperScore); // examPaperScoreDetailService.updateScore(examPaperAnswerUpdates); // // ExamPaperTypeEnum examPaperTypeEnum = ExamPaperTypeEnum.fromCode(examPaperScore.getPaperType()); // switch (examPaperTypeEnum) { // case RandomOrder: //TODO:待完成 //任务试卷批改完成后,需要更新任务的状态 // ExamPaper examPaper = examPaperMapper.selectById(examPaperAnswer.getExamPaperId()); // Integer taskId = examPaper.getTaskExamId(); // Integer userId = examPaperAnswer.getCreateUser(); // TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswerMapper.getByTUid(taskId, userId); // TextContent textContent = textContentService.getById(taskExamCustomerAnswer.getTextContentId()); // List<TaskItemAnswerObject> taskItemAnswerObjects = JsonUtil.toJsonListObject(textContent.getContent(), TaskItemAnswerObject.class); // taskItemAnswerObjects.stream() // .filter(d -> d.getExamPaperAnswerId().equals(examPaperAnswer.getId())) // .findFirst().ifPresent(taskItemAnswerObject -> taskItemAnswerObject.setStatus(examPaperAnswer.getStatus())); // textContentService.jsonConvertUpdate(textContent, taskItemAnswerObjects, null); // textContentService.updateById(textContent); // break; // default: // break; // } // return ExamUtil.scoreToVM(customerScore); return "1"; } @Override public ExamPaperSubmitVO examPaperAnswerToVM(Integer id) { ExamPaperSubmitVO examPaperSubmitVO = new ExamPaperSubmitVO(); // ExamPaperScore examPaperScore = examPaperScoreMapper.selectById(id); // examPaperSubmitVO.setId(examPaperScore.getId()); // examPaperSubmitVO.setDoTime(examPaperScore.getDoTime()); // examPaperSubmitVO.setScore(ExamUtil.scoreToVM(examPaperScore.getUserScore())); // List<ExamPaperScoreDetail> examPaperScoreDetails = examPaperScoreDetailService.selectListByPaperAnswerId(examPaperScore.getId()); // List<ExamPaperSubmitItemVO> examPaperSubmitItemVOS = examPaperScoreDetails.stream() // .map(a -> examPaperScoreDetailService.examPaperQuestionCustomerAnswerToVM(a)) // .collect(Collectors.toList()); // examPaperSubmitVO.setAnswerItems(examPaperSubmitItemVOS); return examPaperSubmitVO; } @Override public Integer selectAllCount() { return examPaperScoreMapper.selectAllCount(); } @Override public List<Integer> selectMothCount() { Date startTime = DateTimeUtil.getMonthStartDay(); Date endTime = DateTimeUtil.getMonthEndDay(); List<KeyValue> mouthCount = examPaperScoreMapper.selectCountByDate(startTime, endTime); List<String> mothStartToNowFormat = DateTimeUtil.MothStartToNowFormat(); return mothStartToNowFormat.stream().map(md -> { KeyValue keyValue = mouthCount.stream().filter(kv -> kv.getName().equals(md)).findAny().orElse(null); return null == keyValue ? 0 : keyValue.getValue(); }).collect(Collectors.toList()); } /** * 用户提交答案的转化存储对象 * * @param question question * @param customerQuestionAnswer customerQuestionAnswer * @param examPaper examPaper * @param itemOrder itemOrder * @param user user * @param now now * @return ExamPaperQuestionCustomerAnswer */ private ExamPaperScoreDetail ExamPaperQuestionCustomerAnswerFromVM(Question question, ExamPaperSubmitItemVO customerQuestionAnswer, ExamPaper examPaper, Integer itemOrder, User user, Date now) { ExamPaperScoreDetail examPaperScoreDetail = new ExamPaperScoreDetail(); examPaperScoreDetail.setQuestionId(question.getId()); examPaperScoreDetail.setExamPaperId(examPaper.getId()); examPaperScoreDetail.setQuestionScore(null); examPaperScoreDetail.setSubjectId(examPaper.getSubjectId()); examPaperScoreDetail.setItemOrder(itemOrder); examPaperScoreDetail.setCreateTime(now); examPaperScoreDetail.setCreateUser(user.getId()); examPaperScoreDetail.setQuestionType(question.getQuestionType()); examPaperScoreDetail.setQuestionContent(question.getContent()); if (null == customerQuestionAnswer) { examPaperScoreDetail.setCustomerScore(0); } else { setSpecialFromVM(examPaperScoreDetail, question, customerQuestionAnswer); } return examPaperScoreDetail; } /** * 判断提交答案是否正确,保留用户提交的答案 * * @param examPaperScoreDetail examPaperQuestionCustomerAnswer * @param question question * @param customerQuestionAnswer customerQuestionAnswer */ private void setSpecialFromVM(ExamPaperScoreDetail examPaperScoreDetail, Question question, ExamPaperSubmitItemVO customerQuestionAnswer) { QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperScoreDetail.getQuestionType()); switch (questionTypeEnum) { case SingleChoice: case TrueFalse: examPaperScoreDetail.setAnswer(customerQuestionAnswer.getContent()); examPaperScoreDetail.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent())); examPaperScoreDetail.setCustomerScore(examPaperScoreDetail.getDoRight() ? null : 0); break; case MultipleChoice: String customerAnswer = ExamUtil.contentToString(customerQuestionAnswer.getContentArray()); examPaperScoreDetail.setAnswer(customerAnswer); examPaperScoreDetail.setDoRight(customerAnswer.equals(question.getCorrect())); examPaperScoreDetail.setCustomerScore(examPaperScoreDetail.getDoRight() ? null : 0); break; case GapFilling: String correctAnswer = JsonUtil.toJsonStr(customerQuestionAnswer.getContentArray()); examPaperScoreDetail.setAnswer(correctAnswer); examPaperScoreDetail.setCustomerScore(0); break; default: examPaperScoreDetail.setAnswer(customerQuestionAnswer.getContent()); examPaperScoreDetail.setCustomerScore(0); break; } } private ExamPaperScore ExamPaperAnswerFromVM(ExamPaperSubmitVO examPaperSubmitVO, ExamPaper examPaper, List<ExamPaperScoreDetail> examPaperScoreDetails, User user, Date now) { Integer systemScore = examPaperScoreDetails.stream().mapToInt(a -> a.getCustomerScore()).sum(); long questionCorrect = examPaperScoreDetails.stream().filter(a -> a.getCustomerScore().equals(a.getQuestionScore())).count(); ExamPaperScore examPaperScore = new ExamPaperScore(); //TODO:待完成 // examPaperAnswer.setPaperName(examPaper.getName()); // examPaperAnswer.setDoTime(examPaperSubmitVO.getDoTime()); // examPaperAnswer.setExamPaperId(examPaper.getId()); // examPaperAnswer.setCreateUser(user.getId()); // examPaperAnswer.setCreateTime(now); // examPaperAnswer.setSubjectId(examPaper.getSubjectId()); // examPaperAnswer.setQuestionCount(examPaper.getQuestionCount()); // examPaperAnswer.setPaperScore(examPaper.getScore()); // examPaperAnswer.setPaperType(examPaper.getPaperType()); // examPaperAnswer.setSystemScore(systemScore); // examPaperAnswer.setUserScore(systemScore); // examPaperAnswer.setTaskExamId(examPaper.getTaskExamId()); // examPaperAnswer.setQuestionCorrect((int) questionCorrect); // boolean needJudge = examPaperQuestionCustomerAnswers.stream().anyMatch(d -> QuestionTypeEnum.needSaveTextContent(d.getQuestionType())); // if (needJudge) { // examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.WaitJudge.getCode()); // } else { // examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.Complete.getCode()); // } return examPaperScore; } @Override public PageInfo<ExamPaperAnswerPageResponseVO> adminPage(ExamPaperAnswerPageRequestVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize()).doSelectPageInfo(() -> examPaperScoreMapper.adminPage(requestVM)); } @Override public List<ExamPaperAnswerPageResponseVO> list(ExamPaperAnswerPageRequestVO requestVM) { return examPaperScoreMapper.adminPage(requestVM); } @Override public PageInfo<ExamPaperAnswerPageResponseVO> pageExamPaper(ExamPaperAnswerPageRequestVO model) { return PageHelper.startPage(model.getPageIndex(), model.getPageSize()).doSelectPageInfo(() -> examPaperScoreMapper.pageExamPaper(model)); } } src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -2,14 +2,13 @@ import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.base.SystemCode; import com.ycl.jxkg.context.WebContext; import com.ycl.jxkg.domain.entity.Exam; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamSubmitTemp; import com.ycl.jxkg.domain.entity.Question; import com.ycl.jxkg.domain.entity.*; import com.ycl.jxkg.domain.exam.PaperFixQuestionDTO; import com.ycl.jxkg.domain.exam.PaperQuestionSettingDTO; import com.ycl.jxkg.domain.form.AddTimeForm; @@ -18,6 +17,12 @@ import com.ycl.jxkg.domain.query.ExamQuery; import com.ycl.jxkg.domain.question.QuestionObject; import com.ycl.jxkg.domain.vo.*; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkAnswerVO; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperReadVO; import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; import com.ycl.jxkg.enums.DeductTypeEnum; import com.ycl.jxkg.enums.ExamPaperTypeEnum; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.enums.WebsocketCommendEnum; @@ -27,14 +32,18 @@ import com.ycl.jxkg.server.WebsocketServer; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.service.ExamService; import com.ycl.jxkg.utils.JsonUtil; import com.ycl.jxkg.utils.PageUtil; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Bean; import org.springframework.transaction.annotation.Transactional; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -56,6 +65,9 @@ private final ExamPaperMapper examPaperMapper; private final ExamPaperService examPaperService; private final WebsocketServer websocketServer; private final UserMapper userMapper; private final ExamPaperScoreMapper examPaperScoreMapper; private final ExamPaperScoreDetailMapper examPaperScoreDetailMapper; /** * 添加 @@ -124,11 +136,11 @@ IPage<ExamVO> page = PageUtil.getPage(query, ExamVO.class); baseMapper.getPage(page, query, webContext.getCurrentUser().getId()); page.getRecords().stream().forEach(item -> { if (! StringUtils.hasText(item.getClassName())) { if (!StringUtils.hasText(item.getClassName())) { item.setClassName("班级不存在或被删除"); item.setClassesId(null); } if (! StringUtils.hasText(item.getExamPaperName())) { if (!StringUtils.hasText(item.getExamPaperName())) { item.setExamPaperName("试卷不存在或被删除"); item.setExamPaperId(null); } @@ -191,7 +203,7 @@ return Result.ok().data(data); } else if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) { // 根据随机试卷的配置,随机生成对应题目 if (! StringUtils.hasText(examPaper.getContent())) { if (!StringUtils.hasText(examPaper.getContent())) { throw new RuntimeException("试卷配置异常,请联系老师"); } List<PaperQuestionSettingDTO> paperSettingList = JSON.parseArray(examPaper.getContent(), PaperQuestionSettingDTO.class); @@ -226,11 +238,13 @@ } ExamSubmitTemp examSubmitTemp = new ExamSubmitTemp(); examSubmitTemp.setExamId(id); examSubmitTemp.setStatus(ExamSubmitTempStatusEnum.TEMP); //TODO examSubmitTemp.setStatus(ExamSubmitTempStatusEnum.temp); examSubmitTemp.setExamSubmit(JSON.toJSONString(examData)); examSubmitTemp.setCreateTime(new Date()); examSubmitTemp.setUserId(webContext.getCurrentUser().getId()); examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.TEMP); //TODO examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.temp); examSubmitTempMapper.insert(examSubmitTemp); StartExamVO startExamVO = new StartExamVO(); startExamVO.setExamName(exam.getExamName()); @@ -249,7 +263,7 @@ * @return */ private List<PaperFixQuestionVO> coverTo(ExamPaper examPaper) { if (! StringUtils.hasText(examPaper.getContent())) { if (!StringUtils.hasText(examPaper.getContent())) { throw new RuntimeException("试卷未配置题目,请联系老师"); } List<PaperFixQuestionDTO> questionWarpList = JSON.parseArray(examPaper.getContent(), PaperFixQuestionDTO.class); @@ -350,7 +364,8 @@ // 阅卷后才往exam_paper_answer保存考试成绩、以及保存到exam_paper_customer_answer // 现在只需要保存到一张临时表 // 该接口是主动提交,所以状态都设置为完成,以便后续老师阅卷 saveTempExam(submitData, ExamSubmitTempStatusEnum.FINISH); //TODO saveTempExam(submitData, ExamSubmitTempStatusEnum.finish); return Result.ok(); } @@ -362,38 +377,45 @@ */ @Override public Result timingSubmit(StartExamVO submitData) { saveTempExam(submitData, ExamSubmitTempStatusEnum.TEMP); //TODO saveTempExam(submitData, ExamSubmitTempStatusEnum.temp); return Result.ok(); } /** * 保存试卷:如果接口是定时保存那么是临时试卷。如果接口是自主提交那么是完成试卷 * * @param submitData 前端传递的试卷数据 * @param status 试卷的状态 * @param submitData 前端传递的试卷数据 * @param status 试卷的状态 */ public void saveTempExam(StartExamVO submitData, ExamSubmitTempStatusEnum status) { ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper) .eq(ExamSubmitTemp::getExamId, submitData.getId()) .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) .eq(ExamSubmitTemp::getDeleted,0) .one(); if (Objects.nonNull(one)) { if (ExamSubmitTempStatusEnum.FINISH.equals(one.getStatus())) { long doTimeL = one.getUpdateTime().getTime() - one.getCreateTime().getTime(); Integer doTime = (int) doTimeL; //TODO if (ExamSubmitTempStatusEnum.finish.equals(one.getStatus())) { return; } one.setDoTime(submitData.getDoTime()); one.setDoTime(doTime); one.setExamSubmit(JSON.toJSONString(submitData.getTitleList())); one.setCreateTime(new Date()); one.setUpdateTime(new Date()); one.setStatus(status); examSubmitTempMapper.updateById(one); } else { ExamSubmitTemp examSubmitTemp = new ExamSubmitTemp(); examSubmitTemp.setExamId(submitData.getId()); examSubmitTemp.setDoTime(submitData.getDoTime()); examSubmitTemp.setDoTime(0); examSubmitTemp.setStatus(status); examSubmitTemp.setUserId(webContext.getCurrentUser().getId()); examSubmitTemp.setExamSubmit(JSON.toJSONString(submitData.getTitleList())); examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.TEMP); //TODO examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.temp); examSubmitTempMapper.insert(examSubmitTemp); } } @@ -414,7 +436,8 @@ // 参考人数 Integer joinExamNum = examSubmitTempList.size(); // 参考但未完成提交人数 Integer joinButNotFinishedNum = Math.toIntExact(examSubmitTempList.stream().filter(item -> ExamSubmitTempStatusEnum.TEMP.equals(item.getStatus())).count()); //TODO Integer joinButNotFinishedNum = Math.toIntExact(examSubmitTempList.stream().filter(item -> ExamSubmitTempStatusEnum.temp.equals(item.getStatus())).count()); List<StudentExamInfoVO> studentExamList = classesUserMapper.getClassesUserList(exam.getClassesId()); // 应考人数 @@ -442,6 +465,7 @@ @Override public Result getMarkPaperInfo(Integer examId, Integer userId) { //学生答题表 ExamSubmitTemp userExam = new LambdaQueryChainWrapper<>(examSubmitTempMapper) .eq(ExamSubmitTemp::getExamId, examId) .eq(ExamSubmitTemp::getUserId, userId) @@ -449,14 +473,214 @@ if (Objects.isNull(userExam)) { throw new RuntimeException("该学员考试记录不存在"); } ExamSubmitVO vo = new ExamSubmitVO(); vo.setExamId(userExam.getExamId()); vo.setDoTime(userExam.getDoTime()); vo.setUpdateTime(userExam.getUpdateTime()); if (StringUtils.hasText(userExam.getExamSubmit())) { vo.setPaperQuestionList(JSON.parseArray(userExam.getExamSubmit(), PaperFixQuestionVO.class)); ExamVO exam = examMapper.getById(examId); User student = userMapper.getUserById(userId); //封装阅卷基本数据 ExamPaperMarkVO paperMarkVO = createVO(userExam, exam, student); //TODO:补充题目答案、解析 List<PaperFixQuestionVO> titleItems = paperMarkVO.getTitleItems(); for (PaperFixQuestionVO titleItem : titleItems) { for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) { } } return Result.ok(vo); //阅卷,客观题打分 Result InnerError = markPaper(paperMarkVO); if (InnerError != null) return InnerError; return Result.ok(paperMarkVO); } //提交批改 @Override @Transactional(rollbackFor = Exception.class) public Result submitMarkPaper(ExamPaperMarkVO examPaperMark) { Integer userId = webContext.getCurrentUser().getId(); //插入exam_paper_answer(成绩表) ExamPaperScore examPaperScore = new ExamPaperScore(); BeanUtils.copyProperties(examPaperMark,examPaperScore); examPaperScore.setUserScore(new BigDecimal(examPaperMark.getScore())); examPaperScore.setPaperScore(new BigDecimal(examPaperMark.getTotalScore())); examPaperScore.setJudgeUser(userId); examPaperScore.setCreateUser(examPaperMark.getUserId()); examPaperScore.setAnswerTime(examPaperMark.getSubmitTime()); examPaperScore.setPaperContent(JSON.toJSONString(examPaperMark.getTitleItems())); long questionCorrect =0; long questionCount=0; if(!CollectionUtils.isEmpty(examPaperMark.getAnswers())){ questionCorrect = examPaperMark.getAnswers().stream().filter(ExamPaperMarkAnswerVO::getRight).count(); questionCount = examPaperMark.getAnswers().size(); } examPaperScore.setQuestionCorrect(Integer.valueOf(questionCorrect+"")); examPaperScore.setQuestionCount(Integer.valueOf(questionCount+"")); examPaperScoreMapper.insert(examPaperScore); return Result.ok(); } //阅卷 private Result markPaper(ExamPaperMarkVO paperMarkVO) { List<PaperFixQuestionVO> titleItems = paperMarkVO.getTitleItems(); //初始化题目序号 Integer num = 1; List<ExamPaperMarkAnswerVO> answers = new ArrayList<>(); for (PaperFixQuestionVO titleItem : titleItems) { for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) { //准备题目序号供前端跳转使用 ExamPaperMarkAnswerVO answerVO = new ExamPaperMarkAnswerVO(); //获取试卷类型 Integer questionType = doQuestionVO.getQuestionType(); /* 如果是简答、计算、分析,不设置right只设置题目序号 */ if (QuestionTypeEnum.ShortAnswer.getCode().equals(questionType) || QuestionTypeEnum.Calculate.getCode().equals(questionType) || QuestionTypeEnum.Analysis.getCode().equals(questionType)) { answerVO.setItemOrder(num); doQuestionVO.setItemOrder(num); } /* 如果是单选、语音、判断(判断答案是A、B) */ else if (QuestionTypeEnum.SingleChoice.getCode().equals(questionType) || QuestionTypeEnum.Audio.getCode().equals(questionType) || QuestionTypeEnum.TrueFalse.getCode().equals(questionType)) { answerVO.setItemOrder(num); doQuestionVO.setItemOrder(num); if (StringUtils.isEmpty(doQuestionVO.getQuestionAnswer())) { return Result.fail(SystemCode.InnerError.getCode(), doQuestionVO.getTitle() + ",此题目缺少答案,请先完善"); } trueOrFalse(doQuestionVO, answerVO, doQuestionVO.getQuestionAnswer().equals(doQuestionVO.getAnswer())); } /* 如果是多选 */ else if (QuestionTypeEnum.MultipleChoice.getCode().equals(questionType)) { answerVO.setItemOrder(num); doQuestionVO.setItemOrder(num); if (StringUtils.isEmpty(doQuestionVO.getQuestionAnswer())) { return Result.fail(SystemCode.InnerError.getCode(), doQuestionVO.getTitle() + ",此题目缺少答案,请先完善"); } //学生答案 List<String> answerList = doQuestionVO.getAnswerList(); String questionAnswer = doQuestionVO.getQuestionAnswer(); //题目答案 List<String> questionAnswerList = Arrays.asList(questionAnswer.split(",")); //学生答案为空,判断为错 if (CollectionUtils.isEmpty(answerList)) { trueOrFalse(doQuestionVO, answerVO, false); continue; } //答案数量,不需要考虑顺序 int answerCount = answerList.size(); Set<String> set1 = new HashSet<>(answerList); Set<String> set2 = new HashSet<>(questionAnswerList); //答案完全一致,满分 if (set1.equals(set2)) { trueOrFalse(doQuestionVO, answerVO, true); continue; } if (paperMarkVO.getDeductType() == null) { return Result.fail(SystemCode.InnerError.getCode(), "试卷没有配置多选得分类型,请联系管理员"); } //如果多选得分类型为 答错不得分 if (Integer.valueOf(DeductTypeEnum.AllCorrect.getCode()).equals(paperMarkVO.getDeductType())) { trueOrFalse(doQuestionVO, answerVO, false); } //如果多选得分类型为 漏选得固定分值,包含错误选项不得分 else if (Integer.valueOf(DeductTypeEnum.PartCorrect.getCode()).equals(paperMarkVO.getDeductType())) { //学生答案移除所有正确答案,如果还有元素说明包含错误选项 answerList.removeAll(questionAnswerList); if (!CollectionUtils.isEmpty(answerList)) { trueOrFalse(doQuestionVO, answerVO, false); } else { answerVO.setRight(false); doQuestionVO.setRight(false); //漏选得固定分 doQuestionVO.setScore(paperMarkVO.getDeductScore()); } } //如果多选得分类型为 每对一题得相应分值,包含错误选项不得分 else if (Integer.valueOf(DeductTypeEnum.EachCorrect.getCode()).equals(paperMarkVO.getDeductType())) { //学生答案移除所有正确答案,如果还有元素说明包含错误选项 answerList.removeAll(questionAnswerList); if (!CollectionUtils.isEmpty(answerList)) { trueOrFalse(doQuestionVO, answerVO, false); } else { answerVO.setRight(false); doQuestionVO.setRight(false); //漏选得分 doQuestionVO.setScore(paperMarkVO.getDeductScore().multiply(new BigDecimal(answerCount))); } } } /* 如果是填空 */ else if (QuestionTypeEnum.GapFilling.getCode().equals(questionType)) { answerVO.setItemOrder(num); doQuestionVO.setItemOrder(num); if (StringUtils.isEmpty(doQuestionVO.getQuestionAnswer())) { return Result.fail(SystemCode.InnerError.getCode(), doQuestionVO.getTitle() + ",此题目缺少答案,请先完善"); } //学生答案 List<String> answerList = doQuestionVO.getAnswerList(); String questionAnswer = doQuestionVO.getQuestionAnswer(); //题目答案 List<String> questionAnswerList = Arrays.asList(questionAnswer.split(",")); //学生答案为空,判断为错 if (CollectionUtils.isEmpty(answerList)) { trueOrFalse(doQuestionVO, answerVO, false); continue; } //总空的数量 int questionAnswerCount = questionAnswerList.size(); //答案完全一致,满分 if (answerList.equals(questionAnswerList)) { trueOrFalse(doQuestionVO, answerVO, true); } else { answerVO.setRight(false); doQuestionVO.setRight(false); //做对的数量,需要按顺序比较 int count = 0; for (int i = 0; i < answerList.size(); i++) { if(answerList.get(i).equals(questionAnswerList.get(i))){ count++; } } //这个题的总分 BigDecimal questionScore = doQuestionVO.getQuestionScore(); //每个空的分数 BigDecimal scoreEach = questionScore.divide(new BigDecimal(questionAnswerCount), 1, RoundingMode.DOWN); BigDecimal score = scoreEach.multiply(new BigDecimal(count)); doQuestionVO.setScore(score); } } num++; answers.add(answerVO); } } paperMarkVO.setAnswers(answers); return null; } //设置全对或全错 private void trueOrFalse(DoQuestionVO doQuestionVO, ExamPaperMarkAnswerVO answerVO, Boolean isCorrect) { if (isCorrect) { //正确 answerVO.setRight(isCorrect); doQuestionVO.setRight(isCorrect); doQuestionVO.setScore(doQuestionVO.getQuestionScore()); } else { //错误 answerVO.setRight(isCorrect); doQuestionVO.setRight(isCorrect); doQuestionVO.setScore(BigDecimal.ZERO); } } //封装阅卷返回数据 private ExamPaperMarkVO createVO(ExamSubmitTemp userExam, ExamVO exam, User student) { ExamPaperMarkVO paperMarkVO = new ExamPaperMarkVO(); BeanUtils.copyProperties(userExam, paperMarkVO); paperMarkVO.setPaperId(exam.getExamPaperId()); //TODO: 试卷总分、(多选得分类型、多选得分分数)需要取ExamSubmitTemp paperMarkVO.setExamName(exam.getExamName()); paperMarkVO.setPaperType(exam.getExamPaperType()); paperMarkVO.setSubmitTime(userExam.getUpdateTime()); paperMarkVO.setUserName(student.getRealName()); paperMarkVO.setTitleItems(JSON.parseArray(userExam.getExamSubmit(), PaperFixQuestionVO.class)); paperMarkVO.setTotalScore("100"); paperMarkVO.setDeductType(DeductTypeEnum.AllCorrect.getCode()); paperMarkVO.setDeductScore(BigDecimal.ZERO); return paperMarkVO; } @Override src/main/java/com/ycl/jxkg/service/impl/MeetServiceImpl.java
@@ -2,6 +2,7 @@ import com.alibaba.fastjson2.JSONArray; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.jxkg.base.SystemCode; import com.ycl.jxkg.context.WebContext; import com.ycl.jxkg.domain.entity.Meet; import com.ycl.jxkg.enums.MeetStatusEnum; @@ -140,7 +141,11 @@ public Result detail(Integer id) { MeetVO vo = baseMapper.getById(id); Assert.notNull(vo, "记录不存在"); return Result.ok().data(vo); if(vo.getStatus().equals(MeetStatusEnum.Starting.getCode())){ return Result.ok(); }else { return Result.fail(SystemCode.InnerError.getCode(),"房间尚未开始或已结束"); } } /** src/main/java/com/ycl/jxkg/service/impl/TaskExamCustomerAnswerImpl.java
@@ -2,18 +2,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamPaperAnswer; import com.ycl.jxkg.domain.entity.ExamPaperScore; import com.ycl.jxkg.domain.entity.TaskExamCustomerAnswer; import com.ycl.jxkg.domain.entity.TextContent; import com.ycl.jxkg.domain.task.TaskItemAnswerObject; import com.ycl.jxkg.mapper.TaskExamCustomerAnswerMapper; import com.ycl.jxkg.service.TaskExamCustomerAnswerService; import com.ycl.jxkg.service.TextContentService; import com.ycl.jxkg.utils.JsonUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -25,7 +21,7 @@ private final TextContentService textContentService; @Override public void insertOrUpdate(ExamPaper examPaper, ExamPaperAnswer examPaperAnswer, Date now) { public void insertOrUpdate(ExamPaper examPaper, ExamPaperScore examPaperScore, Date now) { //TODO:待完成 // Integer taskId = examPaper.getTaskExamId(); // Integer userId = examPaperAnswer.getCreateUser(); src/main/resources/application-dev.yml
@@ -3,7 +3,7 @@ upload: # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) url: E:/ycl/file url: D:/ycl/file spring: datasource: src/main/resources/mapper/ClassesUserMapper.xml
@@ -18,10 +18,10 @@ <result column="real_name" property="realName"/> <result column="do_time" property="doTime"/> <result column="exam_submit" property="examSubmit"/> <result column="status" property="status" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/> <result column="status" property="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> <result column="phone" property="phone"/> <result column="update_time" property="updateTime"/> <result column="mark_paper_status" property="markPaperStatus" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/> <result column="mark_paper_status" property="markPaperStatus" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> </resultMap> src/main/resources/mapper/ExamPaperScoreDetailMapper.xml
File was renamed from src/main/resources/mapper/ExamPaperQuestionCustomerAnswerMapper.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ycl.jxkg.mapper.ExamPaperQuestionCustomerAnswerMapper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaperQuestionCustomerAnswer"> <mapper namespace="com.ycl.jxkg.mapper.ExamPaperScoreDetailMapper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaperScoreDetail"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="question_id" jdbcType="INTEGER" property="questionId"/> <result column="exam_paper_id" jdbcType="INTEGER" property="examPaperId"/> src/main/resources/mapper/ExamPaperScoreMapper.xml
File was renamed from src/main/resources/mapper/ExamPaperAnswerMapper.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ycl.jxkg.mapper.ExamPaperAnswerMapper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaperAnswer"> <mapper namespace="com.ycl.jxkg.mapper.ExamPaperScoreMapper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaperScore"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="exam_paper_id" jdbcType="INTEGER" property="examPaperId"/> <result column="paper_name" jdbcType="VARCHAR" property="paperName"/>