From f7a904e8b88c261f5eb46749ec963f7b89f23ac3 Mon Sep 17 00:00:00 2001 From: dlaren Date: Mon, 4 Aug 2025 15:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=911=E3=80=81?= =?UTF-8?q?=E8=AF=95=E9=A2=98=E6=96=87=E4=BB=B6=E7=94=B1sys=5Ffile?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=88=90exam=5Fquestion=5Ffile=202=E3=80=81C?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E7=A8=8B=E5=BA=8F=E8=AE=BE=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E4=BB=A3=E7=A0=81=E6=AE=B5=E5=86=85=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E9=97=AE=E9=A2=98=EF=BC=8C=E6=9B=B4=E6=96=B0=20?= =?UTF-8?q?=E8=BF=9E=E7=BB=AD=E8=BE=93=E5=85=A5=E5=BE=97=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/exam/exam/dal/ExamQuestion.java | 7 +++---- .../dal/{SysFileUpload.java => ExamQuestionFile.java} | 7 +++---- .../{SysFileMapper.java => ExamQuestionFileMapper.java} | 6 +++--- .../exam/exam/service/c/JudgementServiceImpl.java | 9 ++++++--- .../exam/service/question/ExamQuestionServiceImpl.java | 6 +++--- .../mapper/question/ExamQuestionAnswerMapper.xml | 2 +- .../{SysFileMapper.xml => ExamQuestionFileMapper.xml} | 6 +++--- 7 files changed, 22 insertions(+), 21 deletions(-) rename src/main/java/com/example/exam/exam/dal/{SysFileUpload.java => ExamQuestionFile.java} (91%) rename src/main/java/com/example/exam/exam/mapper/{SysFileMapper.java => ExamQuestionFileMapper.java} (55%) rename src/main/resources/mapper/question/{SysFileMapper.xml => ExamQuestionFileMapper.xml} (77%) diff --git a/src/main/java/com/example/exam/exam/dal/ExamQuestion.java b/src/main/java/com/example/exam/exam/dal/ExamQuestion.java index 0aa1f18..7088752 100644 --- a/src/main/java/com/example/exam/exam/dal/ExamQuestion.java +++ b/src/main/java/com/example/exam/exam/dal/ExamQuestion.java @@ -3,7 +3,6 @@ package com.example.exam.exam.dal; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.util.List; @@ -105,7 +104,7 @@ public class ExamQuestion { /** 试题文件 */ // @Excel(name = "试题文件") @TableField(exist = false) - private List fileUploads; + private List fileUploads; /** 试题判分 */ // @Excel(name = "试题判分") @@ -312,11 +311,11 @@ public class ExamQuestion { this.answerList = answerList; } - public List getFileUploads() { + public List getFileUploads() { return fileUploads; } - public void setFileUploads(List fileUploads) { + public void setFileUploads(List fileUploads) { this.fileUploads = fileUploads; } diff --git a/src/main/java/com/example/exam/exam/dal/SysFileUpload.java b/src/main/java/com/example/exam/exam/dal/ExamQuestionFile.java similarity index 91% rename from src/main/java/com/example/exam/exam/dal/SysFileUpload.java rename to src/main/java/com/example/exam/exam/dal/ExamQuestionFile.java index 8b98cff..621bac3 100644 --- a/src/main/java/com/example/exam/exam/dal/SysFileUpload.java +++ b/src/main/java/com/example/exam/exam/dal/ExamQuestionFile.java @@ -4,19 +4,18 @@ package com.example.exam.exam.dal; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** - * 文件(hyc)对象 sys_file + * 文件(hyc)对象 exam_question_file * * @author pengchen * @date 2025-03-18 */ -@TableName(value = "sys_file", autoResultMap = true) +@TableName(value = "exam_question_file", autoResultMap = true) @Data @Accessors(chain = true) -public class SysFileUpload { +public class ExamQuestionFile { private static final long serialVersionUID = 1L; /** diff --git a/src/main/java/com/example/exam/exam/mapper/SysFileMapper.java b/src/main/java/com/example/exam/exam/mapper/ExamQuestionFileMapper.java similarity index 55% rename from src/main/java/com/example/exam/exam/mapper/SysFileMapper.java rename to src/main/java/com/example/exam/exam/mapper/ExamQuestionFileMapper.java index 5826bd7..3a6ebcb 100644 --- a/src/main/java/com/example/exam/exam/mapper/SysFileMapper.java +++ b/src/main/java/com/example/exam/exam/mapper/ExamQuestionFileMapper.java @@ -1,6 +1,6 @@ package com.example.exam.exam.mapper; -import com.example.exam.exam.dal.SysFileUpload; +import com.example.exam.exam.dal.ExamQuestionFile; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -13,8 +13,8 @@ import java.util.List; * @date 2025-03-18 */ @Mapper -public interface SysFileMapper +public interface ExamQuestionFileMapper { - public List selectSysFileByQuid(String quId); + public List selectSysFileByQuid(String quId); } diff --git a/src/main/java/com/example/exam/exam/service/c/JudgementServiceImpl.java b/src/main/java/com/example/exam/exam/service/c/JudgementServiceImpl.java index 036e8da..d7db601 100644 --- a/src/main/java/com/example/exam/exam/service/c/JudgementServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/c/JudgementServiceImpl.java @@ -87,13 +87,16 @@ public class JudgementServiceImpl implements JudgementService int weight = 0; List> key_list = new ArrayList<>(); - // 只获取 /\\*+Program\\*+/(.*?)/\\*+ End \\*+/ 下的代码进行判断 - String pattern = "/\\*+Program\\*+/(.*?)/\\*+ End \\*+/"; - Pattern r = Pattern.compile(pattern, Pattern.DOTALL); + // 只获取 /\*+\s*[Pp][Rr][Oo][Gg][Rr][Aa][Mm]\s*\*+/(.*?)/\*+\s*[Ee][Nn][Dd]\s*\*+/ 下的代码进行判断 + String pattern = "/\\*+\\s*[Pp][Rr][Oo][Gg][Rr][Aa][Mm]\\s*\\*+/(.*?)/\\*+\\s*[Ee][Nn][Dd]\\s*\\*+/"; + Pattern r = Pattern.compile(pattern, Pattern.DOTALL | Pattern.CASE_INSENSITIVE); Matcher m = r.matcher(code); String result; if (m.find()) { result = m.group(1).trim(); // 提取代码段 + if (result.isEmpty()) { + result = " "; // 如果匹配到但内容为空,返回原代码 + } } else { result = code; // 如果没有匹配到标识符,返回全部代码 } diff --git a/src/main/java/com/example/exam/exam/service/question/ExamQuestionServiceImpl.java b/src/main/java/com/example/exam/exam/service/question/ExamQuestionServiceImpl.java index da15384..9f3e2df 100644 --- a/src/main/java/com/example/exam/exam/service/question/ExamQuestionServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/question/ExamQuestionServiceImpl.java @@ -23,7 +23,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Autowired private ExamQuestionAnswerMapper examQuestionAnswerMapper; @Autowired - private SysFileMapper sysFileMapper; + private ExamQuestionFileMapper sysFileMapper; @Autowired private ExamQuestionScoreMapper examQuestionScoreMapper; @Autowired @@ -41,7 +41,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService //查找试题答案 List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); //查找试题文件 - List sysFileUploads =sysFileMapper.selectSysFileByQuid(quId); + List sysFileUploads =sysFileMapper.selectSysFileByQuid(quId); //查找试题判分 ExamQuestionScore examQuestionScore =examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId); //获取试题关键字 @@ -80,7 +80,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService //查找试题答案 List examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(quId); //查找试题文件 - List sysFileUploads =sysFileMapper.selectSysFileByQuid(quId); + List sysFileUploads =sysFileMapper.selectSysFileByQuid(quId); //查找试题判分 ExamQuestionScore examQuestionScore =examQuestionScoreMapper.selectExamQuestionScoreByQuId(quId); //获取试题关键字 diff --git a/src/main/resources/mapper/question/ExamQuestionAnswerMapper.xml b/src/main/resources/mapper/question/ExamQuestionAnswerMapper.xml index d58ad40..a6b0822 100644 --- a/src/main/resources/mapper/question/ExamQuestionAnswerMapper.xml +++ b/src/main/resources/mapper/question/ExamQuestionAnswerMapper.xml @@ -40,7 +40,7 @@ diff --git a/src/main/resources/mapper/question/SysFileMapper.xml b/src/main/resources/mapper/question/ExamQuestionFileMapper.xml similarity index 77% rename from src/main/resources/mapper/question/SysFileMapper.xml rename to src/main/resources/mapper/question/ExamQuestionFileMapper.xml index 3052e51..4e5d9fc 100644 --- a/src/main/resources/mapper/question/SysFileMapper.xml +++ b/src/main/resources/mapper/question/ExamQuestionFileMapper.xml @@ -2,8 +2,8 @@ - - + + @@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select file_id, qu_id, url, file_type ,file_name from sys_file + select file_id, qu_id, url, file_type ,file_name from exam_question_file