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