From 8df06f4f0719c5af45eaaa5eab055563d43f19ed Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Wed, 11 Jun 2025 15:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=88=A4?= =?UTF-8?q?=E5=88=86=E6=97=B6=E4=B8=8B=E8=BD=BD=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=B8=A6=E4=B8=8A=E6=96=87=E4=BB=B6=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/dataobject/ExamQuestionAnswer.java | 13 ++----- .../file/GetDifferencesBetweenFolders.java | 39 ++++++++++--------- .../mapper/exam/ExamQuestionAnswerMapper.xml | 7 ++-- .../admin/getpoints/GetPointsController.java | 4 +- .../admin/getpoints/vo/FileNode.java | 1 + .../service/file/FileServericeImpl.java | 2 +- .../getpoints/ExamGetPointsServiceImpl.java | 20 ++++++++++ .../auto_tools/AutoToolsServiceImpl.java | 3 +- 8 files changed, 53 insertions(+), 36 deletions(-) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java index ea88091f..a01938a4 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestionAnswer.java @@ -65,18 +65,11 @@ public class ExamQuestionAnswer // @Excel(name = "排序") private Integer sort; + private String attribute; + @TableField(exist = false) @JsonInclude(value = JsonInclude.Include.NON_EMPTY) private List examMysqlKeywordList; - public ExamQuestionAnswer(String answerId, String quId, String isRight, String image, String content, String contentIn, String scoreRate, Integer sort) { - this.answerId = answerId; - this.quId = quId; - this.isRight = isRight; - this.image = image; - this.content = content; - this.contentIn = contentIn; - this.scoreRate = scoreRate; - this.sort = sort; - } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/file/GetDifferencesBetweenFolders.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/file/GetDifferencesBetweenFolders.java index d2014b9c..a0c8cce5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/file/GetDifferencesBetweenFolders.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/file/GetDifferencesBetweenFolders.java @@ -56,30 +56,31 @@ public class GetDifferencesBetweenFolders { // 列出文件夹下的所有文件及其属性 - public static Map listFilesAndFoldersWithAttributes(Path folder) throws IOException { - if (!Files.exists(folder)) return Collections.emptyMap(); - try (Stream stream = Files.walk(folder)) { - return stream.collect(Collectors.toMap( - path -> folder.relativize(path).toString(), - GetDifferencesBetweenFolders::getFileAttributes, - (a, b) -> a, - LinkedHashMap::new - )); + public static Map listFilesAndFoldersWithAttributes(Path folder) throws IOException { + if (!Files.exists(folder)) return Collections.emptyMap(); + try (Stream stream = Files.walk(folder)) { + return stream.collect(Collectors.toMap( + path -> folder.relativize(path).toString(), + GetDifferencesBetweenFolders::getFileAttributes, + (a, b) -> a, + LinkedHashMap::new + )); + } } - } - // 在 getFileAttributes 方法中,只返回文件的属性,如果是文件夹则返回特殊标识 - static String getFileAttributes(Path path) { + // 返回文件和文件夹的属性 + static String getFileAttributes(Path path) { try { - if (Files.isDirectory(path)) { - return "文件夹"; // 特别标记为文件夹 + boolean isDirectory = Files.isDirectory(path); + boolean isHidden = Files.isHidden(path); + boolean isReadable = Files.isReadable(path); + + if (isDirectory) { + return String.format("隐藏: %b, 可读: %b", isHidden, isReadable); } else { - BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class); - boolean isHidden = Files.isHidden(path); - boolean isReadable = Files.isReadable(path); boolean isWritable = Files.isWritable(path); - return String.format("大小: %dB, 隐藏: %b, 可读: %b, 可写: %b", - attrs.size(), isHidden, isReadable, isWritable); + return String.format("隐藏: %b, 可读: %b, 可写: %b", + isHidden, isReadable, isWritable); } } catch (IOException e) { return "无法获取属性"; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml index 5bee46f1..ac8ff6ca 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml @@ -11,11 +11,12 @@ + - select answer_id, qu_id, is_right, image, content,contentIn, score_rate,sort from exam_question_answer + select answer_id, qu_id, is_right, image, content,contentIn, score_rate,attribute,sort from exam_question_answer insert into exam_question_answer - (answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort) + (answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort,attribute) values - (#{item.answerId},#{item.quId},#{item.isRight},#{item.image},#{item.content},#{item.contentIn},#{item.scoreRate},#{item.sort}) + (#{item.answerId},#{item.quId},#{item.isRight},#{item.image},#{item.content},#{item.contentIn},#{item.scoreRate},#{item.sort},#{item.attribute}) diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java index ee6e3afc..371d4ef1 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/GetPointsController.java @@ -66,10 +66,10 @@ public class GetPointsController { return CommonResult.success(examGetPointsService.getPointById(quId)); } /** - * 新增/修改浏览器操作考点 + * 新增/修改浏览器/文件操作考点 * @return 得分 */ - @Operation(summary = "新增/修改浏览器操作考点") + @Operation(summary = "新增/修改浏览器/文件操作考点") @PostMapping("/set_browser_point") @TenantIgnore //老师自己设置,不读文件 diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java index 86e72866..7ba14774 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/getpoints/vo/FileNode.java @@ -11,4 +11,5 @@ public class FileNode { private Long id; private String name; private Long parentId; + private String attribute; } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java index 9a94edd8..c3f73e1d 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/file/FileServericeImpl.java @@ -92,7 +92,7 @@ public class FileServericeImpl implements IFileServerice { // 如果学生提交中存在该文件,且属性匹配,则得分 if (stuFiles.containsKey(filePath)) { String studentAttrs = stuFiles.get(filePath); // 学生提交的属性 - String expectedAttrs = answer.getScoreRate(); // 试题中期望的属性 + String expectedAttrs = answer.getAttribute(); // 试题中期望的属性 isCorrect = studentAttrs.equals(expectedAttrs); } } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java index 3559e11b..17f91725 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/getpoints/ExamGetPointsServiceImpl.java @@ -89,6 +89,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ answer.setContentIn("考察名称"); } else if (value.startsWith("属性不同")) { answer.setContentIn("考察属性"); + answer.setAttribute(value.split(" vs ")[1]); // answer.setContent(key + " -> " + value.split(" vs ")[1]); // 设置属性信息 } return answer; @@ -131,6 +132,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ node.setId(currentId); node.setName(file.getName()); node.setParentId(parentId); + node.setAttribute(getFileAttributes(file)); // 设置属性 list.add(node); if (file.isDirectory()) { @@ -144,6 +146,24 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{ } + private static String getFileAttributes(File file) { + try { + boolean isDirectory = file.isDirectory(); + boolean isHidden = file.isHidden(); + boolean isReadable = file.canRead(); + + if (isDirectory) { + return String.format("隐藏: %b, 可读: %b", isHidden, isReadable); + } else { + boolean isWritable = file.canWrite(); + return String.format(" 隐藏: %b, 可读: %b, 可写: %b", + isHidden, isReadable, isWritable); + } + } catch (SecurityException e) { + return "无法获取属性"; + } + } + diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java index a2efcc6a..4ce02b05 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java @@ -30,6 +30,7 @@ import pc.exam.pp.module.infra.service.file.FileService; import pc.exam.pp.module.judgement.controller.service.browser.IBrowserServerice; import pc.exam.pp.module.judgement.controller.service.file.IFileServerice; import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice; +import pc.exam.pp.module.judgement.controller.utils.zip.ZipUtil; import pc.exam.pp.module.judgement.service.c_programming.JudgementService; import pc.exam.pp.module.judgement.service.choice.JudgementChoiceService; import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService; @@ -271,7 +272,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{ String patn = downloadStudentFile(stuPaperFileDO.getUrl(), config.getValue()); File zip_file = new File(patn); // 4、获取到得是zip文件,需要解压 - String stuFilePath = unzipToNamedFolder(patn); + String stuFilePath = ZipUtil.unzipToNamedFolder(patn); // 5、解压之后得文件获取文件夹和文件 File folder = new File(stuFilePath); File[] files = folder.listFiles();