diff --git a/exam-module-exam/exam-module-exam-biz/pom.xml b/exam-module-exam/exam-module-exam-biz/pom.xml index e05a08b2..ba458b5c 100644 --- a/exam-module-exam/exam-module-exam-biz/pom.xml +++ b/exam-module-exam/exam-module-exam-biz/pom.xml @@ -128,6 +128,7 @@ tika-core + org.apache.poi poi @@ -141,9 +142,9 @@ - org.apache.poi - ooxml-schemas - 1.4 + org.apache.xmlbeans + xmlbeans + 3.1.0 @@ -154,7 +155,6 @@ org.apache.poi poi - org.apache.poi diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/BizException.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/BizException.java new file mode 100644 index 00000000..b5ff86d2 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/BizException.java @@ -0,0 +1,7 @@ +package pc.exam.pp.module.exam.controller.admin.exception; + +public class BizException extends RuntimeException { + public BizException(String message) { + super(message); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java index 5cca20fd..a604a3c1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java @@ -1,9 +1,9 @@ package pc.exam.pp.module.exam.controller.admin.paper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ChangePaperQuVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService; @@ -88,8 +88,37 @@ public class EducationPaperQuController { return CommonResult.success(educationPaperQuService.selectPaperQuListByPaperId(paperId)); } + /** + * 中心端 点击编辑 根据id获取试卷 + */ + @GetMapping(value = "/getPaperCenter") + public CommonResult getPaperCenter(@RequestParam(value = "paperId") String paperId) + { + return CommonResult.success(educationPaperQuService.selectPaperQuListByPaperIdCenter(paperId)); + } + /** + * 更换试卷试题 + * @param changePaperQuVo + * @return + */ + @PostMapping("/changePaperQu") + public CommonResult changePaperQu(@RequestBody ChangePaperQuVo changePaperQuVo) + { + return CommonResult.success(educationPaperQuService.changePaperQu(changePaperQuVo)); + } + + /** + * 随机更换试卷试题 + * @param changePaperQuVo + * @return + */ + @PostMapping("/changePaperQuRandom") + public CommonResult changePaperQuRandom(@RequestBody ChangePaperQuVo changePaperQuVo) + { + return CommonResult.success(educationPaperQuService.changePaperQuRandom(changePaperQuVo)); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java index 3df38d23..0f6c4762 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java @@ -174,8 +174,8 @@ public class EducationPaperTaskController return CommonResult.success("复制成功"); } - @PutMapping("/updateTaskStatus") // 更符合RESTful规范 - public CommonResult updateTaskStatus(@RequestBody StatusDto statusDto) { // 改为Integer类型 + @PutMapping("/updateTaskStatus") + public CommonResult updateTaskStatus(@RequestBody StatusDto statusDto) { return CommonResult.success( educationPaperTaskService.changeStatus(statusDto.getTaskId(), statusDto.getStatus()) ); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ChangePaperQuVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ChangePaperQuVo.java new file mode 100644 index 00000000..58211b7d --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ChangePaperQuVo.java @@ -0,0 +1,15 @@ +package pc.exam.pp.module.exam.controller.admin.paper.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ChangePaperQuVo { + private String paperId; + private String newQuId; + private String oldQuId; + private String subjectName; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java index c391fbb6..3e18b3d4 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java @@ -3,31 +3,32 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; import lombok.Data; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperSession; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import java.util.List; @Data public class ExamPaperVo { String paperId; - List questionList; + List examQuestionList; List educationPaperSchemeList; EducationPaperParam educationPaperParam; - + EducationPaperSession educationPaperSession; StuInfoPaper stuInfoPaper; public ExamPaperVo() { } public ExamPaperVo(List examQuestionList, List educationPaperSchemeList) { - this.questionList = examQuestionList; + this.examQuestionList = examQuestionList; this.educationPaperSchemeList = educationPaperSchemeList; } public List getExamQuestionList() { - return questionList; + return examQuestionList; } public void setExamQuestionList(List examQuestionList) { - this.questionList = examQuestionList; + this.examQuestionList = examQuestionList; } public List getEducationPaperSchemeList() { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java index baca64db..640e2149 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java @@ -42,6 +42,9 @@ public class ExamPersonVo { @Min(value = 1, message = "每页条数最小值为 1") @Max(value = 100, message = "每页条数最大值为 100") private Integer pageSize = PAGE_SIZE; + + private Integer offset; + public Integer getOffset() { return (this.pageNo - 1) * this.pageSize; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java index a0a818df..c467c1f1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java @@ -72,6 +72,9 @@ public class SessionStuPageReqVO { @Min(value = 1, message = "每页条数最小值为 1") @Max(value = 100, message = "每页条数最大值为 100") private Integer pageSize = PAGE_SIZE; + + private Integer offset; + public Integer getOffset() { return (this.pageNo - 1) * this.pageSize; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java index 666958a8..87621940 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java @@ -20,7 +20,9 @@ import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.excel.core.util.ExcelUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; +import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; +import pc.exam.pp.module.exam.controller.admin.question.dto.QuStatusDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; @@ -57,7 +59,7 @@ public class ExamQuestionController private IExamQuestionService examQuestionService; /** - * 查询试题(hyc)列表 + * 查询试题(hyc)列表 ,不带答案 */ //@PreAuthorize("@ss.hasPermi('system:question:list')") @GetMapping("/list") @@ -66,7 +68,12 @@ public class ExamQuestionController PageResult pageResult = examQuestionService.selectExamQuestionList(questionVo); return success(pageResult); } - + @GetMapping("/listAnswer") + public CommonResult> listAnswer(QuestionVo questionVo) + { + PageResult pageResult = examQuestionService.selectExamQuestionListAnswer(questionVo); + return success(pageResult); + } /** * 查询除了审核状态通过的其他状态的试题(试题推送) * @param questionVo @@ -260,4 +267,21 @@ public class ExamQuestionController return error(QESESTION_AUDIT_ERROR); } } + + /** + * 更改试题状态 + * @param quStatusDto + * @return + */ + @PutMapping("/updateQuStatus") + public CommonResult updateQuStatus(@RequestBody QuStatusDto quStatusDto) { + return CommonResult.success( + examQuestionService.changeStatus(quStatusDto.getQuId(), quStatusDto.getStatus()) + ); + } + + + + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/QuStatusDto.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/QuStatusDto.java new file mode 100644 index 00000000..0d0fdc0f --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/QuStatusDto.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.question.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class QuStatusDto { + private String quId; + private String status; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java index a6e05e98..43829899 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java @@ -13,6 +13,8 @@ import pc.exam.pp.framework.common.pojo.PageParam; public class QuestionVo extends PageParam { + private String quId; + private String subjectName; private String quLevel; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperQu.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperQu.java index f33379a4..f6795a78 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperQu.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperQu.java @@ -31,7 +31,7 @@ public class EducationPaperQu /** 试题版本 */ // @Excel(name = "试题版本") - private String sort; + private Integer sort; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java index 54933dd5..7e402928 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java @@ -60,7 +60,7 @@ public class EducationPaperScheme // @Excel(name = "每题分数") private String quScores; - private String sort; + private Integer sort; @TableField(exist = false) private List keyword; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java index 2413a0d3..ea88091f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java @@ -63,13 +63,13 @@ public class ExamQuestionAnswer /** 排序 */ // @Excel(name = "排序") - private String sort; + private Integer sort; @TableField(exist = false) @JsonInclude(value = JsonInclude.Include.NON_EMPTY) private List examMysqlKeywordList; - public ExamQuestionAnswer(String answerId, String quId, String isRight, String image, String content, String contentIn, String scoreRate, String sort) { + public ExamQuestionAnswer(String answerId, String quId, String isRight, String image, String content, String contentIn, String scoreRate, Integer sort) { this.answerId = answerId; this.quId = quId; this.isRight = isRight; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java index bec0e3e3..0b2e0769 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperQuMapper.java @@ -1,6 +1,7 @@ package pc.exam.pp.module.exam.dal.mysql.paper; import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ChangePaperQuVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; import java.util.List; @@ -71,5 +72,10 @@ public interface EducationPaperQuMapper List selectPaperQuListByPaperId(String paperId); + boolean changePaperQu(ChangePaperQuVo changePaperQuVo); + + String selectRamdomQuId(ChangePaperQuVo changePaperQuVo); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java index 320e15eb..c710297c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java @@ -40,6 +40,7 @@ public interface ExamQuestionMapper extends BaseMapperX */ default PageResult selectExamQuestionList(QuestionVo questionVo) { return selectPage(questionVo, new LambdaQueryWrapperX() + .likeIfPresent(ExamQuestion::getQuId,questionVo.getQuId()) .likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel()) .likeIfPresent(ExamQuestion::getCourseName , questionVo.getCourseName()) .likeIfPresent(ExamQuestion::getPointNames , questionVo.getPointNames()) @@ -138,5 +139,7 @@ public interface ExamQuestionMapper extends BaseMapperX void insertOrUpdateList(List examQuestions); + boolean changeStatus(@Param("quId") String quId + ,@Param("status") String status); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java index 6f03d2d9..823eb990 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java @@ -185,13 +185,22 @@ public class MonitorServiceImpl implements MonitorService { System.out.println("是否在允许入场时间段内:" + isWithinEntryTime); if (isWithinEntryTime){ - long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), - DateUtil.toLocalDateTime(endTime)); - info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0); + // 1. 计算剩余时间(秒) + long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), DateUtil.toLocalDateTime(endTime)); + remainingSeconds = Math.max(remainingSeconds, 0); // 防止负数 - //判分后删除 + // 2. 获取测评时长(examTime 是 java.sql.Time)并转换为秒 + long examDurationSeconds = examTime.toLocalTime().toSecondOfDay(); // 将 HH:mm:ss 转为秒数 + + // 3. 规则判断:如果 remainingSeconds > examTime,则限制最大值为 examTime + long finalRemaining = Math.min(remainingSeconds, examDurationSeconds); + + // 4. 设置和返回 + info.setRemainingTime(finalRemaining); + + // 判分后更新记录 monitorMapper.updateById(info); - return remainingSeconds > 0 ? remainingSeconds : 0; + return finalRemaining; }else { return 0; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java index 8f4a151f..a295ed0d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java @@ -96,6 +96,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer @Override public PageResult selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo) { + examPersonVo.setOffset(examPersonVo.getOffset()); List educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonBySessionId(examPersonVo); long total= educationPaperPersonMapper.selectEducationPaperPersonBySessionIdTotal(examPersonVo.getSessionId()); List personRepDtos=new ArrayList<>(); @@ -130,10 +131,12 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer long total; String sessionId = sessionStuPageReqVO.getSessionId(); if (StringUtils.isNotBlank(sessionId)){ + sessionStuPageReqVO.setOffset(sessionStuPageReqVO.getOffset()); personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionId(sessionStuPageReqVO); total=educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionIdTotal(sessionStuPageReqVO); } else { + sessionStuPageReqVO.setOffset(sessionStuPageReqVO.getOffset()); personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotIn(sessionStuPageReqVO); total=educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotInTotal(sessionStuPageReqVO); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java index ac469299..bbe385e6 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java @@ -4,14 +4,21 @@ import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ChangePaperQuVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; +import pc.exam.pp.module.exam.service.question.IExamQuestionService; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 试卷试题Service业务层处理 @@ -40,6 +47,8 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService private SysFileMapper sysFileMapper; @Autowired private EducationPaperTaskMapper educationPaperTaskMapper; + @Autowired + private IExamQuestionService examQuestionService; /** * 查询试卷试题 * @@ -114,17 +123,30 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService @Override public ExamPaperVo selectPaperQuListByPaperId(String paperId) { + System.out.println(paperId); List quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); - List examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); + List examQuestionList=new ArrayList<>(); - if (examQuestionList!=null&&examQuestionList.size()>0){ - for (ExamQuestion examQuestion : examQuestionList) { - //查找原始和素材试题文件 - List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); - examQuestion.setFileUploads(sysFileUploads); - } + if (quIds!=null&&quIds.size()>0){ + examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds); + if (examQuestionList!=null&&examQuestionList.size()>0){ + + // 根据 quIds 顺序重新排序 examQuestionList + Map questionMap = examQuestionList.stream() + .collect(Collectors.toMap(ExamQuestion::getQuId, Function.identity())); + examQuestionList = quIds.stream() + .map(questionMap::get) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + for (ExamQuestion examQuestion : examQuestionList) { + //查找原始和素材试题文件 + List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); + examQuestion.setFileUploads(sysFileUploads); + } + } + } - } String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid); List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); @@ -143,19 +165,23 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskid, String.valueOf(userId)); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); + ExamPaperVo examPaperVo=new ExamPaperVo(); + if (educationPaperPerson!=null){ + String sessionId = educationPaperPerson.getSessionId(); + EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId); + examPaperVo.setEducationPaperSession(educationPaperSession); stuInfoPaper.setBatch(educationPaperPerson.getBatch()); } Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); - String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); - stuInfoPaper.setSchoolName(schoolName); + String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); + stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); - ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setPaperId(paperId); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); @@ -164,5 +190,71 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService return examPaperVo; } + + @Override + public boolean changePaperQu(ChangePaperQuVo changePaperQuVo) { + return educationPaperQuMapper.changePaperQu(changePaperQuVo); + } + + @Override + public boolean changePaperQuRandom(ChangePaperQuVo changePaperQuVo) { + //根据 试卷id 随机查找不在此时卷的 试题id + String quId= educationPaperQuMapper.selectRamdomQuId(changePaperQuVo); + + if (quId!=null){ + changePaperQuVo.setNewQuId(quId); + educationPaperQuMapper.changePaperQu(changePaperQuVo); + } + return true; + } + + @Override + public ExamPaperVo selectPaperQuListByPaperIdCenter(String paperId) { + System.out.println(paperId); + List quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); + List examQuestionList=new ArrayList<>(); + if (quIds != null && !quIds.isEmpty()) { + examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds); + // 按 quIds 顺序重建 examQuestionList + if (examQuestionList != null && !examQuestionList.isEmpty()) { + // 查询得到 map 方便按 id 查找 + Map questionMap = examQuestionList.stream() + .collect(Collectors.toMap(ExamQuestion::getQuId, Function.identity())); + + // 先对所有题目做完整信息更新和知识点设置 + for (String quId : quIds) { + ExamQuestion examQuestion = questionMap.get(quId); + if (examQuestion == null) continue; + + if ("编程题".equals(examQuestion.getSubjectName())) { + ExamQuestion fullExamQuestion = examQuestionService.selectExamQuestionByQuId(examQuestion.getQuId()); + questionMap.put(quId, fullExamQuestion); + } + + if ("程序设计".equals(examQuestion.getSubjectName())) { + List answerList = examQuestionService.getPointById(examQuestion.getQuId()); + examQuestion.setAnswerList(answerList); + } + } + + // 按 quIds 顺序重建 examQuestionList + examQuestionList = quIds.stream() + .map(questionMap::get) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } + } + + + String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId); + List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); + + ExamPaperVo examPaperVo=new ExamPaperVo(); + examPaperVo.setPaperId(paperId); + examPaperVo.setExamQuestionList(examQuestionList); + examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); + + return examPaperVo; + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 1f04e1dc..62976694 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -4,8 +4,18 @@ package pc.exam.pp.module.exam.service.paper; import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.excel.util.StringUtils; import jakarta.servlet.http.HttpServletResponse; +import org.apache.poi.util.Units; import org.apache.poi.xwpf.usermodel.*; import org.checkerframework.checker.units.qual.A; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.nodes.Node; +import org.jsoup.nodes.TextNode; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pc.exam.pp.framework.common.pojo.PageResult; @@ -25,13 +35,13 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; import pc.exam.pp.module.exam.utils.uuid.IdUtils; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.UnsupportedEncodingException; +import java.io.*; +import java.math.BigInteger; +import java.net.URL; import java.net.URLEncoder; import java.sql.Time; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -56,6 +66,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService @Autowired private EducationPaperTaskMapper educationPaperTaskMapper; + @Autowired + private EducationPaperSessionMapper educationPaperSessionMapper; @Autowired private EducationPaperQuMapper educationPaperQuMapper; @@ -215,7 +227,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService EducationPaperQu educationPaperQu=new EducationPaperQu(); educationPaperQu.setPaperId(uuid); educationPaperQu.setQuId(examQuestionId); - educationPaperQu.setSort(String.valueOf(sort++)); + educationPaperQu.setSort(sort++); educationPaperQus.add(educationPaperQu); } educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); @@ -421,24 +433,43 @@ public class EducationPaperServiceImpl implements IEducationPaperService EducationPaperQu educationPaperQu=new EducationPaperQu(); educationPaperQu.setPaperId(uuid); educationPaperQu.setQuId(examQuestionId); - educationPaperQu.setSort(String.valueOf(sort++)); + educationPaperQu.setSort(sort++); educationPaperQus.add(educationPaperQu); } educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); } List quIds =educationPaperQuMapper.selectPaperQuByPaperId(uuid); - List examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); +// List examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); +// if (examQuestionList!=null&&examQuestionList.size()>0){ +// for (ExamQuestion examQuestion : examQuestionList) { +// //查找原始和素材试题文件 +// List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); +// examQuestion.setFileUploads(sysFileUploads); +// } +// +// } + List examQuestionList=new ArrayList<>(); + if (quIds!=null&&quIds.size()>0){ + examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds); if (examQuestionList!=null&&examQuestionList.size()>0){ + + // 根据 quIds 顺序重新排序 examQuestionList + Map questionMap = examQuestionList.stream() + .collect(Collectors.toMap(ExamQuestion::getQuId, Function.identity())); + examQuestionList = quIds.stream() + .map(questionMap::get) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + for (ExamQuestion examQuestion : examQuestionList) { //查找原始和素材试题文件 List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); examQuestion.setFileUploads(sysFileUploads); } - } - + } //设置进入试卷 考生考试信息确认参数 String nickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -448,8 +479,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService StuInfoPaper stuInfoPaper=new StuInfoPaper(); stuInfoPaper.setQueNum(String.valueOf(educationPaperQus.size())); stuInfoPaper.setNickName(nickname); - + ExamPaperVo examPaperVo=new ExamPaperVo(); if (educationPaperPerson!=null){ + String sessionId = educationPaperPerson.getSessionId(); + EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId); + examPaperVo.setEducationPaperSession(educationPaperSession); stuInfoPaper.setBatch(educationPaperPerson.getBatch()); } stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); @@ -461,13 +495,13 @@ public class EducationPaperServiceImpl implements IEducationPaperService String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); - ExamPaperVo examPaperVo=new ExamPaperVo(); - examPaperVo.setExamQuestionList(examQuestionList); - examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); - examPaperVo.setEducationPaperParam(educationPaperParam); - examPaperVo.setPaperId(uuid); + + examPaperVo.setExamQuestionList(examQuestionList); + examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); + examPaperVo.setEducationPaperParam(educationPaperParam); + examPaperVo.setPaperId(uuid); examPaperVo.setStuInfoPaper(stuInfoPaper); - return examPaperVo; + return examPaperVo; } @@ -553,22 +587,33 @@ public class EducationPaperServiceImpl implements IEducationPaperService int columnCount = paperWordList.size(); //写入表格 - XWPFTable table = word.createTable(3, 2 + columnCount); + XWPFTable table = word.createTable(3, 3 + columnCount); table.getRow(0).getCell(0).setText("总 分"); - table.getRow(0).getCell(1).setText("题号"); + table.getRow(0).getCell(2).setText("题号"); for (int i = 0; i < columnCount; i++) { - table.getRow(0).getCell(2 + i).setText(paperWordList.get(i).getUpperNum()); + table.getRow(0).getCell(3 + i).setText(paperWordList.get(i).getUpperNum()); } table.getRow(1).getCell(0).setText("登分人"); - table.getRow(1).getCell(1).setText("题分"); + table.getRow(1).getCell(2).setText("题分"); for (int i = 0; i < columnCount; i++) { - table.getRow(1).getCell(2 + i).setText(String.valueOf(paperWordList.get(i).getTotalScore())); + table.getRow(1).getCell(3 + i).setText(String.valueOf(paperWordList.get(i).getTotalScore())); } table.getRow(2).getCell(0).setText("复查人"); - table.getRow(2).getCell(1).setText("得分"); + table.getRow(2).getCell(2).setText("得分"); for (int i = 0; i < columnCount; i++) { - table.getRow(2).getCell(2 + i).setText(""); + table.getRow(2).getCell(3 + i).setText(""); } + // 设置第二列(索引为1)的固定宽度 + for (int rowIndex = 0; rowIndex < 3; rowIndex++) { + XWPFTableCell cell = table.getRow(rowIndex).getCell(1); + cell.setText(""); // 保持为空白,手动填写名字 + CTTc ctTc = cell.getCTTc(); + CTTcPr tcPr = ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr(); + CTTblWidth width = tcPr.isSetTcW() ? tcPr.getTcW() : tcPr.addNewTcW(); + width.setType(STTblWidth.DXA); + width.setW(BigInteger.valueOf(900)); + } + //写入试卷内容 for (PaperWordDto item : paperWordList) { String typeName = item.getType(); // 题型名,如 “单选题”、“多选题”等 @@ -592,11 +637,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService for (PaperQueWordDto paperQueWordDto : que) { XWPFParagraph queParagraph = word.createParagraph(); XWPFRun queRun = queParagraph.createRun(); - String rawContent = paperQueWordDto.getContent(); - String plainText = rawContent.replaceAll("<[^>]*>", ""); - String content = index + "、" + plainText; - queRun.setText(content); + String rawContent = paperQueWordDto.getContent(); + String prefix = index + "、"; + // 使用封装方法 + insertHtmlContentIntoRun(queRun, rawContent, prefix); queRun.setFontSize(11); queParagraph.setSpacingAfter(100); @@ -608,11 +653,17 @@ public class EducationPaperServiceImpl implements IEducationPaperService for (ExamQuestionAnswer examQuestionAnswer : answerList) { XWPFParagraph optionParagraph = word.createParagraph(); XWPFRun optionRun = optionParagraph.createRun(); - String optionContent = option + ". " + examQuestionAnswer.getContent(); - optionRun.setText(optionContent); + + String optionPrefix = option + ". "; + String rawOptionContent = examQuestionAnswer.getContent(); + + // 使用封装方法 + insertHtmlContentIntoRun(optionRun, rawOptionContent, optionPrefix); + optionRun.setFontSize(10); optionParagraph.setSpacingAfter(50); + if ("0".equals(examQuestionAnswer.getIsRight())) { correctOptions.append(option); } @@ -623,8 +674,6 @@ public class EducationPaperServiceImpl implements IEducationPaperService answerMap .computeIfAbsent(typeName, k -> new StringBuilder()) .append(index).append("、").append(correctOptions).append("\n"); - - } index++; } @@ -700,6 +749,49 @@ public class EducationPaperServiceImpl implements IEducationPaperService return educationPaperMapper.selectPaperIdAndNumByTaskId(taskId); } + public void insertHtmlContentIntoRun(XWPFRun run, String htmlContent, String prefix) { + try { + if (prefix != null) { + run.setText(prefix); + } + + Document doc = Jsoup.parse(htmlContent); + Element body = doc.body(); + + processNode(body, run); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void processNode(Node node, XWPFRun run) { + for (Node child : node.childNodes()) { + if (child instanceof TextNode) { + String text = ((TextNode) child).text(); + run.setText(text); + } else if (child instanceof Element) { + Element el = (Element) child; + + if (el.tagName().equalsIgnoreCase("img")) { + String imgUrl = el.attr("src"); + try (InputStream imgStream = new URL(imgUrl).openStream()) { + run.addPicture( + imgStream, + XWPFDocument.PICTURE_TYPE_JPEG, + "image.jpg", + Units.toEMU(100), // 宽度 + Units.toEMU(60) // 高度 + ); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + // 继续递归处理内部元素,如

等 + processNode(el, run); + } + } + } + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index 5b269545..b4525c9c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -27,6 +27,7 @@ import java.sql.Time; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -417,21 +418,33 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId); + if (StringUtils.isBlank(paperId)){ + return null; + } List examQuestionList=new ArrayList<>(); List educationPaperSchemeList=new ArrayList<>(); List quIds=new ArrayList<>(); if (StringUtils.isNotBlank(paperId)){ - quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); - examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); - if (examQuestionList!=null&&examQuestionList.size()>0){ - for (ExamQuestion examQuestion : examQuestionList) { - //查找原始和素材试题文件 - List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); - examQuestion.setFileUploads(sysFileUploads); - } + quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); + if (quIds!=null&&quIds.size()>0){ + examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds); + if (examQuestionList!=null&&examQuestionList.size()>0){ + // 根据 quIds 顺序重新排序 examQuestionList + Map questionMap = examQuestionList.stream() + .collect(Collectors.toMap(ExamQuestion::getQuId, Function.identity())); + examQuestionList = quIds.stream() + .map(questionMap::get) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + for (ExamQuestion examQuestion : examQuestionList) { + //查找原始和素材试题文件 + List sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); + examQuestion.setFileUploads(sysFileUploads); + } + } } - educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); + educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); } String nickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -448,7 +461,11 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId)); + ExamPaperVo examPaperVo=new ExamPaperVo(); if (educationPaperPerson!=null){ + String sessionId = educationPaperPerson.getSessionId(); + EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId); + examPaperVo.setEducationPaperSession(educationPaperSession); stuInfoPaper.setBatch(educationPaperPerson.getBatch()); } Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); @@ -457,7 +474,6 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); - ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setPaperId(paperId); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperQuService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperQuService.java index 4815fb92..caf652cc 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperQuService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperQuService.java @@ -1,5 +1,6 @@ package pc.exam.pp.module.exam.service.paper; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ChangePaperQuVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; @@ -63,5 +64,11 @@ public interface IEducationPaperQuService ExamPaperVo selectPaperQuListByPaperId(String paperId); + boolean changePaperQu(ChangePaperQuVo changePaperQuVo); + + boolean changePaperQuRandom(ChangePaperQuVo changePaperQuVo); + + ExamPaperVo selectPaperQuListByPaperIdCenter(String paperId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java index b02dfc69..6e3d7c88 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java @@ -6,6 +6,7 @@ import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; import jakarta.validation.ConstraintViolationException; +import org.apache.commons.collections4.CollectionUtils; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +23,7 @@ import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamin import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.dal.mysql.mysqlkeyword.MysqlKeywordMapper; import pc.exam.pp.module.exam.dal.mysql.question.*; import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; @@ -63,6 +65,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService private ExamSpecialtyMapper examSpecialtyMapper; @Autowired private RabbitmqUtils rabbitMqService; + @Autowired + private MysqlKeywordMapper mysqlKeywordMapper; /** * 查询试题(hyc) * @@ -722,7 +726,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); examQuestionAnswer.setQuId(quId); - examQuestionAnswer.setSort(String.valueOf(i++)); + examQuestionAnswer.setSort(i++); // 判断是否为正确答案,忽略大小写和空格 if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { examQuestionAnswer.setIsRight("1"); // 正确 @@ -781,7 +785,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); examQuestionAnswer.setQuId(quId); - examQuestionAnswer.setSort(String.valueOf(i++)); + examQuestionAnswer.setSort(i++); // 判断是否为正确答案,忽略大小写和空格 if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { examQuestionAnswer.setIsRight("1"); // 正确 @@ -808,6 +812,40 @@ public class ExamQuestionServiceImpl implements IExamQuestionService return respVO; } + @Override + public boolean changeStatus(String quId, String status) { + return examQuestionMapper.changeStatus(quId,status); + } + + @Override + public PageResult selectExamQuestionListAnswer(QuestionVo questionVo) { + PageResult examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo); + List list = examQuestionPageResult.getList(); + if (list != null && !list.isEmpty()) { + for (ExamQuestion examQuestion : list) { + String quId = examQuestion.getQuId(); + List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); + examQuestion.setAnswerList(examQuestionAnswers); + } + } + return examQuestionPageResult; + } + + @Override + public List getPointById(String quId) { + List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); + if (!CollectionUtils.isEmpty(examQuestionAnswers)) { + for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) { + String answerId = examQuestionAnswer.getAnswerId(); + List newKeywordList = mysqlKeywordMapper.selectList( + new QueryWrapper().eq("answer_id", answerId) + ); + examQuestionAnswer.setExamMysqlKeywordList(newKeywordList); + } + } + return examQuestionAnswers; + } + private void validateChoice(String a, String b, String c, String d, String answer) { // A 和 B 必须存在 if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java index 7e12df36..ccfc82fb 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java @@ -11,6 +11,7 @@ import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamin import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; +import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; import java.util.List; @@ -103,4 +104,9 @@ public interface IExamQuestionService QueImportRespVO importUserList(List list, Boolean updateSupport); + boolean changeStatus(String quId, String status); + + PageResult selectExamQuestionListAnswer(QuestionVo questionVo); + + List getPointById(String quId); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml index 18d98098..a60be133 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml @@ -70,8 +70,8 @@ specialty_name = #{taskSpecialty} AND subject_name = #{educationPaperScheme.spName} AND tenant_id =#{tId} - and audit = 0 - and status = 0 + and audit = '0' + and status = '0' and deleted ='0' AND qu_level = #{educationPaperScheme.quLevel} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperPersonMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperPersonMapper.xml index 5fbebec9..c4e490b7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperPersonMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperPersonMapper.xml @@ -101,7 +101,7 @@ AND s.class_id = #{classId} ORDER BY s.id DESC - + LIMIT #{pageSize} OFFSET #{offset} + @@ -66,6 +71,12 @@ where paper_id = #{paperId} + + update education_paper_qu + set qu_id = #{newQuId} + where paper_id = #{paperId} and qu_id = #{oldQuId} + + delete from education_paper_qu where paper_id = #{paperId} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml index 7ac426ce..ad8c513f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml @@ -90,8 +90,8 @@ WHERE specialty_name = #{taskSpecialty} AND subject_name = #{spName} AND tenant_id =#{tId} - and audit = 0 - and status = 0 + and audit = '0' + and status = '0' AND qu_level = #{quLevel} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml index 43049b41..e2c7f57a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml @@ -283,6 +283,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + UPDATE exam_question + set status =#{status} + where qu_id =#{quId} + \ No newline at end of file diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java index 621a42af..3a5d8060 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java @@ -3,6 +3,7 @@ package pc.exam.pp.module.judgement.controller.admin.getpoints; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; @@ -23,6 +24,7 @@ public class GetPointsController { * @return 得分 */ @PostMapping("/get_filePoint") + @TenantIgnore public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException { return CommonResult.success(examGetPointsService.get_file_point(pointsVo)); } @@ -31,6 +33,7 @@ public class GetPointsController { * @return 得分 */ @PostMapping("/get_mysql_point") + @TenantIgnore public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException { return CommonResult.success(examGetPointsService.get_mysql_point(pointsVo)); } @@ -47,11 +50,13 @@ public class GetPointsController { * @return 得分 */ @PostMapping("/update_mysql_point") + @TenantIgnore public CommonResult update_mysql_point(@RequestBody Points points) { return CommonResult.success(examGetPointsService.update_mysql_point(points)); } @GetMapping("/get_Point_id/{quId}") + @TenantIgnore public CommonResult getPointById(@PathVariable("quId") String quId) { return CommonResult.success(examGetPointsService.getPointById(quId)); } @@ -60,6 +65,7 @@ public class GetPointsController { * @return 得分 */ @PostMapping("/set_browser_point") + @TenantIgnore //todo 老师自己设置,不读文件 public CommonResult get_browser_point(@RequestBody Points points) { return CommonResult.success(examGetPointsService.get_browser_point(points)); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java index c6caf4a7..40016d2c 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java @@ -78,7 +78,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ answer.setContent(key); // 设置文件路径 answer.setScoreRate("1"); //这里设置answer的排序,按照循环次数来 - answer.setSort(String.valueOf(sortCounter.getAndIncrement())); // 按顺序设置排序值 + answer.setSort(sortCounter.getAndIncrement()); // 按顺序设置排序值 if (value.startsWith("仅存在于 "+stuFilePath)) { answer.setContentIn("考察删除"); } else if (value.startsWith("仅存在于 "+answerFilePath)) { @@ -89,7 +89,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ } return answer; }) - .sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序 + .sorted(Comparator.comparingInt(answer -> answer.getSort())) // 按 sort 排序 .collect(Collectors.toList()); answerList.addAll(formattedDifferences); zip_file_sth.delete(); @@ -188,7 +188,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ //设置sort AtomicInteger sortCounter = new AtomicInteger(1); points.getQuestionAnswerList().forEach(answer -> { - answer.setSort(String.valueOf(sortCounter.getAndIncrement())); + answer.setSort(sortCounter.getAndIncrement()); }); List questionAnswerList = points.getQuestionAnswerList(); for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) { @@ -267,7 +267,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ String answerId = IdUtils.simpleUUID(); answer.setAnswerId(answerId); answer.setQuId(quId); // 以防前端未传 - answer.setSort(String.valueOf(counter.getAndIncrement())); // 设置排序字段(String 类型) + answer.setSort(counter.getAndIncrement()); // 设置排序字段(String 类型) List keywordList = answer.getExamMysqlKeywordList(); if (!CollectionUtils.isEmpty(keywordList)) { for (ExamMysqlKeyword keyword : keywordList) { diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java index 0491e66f..00c6ca52 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java @@ -15,6 +15,7 @@ import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO; import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper; +import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSessionMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper; import pc.exam.pp.module.exam.utils.uuid.IdUtils;