【修改】 选择题文件非空判断

This commit is contained in:
DESKTOP-932OMT8\REN
2025-05-28 10:29:01 +08:00
parent caf42be98e
commit 73824e1662

View File

@@ -184,33 +184,35 @@ public class AutoToolsServiceImpl implements AutoToolsService{
stuPaperFileDO = stuPaperFileDOs; stuPaperFileDO = stuPaperFileDOs;
} }
} }
// 1-1、 穿插选择题判分 // 判断选择题文件是否存在
// 1-1-1、下载选择题文件 if (noZipFileDO != null) {
String select_qu = downloadStudentFile(noZipFileDO.getUrl(), config.getValue()); // 1-1、 穿插选择题判分
File select_file = new File(select_qu); // 1-1-1、下载选择题文件
// 1-1-2、读取内容转换成json String select_qu = downloadStudentFile(noZipFileDO.getUrl(), config.getValue());
String select_string = readFileAsString(select_file.getPath()); File select_file = new File(select_qu);
Stu stu = stringToJson(select_string); // 1-1-2、读取内容转换成json
// 1-1-3、进行选择题判分 String select_string = readFileAsString(select_file.getPath());
for (String key : stu.getQuestionResultMap().keySet()) { Stu stu = stringToJson(select_string);
// 查询该题的成绩 // 1-1-3、进行选择题判分
StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, key); for (String key : stu.getQuestionResultMap().keySet()) {
// 判断是否做过该题 // 查询该题的成绩
boolean isNull = false; StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, key);
if (stuPaperScoreDO == null) { // 判断是否做过该题
stuPaperScoreDO = new StuPaperScoreDO(); boolean isNull = false;
stuPaperScoreDO.setStuId(stuId); if (stuPaperScoreDO == null) {
stuPaperScoreDO.setQuId(key); stuPaperScoreDO = new StuPaperScoreDO();
stuPaperScoreDO.setPaperId(paperId); stuPaperScoreDO.setStuId(stuId);
isNull = true; stuPaperScoreDO.setQuId(key);
stuPaperScoreDO.setPaperId(paperId);
isNull = true;
}
String value = stu.getQuestionResultMap().get(key);
double selectScore = judgementChoiceService.programmingChoice(2.0, key, value, stuPaperScoreDO, isNull);
score += selectScore;
} }
String value = stu.getQuestionResultMap().get(key); // 1-1-4、删除文件
double selectScore = judgementChoiceService.programmingChoice(2.0, key, value, stuPaperScoreDO, isNull); select_file.delete();
score += selectScore;
} }
// 1-1-4、删除文件
select_file.delete();
// 2、判断文件路径是否存在 // 2、判断文件路径是否存在
if (stuPaperFileDO == null) { if (stuPaperFileDO == null) {
// return CommonResult.error(100031, "试题文件没有上传,无法判分!"); // return CommonResult.error(100031, "试题文件没有上传,无法判分!");