【修改】增加后台api接口注释,优化mysql判分,知识点改为存储id,试题已使用,学生除待考其它状态不可删除。。。

【新增】试卷任务参数,在已有的试卷里抽卷。。。
This commit is contained in:
YOHO\20373
2025-06-09 10:51:13 +08:00
parent d34b189598
commit a100427181
45 changed files with 1027 additions and 203 deletions

View File

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

View File

@@ -1,5 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.knowledge;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +25,7 @@ import java.util.Objects;
* @author pengchen
* @date 2025-04-02
*/
@Tag(name = "管理后台 - 知识点")
@RestController
@RequestMapping("/exam/points")
public class ExamKnowledgePointsController{
@@ -33,6 +36,7 @@ public class ExamKnowledgePointsController{
/**
* 查询知识点列表
*/
@Operation(summary = "查询知识点列表")
@GetMapping("/list")
public CommonResult list(ExamKnowledgePoints knowledgePoints) {
@@ -53,6 +57,7 @@ public class ExamKnowledgePointsController{
/**
* 获取知识点详细信息
*/
@Operation(summary = "获取知识点详细信息")
@GetMapping(value = "/{spId}")
public CommonResult getInfo(@PathVariable("spId") Long spId) {
return CommonResult.success(knowledgePointsService.selectKnowledgePointsBySpId(spId));
@@ -61,7 +66,7 @@ public class ExamKnowledgePointsController{
/**
* 新增知识点
*/
@Operation(summary = "新增知识点")
@PostMapping
public CommonResult add(@RequestBody ExamKnowledgePoints knowledgePoints) {
//获取登录用户id
@@ -95,6 +100,7 @@ public class ExamKnowledgePointsController{
/**
* 修改知识点
*/
@Operation(summary = "修改知识点")
@PutMapping
public CommonResult edit(@RequestBody ExamKnowledgePoints knowledgePoints) {
//判断是否修改的根节点
@@ -113,6 +119,7 @@ public class ExamKnowledgePointsController{
/**
* 删除知识点
*/
@Operation(summary = "删除知识点")
@DeleteMapping("/{spIds}")
public CommonResult remove(@PathVariable Long[] spIds) {
//用于判断是否符合删除条件
@@ -150,6 +157,7 @@ public class ExamKnowledgePointsController{
/**
* 构建知识点树状结构
*/
@Operation(summary = "构建知识点树状结构")
@GetMapping("/tree")
public CommonResult listTree(ExamKnowledgePoints knowledgePoints) {
//定义List

View File

@@ -1,6 +1,8 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.java.Log;
import org.checkerframework.checker.units.qual.A;
@@ -12,6 +14,7 @@ import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.common.util.object.BeanUtils;
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueryRequest;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperSubmitDTO;
import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto;
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
@@ -32,6 +35,7 @@ import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.get
* @date 2025-04-15
*/
@RestController
@Tag(name = "管理后台 - 试卷管理")
@RequestMapping("/exam/paper")
public class EducationPaperController
{
@@ -47,6 +51,7 @@ public class EducationPaperController
/**
* 查询试卷列表
*/
@Operation(summary = "查询试卷列表")
@GetMapping("/list")
public CommonResult<PageResult<EducationPaper>> list(PaperPageVo paperPageVo)
{
@@ -68,6 +73,7 @@ public class EducationPaperController
/**
* 获取试卷详细信息
*/
@Operation(summary = "获取试卷详细信息")
@GetMapping(value = "/{paperId}")
public CommonResult getInfo(@PathVariable("paperId") String paperId)
{
@@ -77,6 +83,7 @@ public class EducationPaperController
/**
* 新增试卷
*/
@Operation(summary = "新增试卷")
@GetMapping("/add")
public CommonResult add(@RequestParam("num") Integer num,@RequestParam("taskid") String taskid,@RequestParam("taskSpecialty") String taskSpecialty)
{
@@ -87,6 +94,7 @@ public class EducationPaperController
/**
* 学生端根据任务id返回 考试信息
*/
@Operation(summary = "学生端根据任务id返回 考试信息")
@GetMapping("/stuInfoPaper")
public CommonResult stuInfoPaper(@RequestParam("taskid") String taskid)
{
@@ -107,6 +115,7 @@ public class EducationPaperController
/**
* 修改试卷
*/
@Operation(summary = "修改试卷")
@PutMapping
public CommonResult edit(@RequestBody EducationPaper educationPaper)
{
@@ -116,6 +125,7 @@ public class EducationPaperController
/**
* 删除试卷
*/
@Operation(summary = "删除试卷")
@DeleteMapping("/{paperIds}")
public CommonResult remove(@PathVariable String[] paperIds)
{
@@ -125,6 +135,7 @@ public class EducationPaperController
/**
* 根据方案获取试卷下拉
*/
@Operation(summary = "根据方案获取试卷下拉")
@GetMapping(value = "/getPaperByTaskId")
public CommonResult getPaperByTaskId(@RequestParam(value = "taskId") String taskId)
{
@@ -137,6 +148,7 @@ public class EducationPaperController
* @param educationPaper
* @return
*/
@Operation(summary = "抽卷方式调整")
@PostMapping("/update")
public CommonResult update(@RequestBody EducationPaper educationPaper)
{
@@ -194,6 +206,7 @@ public class EducationPaperController
/**
* 根据方案获取已经设置好的试卷
*/
@Operation(summary = "根据方案获取已经设置好的试卷")
@PostMapping(value = "/getPaperByTaskIdByType")
public CommonResult getPaperByTaskIdByType(@RequestBody PaperQueryRequest requestData)
{
@@ -205,7 +218,7 @@ public class EducationPaperController
* @param statusDto
* @return
*/
@Operation(summary = "更改试卷任务状态")
@PutMapping("/updatePaperStatus")
public CommonResult updateTaskStatus(@RequestBody StatusDto statusDto) { // 改为Integer类型
return CommonResult.success(
@@ -219,6 +232,7 @@ public class EducationPaperController
* @param paperPageVo
* @return
*/
@Operation(summary = "学生端 返回试卷任务列表")
@GetMapping("/stulist")
public CommonResult<PageResult<EducationPaperStuDto>> stulist(PaperPageVo paperPageVo)
{
@@ -229,10 +243,11 @@ public class EducationPaperController
/**
* 下载试卷
* 下载笔试试卷
* @param paperIds
* @return
*/
@Operation(summary = "下载笔试试卷")
@GetMapping("/addUpload/{paperIds}")
public void downLoad(@PathVariable String[] paperIds, HttpServletResponse response) throws Exception {
educationPaperService.downloadWord(paperIds,response);
@@ -240,4 +255,13 @@ public class EducationPaperController
@PostMapping("/addPaperBypaper")
public CommonResult submitPaperList(@RequestBody PaperSubmitDTO dto) {
System.out.println(dto);
educationPaperService.addPaperBypaper(dto);
// 处理逻辑
return CommonResult.success("新增成功");
}
}

View File

@@ -1,6 +1,8 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -14,6 +16,7 @@ import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SESS
* @author pengchen
* @date 2025-04-16
*/
@Tag(name = "管理后台 - 试卷通用参数")
@RestController
@RequestMapping("/exam/param")
public class EducationPaperParamController
@@ -28,6 +31,7 @@ public class EducationPaperParamController
/**
* 获取通用参数详细信息
*/
@Operation(summary = "获取通用参数详细信息")
@GetMapping(value = "/getInfo")
public CommonResult getInfo(@RequestParam("taskId") String taskId)
{
@@ -38,6 +42,7 @@ public class EducationPaperParamController
/**
* 新增通用参数
*/
@Operation(summary = "新增通用参数")
@PostMapping
public CommonResult add(@RequestBody EducationPaperParam educationPaperParam)
{
@@ -47,6 +52,7 @@ public class EducationPaperParamController
/**
* 修改通用参数
*/
@Operation(summary = "修改通用参数")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperParam educationPaperParam)
{
@@ -56,6 +62,7 @@ public class EducationPaperParamController
/**
* 删除通用参数
*/
@Operation(summary = "删除通用参数")
@DeleteMapping("/{paramIds}")
public CommonResult remove(@PathVariable String[] paramIds)
{
@@ -67,6 +74,7 @@ public class EducationPaperParamController
* @param taskId
* @return
*/
@Operation(summary = "步骤条 (考场)警告")
@GetMapping( "/check-can-enter-step4/{taskId}")
public CommonResult ckeckSession(@PathVariable("taskId") String taskId){
EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(taskId);
@@ -84,6 +92,7 @@ public class EducationPaperParamController
* @param taskId
* @return
*/
@Operation(summary = "步骤条 (考场)无警告")
@GetMapping( "/check-can-enter-step4NoMsg/{taskId}")
public CommonResult ckeckSessionNoMsg(@PathVariable("taskId") String taskId){
EducationPaperParam educationPaperParam = educationPaperParamService.selectEducationPaperParamByTaskId(taskId);

View File

@@ -1,5 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
@@ -25,6 +27,7 @@ import java.util.List;
* @author pengchen
* @date 2025-04-18
*/
@Tag(name = "管理后台 - 试卷人员分配")
@RestController
@RequestMapping("/exam/person")
public class EducationPaperPersonController
@@ -38,6 +41,7 @@ public class EducationPaperPersonController
/**
* 查询试卷人员分配列表
*/
@Operation(summary = "查询试卷人员分配列表")
@GetMapping("/list")
public CommonResult list(EducationPaperPerson educationPaperPerson)
{
@@ -61,6 +65,7 @@ public class EducationPaperPersonController
/**
* 新增试卷人员分配
*/
@Operation(summary = "新增试卷人员分配")
@PostMapping
public CommonResult add(@RequestBody EducationPaperPerson educationPaperPerson)
{
@@ -70,6 +75,7 @@ public class EducationPaperPersonController
/**
* 修改试卷人员分配
*/
@Operation(summary = "修改试卷人员分配")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperPerson educationPaperPerson)
{
@@ -79,6 +85,7 @@ public class EducationPaperPersonController
/**
* 删除试卷人员分配
*/
@Operation(summary = "删除试卷人员分配")
@DeleteMapping("/{taskIds}")
public CommonResult remove(@PathVariable String[] taskIds)
{
@@ -89,6 +96,7 @@ public class EducationPaperPersonController
/**
* 根据试卷任务获取人员分配列表
*/
@Operation(summary = "根据试卷任务获取人员分配列表")
@GetMapping( "/getList")
public CommonResult<PageResult<PersonRepDto>> getInfo(ExamPersonVo examPersonVo)
{
@@ -98,6 +106,7 @@ public class EducationPaperPersonController
/**
* 根据试卷场次获取人员分配列表
*/
@Operation(summary = "根据试卷场次获取人员分配列表")
@GetMapping(value = "/getSessionStu")
public CommonResult<PageResult<PersonRepDto>> getSessionStu(ExamPersonVo examPersonVo) {
PageResult<PersonRepDto> list = educationPaperPersonService.selectEducationPaperPersonBySessionId(examPersonVo);
@@ -107,6 +116,7 @@ public class EducationPaperPersonController
/**
* 根据场次id学生信息等多个查询条件 获取人员分配列表(获取没有分配场次的人员)
*/
@Operation(summary = "根据场次id学生信息等多个查询条件 获取人员分配列表(获取没有分配场次的人员)")
@GetMapping(value = "/getSessionStuBySearch")
public CommonResult<PageResult<PersonRepDto>> getSessionStuBySearch(SessionStuPageReqVO sessionStuPageReqVO) {
PageResult<PersonRepDto> list = educationPaperPersonService.selectEducationPaperPersonBySearch(sessionStuPageReqVO);
@@ -121,6 +131,7 @@ public class EducationPaperPersonController
* @param reqVO 包含学生id场次id,试卷任务id
* @return
*/
@Operation(summary = "给任务场次分配学生")
@RequestMapping("/setSessionStu")
public CommonResult<String> handleStudentSelection(@RequestBody StudentSessionReqVO reqVO) {
if (reqVO.getStudentIds()!=null&&reqVO.getStudentIds().size()>0){
@@ -136,6 +147,7 @@ public class EducationPaperPersonController
* @param reqVO
* @return
*/
@Operation(summary = "删除场次学生")
@DeleteMapping("/removeSessionStu")
public CommonResult<Integer> removeSessionStu(@RequestBody StudentSessionReqVO reqVO) {
return CommonResult.success(educationPaperPersonService.removeSessionStu(reqVO));
@@ -147,6 +159,7 @@ public class EducationPaperPersonController
* @param deleteRequestVo
* @return
*/
@Operation(summary = "删除任务学生")
@DeleteMapping("/removeTaskStu")
public CommonResult<Integer> removeTaskStu(@RequestBody DeleteRequestVo deleteRequestVo) {
return CommonResult.success(educationPaperPersonService.removeTaskStu(deleteRequestVo));

View File

@@ -1,5 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
@@ -15,6 +17,7 @@ import java.util.List;
* @author pengchen
* @date 2025-04-15
*/
@Tag(name = "管理后台 - 试卷试题")
@RestController
@RequestMapping("/exam/qu")
public class EducationPaperQuController
@@ -25,6 +28,7 @@ public class EducationPaperQuController
/**
* 查询试卷试题列表
*/
@Operation(summary = "查询试卷试题列表")
@GetMapping("/list")
public CommonResult list(EducationPaperQu educationPaperQu)
{
@@ -46,6 +50,7 @@ public class EducationPaperQuController
/**
* 获取试卷试题详细信息
*/
@Operation(summary = "获取试卷试题详细信息")
@GetMapping(value = "/{paperId}")
public CommonResult getInfo(@PathVariable("paperId") String paperId)
{
@@ -55,6 +60,7 @@ public class EducationPaperQuController
/**
* 新增试卷试题
*/
@Operation(summary = "新增试卷试题")
@PostMapping
public CommonResult add(@RequestBody EducationPaperQu educationPaperQu)
{
@@ -64,6 +70,7 @@ public class EducationPaperQuController
/**
* 修改试卷试题
*/
@Operation(summary = "修改试卷试题")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperQu educationPaperQu)
{
@@ -73,6 +80,7 @@ public class EducationPaperQuController
/**
* 删除试卷试题
*/
@Operation(summary = "删除试卷试题")
@DeleteMapping("/{paperIds}")
public CommonResult remove(@PathVariable String[] paperIds)
{
@@ -83,6 +91,7 @@ public class EducationPaperQuController
/**
* 学生端根据id获取试卷
*/
@Operation(summary = "学生端根据id获取试卷")
@GetMapping(value = "/getPaper")
public CommonResult getPaper(@RequestParam(value = "paperId") String paperId)
{
@@ -91,6 +100,7 @@ public class EducationPaperQuController
/**
* 中心端 点击编辑 根据id获取试卷
*/
@Operation(summary = "中心端 点击编辑 根据id获取试卷")
@GetMapping(value = "/getPaperCenter")
public CommonResult getPaperCenter(@RequestParam(value = "paperId") String paperId)
{
@@ -104,6 +114,7 @@ public class EducationPaperQuController
* @param changePaperQuVo
* @return
*/
@Operation(summary = "更换试卷试题")
@PostMapping("/changePaperQu")
public CommonResult changePaperQu(@RequestBody ChangePaperQuVo changePaperQuVo)
{
@@ -115,6 +126,7 @@ public class EducationPaperQuController
* @param changePaperQuVo
* @return
*/
@Operation(summary = "随机更换试卷试题")
@PostMapping("/changePaperQuRandom")
public CommonResult changePaperQuRandom(@RequestBody ChangePaperQuVo changePaperQuVo)
{

View File

@@ -1,5 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
@@ -23,6 +25,7 @@ import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SCHE
* @author pengchen
* @date 2025-04-15
*/
@Tag(name = "管理后台 - 试卷方案")
@RestController
@RequestMapping("/exam/scheme")
public class EducationPaperSchemeController
@@ -38,6 +41,7 @@ public class EducationPaperSchemeController
/**
* 查询试卷方案列表
*/
@Operation(summary = "查询试卷方案列表")
@GetMapping("/list")
public CommonResult list(EducationPaperScheme educationPaperScheme)
{
@@ -59,6 +63,7 @@ public class EducationPaperSchemeController
/**
* 获取试卷方案详细信息
*/
@Operation(summary = "获取试卷方案详细信息")
@GetMapping(value = "/{schemeId}")
public CommonResult getInfo(@PathVariable("schemeId") String schemeId)
{
@@ -68,6 +73,7 @@ public class EducationPaperSchemeController
/**
* 新增试卷方案
*/
@Operation(summary = "新增试卷方案")
@PostMapping
public CommonResult add(@RequestBody EducationPaperScheme educationPaperScheme)
{
@@ -82,7 +88,9 @@ public class EducationPaperSchemeController
return CommonResult.error(DEMO03_PAPER_TASK_ADD_EXISTS);
}
}
int counts= educationPaperSchemeService.selectEducationPaperSchemeCountsByTaskId(educationPaperScheme.getTaskId());
educationPaperScheme.setSort(++counts);
List<EducationPaperScheme> educationPaperSchemes = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(educationPaperScheme.getTaskId());
//判断 方案下 是否有同题型
String spName = educationPaperScheme.getSpName();
@@ -99,6 +107,7 @@ public class EducationPaperSchemeController
/**
* 修改试卷方案
*/
@Operation(summary = "修改试卷方案")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperScheme educationPaperScheme)
{
@@ -108,6 +117,7 @@ public class EducationPaperSchemeController
/**
* 删除试卷方案
*/
@Operation(summary = "删除试卷方案")
@DeleteMapping("/{schemeIds}")
public CommonResult remove(@PathVariable String schemeIds)
{

View File

@@ -1,5 +1,7 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +26,7 @@ import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstan
* @author pengchen
* @date 2025-04-17
*/
@Tag(name = "管理后台 - 试卷场次")
@RestController
@RequestMapping("/exam/session")
public class EducationPaperSessionController
@@ -34,6 +37,7 @@ public class EducationPaperSessionController
/**
* 查询试卷场次列表
*/
@Operation(summary = "查询试卷场次列表")
@GetMapping("/list")
public CommonResult<PageResult<EducationPaperSession>> list(EducationPaperSessionVo educationPaperSessionVo)
{
@@ -55,6 +59,7 @@ public class EducationPaperSessionController
/**
* 获取试卷场次详细信息
*/
@Operation(summary = "获取试卷场次详细信息")
@GetMapping(value = "/{sessionId}")
public CommonResult getInfo(@PathVariable("sessionId") String sessionId)
{
@@ -64,6 +69,7 @@ public class EducationPaperSessionController
/**
* 新增试卷场次
*/
@Operation(summary = "新增试卷场次")
@PostMapping
public CommonResult add(@RequestBody EducationPaperSession educationPaperSession)
{
@@ -85,6 +91,7 @@ public class EducationPaperSessionController
/**
* 修改试卷场次
*/
@Operation(summary = "修改试卷场次")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperSession educationPaperSession)
{
@@ -104,6 +111,7 @@ public class EducationPaperSessionController
/**
* 删除试卷场次
*/
@Operation(summary = "删除试卷场次")
@DeleteMapping("/{sessionIds}")
public CommonResult remove(@PathVariable String[] sessionIds)
{
@@ -113,6 +121,7 @@ public class EducationPaperSessionController
/**
* 修改试卷场次详细信息
*/
@Operation(summary = "修改试卷场次详细信息")
@PostMapping(value = "/set")
public CommonResult set(@RequestBody SessionParamDto param) {
List<String> rows = param.getRows();
@@ -138,6 +147,7 @@ public class EducationPaperSessionController
* @param statusDto
* @return
*/
@Operation(summary = "更改状态")
@PutMapping("/updateSessionStatus")
public CommonResult updateSessionStatus(@RequestBody StatusDto statusDto) {
return CommonResult.success(
@@ -148,6 +158,7 @@ public class EducationPaperSessionController
/**
* 获取试卷场次答题时间
*/
@Operation(summary = "获取试卷场次答题时间")
@GetMapping(value = "/getTime/{taskId}")
public CommonResult getAnswerTime(@PathVariable("taskId") String taskId)
{

View File

@@ -1,6 +1,8 @@
package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -9,6 +11,7 @@ import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.common.util.object.BeanUtils;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO;
import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam;
import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto;
@@ -25,6 +28,7 @@ import java.util.List;
* @author pengchen
* @date 2025-04-14
*/
@Tag(name = "管理后台 - 试卷任务")
@RestController
@RequestMapping("/exam/task")
public class EducationPaperTaskController
@@ -35,15 +39,25 @@ public class EducationPaperTaskController
/**
* 查询试卷任务列表(服务器端)
*/
@Operation(summary = "查询试卷任务列表(服务器端)")
@GetMapping("/list")
public CommonResult<PageResult<EducationPaperTask>> list(PaperTaskPageVo educationPaperTask)
{
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
}
@Operation(summary = "查询试卷任务列表(带试卷)")
@GetMapping("/listPaper")
public CommonResult<PageResult<EducationPaperTask>> taskAndPaperlist(PaperTaskPageVo educationPaperTask)
{
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperAndTaskList(educationPaperTask);
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
}
/**
* 查询试卷任务列表(学生端)
*/
@Operation(summary = "查询试卷任务列表(学生端)")
@GetMapping("/stulist")
public CommonResult<PageResult<EducationPaperTask>> stulist(PaperTaskPageVo educationPaperTask)
{
@@ -66,6 +80,7 @@ public class EducationPaperTaskController
/**
* 获取试卷任务详细信息
*/
@Operation(summary = "获取试卷任务详细信息")
@GetMapping(value = "/{taskId}")
public CommonResult getInfo(@PathVariable("taskId") String taskId)
{
@@ -75,6 +90,7 @@ public class EducationPaperTaskController
/**
* 新增试卷任务
*/
@Operation(summary = "新增试卷任务")
@PostMapping
public CommonResult add(@RequestBody EducationPaperTask educationPaperTask)
{
@@ -85,6 +101,7 @@ public class EducationPaperTaskController
/**
* 修改试卷任务
*/
@Operation(summary = "修改试卷任务")
@PutMapping
public CommonResult edit(@RequestBody EducationPaperTask educationPaperTask)
{
@@ -94,6 +111,7 @@ public class EducationPaperTaskController
/**
* 删除试卷任务
*/
@Operation(summary = "删除试卷任务")
@DeleteMapping("/del/{taskId}")
public CommonResult remove(@PathVariable String taskId )
{
@@ -102,6 +120,7 @@ public class EducationPaperTaskController
/**
* 批量删除试卷任务
*/
@Operation(summary = "批量删除试卷任务")
@DeleteMapping("/{taskIds}")
public CommonResult removeIds(@PathVariable String[] taskIds )
{
@@ -110,6 +129,7 @@ public class EducationPaperTaskController
/**
* 获取专业列表
*/
@Operation(summary = "获取专业列表")
@GetMapping("/getSpeciality")
public CommonResult getSpeciality()
{
@@ -119,6 +139,7 @@ public class EducationPaperTaskController
/**
* 获取题型列表
*/
@Operation(summary = "获取题型列表")
@GetMapping("/getCourse")
public CommonResult getCourse()
{
@@ -128,6 +149,7 @@ public class EducationPaperTaskController
/**
* 获取关键字
*/
@Operation(summary = "获取关键字")
@GetMapping("/getKeywords")
public CommonResult getKeywords()
{
@@ -136,6 +158,7 @@ public class EducationPaperTaskController
/**
* 获取知识点
*/
@Operation(summary = "获取知识点")
@GetMapping("/getPoints")
public CommonResult getPoints (@RequestParam(value = "name") String name)
{
@@ -146,6 +169,7 @@ public class EducationPaperTaskController
/*
按照方案返回试题数量
*/
@Operation(summary = "按照方案返回试题数量")
@PostMapping("/getQuestionCount")
@PermitAll
public CommonResult fetchQuestionCount(@RequestBody SchemeParam param) {
@@ -160,7 +184,8 @@ public class EducationPaperTaskController
* @param tempDto
* @return
*/
@PostMapping("/submitSelection")
@Operation(summary = "模板库 复制")
@PostMapping("/submitSelection")
public CommonResult submitSelection(@RequestBody TempDto tempDto) {
System.out.println("接收到的任务ID: " + tempDto.getTaskId());
System.out.println("接收到的选项: " + tempDto.getOptions());
@@ -173,7 +198,6 @@ public class EducationPaperTaskController
if (options!=null&&options.size()>0){
educationPaperTaskService.submitSelection(tempDto);
}else {
return CommonResult.error(INTERNAL_SERVER_ERROR.getCode(),"请选择复制的参数!");
}
@@ -186,6 +210,7 @@ public class EducationPaperTaskController
* @param statusDto
* @return
*/
@Operation(summary = "更改 任务状态")
@PutMapping("/updateTaskStatus")
public CommonResult<Boolean> updateTaskStatus(@RequestBody StatusDto statusDto) {
return CommonResult.success(
@@ -195,14 +220,32 @@ public class EducationPaperTaskController
/**
* 学生端 根据taskid返回 试卷信息
* 学生端 根据任务id返回 试卷信息
* @param taskId
* @return
*/
@Operation(summary = "学生端 根据任务id返回 试卷信息")
@GetMapping(value = "/getPaperBytaskId")
public CommonResult getPaperBytaskId(@RequestParam(value = "taskId") String taskId)
{
return CommonResult.success(educationPaperTaskService.selectPaperQuByPaperId(taskId));
}
@PostMapping("/checkType")
public CommonResult checkType(@RequestBody PaperQueUpdateDTO dto) {
String taskId = dto.getTaskId();
List<String> queList = dto.getQue();
try {
educationPaperTaskService.checkType(dto);
return CommonResult.success("题型更新成功");
} catch (Exception e) {
return CommonResult.error(9999999,e.getMessage());
}
}
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.controller.admin.paper.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PaperQueUpdateDTO {
private String taskId;
private List<String> que;
}

View File

@@ -0,0 +1,13 @@
package pc.exam.pp.module.exam.controller.admin.paper.dto;
import lombok.Data;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaper;
import java.util.List;
@Data
public class PaperSubmitDTO {
private String num;
private String taskId;
private List<PaperSubmitListDTO> paperList;
}

View File

@@ -0,0 +1,18 @@
package pc.exam.pp.module.exam.controller.admin.paper.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PaperSubmitListDTO {
private String id;
private String label;
private String num;
private String que;
private String taskName;
private String taskType;
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.controller.admin.paper.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
import java.util.Set;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SchemeInfo {
private Integer count;
private Map<String, Set<String>> schemeToQuestion;
}

View File

@@ -65,9 +65,9 @@ public class EducationPaperParam
// @Excel(name = "考试的模式下定时上传考试目录,每{x}分钟传一次")
private String uploadTime;
/** 完成考试后是否删除考试目录0是1否 */
/** 是否允许复制题干0是1否 */
// @Excel(name = "完成考试后是否删除考试目录", readConverterExp = "0=是1否")
private String isDel;
private String isCopy;
//是否显示重答按钮
private String isRepeat;
@@ -93,5 +93,9 @@ public class EducationPaperParam
private String isNet;
//禁止截屏
private String isScreen;
//是否显示成绩
private String isScore;
//是否显示成绩明细
private String isScoreDetail;
}

View File

@@ -11,6 +11,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
import java.util.List;
/**
* 试卷任务对象 education_paper_task
*
@@ -61,4 +63,10 @@ public class EducationPaperTask extends TenantBaseDO
@TableField(exist = false)
private String score;
@TableField(exist = false)
private List<EducationPaperScheme> educationPaperSchemeList;
@TableField(exist = false)
private List<EducationPaper> educationPaperList;
}

View File

@@ -43,13 +43,15 @@ public class ExamQuestion extends TenantBaseDO {
// @Excel(name = "章节名称")
private String chapteridDictText;
@TableField(exist = false)
private String chapteridDictTextVo;
/** 题型名称 */
// @Excel(name = "题型名称")
private String subjectName;
/** 题型难度0简单1一般2困难 */
// @Excel(name = "题型难度0简单1一般2困难")
private String quLevel;
private Integer quLevel;
/** 试题内容(带样式:<p>下列表格123</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 31.4907%;\">1</td>\) */
// @Excel(name = "试题内容")
@@ -67,6 +69,8 @@ public class ExamQuestion extends TenantBaseDO {
// @Excel(name = "知识点")
private String pointNames;
@TableField(exist = false)
private String pointNamesVo;
/** 关键字 */
// @Excel(name = "关键字")
private String keywords;

View File

@@ -52,4 +52,9 @@ public interface ExamKnowledgePointsMapper extends BaseMapperX<ExamKnowledgePoin
List<SpecialtyQueryVo> selectKnowledgePointsListPage(@Param("knowledgePoints")ExamKnowledgePoints knowledgePoints);
String selectKnowledgeNameBySpId(String spId);
List<ExamKnowledgePoints> selectKnowledgePoints();
}

View File

@@ -57,4 +57,5 @@ return selectPage(reqVO, new LambdaQueryWrapperX<MonitorDO>()
List<String> selectByStuIdAndTaskId(Long stuId);
List<String> selectStuIdByTaskId(String taskId);
}

View File

@@ -99,5 +99,14 @@ public interface EducationPaperQuMapper
String selectRamdomQuId(ChangePaperQuVo changePaperQuVo);
List<String> selectUsedQuestionIds(String[] ids);
/**
* 根据试卷id和题型名称找出该试卷的符合试题
* @param paperId
* @param spName
* @return
*/
List<String> selectByPaperIdAndType(String paperId, String spName);
}

View File

@@ -77,4 +77,5 @@ public interface EducationPaperSchemeMapper
*/
void insertEducationPaperSchemeList(List<EducationPaperScheme> educationPaperSchemeList);
int selectEducationPaperSchemeCountsByTaskId(String taskId);
}

View File

@@ -77,4 +77,9 @@ public interface ExamQuestionAnswerMapper extends BaseMapperX<ExamQuestionAnswe
String selectAnswerFile(String quId);
String selectCountPointByQuId(String quId);
String selectExamQuestionAnswerScoreByAnswerId(String answerId);
}

View File

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.common.util.json.JsonUtils;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto;
@@ -40,6 +41,7 @@ import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 试卷人员分配Service业务层处理
@@ -268,29 +270,66 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
}
@Override
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
public int removeSessionStu(StudentSessionReqVO reqVO) {
//获取前端传入的学生ID列表
List<String> studentIds = reqVO.getStudentIds();
for (String studentId : studentIds) {
String key = "userCache:" + reqVO.getTaskId()+":"+studentId;
redisTemplate.delete(key);
if (studentIds == null || studentIds.isEmpty()) {
return 0; // 无操作
}
//筛选出当前任务中状态为"代考"的学生ID只允许删除这些学生
List<String> proxyStuIds = monitorMapper.selectStuIdByTaskId(reqVO.getTaskId());
List<String> intersection = studentIds.stream()
.filter(proxyStuIds::contains)
.collect(Collectors.toList());
if (intersection.isEmpty()) {
return 0; // 无符合条件的学生
}
//删除监控管理学生
DeleteRequestVo deleteRequestVo=new DeleteRequestVo();
deleteRequestVo.setStudentIds(reqVO.getStudentIds());
deleteRequestVo.setStudentIds(intersection);
deleteRequestVo.setTaskId(reqVO.getTaskId());
monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo);
// 再清理Redis缓存仅删除代考学生的缓存
for (String studentId : intersection) {
String key = "userCache:" + reqVO.getTaskId() + ":" + studentId;
redisTemplate.delete(key);
}
//删除考场学生
reqVO.setStudentIds(intersection);
return educationPaperPersonMapper.removeSessionStu(reqVO);
}
@Override
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
public int removeTaskStu(DeleteRequestVo deleteRequestVo) {
//获取前端传入的学生ID列表
List<String> studentIds = deleteRequestVo.getStudentIds();
for (String studentId : studentIds) {
if (studentIds == null || studentIds.isEmpty()) {
return 0; // 无操作
}
//筛选出当前任务中状态为"代考"的学生ID只允许删除这些学生
List<String> proxyStuIds = monitorMapper.selectStuIdByTaskId(deleteRequestVo.getTaskId());
List<String> intersection = studentIds.stream()
.filter(proxyStuIds::contains)
.collect(Collectors.toList());
if (intersection.isEmpty()) {
return 0; // 无符合条件的学生
}
deleteRequestVo.setStudentIds(intersection);
monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo);
for (String studentId : intersection) {
String key = "userCache:" + deleteRequestVo.getTaskId()+":"+studentId;
redisTemplate.delete(key);
}
monitorMapper.removeMonitorByStuIdAndTaskId(deleteRequestVo);
return educationPaperPersonMapper.removeTaskStu(deleteRequestVo);
}

View File

@@ -9,6 +9,8 @@ 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.dataobject.knowledge.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper;
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;
@@ -50,6 +52,8 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
private EducationPaperTaskMapper educationPaperTaskMapper;
@Autowired
private IExamQuestionService examQuestionService;
@Autowired
private ExamKnowledgePointsMapper knowledgePointsMapper;
/**
* 查询试卷试题
*
@@ -251,7 +255,33 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId);
List<EducationPaperScheme> educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid);
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
// 构造 ID → 名称映射
Map<Long, String> idNameMap = examKnowledgePoints.stream()
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
//赋值 章节知识点
for (ExamQuestion examQuestion : examQuestionList) {
String pointIdStr = examQuestion.getPointNames();
String chapterIdStr = examQuestion.getChapteridDictText();
try {
if (pointIdStr != null) {
Long pointId = Long.valueOf(pointIdStr);
if (idNameMap.containsKey(pointId)) {
examQuestion.setPointNamesVo(idNameMap.get(pointId));
}
}
if (chapterIdStr != null) {
Long chapterId = Long.valueOf(chapterIdStr);
if (idNameMap.containsKey(chapterId)) {
examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId));
}
}
}catch (NumberFormatException e) {
// 日志记录或跳过处理
System.err.println("ID格式错误" + e.getMessage());
}
}
ExamPaperVo examPaperVo=new ExamPaperVo();
examPaperVo.setPaperId(paperId);
examPaperVo.setExamQuestionList(examQuestionList);

View File

@@ -126,5 +126,10 @@ public class EducationPaperSchemeServiceImpl implements IEducationPaperSchemeSer
{
return educationPaperSchemeMapper.deleteEducationPaperSchemeBySchemeId(schemeId);
}
@Override
public int selectEducationPaperSchemeCountsByTaskId(String taskId) {
return educationPaperSchemeMapper.selectEducationPaperSchemeCountsByTaskId(taskId);
}
}

View File

@@ -18,16 +18,15 @@ 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 org.springframework.transaction.annotation.Transactional;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueWordDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperWordDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.*;
import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.SchemeInfo;
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.*;
@@ -133,6 +132,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
public int deleteEducationPaperByPaperIds(String[] paperIds)
{
@@ -793,5 +793,159 @@ public class EducationPaperServiceImpl implements IEducationPaperService
}
}
@Override
public void addPaperBypaper(PaperSubmitDTO dto) {
String num = dto.getNum();
int numInt = Integer.parseInt(num);
List<PaperSubmitListDTO> paperList = dto.getPaperList();
String taskId = dto.getTaskId();
//此试卷任务的 方案规则
List<EducationPaperScheme> educationPaperSchemes = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId);
//构建 方案和 试题id的键值对String,List<String>
List<SchemeInfo> schemeInfoList=new ArrayList<>();
int totalScore = 0;
for (EducationPaperScheme educationPaperScheme : educationPaperSchemes) {
try {
totalScore += Integer.parseInt(educationPaperScheme.getSubtotalScore());
} catch (NumberFormatException e) {
// 非数字按 0 处理
totalScore += 0;
// 可选:记录日志(避免静默忽略)
throw new RuntimeException("非数字 subtotal_score: {}"+ educationPaperScheme.getSubtotalScore());
}
//设置 试题个数
SchemeInfo schemeInfo=new SchemeInfo();
schemeInfo.setCount(educationPaperScheme.getQuNumbers());
//设置 试题题型和id集合
String spName = educationPaperScheme.getSpName();
Map<String, Set<String>> schemeToQuestionIds = new HashMap<>();
schemeToQuestionIds.put(spName,new HashSet<>());
schemeInfo.setSchemeToQuestion(schemeToQuestionIds);
schemeInfoList.add(schemeInfo);
}
for (int i = 0; i <numInt ; i++) {
//把传进来的集合规则 先循环
for (PaperSubmitListDTO paperSubmitListDTO : paperList) {
String que = paperSubmitListDTO.getQue();
//试卷id
String paperId = paperSubmitListDTO.getId();
//如果是全部,就按照 此方案下的规则来选题
if ("全部".equals(que)){
// 遍历 schemeToQuestionIds 的所有方案名
for (SchemeInfo schemeInfo : schemeInfoList) {
// 取出当前 SchemeInfo 的 map
Map<String, Set<String>> schemeToQuestionIds = schemeInfo.getSchemeToQuestion();
for (String spName : schemeToQuestionIds.keySet()) {
// 根据试卷id和题型名称找出该试卷的符合试题
List<String> quIds = educationPaperQuMapper.selectByPaperIdAndType(paperId, spName);
Set<String> questionIds = schemeToQuestionIds.get(spName);
if (quIds != null && !quIds.isEmpty()) {
questionIds.addAll(quIds);
}
}
}
}
else {
// 拆分字符串,得到字符串数组
String[] queArray = que.split(",");
// 转成 List<String>
List<String> queList = Arrays.asList(queArray);
for (String spName : queList) {
// 根据试卷id和题型名称找出该试卷的符合试题
List<String> quIds = educationPaperQuMapper.selectByPaperIdAndType(paperId, spName);
for (SchemeInfo schemeInfo : schemeInfoList) {
// 获取当前方案的题型映射
Map<String, Set<String>> schemeToQuestionIds = schemeInfo.getSchemeToQuestion();
// 取出对应 spName 的 Set<String>
Set<String> questionIds = schemeToQuestionIds.get(spName);
if (questionIds != null && quIds != null && !quIds.isEmpty()) {
questionIds.addAll(quIds);
}
}
}
}
}
System.out.println(schemeInfoList);
List<String> examQuestionIds = new ArrayList<>();
for (SchemeInfo schemeInfo : schemeInfoList) {
Integer count = schemeInfo.getCount(); // 每个方案要取的题数
Map<String, Set<String>> schemeToQuestion = schemeInfo.getSchemeToQuestion();
Random random = new Random();
for (Map.Entry<String, Set<String>> entry : schemeToQuestion.entrySet()) {
Set<String> questionSet = entry.getValue();
if (questionSet == null || questionSet.isEmpty()) {
continue;
}
List<String> questionList = new ArrayList<>(questionSet);
// 随机选 count 个题目count 不能超过 questionList 大小
int takeCount = Math.min(count, questionList.size());
// Fisher-Yates 洗牌 + 取前 takeCount 个
for (int k = questionList.size() - 1; k > 0;k--) {
int j = random.nextInt(k + 1);
String temp = questionList.get(k);
questionList.set(k, questionList.get(j));
questionList.set(j, temp);
}
List<String> randomSelected = questionList.subList(0, takeCount);
examQuestionIds.addAll(randomSelected);
}
// 这里 selectedQuestions 就是从该方案的所有题型集合里随机抽出的题目集合
// 你可以根据需求进一步处理它,比如返回、保存等
}
int number=educationPaperMapper.selectCountPaperList();
// 格式化为8位不足前面补0
String formattedNumber = String.format("%08d", ++number);
System.out.println(examQuestionIds);
//构建试卷
EducationPaper educationPaper =new EducationPaper();
String uuid = IdUtils.simpleUUID();
educationPaper.setPaperId(uuid);
educationPaper.setPaperScore(String.valueOf(totalScore));
educationPaper.setTaskId(taskId);
educationPaper.setNum(formattedNumber);
educationPaper.setTenantId(TenantContextHolder.getRequiredTenantId());
educationPaperMapper.insertEducationPaper(educationPaper);
//构建试卷试题对象
List<EducationPaperQu> educationPaperQus=new ArrayList<>();
if (examQuestionIds!=null&& examQuestionIds.size()>0){
int sort = 1; // 从1开始
for (String examQuestionId : examQuestionIds) {
EducationPaperQu educationPaperQu=new EducationPaperQu();
educationPaperQu.setPaperId(uuid);
educationPaperQu.setQuId(examQuestionId);
educationPaperQu.setSort(sort++);
educationPaperQus.add(educationPaperQu);
}
educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus);
}
}
}
}

View File

@@ -10,6 +10,8 @@ import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
import pc.exam.pp.module.exam.controller.admin.exception.QueTypeException;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO;
import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam;
import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto;
import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo;
@@ -139,7 +141,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperParam.setIsTime("0");
educationPaperParam.setDirectory("KSWJ");
educationPaperParam.setUploadTime("5");
educationPaperParam.setIsDel("0");
educationPaperParam.setIsCopy("1");
educationPaperParam.setIsSession("1");
educationPaperParam.setIsFile("1");
educationPaperParam.setIsNet("1");
@@ -151,10 +153,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperParam.setIsAnswer("1");
educationPaperParam.setIsLook("1");
educationPaperParam.setIsConnect("30");
educationPaperParam.setIsScore("1");
educationPaperParam.setIsScoreDetail("1");
}else {
educationPaperParam.setIsRepeat("0");
educationPaperParam.setIsAnswer("0");
educationPaperParam.setIsLook("0");
educationPaperParam.setIsScore("0");
educationPaperParam.setIsScoreDetail("0");
}
if ("0".equals(educationPaperTask.getTaskType())||"1".equals(educationPaperTask.getTaskType())||"3".equals(educationPaperTask.getTaskType())){
educationPaperTask.setIsOne("0");
@@ -556,4 +562,48 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
return null;
}
}
@Override
public PageResult<EducationPaperTask> selectEducationPaperAndTaskList(PaperTaskPageVo educationPaperTask) {
PageResult<EducationPaperTask> educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask);
List<EducationPaperTask> list = educationPaperTasks.getList();
for (EducationPaperTask paperTask : list) {
String taskId = paperTask.getTaskId();
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(taskId);
List<EducationPaperScheme> educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId);
paperTask.setEducationPaperList(educationPapers);
paperTask.setEducationPaperSchemeList(educationPaperSchemeList);
}
return educationPaperTasks;
}
@Override
public void checkType(PaperQueUpdateDTO dto) {
if (dto.getQue() == null || dto.getQue().isEmpty()) {
throw new QueTypeException("题型参数不能为空");
}
List<EducationPaperScheme> educationPaperSchemeList=educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(dto.getTaskId());
if (educationPaperSchemeList == null) {
educationPaperSchemeList = new ArrayList<>();
}
// 查询数据库中已有的 spName
List<String> existingSpNames = educationPaperSchemeList.stream()
.map(EducationPaperScheme::getSpName)
.collect(Collectors.toList());
// 获取前端传来的 que
List<String> submittedQue = dto.getQue();
// 找出 submittedQue 中比数据库多出来的(即数据库中没有的)
List<String> extraQue = submittedQue.stream()
.filter(q -> !existingSpNames.contains(q))
.collect(Collectors.toList());
if (extraQue.size()>0){
throw new QueTypeException("当前任务方案中不存在以下题型:" + String.join(",", extraQue));
}
}
}

View File

@@ -60,5 +60,8 @@ public interface IEducationPaperSchemeService
* @return 结果
*/
public int deleteEducationPaperSchemeBySchemeId(String schemeId);
int selectEducationPaperSchemeCountsByTaskId(String taskId);
}

View File

@@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperSubmitDTO;
import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
import pc.exam.pp.module.exam.dal.dataobject.PaperListResponseVo;
@@ -127,5 +128,7 @@ public interface IEducationPaperService
*/
List<PaperIdAndNum> selectPaperIdAndNumByTaskId(String taskId);
void addPaperBypaper(PaperSubmitDTO dto);
}

View File

@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
import pc.exam.pp.framework.common.pojo.PageResult;
import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperQueUpdateDTO;
import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam;
import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto;
import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo;
@@ -114,5 +115,9 @@ public interface IEducationPaperTaskService
*/
PageResult<EducationPaperTask> selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask);
PageResult<EducationPaperTask> selectEducationPaperAndTaskList(PaperTaskPageVo educationPaperTask);
void checkType(PaperQueUpdateDTO dto);
}

View File

@@ -22,8 +22,11 @@ import pc.exam.pp.module.exam.controller.admin.question.vo.*;
import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO;
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.knowledge.ExamKnowledgePoints;
import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty;
import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper;
import pc.exam.pp.module.exam.dal.mysql.mysqlkeyword.MysqlKeywordMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
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;
@@ -34,6 +37,7 @@ import pc.exam.pp.module.exam.utils.uuid.IdUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception;
import static pc.exam.pp.module.system.enums.ErrorCodeConstants.*;
@@ -67,6 +71,10 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
private RabbitmqUtils rabbitMqService;
@Autowired
private MysqlKeywordMapper mysqlKeywordMapper;
@Autowired
private ExamKnowledgePointsMapper knowledgePointsMapper;
@Autowired
private EducationPaperQuMapper educationPaperQuMapper;
/**
* 查询试题(hyc)
*
@@ -101,6 +109,12 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
}
}
String chapteridDictText = examQuestion.getChapteridDictText();
String pointNames = examQuestion.getPointNames();
String point= knowledgePointsMapper.selectKnowledgeNameBySpId(pointNames);
String chapterText= knowledgePointsMapper.selectKnowledgeNameBySpId(chapteridDictText);
examQuestion.setPointNamesVo(point);
examQuestion.setChapteridDictTextVo(chapterText);
return examQuestion;
}
@@ -317,19 +331,32 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
public int deleteExamQuestionByQuIds(String[] ids)
{
if (ids != null && ids.length > 0) {
//删除试题答案
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesIds(ids);
//删除试题文件
sysFileMapper.deleteSysFileByQuesIds(ids);
//删除试题的判分
examQuestionScoreMapper.deleteExamQuestionScoreByQuesIds(ids);
//删除试题关键字
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesIds(ids);
// 查询出被使用的题目ID
List<String> usedIds = educationPaperQuMapper.selectUsedQuestionIds(ids);
Set<String> usedIdSet = new HashSet<>(usedIds);
// 找出未被使用的题目ID
List<String> canDeleteIds = Arrays.stream(ids)
.filter(id -> !usedIdSet.contains(id))
.collect(Collectors.toList());
if (canDeleteIds.isEmpty()) {
// 全部试题都已被引用,不能删除
return 0;
}
return examQuestionMapper.deleteExamQuestionByQuIds(ids);
String[] deleteIds = canDeleteIds.toArray(new String[0]);
//删除试题答案
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesIds(deleteIds);
//删除试题文件
sysFileMapper.deleteSysFileByQuesIds(deleteIds);
//删除试题的判分
examQuestionScoreMapper.deleteExamQuestionScoreByQuesIds(deleteIds);
//删除试题关键字
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesIds(deleteIds);
return examQuestionMapper.deleteExamQuestionByQuIds(deleteIds);
}
/**
@@ -348,7 +375,35 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
@Override
public PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) {
return examQuestionMapper.selectExamQuestionList(questionVo);
PageResult<ExamQuestion> examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo);
List<ExamQuestion> list = examQuestionPageResult.getList();
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
// 构造 ID → 名称映射
Map<Long, String> idNameMap = examKnowledgePoints.stream()
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
for (ExamQuestion examQuestion : list) {
String pointIdStr = examQuestion.getPointNames();
String chapterIdStr = examQuestion.getChapteridDictText();
try {
if (pointIdStr != null) {
Long pointId = Long.valueOf(pointIdStr);
if (idNameMap.containsKey(pointId)) {
examQuestion.setPointNamesVo(idNameMap.get(pointId));
}
}
if (chapterIdStr != null) {
Long chapterId = Long.valueOf(chapterIdStr);
if (idNameMap.containsKey(chapterId)) {
examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId));
}
}
} catch (NumberFormatException e) {
// 日志记录或跳过处理
System.err.println("ID格式错误" + e.getMessage());
}
}
return examQuestionPageResult;
}
@@ -707,7 +762,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
examQuestion.setSpecialtyName(importUser.getSpecialtyName());
examQuestion.setCourseName(importUser.getCourseName());
examQuestion.setSubjectName(importUser.getSubjectName());
examQuestion.setQuLevel(importUser.getQuLevel());
examQuestion.setQuLevel(Integer.valueOf(importUser.getQuLevel()));
examQuestion.setContent(importUser.getContent());
examQuestion.setAnalysis(importUser.getAnalysis());
examQuestion.setPointNames(importUser.getPointNames());
@@ -767,7 +822,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
examQuestion.setSpecialtyName(importUser.getSpecialtyName());
examQuestion.setCourseName(importUser.getCourseName());
examQuestion.setSubjectName(importUser.getSubjectName());
examQuestion.setQuLevel(importUser.getQuLevel());
examQuestion.setQuLevel(Integer.valueOf(importUser.getQuLevel()));
examQuestion.setContent(importUser.getContent());
examQuestion.setAnalysis(importUser.getAnalysis());
examQuestion.setPointNames(importUser.getPointNames());
@@ -831,11 +886,36 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
public PageResult<ExamQuestion> selectExamQuestionListAnswer(QuestionVo questionVo) {
PageResult<ExamQuestion> examQuestionPageResult = examQuestionMapper.selectExamQuestionList(questionVo);
List<ExamQuestion> list = examQuestionPageResult.getList();
List<ExamKnowledgePoints> examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints();
// 构造 ID → 名称映射
Map<Long, String> idNameMap = examKnowledgePoints.stream()
.collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName));
if (list != null && !list.isEmpty()) {
for (ExamQuestion examQuestion : list) {
String quId = examQuestion.getQuId();
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId);
examQuestion.setAnswerList(examQuestionAnswers);
String pointIdStr = examQuestion.getPointNames();
String chapterIdStr = examQuestion.getChapteridDictText();
try {
if (pointIdStr != null) {
Long pointId = Long.valueOf(pointIdStr);
if (idNameMap.containsKey(pointId)) {
examQuestion.setPointNamesVo(idNameMap.get(pointId));
}
}
if (chapterIdStr != null) {
Long chapterId = Long.valueOf(chapterIdStr);
if (idNameMap.containsKey(chapterId)) {
examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId));
}
}
}catch (NumberFormatException e) {
// 日志记录或跳过处理
System.err.println("ID格式错误" + e.getMessage());
}
}
}
return examQuestionPageResult;

View File

@@ -19,7 +19,7 @@
<result property="examTime" column="exam_time" />
<result property="directory" column="directory" />
<result property="uploadTime" column="upload_time" />
<result property="isDel" column="is_del" />
<result property="isCopy" column="is_copy" />
<result property="isRepeat" column="is_repeat" />
<result property="isAnswer" column="is_answer" />
<result property="isLook" column="is_look" />
@@ -29,12 +29,14 @@
<result property="isFile" column="is_file" />
<result property="isNet" column="is_net" />
<result property="isScreen" column="is_screen" />
<result property="isScore" column="is_score" />
<result property="isScoreDetail" column="is_score_detail" />
</resultMap>
<sql id="selectEducationPaperParamVo">
select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_time,exam_time,is_del,is_repeat ,is_answer,is_look,is_connect,is_session,warn,is_file,is_net,is_screen from education_paper_param
select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time,
is_time,exam_time,is_copy,is_repeat ,is_answer,is_look,is_connect,is_session,warn,is_file,is_net,is_screen,is_score,is_score_detail from education_paper_param
</sql>
<select id="selectEducationPaperParamList" parameterType="EducationPaperParam" resultMap="EducationPaperParamResult">
@@ -48,7 +50,6 @@
<if test="driver != null and driver != ''"> and driver = #{driver}</if>
<if test="directory != null and directory != ''"> and directory = #{directory}</if>
<if test="uploadTime != null and uploadTime != ''"> and upload_time = #{uploadTime}</if>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
</where>
</select>
@@ -78,7 +79,7 @@
<if test="uploadTime != null">upload_time,</if>
<if test="isTime != null">is_time,</if>
<if test="examTime != null">exam_time,</if>
<if test="isDel != null">is_del,</if>
<if test="isCopy != null">is_copy,</if>
<if test="isRepeat != null">is_repeat,</if>
<if test="isAnswer != null">is_answer,</if>
<if test="isLook != null">is_look,</if>
@@ -88,6 +89,10 @@
<if test="isFile != null">is_file,</if>
<if test="isNet != null">is_net,</if>
<if test="isScreen != null">is_screen,</if>
<if test="isScore != null">is_score,</if>
<if test="isScoreDetail != null">is_score_detail,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="paramId != null">#{paramId},</if>
@@ -104,7 +109,7 @@
<if test="uploadTime != null">#{uploadTime},</if>
<if test="isTime != null">#{isTime},</if>
<if test="examTime != null">#{examTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="isCopy != null">#{isCopy},</if>
<if test="isRepeat != null">#{isRepeat},</if>
<if test="isAnswer != null">#{isAnswer},</if>
<if test="isLook != null">#{isLook},</if>
@@ -114,6 +119,8 @@
<if test="isFile != null">#{isFile},</if>
<if test="isNet != null">#{isNet},</if>
<if test="isScreen != null">#{isScreen},</if>
<if test="isScore != null">#{isScore},</if>
<if test="isScoreDetail != null">#{isScoreDetail},</if>
</trim>
</insert>
@@ -133,7 +140,7 @@
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
<if test="isTime != null">is_time = #{isTime},</if>
<if test="examTime != null">exam_time = #{examTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="isCopy != null">is_copy = #{isCopy},</if>
<if test="isRepeat != null">is_repeat = #{isRepeat},</if>
<if test="isAnswer != null">is_answer = #{isAnswer},</if>
<if test="isLook != null">is_look = #{isLook},</if>
@@ -143,6 +150,8 @@
<if test="isFile != null">is_file = #{isFile},</if>
<if test="isNet != null">is_net = #{isNet},</if>
<if test="isScreen != null">is_screen = #{isScreen},</if>
<if test="isScore != null">is_score = #{isScore},</if>
<if test="isScoreDetail != null">is_score_detail = #{isScoreDetail},</if>
</trim>
where param_id = #{paramId}

View File

@@ -39,6 +39,22 @@
(select qu_id from education_paper_qu where paper_id =#{paperId})ORDER BY RAND()
LIMIT 1;
</select>
<select id="selectUsedQuestionIds" resultType="java.lang.String">
SELECT DISTINCT qu_id
FROM education_paper_qu
WHERE qu_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectByPaperIdAndType" resultType="java.lang.String">
SELECT epq.qu_id
FROM education_paper_qu epq
JOIN exam_question eq ON epq.qu_id = eq.qu_id
WHERE epq.paper_id = #{paperId}
AND eq.subject_name = #{spName}
</select>
<insert id="insertEducationPaperQu" parameterType="EducationPaperQu">

View File

@@ -44,6 +44,9 @@
<select id="selectEducationPaperTaskByTaskId" resultMap="EducationPaperSchemeResult">
select * from education_paper_scheme where task_id =#{taskid} order by sort asc
</select>
<select id="selectEducationPaperSchemeCountsByTaskId" resultType="java.lang.Integer">
select count(*) from education_paper_scheme where task_id =#{taskId}
</select>
<insert id="insertEducationPaperScheme" parameterType="EducationPaperScheme">
insert into education_paper_scheme

View File

@@ -95,6 +95,14 @@
<select id="selectAnswerFile" resultType="java.lang.String">
select url from sys_file where qu_id =#{quId} and file_type ='2'
</select>
<select id="selectCountPointByQuId" resultType="java.lang.String">
SELECT SUM(score_rate) AS totalKeyScore
FROM exam_question_answer
WHERE qu_id =#{quId};
</select>
<select id="selectExamQuestionAnswerScoreByAnswerId" resultType="java.lang.String">
select score_rate from exam_question_answer where answer_id =#{answerId}
</select>
<insert id="insertExamQuestionAnswerList">
insert into exam_question_answer
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort)

View File

@@ -44,6 +44,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and deleted = 0
</where>
</select>
<select id="selectKnowledgeNameBySpId" resultType="java.lang.String">
select sp_name from exam_knowledge_points where sp_id =#{spId}
</select>
<select id="selectKnowledgePoints" resultMap="KnowledgePointsResult">
select sp_id ,sp_name from exam_knowledge_points where deleted = 0
</select>
<update id="deleteKnowledgePointsBySpId" parameterType="Long">
update exam_knowledge_points

View File

@@ -15,4 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByStuIdAndTaskId" resultType="java.lang.String">
select task_id from exam_monitor where stu_id = #{stuId} and exam_status !='2'
</select>
<select id="selectStuIdByTaskId" resultType="java.lang.String">
select stu_id from exam_monitor where task_id =#{taskId} and deleted ='0' and exam_status ='0'
</select>
</mapper>