Accept Merge Request #112: (hyc -> master)
Merge Request: 【修改】判分时下载的文件带上文件的属性 Created By: @华允传 Accepted By: @华允传 URL: https://g-iswv8783.coding.net/p/education/d/pengchen-exam-java/git/merge/112?initial=true
This commit is contained in:
@@ -65,18 +65,11 @@ public class ExamQuestionAnswer
|
|||||||
// @Excel(name = "排序")
|
// @Excel(name = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
private String attribute;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
|
||||||
private List<ExamMysqlKeyword> examMysqlKeywordList;
|
private List<ExamMysqlKeyword> 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -56,30 +56,31 @@ public class GetDifferencesBetweenFolders {
|
|||||||
|
|
||||||
|
|
||||||
// 列出文件夹下的所有文件及其属性
|
// 列出文件夹下的所有文件及其属性
|
||||||
public static Map<String, String> listFilesAndFoldersWithAttributes(Path folder) throws IOException {
|
public static Map<String, String> listFilesAndFoldersWithAttributes(Path folder) throws IOException {
|
||||||
if (!Files.exists(folder)) return Collections.emptyMap();
|
if (!Files.exists(folder)) return Collections.emptyMap();
|
||||||
try (Stream<Path> stream = Files.walk(folder)) {
|
try (Stream<Path> stream = Files.walk(folder)) {
|
||||||
return stream.collect(Collectors.toMap(
|
return stream.collect(Collectors.toMap(
|
||||||
path -> folder.relativize(path).toString(),
|
path -> folder.relativize(path).toString(),
|
||||||
GetDifferencesBetweenFolders::getFileAttributes,
|
GetDifferencesBetweenFolders::getFileAttributes,
|
||||||
(a, b) -> a,
|
(a, b) -> a,
|
||||||
LinkedHashMap::new
|
LinkedHashMap::new
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 在 getFileAttributes 方法中,只返回文件的属性,如果是文件夹则返回特殊标识
|
// 返回文件和文件夹的属性
|
||||||
static String getFileAttributes(Path path) {
|
static String getFileAttributes(Path path) {
|
||||||
try {
|
try {
|
||||||
if (Files.isDirectory(path)) {
|
boolean isDirectory = Files.isDirectory(path);
|
||||||
return "文件夹"; // 特别标记为文件夹
|
boolean isHidden = Files.isHidden(path);
|
||||||
|
boolean isReadable = Files.isReadable(path);
|
||||||
|
|
||||||
|
if (isDirectory) {
|
||||||
|
return String.format("隐藏: %b, 可读: %b", isHidden, isReadable);
|
||||||
} else {
|
} else {
|
||||||
BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
|
|
||||||
boolean isHidden = Files.isHidden(path);
|
|
||||||
boolean isReadable = Files.isReadable(path);
|
|
||||||
boolean isWritable = Files.isWritable(path);
|
boolean isWritable = Files.isWritable(path);
|
||||||
return String.format("大小: %dB, 隐藏: %b, 可读: %b, 可写: %b",
|
return String.format("隐藏: %b, 可读: %b, 可写: %b",
|
||||||
attrs.size(), isHidden, isReadable, isWritable);
|
isHidden, isReadable, isWritable);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return "无法获取属性";
|
return "无法获取属性";
|
||||||
|
@@ -11,11 +11,12 @@
|
|||||||
<result property="content" column="content" />
|
<result property="content" column="content" />
|
||||||
<result property="contentIn" column="contentIn" />
|
<result property="contentIn" column="contentIn" />
|
||||||
<result property="scoreRate" column="score_rate" />
|
<result property="scoreRate" column="score_rate" />
|
||||||
|
<result property="attribute" column="attribute" />
|
||||||
<result property="sort" column="sort" />
|
<result property="sort" column="sort" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectExamQuestionAnswerVo">
|
<sql id="selectExamQuestionAnswerVo">
|
||||||
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
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectExamQuestionAnswerList" parameterType="ExamQuestionAnswer" resultMap="ExamQuestionAnswerResult">
|
<select id="selectExamQuestionAnswerList" parameterType="ExamQuestionAnswer" resultMap="ExamQuestionAnswerResult">
|
||||||
@@ -105,10 +106,10 @@
|
|||||||
</select>
|
</select>
|
||||||
<insert id="insertExamQuestionAnswerList">
|
<insert id="insertExamQuestionAnswerList">
|
||||||
insert into 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
|
values
|
||||||
<foreach collection="collection" separator="," item="item">
|
<foreach collection="collection" separator="," item="item">
|
||||||
(#{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})
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
@@ -66,10 +66,10 @@ public class GetPointsController {
|
|||||||
return CommonResult.success(examGetPointsService.getPointById(quId));
|
return CommonResult.success(examGetPointsService.getPointById(quId));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 新增/修改浏览器操作考点
|
* 新增/修改浏览器/文件操作考点
|
||||||
* @return 得分
|
* @return 得分
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "新增/修改浏览器操作考点")
|
@Operation(summary = "新增/修改浏览器/文件操作考点")
|
||||||
@PostMapping("/set_browser_point")
|
@PostMapping("/set_browser_point")
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
//老师自己设置,不读文件
|
//老师自己设置,不读文件
|
||||||
|
@@ -11,4 +11,5 @@ public class FileNode {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
private String attribute;
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ public class FileServericeImpl implements IFileServerice {
|
|||||||
// 如果学生提交中存在该文件,且属性匹配,则得分
|
// 如果学生提交中存在该文件,且属性匹配,则得分
|
||||||
if (stuFiles.containsKey(filePath)) {
|
if (stuFiles.containsKey(filePath)) {
|
||||||
String studentAttrs = stuFiles.get(filePath); // 学生提交的属性
|
String studentAttrs = stuFiles.get(filePath); // 学生提交的属性
|
||||||
String expectedAttrs = answer.getScoreRate(); // 试题中期望的属性
|
String expectedAttrs = answer.getAttribute(); // 试题中期望的属性
|
||||||
isCorrect = studentAttrs.equals(expectedAttrs);
|
isCorrect = studentAttrs.equals(expectedAttrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,6 +89,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
|||||||
answer.setContentIn("考察名称");
|
answer.setContentIn("考察名称");
|
||||||
} else if (value.startsWith("属性不同")) {
|
} else if (value.startsWith("属性不同")) {
|
||||||
answer.setContentIn("考察属性");
|
answer.setContentIn("考察属性");
|
||||||
|
answer.setAttribute(value.split(" vs ")[1]);
|
||||||
// answer.setContent(key + " -> " + value.split(" vs ")[1]); // 设置属性信息
|
// answer.setContent(key + " -> " + value.split(" vs ")[1]); // 设置属性信息
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
@@ -131,6 +132,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
|||||||
node.setId(currentId);
|
node.setId(currentId);
|
||||||
node.setName(file.getName());
|
node.setName(file.getName());
|
||||||
node.setParentId(parentId);
|
node.setParentId(parentId);
|
||||||
|
node.setAttribute(getFileAttributes(file)); // 设置属性
|
||||||
list.add(node);
|
list.add(node);
|
||||||
|
|
||||||
if (file.isDirectory()) {
|
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 "无法获取属性";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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.browser.IBrowserServerice;
|
||||||
import pc.exam.pp.module.judgement.controller.service.file.IFileServerice;
|
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.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.c_programming.JudgementService;
|
||||||
import pc.exam.pp.module.judgement.service.choice.JudgementChoiceService;
|
import pc.exam.pp.module.judgement.service.choice.JudgementChoiceService;
|
||||||
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
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());
|
String patn = downloadStudentFile(stuPaperFileDO.getUrl(), config.getValue());
|
||||||
File zip_file = new File(patn);
|
File zip_file = new File(patn);
|
||||||
// 4、获取到得是zip文件,需要解压
|
// 4、获取到得是zip文件,需要解压
|
||||||
String stuFilePath = unzipToNamedFolder(patn);
|
String stuFilePath = ZipUtil.unzipToNamedFolder(patn);
|
||||||
// 5、解压之后得文件获取文件夹和文件
|
// 5、解压之后得文件获取文件夹和文件
|
||||||
File folder = new File(stuFilePath);
|
File folder = new File(stuFilePath);
|
||||||
File[] files = folder.listFiles();
|
File[] files = folder.listFiles();
|
||||||
|
Reference in New Issue
Block a user