From 0328bac4c8c32dfeace95d420685365423b1d558 Mon Sep 17 00:00:00 2001 From: xusd Date: Fri, 10 May 2024 17:15:29 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=80=83=E6=A0=B8=E8=AF=84=E4=BC=B0-?= =?UTF-8?q?=E8=80=83=E9=A2=98=E8=87=AA=E5=8A=A8=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examine/ExamMyExamineController.java | 18 ++- .../examine/domain/ExamAttestation.java | 5 + .../inspur/examine/domain/ExamPaperInfo.java | 5 + .../inspur/examine/dto/CorrectAnswerDTO.java | 30 ++++ .../com/inspur/examine/dto/SubmitExamDTO.java | 47 ++++++ .../dto/SubmitExamPaperQuestionDTO.java | 32 +++++ .../mapper/ExamPaperQuestionMapper.java | 10 ++ .../examine/mapper/MyExamineMapper.java | 25 ++++ .../service/IExamPaperQuestionService.java | 10 ++ .../service/IExamQuestionBankService.java | 1 + .../examine/service/IMyExamineService.java | 14 ++ .../impl/ExamPaperQuestionServiceImpl.java | 14 ++ .../service/impl/MyExamineServiceImpl.java | 135 ++++++++++++++++++ .../examine/vo/MyExamPaperQuestionVO.java | 34 +++++ .../java/com/inspur/examine/vo/MyExamVO.java | 72 ++++++++++ .../mapper/ExamPaperQuestionMapper.xml | 21 +++ .../main/resources/mapper/MyExamineMapper.xml | 55 ++++++- .../src/views/examine/myExamine/index.vue | 4 +- 18 files changed, 527 insertions(+), 5 deletions(-) create mode 100644 inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/CorrectAnswerDTO.java create mode 100644 inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamDTO.java create mode 100644 inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamPaperQuestionDTO.java create mode 100644 inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java create mode 100644 inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamVO.java diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java index 984c36e..3054fd5 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java @@ -6,11 +6,14 @@ import com.inspur.common.core.page.TableDataInfo; import com.inspur.examine.domain.ExamAttestation; import com.inspur.examine.domain.ExamInfo; import com.inspur.examine.domain.ExamPaperInfo; +import com.inspur.examine.dto.SubmitExamDTO; import com.inspur.examine.service.IMyExamineService; +import com.inspur.examine.vo.MyExamVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.List; /** @@ -63,8 +66,8 @@ public class ExamMyExamineController extends BaseController { */ @PreAuthorize("@ss.hasPermi('examine:myExamine:getExam')") @GetMapping("/getExam/{id}") - public void getExam(@PathVariable("id") String id){ - //todo: 获取考试信息以及试题 + public MyExamVO getExam(@PathVariable("id") String id){ + return myExamineService.getExam(id); } /** @@ -91,4 +94,15 @@ public class ExamMyExamineController extends BaseController { return getDataTable(list); } + /** + * 提交考试 + * + * @param submitExamDTO 考试及答案 + */ + @PostMapping("/submitExam") + @PreAuthorize("@ss.hasPermi('examine:myExamine:submitExam')") + public AjaxResult submitExam(@Valid @RequestBody SubmitExamDTO submitExamDTO) { + return toAjax(myExamineService.submitExam(submitExamDTO)); + } + } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamAttestation.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamAttestation.java index 0d22f70..39098db 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamAttestation.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamAttestation.java @@ -67,4 +67,9 @@ public class ExamAttestation { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date attestationTime; + + /** + * 相关考试 + */ + private String examName; } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamPaperInfo.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamPaperInfo.java index 032d9a1..009de4d 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamPaperInfo.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/domain/ExamPaperInfo.java @@ -90,4 +90,9 @@ public class ExamPaperInfo { * 总分数 */ private BigDecimal totalScore; + + /** + * 通过分数 + */ + private BigDecimal passScore; } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/CorrectAnswerDTO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/CorrectAnswerDTO.java new file mode 100644 index 0000000..a297fbc --- /dev/null +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/CorrectAnswerDTO.java @@ -0,0 +1,30 @@ +package com.inspur.examine.dto; + +import com.inspur.common.annotation.Excel; +import lombok.Data; + +/** + * 正确答案 + * + * @Author xusd + * @Date 2024/5/10 15:14 + **/ +@Data +public class CorrectAnswerDTO { + + /** + * 试卷试题表id + */ + private String id; + + /** + * 试题类型 0 单选,1 多选,2 判断 + */ + private String questionType; + + /** + * 试题答案 + */ + private String questionAnswer; + +} diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamDTO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamDTO.java new file mode 100644 index 0000000..4e2ff98 --- /dev/null +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamDTO.java @@ -0,0 +1,47 @@ +package com.inspur.examine.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +/** + * 交卷 + * + * @Author xusd + * @Date 2024/5/10 10:59 + **/ +@Data +public class SubmitExamDTO { + + /** + * 试卷id + */ + @NotBlank(message = "试卷id不能为空") + private String paperId; + + /** + * 考试开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @NotNull(message = "考试开始时间不能为空") + private Date examStartTime; + + /** + * 考试结束时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @NotNull(message = "考试结束时间不能为空") + private Date examEndTime; + + /** + * 答案 + */ + @NotEmpty + private List answerList; + +} diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamPaperQuestionDTO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamPaperQuestionDTO.java new file mode 100644 index 0000000..f402773 --- /dev/null +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/dto/SubmitExamPaperQuestionDTO.java @@ -0,0 +1,32 @@ +package com.inspur.examine.dto; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 答案 + * + * @Author xusd + * @Date 2024/5/10 11:02 + **/ +@Data +public class SubmitExamPaperQuestionDTO { + + /** + * 试卷试题id + */ + @NotBlank(message = "试卷试题id不能为空") + private String id; + + /** + * 考生答案 + */ + private String examineAnswer; + + /** + * 是否正确(0:正确,1:错误) + */ + private String isSure; + +} diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/ExamPaperQuestionMapper.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/ExamPaperQuestionMapper.java index 0510c85..f5aef29 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/ExamPaperQuestionMapper.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/ExamPaperQuestionMapper.java @@ -2,6 +2,7 @@ package com.inspur.examine.mapper; import java.util.List; import com.inspur.examine.domain.ExamPaperQuestion; +import com.inspur.examine.dto.SubmitExamPaperQuestionDTO; import org.apache.ibatis.annotations.Param; /** @@ -68,4 +69,13 @@ public interface ExamPaperQuestionMapper * @param paperQuestionList 数据 */ void batchInsertPaperQuestion(@Param("paperQuestionList") List paperQuestionList); + + /** + * 批量修改考生答案和是否答对 + * + * @param answerList 数据 + * @Author xusd + * @Date 11:33 2024/5/10 + */ + void batchUpdatePaperQuestion(@Param("answerList") List answerList); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java index 75b11eb..e0a36dd 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java @@ -3,6 +3,9 @@ package com.inspur.examine.mapper; import com.inspur.examine.domain.ExamAttestation; import com.inspur.examine.domain.ExamInfo; import com.inspur.examine.domain.ExamPaperInfo; +import com.inspur.examine.dto.CorrectAnswerDTO; +import com.inspur.examine.vo.MyExamPaperQuestionVO; +import com.inspur.examine.vo.MyExamVO; import java.util.List; @@ -31,4 +34,26 @@ public interface MyExamineMapper { * 查询我的认证管理列表 */ List attestationList(ExamAttestation examAttestation); + + /** + * 获取考试信息 + */ + MyExamVO getExam(String id); + + /** + * 根据考试id获取考试题 + * @param paperId 考试id + * @return + */ + List selectPaperQuestionNoAnswerListByPaperId(String paperId); + + /** + * 正确答案 + * + * @Author xusd + * @Date 15:20 2024/5/10 + * @param paperId 考试id + * @return java.util.List + */ + List selectPaperQuestionHaveAnswerListByPaperId(String paperId); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamPaperQuestionService.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamPaperQuestionService.java index 901a4c3..f318c9b 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamPaperQuestionService.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamPaperQuestionService.java @@ -2,6 +2,7 @@ package com.inspur.examine.service; import java.util.List; import com.inspur.examine.domain.ExamPaperQuestion; +import com.inspur.examine.dto.SubmitExamPaperQuestionDTO; /** * 试卷试题Service接口 @@ -67,4 +68,13 @@ public interface IExamPaperQuestionService * @param paperQuestionList 数据 */ void batchInsertPaperQuestion(List paperQuestionList); + + /** + * 批量修改考生答案和是否答对 + * + * @param answerList 数据 + * @Author xusd + * @Date 11:33 2024/5/10 + */ + void batchUpdatePaperQuestion(List answerList); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamQuestionBankService.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamQuestionBankService.java index 895ff7e..430aa1a 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamQuestionBankService.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IExamQuestionBankService.java @@ -2,6 +2,7 @@ package com.inspur.examine.service; import java.util.List; import com.inspur.examine.domain.ExamQuestionBank; +import com.inspur.examine.dto.CorrectAnswerDTO; /** * 试题库Service接口 diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java index fead92f..db1ebca 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java @@ -4,6 +4,8 @@ import com.inspur.common.core.domain.AjaxResult; import com.inspur.examine.domain.ExamAttestation; import com.inspur.examine.domain.ExamInfo; import com.inspur.examine.domain.ExamPaperInfo; +import com.inspur.examine.dto.SubmitExamDTO; +import com.inspur.examine.vo.MyExamVO; import java.util.List; @@ -39,4 +41,16 @@ public interface IMyExamineService { * 查询我的认证管理列表 */ List attestationList(ExamAttestation examAttestation); + + /** + * 获取考试信息以及试题 + */ + MyExamVO getExam(String id); + + /** + * 提交考试 + * + * @param submitExamDTO 考试及答案 + */ + int submitExam(SubmitExamDTO submitExamDTO); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/ExamPaperQuestionServiceImpl.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/ExamPaperQuestionServiceImpl.java index d75a1bb..753f46e 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/ExamPaperQuestionServiceImpl.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/ExamPaperQuestionServiceImpl.java @@ -1,6 +1,8 @@ package com.inspur.examine.service.impl; import java.util.List; + +import com.inspur.examine.dto.SubmitExamPaperQuestionDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.examine.mapper.ExamPaperQuestionMapper; @@ -102,4 +104,16 @@ public class ExamPaperQuestionServiceImpl implements IExamPaperQuestionService public void batchInsertPaperQuestion(List paperQuestionList) { examPaperQuestionMapper.batchInsertPaperQuestion(paperQuestionList); } + + /** + * 批量修改考生答案和是否答对 + * + * @param answerList 数据 + * @Author xusd + * @Date 11:33 2024/5/10 + */ + @Override + public void batchUpdatePaperQuestion(List answerList) { + examPaperQuestionMapper.batchUpdatePaperQuestion(answerList); + } } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java index f18e2e1..9fda4dc 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java @@ -5,12 +5,18 @@ import com.inspur.common.utils.SecurityUtils; import com.inspur.common.utils.StringUtils; import com.inspur.common.utils.uuid.IdUtils; import com.inspur.examine.domain.*; +import com.inspur.examine.dto.CorrectAnswerDTO; +import com.inspur.examine.dto.SubmitExamDTO; +import com.inspur.examine.dto.SubmitExamPaperQuestionDTO; import com.inspur.examine.mapper.MyExamineMapper; import com.inspur.examine.service.*; +import com.inspur.examine.vo.MyExamPaperQuestionVO; +import com.inspur.examine.vo.MyExamVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -38,6 +44,9 @@ public class MyExamineServiceImpl implements IMyExamineService { @Autowired private IExamPaperQuestionService examPaperQuestionService; + @Autowired + private IExamAttestationPeopleService attestationPeopleService; + /** * 查询考试信息列表 */ @@ -203,4 +212,130 @@ public class MyExamineServiceImpl implements IMyExamineService { examAttestation.setUserId(SecurityUtils.getUserId()); return myExamineMapper.attestationList(examAttestation); } + + /** + * 获取考试信息以及试题 + */ + @Override + public MyExamVO getExam(String id) { + MyExamVO myExam = myExamineMapper.getExam(id); + if (Objects.isNull(myExam)){ + throw new ServiceException("未查询到考试信息"); + } + //考试题 + List allPaperQuestionList = myExamineMapper.selectPaperQuestionNoAnswerListByPaperId(id); + if (StringUtils.isEmpty(allPaperQuestionList)){ + throw new ServiceException("未查询到考试题目"); + } + //试题类型 0 单选,1 多选,2 判断 + Map> allPaperQuestionMap = allPaperQuestionList.stream().collect(Collectors.groupingBy(MyExamPaperQuestionVO::getQuestionType)); + //单选 + myExam.setSingleChoiceList(allPaperQuestionMap.get("0")); + //多选 + myExam.setMultiChoiceList(allPaperQuestionMap.get("1")); + //判断 + myExam.setJudgeList(allPaperQuestionMap.get("2")); + return myExam; + } + + /** + * 提交考试 + * + * @param submitExamDTO 考试及答案 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int submitExam(SubmitExamDTO submitExamDTO) { + //获取考试各个类型试题分数 + ExamPaperInfo paperInfo = examPaperInfoService.selectExamPaperInfoById(submitExamDTO.getPaperId()); + if (Objects.isNull(paperInfo)){ + throw new ServiceException("未查询到考生考试信息"); + } + if (!"0".equals(paperInfo.getStatus())){ + throw new ServiceException("已参与过考试,请勿重复参加"); + } + ExamInfo examInfo = examInfoService.selectExamInfoById(paperInfo.getExamId()); + if (Objects.isNull(examInfo)){ + throw new ServiceException("未查询到考试信息"); + } + //计算成绩 + //考生答案 + List userAnswerList = submitExamDTO.getAnswerList(); + //正确答案 + List correctAnswerList = myExamineMapper.selectPaperQuestionHaveAnswerListByPaperId(submitExamDTO.getPaperId()); + if (StringUtils.isEmpty(correctAnswerList)){ + throw new ServiceException("未查询到考试试题信息"); + } + //判断答案是否正确,未作答也是回答错误 + Map correctAnswerMap = correctAnswerList.stream().collect(Collectors.toMap(CorrectAnswerDTO::getId, item->item)); + //考试关联证书 + String attestationId = examInfo.getAttestationId(); + //通过分数 + BigDecimal passScore = examInfo.getPassScore(); + //单选题分数 + BigDecimal singleChoiceScore = examInfo.getSingleChoiceScore(); + //多选题分数 + BigDecimal multipleChoiceScore = examInfo.getMultipleChoiceScore(); + //判断题分数 + BigDecimal judgeScore = examInfo.getJudgeScore(); + //单选题回答正确数量 + int singleChoice = 0; + //多选题回答正确数量 + int multipleChoice = 0; + //判断题回答正确数量 + int judge = 0; + for (SubmitExamPaperQuestionDTO item : userAnswerList) { + //是否正确 0:正确,1:错误 + //试题类型 0 单选,1 多选,2 判断 + CorrectAnswerDTO correctAnswerDTO = correctAnswerMap.get(item.getId()); + if (Objects.nonNull(correctAnswerDTO)){ + String correctAnswer = correctAnswerDTO.getQuestionAnswer(); + String questionType = correctAnswerDTO.getQuestionType(); + if (StringUtils.isEmpty(item.getExamineAnswer())){ + item.setIsSure("1"); + }else { + if (correctAnswer.replace("\\s","").equals(item.getExamineAnswer().replace("\\s",""))){ + item.setIsSure("0"); + if ("0".equals(questionType)){ + singleChoice++; + }else if ("1".equals(questionType)){ + multipleChoice++; + }else if ("2".equals(questionType)){ + judge++; + } + }else { + item.setIsSure("1"); + } + } + } + } + //考生分数 + BigDecimal score = (singleChoiceScore.multiply(new BigDecimal(singleChoice))).add(multipleChoiceScore.multiply(new BigDecimal(multipleChoice))).add(judgeScore.multiply(new BigDecimal(judge))); + //批量设置答案和是否答对 + examPaperQuestionService.batchUpdatePaperQuestion(userAnswerList); + ExamPaperInfo examPaperInfo = new ExamPaperInfo(); + examPaperInfo.setId(submitExamDTO.getPaperId()); + examPaperInfo.setScore(score); + //状态 0 未作答,1 未通过,2通过 + if (score.compareTo(passScore) < 0){ + //未通过 + examPaperInfo.setStatus("1"); + }else { + //通过 + examPaperInfo.setStatus("2"); + //通过后判断考试是否关联证书,如果关联则新增证书关联信息 + if (StringUtils.isNotEmpty(attestationId)){ + ExamAttestationPeople examAttestationPeople = new ExamAttestationPeople(); + examAttestationPeople.setId(IdUtils.fastSimpleUUID()); + examAttestationPeople.setAttestationId(attestationId); + examAttestationPeople.setPeopleId(SecurityUtils.getUserId()); + examAttestationPeople.setAttestationTime(new Date()); + examAttestationPeople.setTenantId(SecurityUtils.getTenantId()); + attestationPeopleService.insertExamAttestationPeople(examAttestationPeople); + } + } + examPaperInfo.setExamStartTime(submitExamDTO.getExamStartTime()); + examPaperInfo.setExamEndTime(submitExamDTO.getExamEndTime()); + return examPaperInfoService.updateExamPaperInfo(examPaperInfo); + } } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java new file mode 100644 index 0000000..c24a293 --- /dev/null +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java @@ -0,0 +1,34 @@ +package com.inspur.examine.vo; + +import lombok.Data; + +/** + * 我的考试试题返回对象 + * + * @Author xusd + * @Date 2024/5/10 10:31 + **/ +@Data +public class MyExamPaperQuestionVO { + + /** + * 试卷试题表id + */ + private String id; + + /** + * 试题类型 0 单选,1 多选,2 判断 + */ + private String questionType; + + /** + * 试题题目 + */ + private String questionTitle; + + /** + * 试题选项 + */ + private String questionOptions; + +} diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamVO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamVO.java new file mode 100644 index 0000000..03212e4 --- /dev/null +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamVO.java @@ -0,0 +1,72 @@ +package com.inspur.examine.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 我的试卷 + * + * @Author xusd + * @Date 2024/5/9 17:34 + **/ +@Data +public class MyExamVO { + + /** + * 试卷id + */ + private String id; + + /** + * 考试名称 + */ + private String examName; + + /** + * 考生名称 + */ + private String examineName; + + /** + * 证书名称 + */ + private String attestationName; + + /** + * 考试时长 + */ + private Integer examDuration; + + /** + * 考试规则 + */ + private String examRules; + + /** + * 总分数 + */ + private BigDecimal totalScore; + + /** + * 通过分数 + */ + private BigDecimal passScore; + + /** + * 单选题题目 + */ + private List singleChoiceList; + + /** + * 多选题题目 + */ + private List multiChoiceList; + + /** + * 判断题题目 + */ + private List judgeList; + +} diff --git a/inspur-service/inspur-examine/src/main/resources/mapper/ExamPaperQuestionMapper.xml b/inspur-service/inspur-examine/src/main/resources/mapper/ExamPaperQuestionMapper.xml index 69ad96f..36dacf2 100644 --- a/inspur-service/inspur-examine/src/main/resources/mapper/ExamPaperQuestionMapper.xml +++ b/inspur-service/inspur-examine/src/main/resources/mapper/ExamPaperQuestionMapper.xml @@ -63,6 +63,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update + exam_paper_question + set + + + when #{item.id} then #{item.examineAnswer} + + + + + when #{item.id} then #{item.isSure} + + + where + id in + + #{item.id} + + + delete from exam_paper_question where id = #{id} diff --git a/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml b/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml index d19dc23..5374342 100644 --- a/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml +++ b/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml @@ -40,6 +40,7 @@ + @@ -50,6 +51,7 @@ + + + + + + + \ No newline at end of file diff --git a/inspur-ui/src/views/examine/myExamine/index.vue b/inspur-ui/src/views/examine/myExamine/index.vue index e0af438..846f319 100644 --- a/inspur-ui/src/views/examine/myExamine/index.vue +++ b/inspur-ui/src/views/examine/myExamine/index.vue @@ -155,8 +155,9 @@ - + + - + --> - - + --> Date: Fri, 10 May 2024 17:52:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=80=83=E6=A0=B8=E8=AF=84=E4=BC=B0-?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E7=AD=94=E9=A2=98=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examine/ExamMyExamineController.java | 9 +++++ .../examine/mapper/MyExamineMapper.java | 16 ++++++++ .../examine/service/IMyExamineService.java | 6 +++ .../service/impl/MyExamineServiceImpl.java | 26 +++++++++++++ .../examine/vo/MyExamPaperQuestionVO.java | 21 ++++++++++ .../main/resources/mapper/MyExamineMapper.xml | 39 ++++++++++++++++++- 6 files changed, 116 insertions(+), 1 deletion(-) diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java index 3054fd5..35ba166 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/examine/ExamMyExamineController.java @@ -82,6 +82,15 @@ public class ExamMyExamineController extends BaseController { return getDataTable(list); } + /** + * 查看历史作答详情 + */ + @PreAuthorize("@ss.hasPermi('examine:myExamine:getHistoryExam')") + @GetMapping("/getHistoryExam/{id}") + public MyExamVO getHistoryExam(@PathVariable("id") String id){ + return myExamineService.getHistoryExam(id); + } + /** * 查询我的认证管理列表 */ diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java index e0a36dd..edcf2b8 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/mapper/MyExamineMapper.java @@ -56,4 +56,20 @@ public interface MyExamineMapper { * @return java.util.List */ List selectPaperQuestionHaveAnswerListByPaperId(String paperId); + + /** + * 查看历史作答考试基本信息 + * @param id 试卷id + */ + MyExamVO getHistoryExam(String id); + + /** + * 获取答题记录和试题答案以及解析 + * + * @param paperId 试卷id + * @return java.util.List + * @Author xusd + * @Date 17:49 2024/5/10 + */ + List selectHistoryPaperQuestionNoAnswerListByPaperId(String paperId); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java index db1ebca..85f895d 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/IMyExamineService.java @@ -53,4 +53,10 @@ public interface IMyExamineService { * @param submitExamDTO 考试及答案 */ int submitExam(SubmitExamDTO submitExamDTO); + + /** + * 查看历史作答详情 + * @param id 试卷id + */ + MyExamVO getHistoryExam(String id); } diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java index 9fda4dc..3a9c2f8 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/service/impl/MyExamineServiceImpl.java @@ -203,6 +203,32 @@ public class MyExamineServiceImpl implements IMyExamineService { return myExamineMapper.examHistoryList(examPaperInfo); } + /** + * 查看历史作答详情 + * @param id 试卷id + */ + @Override + public MyExamVO getHistoryExam(String id) { + MyExamVO myExam = myExamineMapper.getHistoryExam(id); + if (Objects.isNull(myExam)){ + throw new ServiceException("未查询到考试信息"); + } + //考试题 + List allPaperQuestionList = myExamineMapper.selectHistoryPaperQuestionNoAnswerListByPaperId(id); + if (StringUtils.isEmpty(allPaperQuestionList)){ + throw new ServiceException("未查询到考试题目"); + } + //试题类型 0 单选,1 多选,2 判断 + Map> allPaperQuestionMap = allPaperQuestionList.stream().collect(Collectors.groupingBy(MyExamPaperQuestionVO::getQuestionType)); + //单选 + myExam.setSingleChoiceList(allPaperQuestionMap.get("0")); + //多选 + myExam.setMultiChoiceList(allPaperQuestionMap.get("1")); + //判断 + myExam.setJudgeList(allPaperQuestionMap.get("2")); + return myExam; + } + /** * 查询我的认证管理列表 */ diff --git a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java index c24a293..4df9148 100644 --- a/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java +++ b/inspur-service/inspur-examine/src/main/java/com/inspur/examine/vo/MyExamPaperQuestionVO.java @@ -1,5 +1,6 @@ package com.inspur.examine.vo; +import com.inspur.common.annotation.Excel; import lombok.Data; /** @@ -31,4 +32,24 @@ public class MyExamPaperQuestionVO { */ private String questionOptions; + /** + * 试题答案 + */ + private String questionAnswer; + + /** + * 答案解析 + */ + private String questionAnswerAnalysis; + + /** + * 考生答案 + */ + private String examineAnswer; + + /** + * 是否正确(0:正确,1:错误) + */ + private String isSure; + } diff --git a/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml b/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml index 5374342..1056567 100644 --- a/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml +++ b/inspur-service/inspur-examine/src/main/resources/mapper/MyExamineMapper.xml @@ -180,7 +180,7 @@ LEFT JOIN sys_user AS su ON epi.examine_id = su.user_id LEFT JOIN exam_attestation AS ea ON ei.attestation_id = ea.id WHERE - epi.id = '38d240be52914ddd855054c183f6f0a3' + epi.id = #{id} AND epi.`status` = '0' @@ -210,4 +210,41 @@ epq.paper_id = #{paperId} + + + \ No newline at end of file From aa249d1d4c5cee301ec4a8bc032a3332bf30a503 Mon Sep 17 00:00:00 2001 From: xusd Date: Fri, 10 May 2024 17:56:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=80=83=E6=A0=B8=E8=AF=84=E4=BC=B0-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=A5=E8=AF=86=E5=BA=93=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inspur-ui/src/views/knowledgeBase/industry/ceramics/index.vue | 2 +- .../src/views/knowledgeBase/industry/chemicalIndustry/index.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inspur-ui/src/views/knowledgeBase/industry/ceramics/index.vue b/inspur-ui/src/views/knowledgeBase/industry/ceramics/index.vue index 5ed533d..d6870a2 100644 --- a/inspur-ui/src/views/knowledgeBase/industry/ceramics/index.vue +++ b/inspur-ui/src/views/knowledgeBase/industry/ceramics/index.vue @@ -536,7 +536,7 @@ export default { handleExport() { this.download('industry/ceramics/export', { ...this.queryParams - }, `papermaking_${new Date().getTime()}.xlsx`) + }, `ceramics_${new Date().getTime()}.xlsx`) } } }; diff --git a/inspur-ui/src/views/knowledgeBase/industry/chemicalIndustry/index.vue b/inspur-ui/src/views/knowledgeBase/industry/chemicalIndustry/index.vue index 5bc0267..bb545a9 100644 --- a/inspur-ui/src/views/knowledgeBase/industry/chemicalIndustry/index.vue +++ b/inspur-ui/src/views/knowledgeBase/industry/chemicalIndustry/index.vue @@ -536,7 +536,7 @@ export default { handleExport() { this.download('industry/chemicalIndustry/export', { ...this.queryParams - }, `papermaking_${new Date().getTime()}.xlsx`) + }, `chemicalIndustry_${new Date().getTime()}.xlsx`) } } };