【修改】笔试试卷 表格格式,返回试卷sort顺序等

This commit is contained in:
YOHO\20373
2025-05-29 17:57:35 +08:00
parent 06054139c7
commit 19bd805831
32 changed files with 478 additions and 86 deletions

View File

@@ -128,6 +128,7 @@
<artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 --> <artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 -->
</dependency> </dependency>
<!-- Apache POI 相关 --> <!-- Apache POI 相关 -->
<!-- Apache POI 核心 -->
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
@@ -141,9 +142,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.xmlbeans</groupId>
<artifactId>ooxml-schemas</artifactId> <artifactId>xmlbeans</artifactId>
<version>1.4</version> <version>3.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -154,7 +155,6 @@
<exclusion> <exclusion>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>

View File

@@ -0,0 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.exception;
public class BizException extends RuntimeException {
public BizException(String message) {
super(message);
}
}

View File

@@ -1,9 +1,9 @@
package pc.exam.pp.module.exam.controller.admin.paper; package pc.exam.pp.module.exam.controller.admin.paper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult; 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.dal.dataobject.EducationPaperQu;
import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService; import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService;
@@ -88,8 +88,37 @@ public class EducationPaperQuController
{ {
return CommonResult.success(educationPaperQuService.selectPaperQuListByPaperId(paperId)); 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));
}
} }

View File

@@ -174,8 +174,8 @@ public class EducationPaperTaskController
return CommonResult.success("复制成功"); return CommonResult.success("复制成功");
} }
@PutMapping("/updateTaskStatus") // 更符合RESTful规范 @PutMapping("/updateTaskStatus")
public CommonResult<Boolean> updateTaskStatus(@RequestBody StatusDto statusDto) { // 改为Integer类型 public CommonResult<Boolean> updateTaskStatus(@RequestBody StatusDto statusDto) {
return CommonResult.success( return CommonResult.success(
educationPaperTaskService.changeStatus(statusDto.getTaskId(), statusDto.getStatus()) educationPaperTaskService.changeStatus(statusDto.getTaskId(), statusDto.getStatus())
); );

View File

@@ -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;
}

View File

@@ -3,31 +3,32 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo;
import lombok.Data; import lombok.Data;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; 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.EducationPaperScheme;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperSession;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
import java.util.List; import java.util.List;
@Data @Data
public class ExamPaperVo { public class ExamPaperVo {
String paperId; String paperId;
List<ExamQuestion> questionList; List<ExamQuestion> examQuestionList;
List<EducationPaperScheme> educationPaperSchemeList; List<EducationPaperScheme> educationPaperSchemeList;
EducationPaperParam educationPaperParam; EducationPaperParam educationPaperParam;
EducationPaperSession educationPaperSession;
StuInfoPaper stuInfoPaper; StuInfoPaper stuInfoPaper;
public ExamPaperVo() { public ExamPaperVo() {
} }
public ExamPaperVo(List<ExamQuestion> examQuestionList, List<EducationPaperScheme> educationPaperSchemeList) { public ExamPaperVo(List<ExamQuestion> examQuestionList, List<EducationPaperScheme> educationPaperSchemeList) {
this.questionList = examQuestionList; this.examQuestionList = examQuestionList;
this.educationPaperSchemeList = educationPaperSchemeList; this.educationPaperSchemeList = educationPaperSchemeList;
} }
public List<ExamQuestion> getExamQuestionList() { public List<ExamQuestion> getExamQuestionList() {
return questionList; return examQuestionList;
} }
public void setExamQuestionList(List<ExamQuestion> examQuestionList) { public void setExamQuestionList(List<ExamQuestion> examQuestionList) {
this.questionList = examQuestionList; this.examQuestionList = examQuestionList;
} }
public List<EducationPaperScheme> getEducationPaperSchemeList() { public List<EducationPaperScheme> getEducationPaperSchemeList() {

View File

@@ -42,6 +42,9 @@ public class ExamPersonVo {
@Min(value = 1, message = "每页条数最小值为 1") @Min(value = 1, message = "每页条数最小值为 1")
@Max(value = 100, message = "每页条数最大值为 100") @Max(value = 100, message = "每页条数最大值为 100")
private Integer pageSize = PAGE_SIZE; private Integer pageSize = PAGE_SIZE;
private Integer offset;
public Integer getOffset() { public Integer getOffset() {
return (this.pageNo - 1) * this.pageSize; return (this.pageNo - 1) * this.pageSize;
} }

View File

@@ -72,6 +72,9 @@ public class SessionStuPageReqVO {
@Min(value = 1, message = "每页条数最小值为 1") @Min(value = 1, message = "每页条数最小值为 1")
@Max(value = 100, message = "每页条数最大值为 100") @Max(value = 100, message = "每页条数最大值为 100")
private Integer pageSize = PAGE_SIZE; private Integer pageSize = PAGE_SIZE;
private Integer offset;
public Integer getOffset() { public Integer getOffset() {
return (this.pageNo - 1) * this.pageSize; return (this.pageNo - 1) * this.pageSize;
} }

View File

@@ -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.common.pojo.PageResult;
import pc.exam.pp.framework.excel.core.util.ExcelUtils; import pc.exam.pp.framework.excel.core.util.ExcelUtils;
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; 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.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.dto.TenantDto;
import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO;
import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO;
@@ -57,7 +59,7 @@ public class ExamQuestionController
private IExamQuestionService examQuestionService; private IExamQuestionService examQuestionService;
/** /**
* 查询试题(hyc)列表 * 查询试题(hyc)列表 ,不带答案
*/ */
//@PreAuthorize("@ss.hasPermi('system:question:list')") //@PreAuthorize("@ss.hasPermi('system:question:list')")
@GetMapping("/list") @GetMapping("/list")
@@ -66,7 +68,12 @@ public class ExamQuestionController
PageResult<ExamQuestion> pageResult = examQuestionService.selectExamQuestionList(questionVo); PageResult<ExamQuestion> pageResult = examQuestionService.selectExamQuestionList(questionVo);
return success(pageResult); return success(pageResult);
} }
@GetMapping("/listAnswer")
public CommonResult<PageResult<ExamQuestion>> listAnswer(QuestionVo questionVo)
{
PageResult<ExamQuestion> pageResult = examQuestionService.selectExamQuestionListAnswer(questionVo);
return success(pageResult);
}
/** /**
* 查询除了审核状态通过的其他状态的试题(试题推送) * 查询除了审核状态通过的其他状态的试题(试题推送)
* @param questionVo * @param questionVo
@@ -260,4 +267,21 @@ public class ExamQuestionController
return error(QESESTION_AUDIT_ERROR); return error(QESESTION_AUDIT_ERROR);
} }
} }
/**
* 更改试题状态
* @param quStatusDto
* @return
*/
@PutMapping("/updateQuStatus")
public CommonResult<Boolean> updateQuStatus(@RequestBody QuStatusDto quStatusDto) {
return CommonResult.success(
examQuestionService.changeStatus(quStatusDto.getQuId(), quStatusDto.getStatus())
);
}
} }

View File

@@ -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;
}

View File

@@ -13,6 +13,8 @@ import pc.exam.pp.framework.common.pojo.PageParam;
public class QuestionVo extends PageParam { public class QuestionVo extends PageParam {
private String quId;
private String subjectName; private String subjectName;
private String quLevel; private String quLevel;

View File

@@ -31,7 +31,7 @@ public class EducationPaperQu
/** 试题版本 */ /** 试题版本 */
// @Excel(name = "试题版本") // @Excel(name = "试题版本")
private String sort; private Integer sort;
} }

View File

@@ -60,7 +60,7 @@ public class EducationPaperScheme
// @Excel(name = "每题分数") // @Excel(name = "每题分数")
private String quScores; private String quScores;
private String sort; private Integer sort;
@TableField(exist = false) @TableField(exist = false)
private List<String> keyword; private List<String> keyword;

View File

@@ -63,13 +63,13 @@ public class ExamQuestionAnswer
/** 排序 */ /** 排序 */
// @Excel(name = "排序") // @Excel(name = "排序")
private String sort; private Integer sort;
@TableField(exist = false) @TableField(exist = false)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY) @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<ExamMysqlKeyword> examMysqlKeywordList; private List<ExamMysqlKeyword> 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.answerId = answerId;
this.quId = quId; this.quId = quId;
this.isRight = isRight; this.isRight = isRight;

View File

@@ -1,6 +1,7 @@
package pc.exam.pp.module.exam.dal.mysql.paper; package pc.exam.pp.module.exam.dal.mysql.paper;
import org.apache.ibatis.annotations.Mapper; 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 pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu;
import java.util.List; import java.util.List;
@@ -71,5 +72,10 @@ public interface EducationPaperQuMapper
List<EducationPaperQu> selectPaperQuListByPaperId(String paperId); List<EducationPaperQu> selectPaperQuListByPaperId(String paperId);
boolean changePaperQu(ChangePaperQuVo changePaperQuVo);
String selectRamdomQuId(ChangePaperQuVo changePaperQuVo);
} }

View File

@@ -40,6 +40,7 @@ public interface ExamQuestionMapper extends BaseMapperX<ExamQuestion>
*/ */
default PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) { default PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) {
return selectPage(questionVo, new LambdaQueryWrapperX<ExamQuestion>() return selectPage(questionVo, new LambdaQueryWrapperX<ExamQuestion>()
.likeIfPresent(ExamQuestion::getQuId,questionVo.getQuId())
.likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel()) .likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel())
.likeIfPresent(ExamQuestion::getCourseName , questionVo.getCourseName()) .likeIfPresent(ExamQuestion::getCourseName , questionVo.getCourseName())
.likeIfPresent(ExamQuestion::getPointNames , questionVo.getPointNames()) .likeIfPresent(ExamQuestion::getPointNames , questionVo.getPointNames())
@@ -138,5 +139,7 @@ public interface ExamQuestionMapper extends BaseMapperX<ExamQuestion>
void insertOrUpdateList(List<ExamQuestion> examQuestions); void insertOrUpdateList(List<ExamQuestion> examQuestions);
boolean changeStatus(@Param("quId") String quId
,@Param("status") String status);
} }

View File

@@ -185,13 +185,22 @@ public class MonitorServiceImpl implements MonitorService {
System.out.println("是否在允许入场时间段内:" + isWithinEntryTime); System.out.println("是否在允许入场时间段内:" + isWithinEntryTime);
if (isWithinEntryTime){ if (isWithinEntryTime){
long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), // 1. 计算剩余时间(秒)
DateUtil.toLocalDateTime(endTime)); long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), DateUtil.toLocalDateTime(endTime));
info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0); 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); monitorMapper.updateById(info);
return remainingSeconds > 0 ? remainingSeconds : 0; return finalRemaining;
}else { }else {
return 0; return 0;
} }

View File

@@ -96,6 +96,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
@Override @Override
public PageResult<PersonRepDto> selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo) { public PageResult<PersonRepDto> selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo) {
examPersonVo.setOffset(examPersonVo.getOffset());
List<EducationPaperPerson> educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonBySessionId(examPersonVo); List<EducationPaperPerson> educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonBySessionId(examPersonVo);
long total= educationPaperPersonMapper.selectEducationPaperPersonBySessionIdTotal(examPersonVo.getSessionId()); long total= educationPaperPersonMapper.selectEducationPaperPersonBySessionIdTotal(examPersonVo.getSessionId());
List<PersonRepDto> personRepDtos=new ArrayList<>(); List<PersonRepDto> personRepDtos=new ArrayList<>();
@@ -130,10 +131,12 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
long total; long total;
String sessionId = sessionStuPageReqVO.getSessionId(); String sessionId = sessionStuPageReqVO.getSessionId();
if (StringUtils.isNotBlank(sessionId)){ if (StringUtils.isNotBlank(sessionId)){
sessionStuPageReqVO.setOffset(sessionStuPageReqVO.getOffset());
personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionId(sessionStuPageReqVO); personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionId(sessionStuPageReqVO);
total=educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionIdTotal(sessionStuPageReqVO); total=educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionIdTotal(sessionStuPageReqVO);
} }
else { else {
sessionStuPageReqVO.setOffset(sessionStuPageReqVO.getOffset());
personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotIn(sessionStuPageReqVO); personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotIn(sessionStuPageReqVO);
total=educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotInTotal(sessionStuPageReqVO); total=educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotInTotal(sessionStuPageReqVO);

View File

@@ -4,14 +4,21 @@ import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; 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.ExamPaperVo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; 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.dataobject.*;
import pc.exam.pp.module.exam.dal.mysql.paper.*; 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.ExamQuestionMapper;
import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; 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.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 试卷试题Service业务层处理 * 试卷试题Service业务层处理
@@ -40,6 +47,8 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
private SysFileMapper sysFileMapper; private SysFileMapper sysFileMapper;
@Autowired @Autowired
private EducationPaperTaskMapper educationPaperTaskMapper; private EducationPaperTaskMapper educationPaperTaskMapper;
@Autowired
private IExamQuestionService examQuestionService;
/** /**
* 查询试卷试题 * 查询试卷试题
* *
@@ -114,17 +123,30 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
@Override @Override
public ExamPaperVo selectPaperQuListByPaperId(String paperId) { public ExamPaperVo selectPaperQuListByPaperId(String paperId) {
System.out.println(paperId);
List<String> quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); List<String> quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId);
List<ExamQuestion> examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); List<ExamQuestion> examQuestionList=new ArrayList<>();
if (examQuestionList!=null&&examQuestionList.size()>0){ if (quIds!=null&&quIds.size()>0){
for (ExamQuestion examQuestion : examQuestionList) { examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds);
//查找原始和素材试题文件 if (examQuestionList!=null&&examQuestionList.size()>0){
List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads); // 根据 quIds 顺序重新排序 examQuestionList
} Map<String, ExamQuestion> 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<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads);
}
}
}
}
String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId); String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId);
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid);
List<EducationPaperScheme> educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); List<EducationPaperScheme> educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid);
@@ -143,19 +165,23 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId);
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskid, String.valueOf(userId)); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskid, String.valueOf(userId));
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid);
ExamPaperVo examPaperVo=new ExamPaperVo();
if (educationPaperPerson!=null){ if (educationPaperPerson!=null){
String sessionId = educationPaperPerson.getSessionId();
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId);
examPaperVo.setEducationPaperSession(educationPaperSession);
stuInfoPaper.setBatch(educationPaperPerson.getBatch()); stuInfoPaper.setBatch(educationPaperPerson.getBatch());
} }
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId);
stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSchoolName(schoolName);
stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime());
stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); stuInfoPaper.setPaperScore(educationPaper.getPaperScore());
stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName());
stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName());
stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ());
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
ExamPaperVo examPaperVo=new ExamPaperVo();
examPaperVo.setPaperId(paperId); examPaperVo.setPaperId(paperId);
examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setExamQuestionList(examQuestionList);
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
@@ -164,5 +190,71 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
return examPaperVo; 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<String> quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId);
List<ExamQuestion> examQuestionList=new ArrayList<>();
if (quIds != null && !quIds.isEmpty()) {
examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
// 按 quIds 顺序重建 examQuestionList
if (examQuestionList != null && !examQuestionList.isEmpty()) {
// 查询得到 map 方便按 id 查找
Map<String, ExamQuestion> 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<ExamQuestionAnswer> 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<EducationPaperScheme> educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid);
ExamPaperVo examPaperVo=new ExamPaperVo();
examPaperVo.setPaperId(paperId);
examPaperVo.setExamQuestionList(examQuestionList);
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
return examPaperVo;
}
} }

View File

@@ -4,8 +4,18 @@ package pc.exam.pp.module.exam.service.paper;
import cn.afterturn.easypoi.word.WordExportUtil; import cn.afterturn.easypoi.word.WordExportUtil;
import com.alibaba.excel.util.StringUtils; import com.alibaba.excel.util.StringUtils;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.checkerframework.checker.units.qual.A; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pc.exam.pp.framework.common.pojo.PageResult; 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.dal.mysql.question.SysFileMapper;
import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.File; import java.math.BigInteger;
import java.io.FileOutputStream; import java.net.URL;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.sql.Time; import java.sql.Time;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@@ -56,6 +66,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService
@Autowired @Autowired
private EducationPaperTaskMapper educationPaperTaskMapper; private EducationPaperTaskMapper educationPaperTaskMapper;
@Autowired
private EducationPaperSessionMapper educationPaperSessionMapper;
@Autowired @Autowired
private EducationPaperQuMapper educationPaperQuMapper; private EducationPaperQuMapper educationPaperQuMapper;
@@ -215,7 +227,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService
EducationPaperQu educationPaperQu=new EducationPaperQu(); EducationPaperQu educationPaperQu=new EducationPaperQu();
educationPaperQu.setPaperId(uuid); educationPaperQu.setPaperId(uuid);
educationPaperQu.setQuId(examQuestionId); educationPaperQu.setQuId(examQuestionId);
educationPaperQu.setSort(String.valueOf(sort++)); educationPaperQu.setSort(sort++);
educationPaperQus.add(educationPaperQu); educationPaperQus.add(educationPaperQu);
} }
educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus);
@@ -421,24 +433,43 @@ public class EducationPaperServiceImpl implements IEducationPaperService
EducationPaperQu educationPaperQu=new EducationPaperQu(); EducationPaperQu educationPaperQu=new EducationPaperQu();
educationPaperQu.setPaperId(uuid); educationPaperQu.setPaperId(uuid);
educationPaperQu.setQuId(examQuestionId); educationPaperQu.setQuId(examQuestionId);
educationPaperQu.setSort(String.valueOf(sort++)); educationPaperQu.setSort(sort++);
educationPaperQus.add(educationPaperQu); educationPaperQus.add(educationPaperQu);
} }
educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus);
} }
List<String> quIds =educationPaperQuMapper.selectPaperQuByPaperId(uuid); List<String> quIds =educationPaperQuMapper.selectPaperQuByPaperId(uuid);
List<ExamQuestion> examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); // List<ExamQuestion> examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds);
// if (examQuestionList!=null&&examQuestionList.size()>0){
// for (ExamQuestion examQuestion : examQuestionList) {
// //查找原始和素材试题文件
// List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
// examQuestion.setFileUploads(sysFileUploads);
// }
//
// }
List<ExamQuestion> examQuestionList=new ArrayList<>();
if (quIds!=null&&quIds.size()>0){
examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds);
if (examQuestionList!=null&&examQuestionList.size()>0){ if (examQuestionList!=null&&examQuestionList.size()>0){
// 根据 quIds 顺序重新排序 examQuestionList
Map<String, ExamQuestion> 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) { for (ExamQuestion examQuestion : examQuestionList) {
//查找原始和素材试题文件 //查找原始和素材试题文件
List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId()); List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads); examQuestion.setFileUploads(sysFileUploads);
} }
} }
}
//设置进入试卷 考生考试信息确认参数 //设置进入试卷 考生考试信息确认参数
String nickname = SecurityFrameworkUtils.getLoginUserNickname(); String nickname = SecurityFrameworkUtils.getLoginUserNickname();
@@ -448,8 +479,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService
StuInfoPaper stuInfoPaper=new StuInfoPaper(); StuInfoPaper stuInfoPaper=new StuInfoPaper();
stuInfoPaper.setQueNum(String.valueOf(educationPaperQus.size())); stuInfoPaper.setQueNum(String.valueOf(educationPaperQus.size()));
stuInfoPaper.setNickName(nickname); stuInfoPaper.setNickName(nickname);
ExamPaperVo examPaperVo=new ExamPaperVo();
if (educationPaperPerson!=null){ if (educationPaperPerson!=null){
String sessionId = educationPaperPerson.getSessionId();
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId);
examPaperVo.setEducationPaperSession(educationPaperSession);
stuInfoPaper.setBatch(educationPaperPerson.getBatch()); stuInfoPaper.setBatch(educationPaperPerson.getBatch());
} }
stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime());
@@ -461,13 +495,13 @@ public class EducationPaperServiceImpl implements IEducationPaperService
String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId);
stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSchoolName(schoolName);
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
ExamPaperVo examPaperVo=new ExamPaperVo();
examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setExamQuestionList(examQuestionList);
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
examPaperVo.setEducationPaperParam(educationPaperParam); examPaperVo.setEducationPaperParam(educationPaperParam);
examPaperVo.setPaperId(uuid); examPaperVo.setPaperId(uuid);
examPaperVo.setStuInfoPaper(stuInfoPaper); examPaperVo.setStuInfoPaper(stuInfoPaper);
return examPaperVo; return examPaperVo;
} }
@@ -553,22 +587,33 @@ public class EducationPaperServiceImpl implements IEducationPaperService
int columnCount = paperWordList.size(); 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(0).setText("总 分");
table.getRow(0).getCell(1).setText("题号"); table.getRow(0).getCell(2).setText("题号");
for (int i = 0; i < columnCount; i++) { 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(0).setText("登分人");
table.getRow(1).getCell(1).setText("题分"); table.getRow(1).getCell(2).setText("题分");
for (int i = 0; i < columnCount; i++) { 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(0).setText("复查人");
table.getRow(2).getCell(1).setText("得分"); table.getRow(2).getCell(2).setText("得分");
for (int i = 0; i < columnCount; i++) { 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) { for (PaperWordDto item : paperWordList) {
String typeName = item.getType(); // 题型名,如 “单选题”、“多选题”等 String typeName = item.getType(); // 题型名,如 “单选题”、“多选题”等
@@ -592,11 +637,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService
for (PaperQueWordDto paperQueWordDto : que) { for (PaperQueWordDto paperQueWordDto : que) {
XWPFParagraph queParagraph = word.createParagraph(); XWPFParagraph queParagraph = word.createParagraph();
XWPFRun queRun = queParagraph.createRun(); 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); queRun.setFontSize(11);
queParagraph.setSpacingAfter(100); queParagraph.setSpacingAfter(100);
@@ -608,11 +653,17 @@ public class EducationPaperServiceImpl implements IEducationPaperService
for (ExamQuestionAnswer examQuestionAnswer : answerList) { for (ExamQuestionAnswer examQuestionAnswer : answerList) {
XWPFParagraph optionParagraph = word.createParagraph(); XWPFParagraph optionParagraph = word.createParagraph();
XWPFRun optionRun = optionParagraph.createRun(); 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); optionRun.setFontSize(10);
optionParagraph.setSpacingAfter(50); optionParagraph.setSpacingAfter(50);
if ("0".equals(examQuestionAnswer.getIsRight())) { if ("0".equals(examQuestionAnswer.getIsRight())) {
correctOptions.append(option); correctOptions.append(option);
} }
@@ -623,8 +674,6 @@ public class EducationPaperServiceImpl implements IEducationPaperService
answerMap answerMap
.computeIfAbsent(typeName, k -> new StringBuilder()) .computeIfAbsent(typeName, k -> new StringBuilder())
.append(index).append("").append(correctOptions).append("\n"); .append(index).append("").append(correctOptions).append("\n");
} }
index++; index++;
} }
@@ -700,6 +749,49 @@ public class EducationPaperServiceImpl implements IEducationPaperService
return educationPaperMapper.selectPaperIdAndNumByTaskId(taskId); 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 {
// 继续递归处理内部元素,如 <p>、<span> 等
processNode(el, run);
}
}
}
}
} }

View File

@@ -27,6 +27,7 @@ import java.sql.Time;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -417,21 +418,33 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId); String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId);
if (StringUtils.isBlank(paperId)){
return null;
}
List<ExamQuestion> examQuestionList=new ArrayList<>(); List<ExamQuestion> examQuestionList=new ArrayList<>();
List<EducationPaperScheme> educationPaperSchemeList=new ArrayList<>(); List<EducationPaperScheme> educationPaperSchemeList=new ArrayList<>();
List<String> quIds=new ArrayList<>(); List<String> quIds=new ArrayList<>();
if (StringUtils.isNotBlank(paperId)){ if (StringUtils.isNotBlank(paperId)){
quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId);
examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); if (quIds!=null&&quIds.size()>0){
if (examQuestionList!=null&&examQuestionList.size()>0){ examQuestionList =examQuestionMapper.selectExamQuestionListByQuIds(quIds);
for (ExamQuestion examQuestion : examQuestionList) { if (examQuestionList!=null&&examQuestionList.size()>0){
//查找原始和素材试题文件
List<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads);
}
// 根据 quIds 顺序重新排序 examQuestionList
Map<String, ExamQuestion> 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<SysFileUpload> sysFileUploads =sysFileMapper.selectSysFileByQuidIN(examQuestion.getQuId());
examQuestion.setFileUploads(sysFileUploads);
}
}
} }
educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId);
} }
String nickname = SecurityFrameworkUtils.getLoginUserNickname(); String nickname = SecurityFrameworkUtils.getLoginUserNickname();
@@ -448,7 +461,11 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName());
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId)); EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId));
ExamPaperVo examPaperVo=new ExamPaperVo();
if (educationPaperPerson!=null){ if (educationPaperPerson!=null){
String sessionId = educationPaperPerson.getSessionId();
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId);
examPaperVo.setEducationPaperSession(educationPaperSession);
stuInfoPaper.setBatch(educationPaperPerson.getBatch()); stuInfoPaper.setBatch(educationPaperPerson.getBatch());
} }
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
@@ -457,7 +474,6 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ());
stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setSchoolName(schoolName);
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX()); stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
ExamPaperVo examPaperVo=new ExamPaperVo();
examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setExamQuestionList(examQuestionList);
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
examPaperVo.setPaperId(paperId); examPaperVo.setPaperId(paperId);

View File

@@ -1,5 +1,6 @@
package pc.exam.pp.module.exam.service.paper; 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.controller.admin.paper.vo.ExamPaperVo;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu;
@@ -63,5 +64,11 @@ public interface IEducationPaperQuService
ExamPaperVo selectPaperQuListByPaperId(String paperId); ExamPaperVo selectPaperQuListByPaperId(String paperId);
boolean changePaperQu(ChangePaperQuVo changePaperQuVo);
boolean changePaperQuRandom(ChangePaperQuVo changePaperQuVo);
ExamPaperVo selectPaperQuListByPaperIdCenter(String paperId);
} }

View File

@@ -6,6 +6,7 @@ import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
import org.apache.commons.collections4.CollectionUtils;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO;
import pc.exam.pp.module.exam.dal.dataobject.*; 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.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.question.*;
import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper;
import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper;
@@ -63,6 +65,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
private ExamSpecialtyMapper examSpecialtyMapper; private ExamSpecialtyMapper examSpecialtyMapper;
@Autowired @Autowired
private RabbitmqUtils rabbitMqService; private RabbitmqUtils rabbitMqService;
@Autowired
private MysqlKeywordMapper mysqlKeywordMapper;
/** /**
* 查询试题(hyc) * 查询试题(hyc)
* *
@@ -722,7 +726,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer();
examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); examQuestionAnswer.setAnswerId(IdUtils.simpleUUID());
examQuestionAnswer.setQuId(quId); examQuestionAnswer.setQuId(quId);
examQuestionAnswer.setSort(String.valueOf(i++)); examQuestionAnswer.setSort(i++);
// 判断是否为正确答案,忽略大小写和空格 // 判断是否为正确答案,忽略大小写和空格
if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { if (option.equalsIgnoreCase(importUser.getAnswer().trim())) {
examQuestionAnswer.setIsRight("1"); // 正确 examQuestionAnswer.setIsRight("1"); // 正确
@@ -781,7 +785,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer();
examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); examQuestionAnswer.setAnswerId(IdUtils.simpleUUID());
examQuestionAnswer.setQuId(quId); examQuestionAnswer.setQuId(quId);
examQuestionAnswer.setSort(String.valueOf(i++)); examQuestionAnswer.setSort(i++);
// 判断是否为正确答案,忽略大小写和空格 // 判断是否为正确答案,忽略大小写和空格
if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { if (option.equalsIgnoreCase(importUser.getAnswer().trim())) {
examQuestionAnswer.setIsRight("1"); // 正确 examQuestionAnswer.setIsRight("1"); // 正确
@@ -808,6 +812,40 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
return respVO; return respVO;
} }
@Override
public boolean changeStatus(String quId, String status) {
return examQuestionMapper.changeStatus(quId,status);
}
@Override
public PageResult<ExamQuestion> selectExamQuestionListAnswer(QuestionVo questionVo) {
PageResult<ExamQuestion> examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo);
List<ExamQuestion> list = examQuestionPageResult.getList();
if (list != null && !list.isEmpty()) {
for (ExamQuestion examQuestion : list) {
String quId = examQuestion.getQuId();
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
examQuestion.setAnswerList(examQuestionAnswers);
}
}
return examQuestionPageResult;
}
@Override
public List<ExamQuestionAnswer> getPointById(String quId) {
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
if (!CollectionUtils.isEmpty(examQuestionAnswers)) {
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
String answerId = examQuestionAnswer.getAnswerId();
List<ExamMysqlKeyword> newKeywordList = mysqlKeywordMapper.selectList(
new QueryWrapper<ExamMysqlKeyword>().eq("answer_id", answerId)
);
examQuestionAnswer.setExamMysqlKeywordList(newKeywordList);
}
}
return examQuestionAnswers;
}
private void validateChoice(String a, String b, String c, String d, String answer) { private void validateChoice(String a, String b, String c, String d, String answer) {
// A 和 B 必须存在 // A 和 B 必须存在
if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) { if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) {

View File

@@ -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.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; 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.ExamQuestion;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
import java.util.List; import java.util.List;
@@ -103,4 +104,9 @@ public interface IExamQuestionService
QueImportRespVO importUserList(List<QuemportExcelVO> list, Boolean updateSupport); QueImportRespVO importUserList(List<QuemportExcelVO> list, Boolean updateSupport);
boolean changeStatus(String quId, String status);
PageResult<ExamQuestion> selectExamQuestionListAnswer(QuestionVo questionVo);
List<ExamQuestionAnswer> getPointById(String quId);
} }

View File

@@ -70,8 +70,8 @@
specialty_name = #{taskSpecialty} specialty_name = #{taskSpecialty}
AND subject_name = #{educationPaperScheme.spName} AND subject_name = #{educationPaperScheme.spName}
AND tenant_id =#{tId} AND tenant_id =#{tId}
and audit = 0 and audit = '0'
and status = 0 and status = '0'
and deleted ='0' and deleted ='0'
<if test="educationPaperScheme.quLevel != null and educationPaperScheme.quLevel != ''"> <if test="educationPaperScheme.quLevel != null and educationPaperScheme.quLevel != ''">
AND qu_level = #{educationPaperScheme.quLevel} AND qu_level = #{educationPaperScheme.quLevel}

View File

@@ -101,7 +101,7 @@
AND s.class_id = #{classId} AND s.class_id = #{classId}
</if> </if>
ORDER BY s.id DESC ORDER BY s.id DESC
LIMIT #{pageSize} OFFSET #{offset}
</select> </select>
<select id="selectStuIdByTaskId" resultType="java.lang.String"> <select id="selectStuIdByTaskId" resultType="java.lang.String">

View File

@@ -34,6 +34,11 @@
<include refid="selectEducationPaperQuVo"/> <include refid="selectEducationPaperQuVo"/>
where paper_id = #{paperId} where paper_id = #{paperId}
</select> </select>
<select id="selectRamdomQuId" resultType="java.lang.String">
SELECT qu_id from exam_question WHERE subject_name =#{subjectName} and qu_id not IN
(select qu_id from education_paper_qu where paper_id =#{paperId})ORDER BY RAND()
LIMIT 1;
</select>
<insert id="insertEducationPaperQu" parameterType="EducationPaperQu"> <insert id="insertEducationPaperQu" parameterType="EducationPaperQu">
@@ -66,6 +71,12 @@
</trim> </trim>
where paper_id = #{paperId} where paper_id = #{paperId}
</update> </update>
<update id="changePaperQu">
update education_paper_qu
set qu_id = #{newQuId}
where paper_id = #{paperId} and qu_id = #{oldQuId}
</update>
<delete id="deleteEducationPaperQuByPaperId" parameterType="String"> <delete id="deleteEducationPaperQuByPaperId" parameterType="String">
delete from education_paper_qu where paper_id = #{paperId} delete from education_paper_qu where paper_id = #{paperId}

View File

@@ -90,8 +90,8 @@
WHERE specialty_name = #{taskSpecialty} WHERE specialty_name = #{taskSpecialty}
AND subject_name = #{spName} AND subject_name = #{spName}
AND tenant_id =#{tId} AND tenant_id =#{tId}
and audit = 0 and audit = '0'
and status = 0 and status = '0'
<if test="quLevel != null and quLevel != ''"> <if test="quLevel != null and quLevel != ''">
AND qu_level = #{quLevel} AND qu_level = #{quLevel}
</if> </if>

View File

@@ -283,6 +283,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</update> </update>
<update id="changeStatus">
UPDATE exam_question
set status =#{status}
where qu_id =#{quId}
</update>
</mapper> </mapper>

View File

@@ -3,6 +3,7 @@ package pc.exam.pp.module.judgement.controller.admin.getpoints;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult; 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.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.Points;
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo; import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo;
@@ -23,6 +24,7 @@ public class GetPointsController {
* @return 得分 * @return 得分
*/ */
@PostMapping("/get_filePoint") @PostMapping("/get_filePoint")
@TenantIgnore
public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException { public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException {
return CommonResult.success(examGetPointsService.get_file_point(pointsVo)); return CommonResult.success(examGetPointsService.get_file_point(pointsVo));
} }
@@ -31,6 +33,7 @@ public class GetPointsController {
* @return 得分 * @return 得分
*/ */
@PostMapping("/get_mysql_point") @PostMapping("/get_mysql_point")
@TenantIgnore
public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException { public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException {
return CommonResult.success(examGetPointsService.get_mysql_point(pointsVo)); return CommonResult.success(examGetPointsService.get_mysql_point(pointsVo));
} }
@@ -47,11 +50,13 @@ public class GetPointsController {
* @return 得分 * @return 得分
*/ */
@PostMapping("/update_mysql_point") @PostMapping("/update_mysql_point")
@TenantIgnore
public CommonResult update_mysql_point(@RequestBody Points points) { public CommonResult update_mysql_point(@RequestBody Points points) {
return CommonResult.success(examGetPointsService.update_mysql_point(points)); return CommonResult.success(examGetPointsService.update_mysql_point(points));
} }
@GetMapping("/get_Point_id/{quId}") @GetMapping("/get_Point_id/{quId}")
@TenantIgnore
public CommonResult getPointById(@PathVariable("quId") String quId) { public CommonResult getPointById(@PathVariable("quId") String quId) {
return CommonResult.success(examGetPointsService.getPointById(quId)); return CommonResult.success(examGetPointsService.getPointById(quId));
} }
@@ -60,6 +65,7 @@ public class GetPointsController {
* @return 得分 * @return 得分
*/ */
@PostMapping("/set_browser_point") @PostMapping("/set_browser_point")
@TenantIgnore
//todo 老师自己设置,不读文件 //todo 老师自己设置,不读文件
public CommonResult get_browser_point(@RequestBody Points points) { public CommonResult get_browser_point(@RequestBody Points points) {
return CommonResult.success(examGetPointsService.get_browser_point(points)); return CommonResult.success(examGetPointsService.get_browser_point(points));

View File

@@ -78,7 +78,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
answer.setContent(key); // 设置文件路径 answer.setContent(key); // 设置文件路径
answer.setScoreRate("1"); answer.setScoreRate("1");
//这里设置answer的排序按照循环次数来 //这里设置answer的排序按照循环次数来
answer.setSort(String.valueOf(sortCounter.getAndIncrement())); // 按顺序设置排序值 answer.setSort(sortCounter.getAndIncrement()); // 按顺序设置排序值
if (value.startsWith("仅存在于 "+stuFilePath)) { if (value.startsWith("仅存在于 "+stuFilePath)) {
answer.setContentIn("考察删除"); answer.setContentIn("考察删除");
} else if (value.startsWith("仅存在于 "+answerFilePath)) { } else if (value.startsWith("仅存在于 "+answerFilePath)) {
@@ -89,7 +89,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
} }
return answer; return answer;
}) })
.sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序 .sorted(Comparator.comparingInt(answer -> answer.getSort())) // 按 sort 排序
.collect(Collectors.toList()); .collect(Collectors.toList());
answerList.addAll(formattedDifferences); answerList.addAll(formattedDifferences);
zip_file_sth.delete(); zip_file_sth.delete();
@@ -188,7 +188,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
//设置sort //设置sort
AtomicInteger sortCounter = new AtomicInteger(1); AtomicInteger sortCounter = new AtomicInteger(1);
points.getQuestionAnswerList().forEach(answer -> { points.getQuestionAnswerList().forEach(answer -> {
answer.setSort(String.valueOf(sortCounter.getAndIncrement())); answer.setSort(sortCounter.getAndIncrement());
}); });
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList(); List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) { for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) {
@@ -267,7 +267,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
String answerId = IdUtils.simpleUUID(); String answerId = IdUtils.simpleUUID();
answer.setAnswerId(answerId); answer.setAnswerId(answerId);
answer.setQuId(quId); // 以防前端未传 answer.setQuId(quId); // 以防前端未传
answer.setSort(String.valueOf(counter.getAndIncrement())); // 设置排序字段String 类型) answer.setSort(counter.getAndIncrement()); // 设置排序字段String 类型)
List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList(); List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList();
if (!CollectionUtils.isEmpty(keywordList)) { if (!CollectionUtils.isEmpty(keywordList)) {
for (ExamMysqlKeyword keyword : keywordList) { for (ExamMysqlKeyword keyword : keywordList) {

View File

@@ -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.monitor.MonitorMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper; 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.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.paper.EducationPaperTaskMapper;
import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper;
import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils;