【修改】增加后台api接口注释,优化mysql判分,知识点改为存储id,试题已使用,学生除待考其它状态不可删除。。。
【新增】试卷任务参数,在已有的试卷里抽卷。。。
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package pc.exam.pp.module.exam.controller.admin.exception;
|
||||
|
||||
public class QueTypeException extends RuntimeException {
|
||||
public QueTypeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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("新增成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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));
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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,6 +184,7 @@ public class EducationPaperTaskController
|
||||
* @param tempDto
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模板库 复制")
|
||||
@PostMapping("/submitSelection")
|
||||
public CommonResult submitSelection(@RequestBody TempDto tempDto) {
|
||||
System.out.println("接收到的任务ID: " + tempDto.getTaskId());
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -52,4 +52,9 @@ public interface ExamKnowledgePointsMapper extends BaseMapperX<ExamKnowledgePoin
|
||||
List<SpecialtyQueryVo> selectKnowledgePointsListPage(@Param("knowledgePoints")ExamKnowledgePoints knowledgePoints);
|
||||
|
||||
|
||||
String selectKnowledgeNameBySpId(String spId);
|
||||
|
||||
List<ExamKnowledgePoints> selectKnowledgePoints();
|
||||
|
||||
|
||||
}
|
||||
|
@@ -57,4 +57,5 @@ return selectPage(reqVO, new LambdaQueryWrapperX<MonitorDO>()
|
||||
|
||||
List<String> selectByStuIdAndTaskId(Long stuId);
|
||||
|
||||
List<String> selectStuIdByTaskId(String taskId);
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -77,4 +77,5 @@ public interface EducationPaperSchemeMapper
|
||||
*/
|
||||
void insertEducationPaperSchemeList(List<EducationPaperScheme> educationPaperSchemeList);
|
||||
|
||||
int selectEducationPaperSchemeCountsByTaskId(String taskId);
|
||||
}
|
||||
|
@@ -77,4 +77,9 @@ public interface ExamQuestionAnswerMapper extends BaseMapperX<ExamQuestionAnswe
|
||||
|
||||
String selectAnswerFile(String quId);
|
||||
|
||||
String selectCountPointByQuId(String quId);
|
||||
|
||||
String selectExamQuestionAnswerScoreByAnswerId(String answerId);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -126,5 +126,10 @@ public class EducationPaperSchemeServiceImpl implements IEducationPaperSchemeSer
|
||||
{
|
||||
return educationPaperSchemeMapper.deleteEducationPaperSchemeBySchemeId(schemeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectEducationPaperSchemeCountsByTaskId(String taskId) {
|
||||
return educationPaperSchemeMapper.selectEducationPaperSchemeCountsByTaskId(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -60,5 +60,8 @@ public interface IEducationPaperSchemeService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEducationPaperSchemeBySchemeId(String schemeId);
|
||||
|
||||
int selectEducationPaperSchemeCountsByTaskId(String taskId);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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}
|
||||
|
@@ -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">
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.getpoints;
|
||||
|
||||
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;
|
||||
@@ -11,7 +13,7 @@ import pc.exam.pp.module.judgement.controller.service.getpoints.ExamGetPointsSer
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "管理后台 - 考点操作")
|
||||
@RestController
|
||||
@RequestMapping("/exam/getPoints")
|
||||
public class GetPointsController {
|
||||
@@ -23,6 +25,7 @@ public class GetPointsController {
|
||||
* 得出文件操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@Operation(summary = "得出文件操作考点")
|
||||
@PostMapping("/get_filePoint")
|
||||
@TenantIgnore
|
||||
public CommonResult get_file_point(@RequestBody PointsVo pointsVo) throws IOException {
|
||||
@@ -32,6 +35,7 @@ public class GetPointsController {
|
||||
* 文件得出MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@Operation(summary = "文件得出MYSQL操作考点")
|
||||
@PostMapping("/get_mysql_point")
|
||||
@TenantIgnore
|
||||
public CommonResult get_mysql_point(@RequestBody PointsVo pointsVo) throws IOException {
|
||||
@@ -49,24 +53,26 @@ public class GetPointsController {
|
||||
* 新增/更新MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@Operation(summary = "新增/更新MYSQL操作考点")
|
||||
@PostMapping("/update_mysql_point")
|
||||
@TenantIgnore
|
||||
public CommonResult update_mysql_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.update_mysql_point(points));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取考点详情")
|
||||
@GetMapping("/get_Point_id/{quId}")
|
||||
@TenantIgnore
|
||||
public CommonResult getPointById(@PathVariable("quId") String quId) {
|
||||
return CommonResult.success(examGetPointsService.getPointById(quId));
|
||||
}
|
||||
/**
|
||||
* 新增修改浏览器操作考点
|
||||
* 新增/修改浏览器操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@Operation(summary = "新增/修改浏览器操作考点")
|
||||
@PostMapping("/set_browser_point")
|
||||
@TenantIgnore
|
||||
//todo 老师自己设置,不读文件
|
||||
//老师自己设置,不读文件
|
||||
public CommonResult get_browser_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.get_browser_point(points));
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.getpoints.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileNode {
|
||||
private Long id;
|
||||
private String name;
|
||||
private Long parentId;
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.getpoints.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FilePointsVo {
|
||||
List<FileNode> nodeList;
|
||||
List<ExamQuestionAnswer> examQuestionAnswerList;
|
||||
}
|
@@ -14,6 +14,8 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -24,6 +26,8 @@ public class BrowserServericeImpl implements IBrowserServerice {
|
||||
static String answerLogPath ; // 文件路径
|
||||
@Resource
|
||||
private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
||||
private static final DateTimeFormatter formatter =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
//考生试题文件夹
|
||||
// static final String BASE_DIR = "D:/exam/4/";
|
||||
//谷歌浏览器
|
||||
@@ -149,7 +153,9 @@ public class BrowserServericeImpl implements IBrowserServerice {
|
||||
*/
|
||||
public static void appendToFile(String filePath, String content) {
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
||||
writer.write(content);
|
||||
String timestamp = LocalDateTime.now().format(formatter);
|
||||
String logLine = String.format("[%s] %s", timestamp, content);
|
||||
writer.write(logLine);
|
||||
writer.newLine(); // 可选:添加换行符
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -12,6 +12,8 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -23,6 +25,8 @@ public class FileServericeImpl implements IFileServerice {
|
||||
static String answerLogPath ; // 文件路径
|
||||
@Resource
|
||||
private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
||||
private static final DateTimeFormatter formatter =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
@Override
|
||||
public double run_file_point(double score,File file, ExamQuestion question) throws IOException {
|
||||
|
||||
@@ -116,7 +120,9 @@ public class FileServericeImpl implements IFileServerice {
|
||||
*/
|
||||
public static void appendToFile(String filePath, String content) {
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
||||
writer.write(content);
|
||||
String timestamp = LocalDateTime.now().format(formatter);
|
||||
String logLine = String.format("[%s] %s", timestamp, content);
|
||||
writer.write(logLine);
|
||||
writer.newLine(); // 可选:添加换行符
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package pc.exam.pp.module.judgement.controller.service.getpoints;
|
||||
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
||||
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FilePointsVo;
|
||||
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.Points;
|
||||
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.PointsVo;
|
||||
|
||||
@@ -11,7 +12,7 @@ public interface ExamGetPointsService {
|
||||
|
||||
|
||||
|
||||
List<ExamQuestionAnswer> get_file_point(PointsVo pointsVo) throws IOException;
|
||||
FilePointsVo get_file_point(PointsVo pointsVo) throws IOException;
|
||||
|
||||
List<String> get_mysql_point(PointsVo pointsVo) throws IOException;
|
||||
|
||||
|
@@ -15,6 +15,8 @@ import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders;
|
||||
import pc.exam.pp.module.exam.utils.uuid.IdUtils;
|
||||
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FileNode;
|
||||
import pc.exam.pp.module.judgement.controller.admin.getpoints.vo.FilePointsVo;
|
||||
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.utils.zip.ZipUtil;
|
||||
@@ -27,6 +29,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -34,6 +37,7 @@ import java.util.stream.Collectors;
|
||||
public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
@Resource
|
||||
ConfigService configService;
|
||||
private static final AtomicLong ID_GENERATOR = new AtomicLong(1); // 自增 ID
|
||||
|
||||
@Resource
|
||||
MysqlKeywordMapper mysqlKeywordMapper;
|
||||
@@ -42,7 +46,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
|
||||
|
||||
@Override
|
||||
public List<ExamQuestionAnswer> get_file_point(PointsVo pointsVo) throws IOException {
|
||||
public FilePointsVo get_file_point(PointsVo pointsVo) throws IOException {
|
||||
|
||||
// 获取平台文件参数
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
@@ -59,10 +63,10 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
//解压之后得文件获取文件夹和文件
|
||||
File folderStu = new File(stuFilePath);
|
||||
|
||||
File folderAnswer = new File(stuFilePath);
|
||||
|
||||
|
||||
File folderAnswer = new File(answerFilePath);
|
||||
|
||||
List<FileNode> nodeList = ExamGetPointsServiceImpl.buildFileNodeTree(folderAnswer);
|
||||
System.out.println(nodeList);
|
||||
|
||||
List<ExamQuestionAnswer> answerList = new ArrayList<>();
|
||||
AtomicInteger sortCounter = new AtomicInteger(1); // 计数器
|
||||
@@ -96,13 +100,56 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
zip_file_answer.delete();
|
||||
deleteFolder(folderStu);
|
||||
deleteFolder(folderAnswer);
|
||||
return answerList;
|
||||
|
||||
FilePointsVo filePointsVo=new FilePointsVo();
|
||||
filePointsVo.setNodeList(nodeList);
|
||||
filePointsVo.setExamQuestionAnswerList(answerList);
|
||||
return filePointsVo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<FileNode> buildFileNodeTree(File root) {
|
||||
List<FileNode> result = new ArrayList<>();
|
||||
|
||||
if (root != null && root.exists() && root.isDirectory()) {
|
||||
File[] children = root.listFiles();
|
||||
if (children != null) {
|
||||
for (File child : children) {
|
||||
buildRecursive(child, null, result); // 从子文件夹开始构建,跳过 root
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void buildRecursive(File file, Long parentId, List<FileNode> list) {
|
||||
Long currentId = ID_GENERATOR.getAndIncrement();
|
||||
|
||||
FileNode node = new FileNode();
|
||||
node.setId(currentId);
|
||||
node.setName(file.getName());
|
||||
node.setParentId(parentId);
|
||||
list.add(node);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
File[] children = file.listFiles();
|
||||
if (children != null) {
|
||||
for (File child : children) {
|
||||
buildRecursive(child, currentId, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> get_mysql_point(PointsVo pointsVo) throws IOException {
|
||||
|
||||
String answerPath = pointsVo.getAnswerPath();
|
||||
// 获取平台文件参数
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
|
||||
|
@@ -20,12 +20,16 @@ import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -41,7 +45,8 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
static String databaseName;
|
||||
static String databaseNameStu;
|
||||
static String answerLogPath; // 文件路径
|
||||
|
||||
private static final DateTimeFormatter formatter =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
@Resource
|
||||
private ExamMysqlKeywordMapper examMysqlKeywordMapper;
|
||||
@Resource
|
||||
@@ -49,7 +54,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
@Override
|
||||
public double Judgement(double score,File filepath, ExamQuestion examQuestion) throws IOException, SQLException {
|
||||
|
||||
double scoreTotal =0.0;
|
||||
String fileUrl= examQuestionAnswerMapper.selectAnswerFile(examQuestion.getQuId());
|
||||
String path = ZipUtil.downloadStudentFile(fileUrl, "data");
|
||||
// 4、获取到得是zip文件,需要解压
|
||||
@@ -61,18 +66,20 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
// 5.2、查询试题ID
|
||||
|
||||
|
||||
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(examQuestion.getQuId());
|
||||
String totalKeyScore ="0";
|
||||
if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
||||
List<String> answerIdList = examQuestionAnswers.stream()
|
||||
.map(ExamQuestionAnswer::getAnswerId) // 提取每个对象的 answerId
|
||||
.collect(Collectors.toList());
|
||||
//得到总计得分点
|
||||
System.out.println(answerIdList);
|
||||
totalKeyScore=examMysqlKeywordMapper.selectByAnswerIds(answerIdList);
|
||||
//得出 这个题总共的权值点
|
||||
totalKeyScore=examQuestionAnswerMapper.selectCountPointByQuId(examQuestion.getQuId());
|
||||
|
||||
}
|
||||
// if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
||||
// List<String> answerIdList = examQuestionAnswers.stream()
|
||||
// .map(ExamQuestionAnswer::getAnswerId) // 提取每个对象的 answerId
|
||||
// .collect(Collectors.toList());
|
||||
// //得到总计得分点
|
||||
// System.out.println(answerIdList);
|
||||
// totalKeyScore=examMysqlKeywordMapper.selectByAnswerIds(answerIdList);
|
||||
//
|
||||
// }
|
||||
answerLogPath = filepath.getParent() + File.separator + "log.txt";
|
||||
|
||||
AtomicInteger total = new AtomicInteger();
|
||||
@@ -223,12 +230,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
if (entry.getValue().trim().toUpperCase().startsWith("CREATE TABLE")) {
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
appendToFile(answerLogPath, "==================建表语句==================");
|
||||
String answerId = null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -242,35 +250,57 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
// 查询建表语句
|
||||
String showCreateTableSql = "SHOW CREATE TABLE " + tableName;
|
||||
String sql = "SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, EXTRA " +
|
||||
"FROM INFORMATION_SCHEMA.COLUMNS " +
|
||||
"WHERE TABLE_NAME = '" + tableName + "' AND TABLE_SCHEMA = '" + databaseName + "'";
|
||||
String sql2 = "SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, EXTRA " +
|
||||
"FROM INFORMATION_SCHEMA.COLUMNS " +
|
||||
"WHERE TABLE_NAME = '" + tableName + "' AND TABLE_SCHEMA = '" + databaseNameStu + "'";
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery(showCreateTableSql)) {
|
||||
if (rs.next()) {
|
||||
String createTableSql = rs.getString("Create Table");
|
||||
// 替换 result 中的值
|
||||
entry.setValue(createTableSql);
|
||||
String sql1 = result.get(entry.getKey());
|
||||
String sql2 = resultStu.get(entry.getKey());
|
||||
String normalizedSql1 = simplifyCreateTableSql(sql1);
|
||||
// 获取主库字段信息
|
||||
Set<Map<String, String>> table1Columns = new HashSet<>();
|
||||
try (ResultSet rs = stmt.executeQuery(sql)) {
|
||||
while (rs.next()) {
|
||||
Map<String, String> column = new HashMap<>();
|
||||
column.put("COLUMN_NAME", rs.getString("COLUMN_NAME"));
|
||||
column.put("COLUMN_TYPE", rs.getString("COLUMN_TYPE"));
|
||||
column.put("IS_NULLABLE", rs.getString("IS_NULLABLE"));
|
||||
column.put("COLUMN_KEY", rs.getString("COLUMN_KEY"));
|
||||
column.put("EXTRA", rs.getString("EXTRA"));
|
||||
table1Columns.add(column);
|
||||
|
||||
String normalizedSql2 = simplifyCreateTableSql(sql2);
|
||||
}
|
||||
appendToFile(answerLogPath, "标准答案建表键值对:"+table1Columns);
|
||||
|
||||
if (normalizedSql1.equals(normalizedSql2)) {
|
||||
|
||||
}
|
||||
// 获取学生库字段信息
|
||||
Set<Map<String, String>> table2Columns = new HashSet<>();
|
||||
try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password);
|
||||
Statement stmtstu = connstu.createStatement()) {
|
||||
try (ResultSet rsstu = stmtstu.executeQuery(sql2)) {
|
||||
while (rsstu.next()) {
|
||||
Map<String, String> column = new HashMap<>();
|
||||
column.put("COLUMN_NAME", rsstu.getString("COLUMN_NAME"));
|
||||
column.put("COLUMN_TYPE", rsstu.getString("COLUMN_TYPE"));
|
||||
column.put("IS_NULLABLE", rsstu.getString("IS_NULLABLE"));
|
||||
column.put("COLUMN_KEY", rsstu.getString("COLUMN_KEY"));
|
||||
column.put("EXTRA", rsstu.getString("EXTRA"));
|
||||
table2Columns.add(column);
|
||||
}
|
||||
appendToFile(answerLogPath, "学生答案建表键值对:"+table2Columns);
|
||||
|
||||
}
|
||||
}
|
||||
String sql3 = resultStu.get(entry.getKey());
|
||||
if (table1Columns.equals(table2Columns)) {
|
||||
//
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql3,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
|
||||
double sw= calculateTotalScoreRate(sql3, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行验证 SQL 出错!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -284,12 +314,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
if (matcher.find()) {
|
||||
String tableName = matcher.group(1).replace("`", ""); // 获取表名
|
||||
String answerId=null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -302,12 +333,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
boolean equals = sql1.equals(sql2);
|
||||
if (equals) {
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
|
||||
double sr=accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
|
||||
double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +351,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
String delStatement = entry.getValue();
|
||||
delStatement = delStatement.trim().replaceAll(";+\\s*$", "");
|
||||
|
||||
String answerId =null;
|
||||
String sql2 = resultStu.get(entry.getKey());
|
||||
// 正则提取表名和 WHERE 条件
|
||||
Pattern pattern = Pattern.compile("DELETE\\s+FROM\\s+(\\w+)\\s+WHERE\\s+(.+)", Pattern.CASE_INSENSITIVE);
|
||||
@@ -329,9 +359,9 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -360,13 +390,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
//累加删除语句的所有权值 examQuestionKeywords累加scorerate
|
||||
appendToFile(answerLogPath, "验证通过:符合 DELETE 条件的记录已删除。");
|
||||
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
|
||||
double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
}
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
@@ -394,12 +422,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
appendToFile(answerLogPath, "==================更新语句==================");
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
String sql1 = entry.getValue();
|
||||
String answerId=null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -413,11 +442,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
//
|
||||
if (b) {
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
// appendToFile(answerLogPath,"语句"+sql2+"不正确,关键得分:"+scoreAnswerNotAllTrue+ "❌");
|
||||
double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
|
||||
}
|
||||
|
||||
@@ -426,12 +455,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
if (entry.getValue().trim().toUpperCase().startsWith("SELECT")) {
|
||||
appendToFile(answerLogPath, "==================查找语句==================");
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
String answerId =null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -446,6 +476,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
Statement stmtan = connanswer.createStatement()) {
|
||||
try (ResultSet answer = stmtan.executeQuery(sql1)) {
|
||||
answerList = getAnswerList(answer);
|
||||
appendToFile(answerLogPath, "查找语句标准答案");
|
||||
printResult(answerList);
|
||||
}catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行验证语句"+sql1+"时发生错误: " + e.getMessage());
|
||||
@@ -456,9 +487,10 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
Statement stmtstu = connstu.createStatement()) {
|
||||
try (ResultSet answer = stmtstu.executeQuery(sql2)) {
|
||||
answerListStu = getAnswerList(answer);
|
||||
appendToFile(answerLogPath, "学生语句答案");
|
||||
printResult(answerListStu);
|
||||
} catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()+"得分:0 ❌");
|
||||
appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -471,13 +503,12 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
if (isEquivalent) {
|
||||
//todo 得分
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
// appendToFile(answerLogPath,"语句"+sql2+"不正确,关键得分:"+scoreAnswerNotAllTrue+ "❌");
|
||||
double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
|
||||
}
|
||||
|
||||
@@ -488,12 +519,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
if (entry.getValue().trim().replaceAll("\\s+", " ").matches("(?i)^CREATE( OR REPLACE)?( ALGORITHM\\s*=\\s*\\w+)?( DEFINER\\s*=\\s*[`\"'\\w@%\\.]+)?( SQL SECURITY \\w+)? VIEW\\b.*")) {
|
||||
appendToFile(answerLogPath, "==================视图语句==================");
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
String answerId=null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -526,12 +558,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
// 执行 CREATE VIEW 语句,创建视图
|
||||
stmt.execute(createView1);
|
||||
|
||||
|
||||
boolean hasError = false; // 添加标志变量
|
||||
try {
|
||||
stmt.execute(createView2);
|
||||
|
||||
} catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行学生库语句"+createView2+"时发生错误: " + e.getMessage()+"得分:0 ❌");
|
||||
appendToFile(answerLogPath, "执行学生库语句"+createView2+"时发生错误: " + e.getMessage());
|
||||
hasError = true; // 发生异常,设为 true
|
||||
}
|
||||
|
||||
// 执行查询,获取视图1的结果
|
||||
@@ -546,7 +579,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
printResult(result2);
|
||||
|
||||
// 比较两个视图的结果
|
||||
boolean isEquivalent = compareResults(result1, result2);
|
||||
boolean isEquivalent = !hasError &&compareResults(result1, result2);
|
||||
appendToFile(answerLogPath, "\n是否结果等价: " + isEquivalent);
|
||||
|
||||
// 删除视图
|
||||
@@ -554,12 +587,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
stmt.execute("DROP VIEW IF EXISTS " + viewName1);
|
||||
stmt.execute("DROP VIEW IF EXISTS " + viewName2);
|
||||
if (isEquivalent) {
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
|
||||
double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -569,13 +601,14 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
|
||||
//存储过程
|
||||
if (entry.getValue().trim().toUpperCase().toUpperCase().contains("PROCEDURE")) {
|
||||
String answerId=null;
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -603,7 +636,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
} catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行标准库 SQL CALL 语句时发生错误: " + e.getMessage());
|
||||
}
|
||||
|
||||
boolean hasError = false; // 添加标志变量
|
||||
|
||||
try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password);
|
||||
Statement stmtstu = connstu.createStatement()) {
|
||||
@@ -616,26 +649,31 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
stuResults.addAll(extractResults(oldResult));
|
||||
} catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行学生库 SQL CALL 语句时发生错误: " + e.getMessage());
|
||||
hasError = true; // 发生异常,设为 true
|
||||
}
|
||||
|
||||
// 比较结果
|
||||
boolean flag = compareExtractResults(anwerResults, stuResults);
|
||||
|
||||
if (flag) {
|
||||
//todo 得分
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
|
||||
} else {
|
||||
//得分
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage()+"得分:0 ❌");
|
||||
appendToFile(answerLogPath, "执行学生库语句"+sql2+"时发生错误: " + e.getMessage());
|
||||
hasError = true; // 发生异常,设为 true
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 比较结果(如果发生异常,可以认为比较失败)
|
||||
boolean flag = !hasError && compareExtractResults(anwerResults, stuResults);
|
||||
|
||||
if (flag) {
|
||||
//todo 得分
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
//得分
|
||||
double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,12 +684,13 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
if (entry.getValue().trim().toUpperCase().toUpperCase().contains("TRIGGER")) {
|
||||
appendToFile(answerLogPath, "==================触发器==================");
|
||||
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
|
||||
String answerId=null;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
|
||||
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
|
||||
// 匹配成功
|
||||
String answerId = examQuestionAnswer.getAnswerId();
|
||||
answerId = examQuestionAnswer.getAnswerId();
|
||||
examMysqlKeywordList= examMysqlKeywordMapper.selectListByAnswerId(answerId);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -675,10 +714,12 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
boolean equals = normalizedTriggerSql1.equals(normalizedTriggerSql2);
|
||||
if (equals) {
|
||||
//todo 得分
|
||||
accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score);
|
||||
double sr= accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, sql2, totalKeyScore, score, answerId, scoreTotal);
|
||||
scoreTotal+=sr;
|
||||
} else {
|
||||
int scoreAnswerNotAllTrue =calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score);
|
||||
total.addAndGet(scoreAnswerNotAllTrue);
|
||||
double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal);
|
||||
scoreTotal+=sw;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -698,25 +739,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
}
|
||||
}
|
||||
double roundedResult =0.0;
|
||||
try {
|
||||
int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim());
|
||||
if (totalKeyScoreInt != 0) {
|
||||
double result = (total.get() * 1.0 / totalKeyScoreInt) * score;
|
||||
|
||||
// 保留两位小数
|
||||
// 保留两位小数的 double(四舍五入)
|
||||
roundedResult = Math.round(result * 100.0) / 100.0;
|
||||
System.out.println("最终结果是:" + roundedResult);
|
||||
} else {
|
||||
System.out.println("除数不能为 0");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("无效的 totalKeyScore 值:" + totalKeyScore);
|
||||
}
|
||||
appendToFile(answerLogPath, "共得分:"+roundedResult);
|
||||
appendToFile(answerLogPath, "共得分:"+scoreTotal);
|
||||
folderzip.delete();
|
||||
deleteFolder(folder);
|
||||
return roundedResult;
|
||||
return scoreTotal;
|
||||
}
|
||||
|
||||
|
||||
@@ -731,34 +758,66 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
}
|
||||
folder.delete(); // 删除空文件夹或文件
|
||||
}
|
||||
//如果这个小题对了,直接累加对应的权值分
|
||||
private double accumulateScoreAndLog(List<ExamMysqlKeyword> examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score,String answerId,double scoreTotal) {
|
||||
//用answerid查对应答案的权值 。除以总权值
|
||||
String scoreRateStr= examQuestionAnswerMapper.selectExamQuestionAnswerScoreByAnswerId(answerId);
|
||||
|
||||
private static void accumulateScoreAndLog(List<ExamMysqlKeyword> examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score) {
|
||||
AtomicInteger singleTotal = new AtomicInteger(); // 单独累加 scoreRateStr 的总和
|
||||
for (ExamMysqlKeyword examMysqlKeyword : examMysqlKeywordList) {
|
||||
String scoreRateStr = examMysqlKeyword.getScoreRate();
|
||||
if (scoreRateStr != null && !scoreRateStr.trim().isEmpty()) {
|
||||
// 解析权值
|
||||
double scoreRate = 0.0;
|
||||
double totalKey = 0.0;
|
||||
double singleScore = 0.0;
|
||||
try {
|
||||
int scoreAnswerAllTrue = Integer.parseInt(scoreRateStr.trim());
|
||||
total.addAndGet(scoreAnswerAllTrue);
|
||||
scoreRate = Double.parseDouble(scoreRateStr);
|
||||
totalKey = Double.parseDouble(totalKeyScore);
|
||||
// 计算该答案对应的得分
|
||||
|
||||
if (totalKey > 0) {
|
||||
singleScore = (scoreRate / totalKey) * score;
|
||||
singleScore = Math.round(singleScore * 100.0) / 100.0;
|
||||
System.out.println(scoreTotal);
|
||||
System.out.println(singleScore);
|
||||
|
||||
System.out.println(scoreTotal);
|
||||
|
||||
singleTotal.addAndGet(scoreAnswerAllTrue); // 单独累加
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("无效的scoreRate值:" + scoreRateStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim());
|
||||
double finalScore = ((double) singleTotal.get() / totalKeyScoreInt) * score;
|
||||
String formattedScore = String.format("%.1f", finalScore);
|
||||
appendToFile(answerLogPath, "✅语句" + sql2 + "正确,关键得分权值:" + singleTotal.get() + ",得分" + formattedScore);
|
||||
|
||||
appendToFile(answerLogPath, "✅语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("无效的totalKeyScore值:" + totalKeyScore);
|
||||
}
|
||||
return singleScore;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public double calculateTotalScoreRate(String sql, List<ExamMysqlKeyword> examQuestionKeywords, String totalKeyScore, double score,String answerId,double scoreTotal) {
|
||||
//用answerid查对应答案的权值 。除以总权值
|
||||
String scoreRateStr= examQuestionAnswerMapper.selectExamQuestionAnswerScoreByAnswerId(answerId);
|
||||
|
||||
|
||||
|
||||
// 解析权值
|
||||
double scoreRate = 0.0;
|
||||
double totalKey = 0.0;
|
||||
// 计算该答案对应的得分
|
||||
double singleScore = 0.0;
|
||||
try {
|
||||
scoreRate = Double.parseDouble(scoreRateStr);
|
||||
totalKey = Double.parseDouble(totalKeyScore);
|
||||
|
||||
if (totalKey > 0) {
|
||||
singleScore = (scoreRate / totalKey) * score;
|
||||
singleScore = Math.round(singleScore * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("无效的totalKeyScore值:" + totalKeyScore);
|
||||
}
|
||||
|
||||
|
||||
public static int calculateTotalScoreRate(String sql, List<ExamMysqlKeyword> examQuestionKeywords, String totalKeyScore, double score) {
|
||||
int totalScoreRate = 0;
|
||||
Set<String> matchedKeywords = new HashSet<>();
|
||||
for (ExamMysqlKeyword keyword : examQuestionKeywords) {
|
||||
@@ -777,11 +836,20 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
}
|
||||
}
|
||||
}
|
||||
int totalKeyScoreInt = Integer.parseInt(totalKeyScore.trim());
|
||||
double finalScore = ((double) totalScoreRate / totalKeyScoreInt) * score;
|
||||
String formattedScore = String.format("%.1f", finalScore);
|
||||
appendToFile(answerLogPath,"❌语句"+sql+"不正确,答对得分点为:"+matchedKeywords+"关键得分权值"+ totalScoreRate+ ",得分" + formattedScore);
|
||||
return totalScoreRate;
|
||||
//累加答案关键字的所有权值
|
||||
int totalKeyScoreInt = examQuestionKeywords.stream()
|
||||
.map(ExamMysqlKeyword::getScoreRate)
|
||||
.filter(s -> s != null && !s.isEmpty())
|
||||
.mapToInt(Integer::parseInt)
|
||||
.sum();
|
||||
|
||||
//乘以 对了多少个 关键字 权值
|
||||
double finalRoundedScore = new BigDecimal(
|
||||
((double) totalScoreRate / totalKeyScoreInt) * singleScore
|
||||
).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
|
||||
appendToFile(answerLogPath,"❌语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore);
|
||||
return finalRoundedScore;
|
||||
}
|
||||
|
||||
// 预处理函数:去除空格和换行并转为大写
|
||||
@@ -1033,21 +1101,26 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
*/
|
||||
private static void printResult(List<List<String>> result) {
|
||||
if (result.isEmpty()) {
|
||||
appendToFile(answerLogPath,"查询结果为空");
|
||||
appendToFile(answerLogPath, "查询结果为空");
|
||||
} else {
|
||||
// 打印每一行数据
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
List<String> row = result.get(i);
|
||||
if (i == 0) { // 打印列名
|
||||
appendToFile(answerLogPath,"列名:");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (i == 0) {
|
||||
sb.append("列名:");
|
||||
}
|
||||
|
||||
for (String value : row) {
|
||||
appendToFile(answerLogPath,value + "\t");
|
||||
sb.append(value).append("\t");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// 输出整行
|
||||
appendToFile(answerLogPath, sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用提供的正则表达式模式从给定的 SQL 语句中提取视图名称。
|
||||
*/
|
||||
@@ -1250,7 +1323,9 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
||||
*/
|
||||
public static void appendToFile(String filePath, String content) {
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
||||
writer.write(content);
|
||||
String timestamp = LocalDateTime.now().format(formatter);
|
||||
String logLine = String.format("[%s] %s", timestamp, content);
|
||||
writer.write(logLine);
|
||||
writer.newLine(); // 可选:添加换行符
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
Reference in New Issue
Block a user