【修改】mysql判分txt加上答案语句,文件夹出题加上初始文件夹回显

This commit is contained in:
YOHO\20373
2025-06-11 21:51:54 +08:00
parent 734bb5d5bb
commit 140407b8c3
3 changed files with 16 additions and 10 deletions

View File

@@ -12,5 +12,6 @@ import java.util.List;
@NoArgsConstructor
public class FilePointsVo {
List<FileNode> nodeList;
List<FileNode> stuList;
List<ExamQuestionAnswer> examQuestionAnswerList;
}

View File

@@ -66,6 +66,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
File folderAnswer = new File(answerFilePath);
List<FileNode> nodeList = ExamGetPointsServiceImpl.buildFileNodeTree(folderAnswer);
List<FileNode> stuList = ExamGetPointsServiceImpl.buildFileNodeTree(folderStu);
System.out.println(nodeList);
List<ExamQuestionAnswer> answerList = new ArrayList<>();
@@ -104,6 +105,7 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
FilePointsVo filePointsVo=new FilePointsVo();
filePointsVo.setNodeList(nodeList);
filePointsVo.setStuList(stuList);
filePointsVo.setExamQuestionAnswerList(answerList);
return filePointsVo;
}

View File

@@ -364,6 +364,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
appendToFile(answerLogPath, "==================删除语句==================");
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
String delStatement = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + delStatement);
delStatement = delStatement.trim().replaceAll(";+\\s*$", "");
String answerId =null;
String sql2 = resultStu.get(entry.getKey());
@@ -383,11 +384,11 @@ public class MysqlServericeImpl implements IMysqlServerice {
String tableName = matcher.group(1).trim();
String whereClause = matcher.group(2).trim();
MysqlServericeImpl.DeleteInfo deleteInfo = new MysqlServericeImpl.DeleteInfo(tableName, whereClause);
appendToFile(answerLogPath, "提取出的表名: " + deleteInfo.tableName);
appendToFile(answerLogPath, "提取出的条件: " + deleteInfo.whereClause);
// appendToFile(answerLogPath, "提取出的表名: " + deleteInfo.tableName);
// appendToFile(answerLogPath, "提取出的条件: " + deleteInfo.whereClause);
// 构造验证 SQL
String verifySql = "SELECT COUNT(*) FROM " + deleteInfo.tableName + " WHERE " + deleteInfo.whereClause;
appendToFile(answerLogPath, "验证 SQL: " + verifySql);
// appendToFile(answerLogPath, "验证 SQL: " + verifySql);
//查找正确答案的
// try (Connection conn = DriverManager.getConnection(newDbUrl, user, password);
// Statement stmt = conn.createStatement()) {
@@ -436,6 +437,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
appendToFile(answerLogPath, "==================更新语句==================");
List<ExamMysqlKeyword> examMysqlKeywordList =new ArrayList<>();
String sql1 = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + sql1);
String answerId=null;
for (ExamQuestionAnswer examQuestionAnswer : examQuestionAnswers) {
if (normalize(examQuestionAnswer.getContent()).equals(normalize(entry.getValue()))) {
@@ -480,7 +482,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
String sql1 = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + sql1);
String sql2 = resultStu.get(entry.getKey());
@@ -544,6 +546,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
String sql1 = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + sql1);
String sql2 = resultStu.get(entry.getKey());
// 正则表达式,用于匹配 "VIEW" 后面的视图名称
String regex = "(?<=VIEW\\s)([\\w`_]+)";
@@ -582,12 +585,12 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
// 执行查询获取视图1的结果
appendToFile(answerLogPath, "执行正确答案视图语句" + viewName1 + " 的查询结果:");
appendToFile(answerLogPath, "执行正确答案视图语句的查询结果:");
String sql3 = "SELECT * FROM " + viewName1;
List<List<String>> result1 = executeQuery(stmt, sql3);
printResult(result1);
// 执行查询获取视图2的结果
appendToFile(answerLogPath, "执行考生视图语句" + viewName2 + " 的查询结果:");
appendToFile(answerLogPath, "执行考生视图语句的查询结果:");
String sql4 = "SELECT * FROM " + viewName2;
List<List<String>> result2 = executeQuery(stmt, sql4);
printResult(result2);
@@ -628,7 +631,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
appendToFile(answerLogPath, "==================储存过程==================");
String sql1 = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + sql1);
String sql2 = resultStu.get(entry.getKey());
//提取call语句
List<String> extractCallStatements = extractCallStatements(sql1);
@@ -707,7 +710,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
String sql1 = entry.getValue();
appendToFile(answerLogPath, "正确语句: " + sql1);
String sql2 = resultStu.get(entry.getKey());
// 清洗触发器语句(去除注释等)
@@ -794,7 +797,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
appendToFile(answerLogPath, "✅语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore);
appendToFile(answerLogPath, "学生语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore);
} catch (NumberFormatException e) {
System.err.println("无效的totalKeyScore值" + totalKeyScore);
}
@@ -860,7 +863,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
((double) totalScoreRate / totalKeyScoreInt) * singleScore
).setScale(2, RoundingMode.HALF_UP).doubleValue();
appendToFile(answerLogPath,"❌语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore);
appendToFile(answerLogPath,"学生语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore);
return finalRoundedScore;
}