This commit is contained in:
huababa1
2025-08-25 21:05:14 +08:00
20 changed files with 183 additions and 150 deletions

View File

@@ -148,11 +148,11 @@ public class AutoForWinEmailSettingServiceImpl implements AutoForWinEmailSetting
Map<String, String> map = objectMapper.readValue(jsonText, Map.class);
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: 邮箱 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: 邮箱 </h2>";
judgementStr += "<p>✅ 开始QQ邮箱提判分</p>";
// 考试进行比对
for (ExamQuestionAnswer questionAnswer : examQuestion.getAnswerList()) {
boolean flag = false;
@@ -178,12 +178,12 @@ public class AutoForWinEmailSettingServiceImpl implements AutoForWinEmailSetting
oneScore += one_sorce;
score = score.add(new BigDecimal(one_sorce));
if (flag) {
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + questionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, questionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce + " 【✅】");
} else {
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + questionAnswer.getContentIn() + " 得分失败");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, questionAnswer.getContentIn() + " 得分失败 【❌】");
}
}
judgementStr += "<p>试题得分: " + oneScore + " </p>";
judgementStr += "<h2>试题得分: " + oneScore + " </h2>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());
@@ -227,12 +227,13 @@ public class AutoForWinEmailSettingServiceImpl implements AutoForWinEmailSetting
// 根据ID查询试题
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: 邮箱 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: 邮箱 </p>";
judgementStr += "<p>✅ 开始QQ邮箱提判分</p>";
judgementStr += "<p>❌ 未成功检测到作答情况</p>";
judgementStr += "<p>试题得分: 0分 </p>";
judgementStr += "<h2>试题得分: 0分 </h2>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());

View File

@@ -148,11 +148,11 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe
Map<String, String> map = objectMapper.readValue(jsonText, Map.class);
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: windows网络设置 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: windows网络设置 </h2>";
judgementStr += "<p>✅ 开始EDGE浏览器网络设置判分</p>";
// 考试进行比对
for (ExamQuestionAnswer questionAnswer : examQuestion.getAnswerList()) {
boolean flag = false;
@@ -178,12 +178,12 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe
oneScore += one_sorce;
score = score.add(new BigDecimal(one_sorce));
if (flag) {
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + questionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, questionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce + " 【✅】");
} else {
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + questionAnswer.getContentIn() + " 得分失败");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, questionAnswer.getContentIn() + " 得分失败 【❌】");
}
}
judgementStr += "<p>试题得分: " + oneScore + " </p>";
judgementStr += "<h2>试题得分: " + oneScore + " </h2>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());
@@ -227,12 +227,13 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe
// 根据ID查询试题
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: windows网络设置 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: windows网络设置 </h2>";
judgementStr += "<p>✅ 开始EDGE浏览器网络设置判分</p>";
judgementStr += "<p>❌ 未成功检测到作答情况</p>";
judgementStr += "<p>试题得分: 0分 </p>";
judgementStr += "<h2>试题得分: 0分 </h2>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());

View File

@@ -74,14 +74,15 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService {
EducationPaperQu educationPaperQu = results.get();
String quScore = educationPaperScheme.getQuScores();
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始网络提判分</p>";
SourceAndText cpojo = judgementBrowerService.Judgement(Double.parseDouble(quScore), stFile, examQuestion, judgementStr);
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = cpojo.getText();
judgementStr += "<p>试题得分:" + cpojo.getScore() + "</p>";
judgementStr += "<h2>试题得分:" + cpojo.getScore() + "</h2>";
// 4、需要更新学生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -8,6 +8,7 @@ import com.example.exam.exam.service.c.JudgementService;
import com.example.exam.exam.service.question.IExamQuestionService;
import com.example.exam.exam.service.stupaperscore.StuPaperScoreService;
import com.example.exam.exam.service.tenant.SystemTenantService;
import com.example.exam.exam.utils.HtmlAppender;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -72,16 +73,17 @@ public class AutoForCServiceImpl implements AutoForCService {
String quScore = educationPaperScheme.getQuScores();
if (wjFile.getName().contains(".c")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始C语言编程题判分</p>";
// 获取不带文件名称的路径
String filePaths = wjFile.getParent();
SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), filePaths, wjFile.getName(), examQuestion, judgementStr);
judgementStr = cpojo.getText();
BigDecimal dangSource = new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP);
judgementStr += "<p>试题得分:" + dangSource + "</p>";
judgementStr += "<h2>试题得分:" + dangSource + "</h2>";
// 4、需要更新学生试题得分首先需要查询试题的数据库是否保存信息
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
// 直接进行新增,不需要进行更新

View File

@@ -122,22 +122,22 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService {
stuAnswerSort = convertToLetter(resultAnswer.get().getSort());
}
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: 选择题 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: 选择题 </h2>";
judgementStr += "<p>学生答案:" + stuAnswerSort + "</p>";
judgementStr += "<p>正确答案:" + trueAbswerSort + "</p>";
boolean isRight = false;
// 开始判断学生的答案是否正确
if (stuAnswerId.equals(trueAnswerId)) {
// 正确
judgementStr += "<p>得分:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<h2>得分:" + Double.parseDouble(quScore) + "</h2>";
isRight = true;
score += Double.parseDouble(quScore);
} else {
// 不正确
judgementStr += "<p>得分0 </p>";
judgementStr += "<h2>得分0 </h2>";
isRight = false;
}
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
@@ -165,13 +165,13 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService {
}
// 没有找到作答情况直接该题判0分
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: 选择题 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: 选择题 </h2>";
judgementStr += "<p>学生答案: 未作答 </p>";
judgementStr += "<p>正确答案:" + trueAbswerSort + "</p>";
judgementStr += "<p>得分0 </p>";
judgementStr += "<h2>得分0 </h2>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());
@@ -215,13 +215,13 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService {
EducationPaperQu educationPaperQu = resultss.get();
// 没有找到作答情况直接该题判0分
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称: 选择题 </p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2p>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称: 选择题 </h2>";
judgementStr += "<p>学生答案: 未作答 </p>";
judgementStr += "<p>正确答案:" + trueAbswerSort + "</p>";
judgementStr += "<p>得分0 </p>";
judgementStr += "<h2>得分0 </p>";
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());

View File

@@ -80,14 +80,15 @@ public class AutoForFileServiceImpl implements AutoForFileService {
EducationPaperQu educationPaperQu = results.get();
String quScore = educationPaperScheme.getQuScores();
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始文件题判分</p>";
SourceAndText cpojo = fileServerice.Judgement(Double.parseDouble(quScore), stFile, examQuestion, judgementStr);
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = cpojo.getText();
judgementStr += "<p>试题得分:" + cpojo.getScore() + "</p>";
judgementStr += "<h2>试题得分:" + cpojo.getScore() + "</h2>";
// 4、需要更新学生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -78,14 +78,15 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService {
if (wjFile.getName().contains(".sql")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始MYSQL判分</p>";
SourceAndText cpojo = mysqlLocalService.Judgement(Double.parseDouble(quScore), stFile, examQuestion, judgementStr);
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = cpojo.getText();
judgementStr += "<p>试题得分:" + cpojo.getScore() + "</p>";
judgementStr += "<h2>试题得分:" + cpojo.getScore() + "</h2>";
// 4、需要更新学生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -69,14 +69,15 @@ public class AutoForPsServiceImpl implements AutoForPsService {
if (wjFile.getName().contains("原始")) {
String filePaths = wjFile.getParent();
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始QQ邮箱提判分</p>";
SourceAndText wordpojo = psService.Judgement(Double.parseDouble(quScore), filePaths, wjFile.getPath(), examQuestion, judgementStr);
score = score.add(new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = wordpojo.getText();
judgementStr += "<p>试题得分:" + wordpojo.getScore() + "</p>";
judgementStr += "<h2>试题得分:" + wordpojo.getScore() + "</h2>";
// 4、需要更新学生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -100,12 +100,12 @@ public class JudgementBrowerServiceImpl implements JudgementBrowerService {
String formattedWeightScore = String.format("%.1f", weightScore);
appendToFile(answerLogPath, "✅考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分:" + formattedWeightScore + " 【✅】");
//删除此书签
BookmarkDeleter.deleteBookmarkByName(chromeBookmarkPath, bookmarkNameToDelete);
} else {
appendToFile(answerLogPath, "❌考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + bookmarkNameToDelete + " -> 得分权值:" + currentScore + "-> 得分0 【❌】");
}
}
@@ -146,10 +146,10 @@ public class JudgementBrowerServiceImpl implements JudgementBrowerService {
double weightScore = ((double) currentScore / total) * score;
String formattedWeightScore = String.format("%.1f", weightScore);
appendToFile(answerLogPath, "✅考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore + " 【✅】");
} else {
appendToFile(answerLogPath, "❌考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "考点" + answer.getContent() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0 【❌】");
}
}
}

View File

@@ -12,9 +12,10 @@ import java.util.List;
public interface IMysqlLocalService {
void delMysqlConnect(List<String> tNames);
SourceAndText Judgement(double source, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
void delMysqlConnect(List<String> tNames);
void JudgementFile(File mysqlFile, ExamQuestion examQuestion);
SourceAndText Judgement(double source, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
void JudgementFile(File mysqlFile, ExamQuestion examQuestion);
}

View File

@@ -195,7 +195,7 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
boolean tableExists = false;
//学生语句
String stuSQL = null;
String yuju=null;
String yuju = null;
try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password);
Statement stmtstu = connstu.createStatement()) {
try (ResultSet rsstu = stmtstu.executeQuery(sql2)) {
@@ -224,7 +224,7 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
} else {
// 表不存在时的处理逻辑
System.out.println("" + tableName + " 在学生数据库中不存在");
yuju = compareTables(table1Columns, table2Columns, stuDataName, tableName, null, judgementStr);
yuju = compareTables(table1Columns, table2Columns, stuDataName, tableName, null, judgementStr);
}
@@ -949,23 +949,23 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
boolean equals = normalizedTriggerSql1.equals(normalizedTriggerSql2);
if (equals) {
correctCount++; // 完全正确
appendToFile(answerLogPath, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【结果】【√】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【结果】【✅】");
appendToFile(answerLogPath, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【结果】【√】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【结果】【✅】");
//todo 得分
SourceAndText studentScorePojo = accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, stuAnswer.get(), totalKeyScore, score, answerId, scoreTotal, judgementStr);
scoreTotal += studentScorePojo.getScore();
judgementStr = studentScorePojo.getText();
} else {
appendToFile(answerLogPath, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【结果】【×】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【验证】【结果】【❌】");
appendToFile(answerLogPath, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【结果】【×】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【验证】【结果】【❌】");
SourceAndText studentScorePojo = calculateTotalScoreRate(stuAnswer.get(), examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal, judgementStr);
scoreTotal += studentScorePojo.getScore();
judgementStr = studentScorePojo.getText();
}
} else {
appendToFile(answerLogPath, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【结果】【×】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】"+answerSQL+"【验证】【文件】 【" + fileName.get() + "】【结果】【❌】");
appendToFile(answerLogPath, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【结果】【×】");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【执行】" + answerSQL + "【验证】【文件】 【" + fileName.get() + "】【结果】【❌】");
SourceAndText studentScorePojo = calculateTotalScoreRate(stuAnswer.get(), examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal, judgementStr);
scoreTotal += studentScorePojo.getScore();
judgementStr = studentScorePojo.getText();
@@ -1055,7 +1055,7 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
SourceAndText studentScorePojo = calculateTotalScoreRate(alterSQL, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal, judgementStr);
scoreTotal += studentScorePojo.getScore();
judgementStr = studentScorePojo.getText();
}else {
} else {
SourceAndText studentScorePojo = calculateTotalScoreRate(null, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal, judgementStr);
scoreTotal += studentScorePojo.getScore();
judgementStr = studentScorePojo.getText();
@@ -1215,14 +1215,14 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
private static String compareTables(Set<Map<String, String>> standardSet, Set<Map<String, String>> studentSet, String dbTable, String tableName, String tableNameStu, String judgementStr) {
int index = 1;
// 判断表名是否一致
String tableNameCheck=null;
String tableNameCheckOther=null;
if (tableNameStu==null){
tableNameCheck = "x";
tableNameCheckOther = "";
}else {
tableNameCheck = tableName.equalsIgnoreCase(tableNameStu) ? "" : "x";
tableNameCheckOther = tableName.equalsIgnoreCase(tableNameStu) ? "" : "";
String tableNameCheck = null;
String tableNameCheckOther = null;
if (tableNameStu == null) {
tableNameCheck = "x";
tableNameCheckOther = "";
} else {
tableNameCheck = tableName.equalsIgnoreCase(tableNameStu) ? "" : "x";
tableNameCheckOther = tableName.equalsIgnoreCase(tableNameStu) ? "" : "";
}
// 输出
System.out.printf("%02d.【数据表】【%s】【名称】【%s】【%s】\n", index, dbTable, tableName, tableNameCheck);

View File

@@ -58,8 +58,8 @@ public class FileServericeImpl implements IFileServerice {
int totalScore = answerList.stream()
.mapToInt(a -> Integer.parseInt(a.getScoreRate()))
.sum();
appendToFile(answerLogPath, "=== 学生提交内容得分点 ===");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "=== 学生提交内容得分点 ===");
// appendToFile(answerLogPath, "=== 学生提交内容得分点 ===");
// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "=== 学生提交内容得分点 ===");
// 对比学生提交内容与试题得分点
SourceAndTextAndTotal studentScorePojo = compareStuAndTestFiles(answerList, stuFiles, score, totalScore, judgementStr);
double studentScore = studentScorePojo.getScore();
@@ -114,10 +114,10 @@ public class FileServericeImpl implements IFileServerice {
double weightScore = ((double) currentScore / total) * score;
String formattedWeightScore = String.format("%.1f", weightScore);
appendToFile(answerLogPath, "" + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore);
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分:" + formattedWeightScore + " 【✅】");
} else {
appendToFile(answerLogPath, "×" + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate() + "-> 得分0 【❌】");
}
}
sourceAndText.setText(judgementStr);

View File

@@ -28,7 +28,7 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
List<WpsXlsxInfoVo> wpsXlsxInfos = new ArrayList<>();
boolean isAllTrue = true; // 判断考点是否全对标识
// 日志:开始判分
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Xlsx判分");
// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Xlsx判分");
double wps_xlsx_score = 0;
// 获取答案组成
@@ -79,14 +79,14 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
if (flag) {
judgementStr = HtmlAppender.appendHtmlLine(
judgementStr,
"" + examQuestionAnswer.getContentIn() + " 得分成功,得分:" +
new BigDecimal(one_score).setScale(1, RoundingMode.HALF_UP)
examQuestionAnswer.getContentIn() + " 得分成功,得分:" +
new BigDecimal(one_score).setScale(1, RoundingMode.HALF_UP) + " 【✅】"
);
} else {
isAllTrue = false;
judgementStr = HtmlAppender.appendHtmlLine(
judgementStr,
"" + examQuestionAnswer.getContentIn() + " 得分失败"
examQuestionAnswer.getContentIn() + " 得分失败 【❌】"
);
}
}

View File

@@ -73,15 +73,16 @@ public class JudgementForExcelServiceImpl implements JudgementForExcelService {
System.out.println(wjFile.getName());
if (wjFile.getName().contains("文档")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始WPS_EXCEL判分</p>";
SourceAndText excelpojo = judgementWpsExcelService.judgementWpsXlsx(Double.parseDouble(quScore), wjFile.getPath(), wjFile.getPath(), examQuestion, judgementStr);
score = score.add(new BigDecimal(excelpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = excelpojo.getText();
BigDecimal dangSource = new BigDecimal(excelpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP);
judgementStr += "<p>试题得分:" + dangSource + "</p>";
judgementStr += "<h2>试题得分:" + dangSource + "</h2>";
// 4、需要新增生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -10,5 +10,7 @@ import java.util.List;
* @author REN
*/
public interface JudgementWpsPptxService {
SourceAndText judgementWpsPptx(double source, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception;
}

View File

@@ -27,7 +27,7 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService {
public SourceAndText judgementWpsPptx(double source, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception {
SourceAndText sourceAndText = new SourceAndText();
Boolean isAllTrue = true;
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Pptx判分");
// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Pptx判分");
double wpsPptScore = 0;
List<WpsSlideInfoVo> judgementReq = new ArrayList<>();
// 3、获取答案得组成
@@ -65,10 +65,10 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService {
}
wpsPptScore += one_sorce;
if (flag) {
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP));
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, examQuestionAnswer.getContentIn() + " 得分成功,得分:" + new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP) + " 【✅】");
} else {
isAllTrue = false;
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "" + examQuestionAnswer.getContentIn() + " 得分失败");
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, examQuestionAnswer.getContentIn() + " 得分失败 【❌】");
}
}
if (isAllTrue) {

View File

@@ -74,15 +74,16 @@ public class JudgementForPptxServiceImpl implements JudgementForPptxService {
String quScore = educationPaperScheme.getQuScores();
if (wjFile.getName().contains("文档")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始WPS_PPTX判分</p>";
SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), wjFile.getPath(), wjFile.getPath(), examQuestion, judgementStr);
score = score.add(new BigDecimal(pptxpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = pptxpojo.getText();
BigDecimal dangSource = new BigDecimal(pptxpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP);
judgementStr += "<p>试题得分:" + dangSource + "</p>";
judgementStr += "<h2>试题得分:" + dangSource + "</h2>";
// 4、需要新增生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -30,7 +30,7 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
List<WpsDocxInfoVo> wpsDocxInfos = new ArrayList<>();
boolean isAllTrue = true; // 判断考点是否全对标识
// 日志:开始判分
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Word判分");
// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Word判分");
double wps_word_sorce = 0;
// 获取答案组成
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
@@ -75,14 +75,14 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
if (flag) {
judgementStr = HtmlAppender.appendHtmlLine(
judgementStr,
"" + examQuestionAnswer.getContentIn() + " 得分成功,得分:" +
new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP)
examQuestionAnswer.getContentIn() + " 得分成功,得分:" +
new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP) + " 【✅】"
);
} else {
isAllTrue = false; // 有一个考点不对,标识为不全对
judgementStr = HtmlAppender.appendHtmlLine(
judgementStr,
"" + examQuestionAnswer.getContentIn() + " 得分失败"
examQuestionAnswer.getContentIn() + " 得分失败 【❌】"
);
}
}

View File

@@ -71,15 +71,16 @@ public class JudgementForWordServiceImpl implements JudgementForWordService {
String quScore = educationPaperScheme.getQuScores();
if (wjFile.getName().contains("文档")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
judgementStr += "<h2>试题序号:" + educationPaperQu.getSort() + "</h2>";
judgementStr += "<h2>试题编号:" + examQuestion.getQuNum() + "</h2>";
judgementStr += "<h2>试题分数:" + Double.parseDouble(quScore) + "</h2>";
judgementStr += "<h2>试题名称:" + name + "</h2>";
judgementStr += "<p>✅ 开始WPS_WORD判分</p>";
SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), wjFile.getPath(), wjFile.getPath(), examQuestion, judgementStr);
score = score.add(new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = wordpojo.getText();
BigDecimal dangSource = new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP);
judgementStr += "<p>试题得分:" + dangSource + "</p>";
judgementStr += "<h2>试题得分:" + dangSource + "</h2>";
// 4、需要新增学生试题得分
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());

View File

@@ -120,18 +120,22 @@ public class JudgementCUtils
}
public static String run_codes(String pathC, String code, String input, String standard, String text) {
try {
boolean hasInput = code.contains("scanf") || code.contains("fgets") || code.contains("getchar");
boolean hasInput = code != null && (code.contains("scanf") || code.contains("fgets") || code.contains("getchar"));
File workDir = new File(pathC);
if (!workDir.exists()) workDir.mkdirs();
boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");
java.nio.charset.Charset charset = pickCharset(text, isWindows);
String programC = new File(workDir, "program.c").getAbsolutePath();
String programOut = new File(workDir, isWindows ? "program.exe" : "program.out").getAbsolutePath();
// 写入 C 源码
try (FileWriter writer = new FileWriter(programC)) {
writer.write(code);
// 写入 C 源码(按指定字符集)
try (java.io.OutputStream os = new java.io.FileOutputStream(programC);
java.io.OutputStreamWriter writer = new java.io.OutputStreamWriter(os, charset)) {
writer.write(code == null ? "" : code);
writer.flush();
}
// jar 所在目录
@@ -149,21 +153,15 @@ public class JudgementCUtils
}
// 编译命令
ProcessBuilder compileBuilder;
if (stdFlag == null) {
compileBuilder = new ProcessBuilder(tccExe.getAbsolutePath(), programC, "-o", programOut);
} else {
compileBuilder = new ProcessBuilder(tccExe.getAbsolutePath(), stdFlag, programC, "-o", programOut);
}
ProcessBuilder compileBuilder = (stdFlag == null)
? new ProcessBuilder(tccExe.getAbsolutePath(), programC, "-o", programOut)
: new ProcessBuilder(tccExe.getAbsolutePath(), stdFlag, programC, "-o", programOut);
compileBuilder.directory(workDir);
compileBuilder.redirectErrorStream(true);
Process compileProcess = compileBuilder.start();
StringBuilder compileOutput = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(compileProcess.getInputStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) compileOutput.append(line).append("\n");
}
String compileOutput = readAll(compileProcess.getInputStream(), charset);
int compileResult = compileProcess.waitFor();
if (compileResult != 0 || !new File(programOut).exists()) {
return "❌ 编译失败,输出:\n" + compileOutput;
@@ -176,29 +174,25 @@ public class JudgementCUtils
Process runProcess = runBuilder.start();
if (hasInput && input != null) {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(runProcess.getOutputStream()))) {
try (java.io.OutputStream os = runProcess.getOutputStream();
java.io.OutputStreamWriter osw = new java.io.OutputStreamWriter(os, charset);
java.io.BufferedWriter bw = new java.io.BufferedWriter(osw)) {
bw.write(input);
bw.newLine();
bw.flush();
}
} else {
// 关闭输入流,避免某些程序等待 STDIN
try { runProcess.getOutputStream().close(); } catch (Exception ignore) {}
}
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<String> future = executor.submit(() -> {
StringBuilder output = new StringBuilder();
// 运行过程读取输出
try (BufferedReader br = new BufferedReader(
new InputStreamReader(runProcess.getInputStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) output.append(line).append("\n");
}
return output.toString();
});
java.util.concurrent.ExecutorService executor = java.util.concurrent.Executors.newSingleThreadExecutor();
java.util.concurrent.Future<String> future = executor.submit(() -> readAll(runProcess.getInputStream(), charset));
String output;
try {
output = future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException e) {
output = future.get(5, java.util.concurrent.TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
runProcess.destroyForcibly();
future.cancel(true);
output = "⏰ 程序运行超时(超过 5 秒)";
@@ -213,6 +207,31 @@ public class JudgementCUtils
return "运行 C 代码时出错:" + ex.getMessage();
}
}
private static java.nio.charset.Charset pickCharset(String text, boolean isWindows) {
if (text != null && !text.isBlank()) {
try {
return java.nio.charset.Charset.forName(text.trim());
} catch (Exception ignore) {
// ignore and fallback
}
}
// 常见场景Windows 中文环境默认 GBK其他系统默认 UTF-8
return isWindows ? java.nio.charset.Charset.forName("GBK") : java.nio.charset.StandardCharsets.UTF_8;
}
private static String readAll(java.io.InputStream is, java.nio.charset.Charset cs) throws java.io.IOException {
try (java.io.InputStream in = is;
java.io.InputStreamReader isr = new java.io.InputStreamReader(in, cs);
java.io.BufferedReader br = new java.io.BufferedReader(isr)) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line).append('\n');
}
return sb.toString();
}
}
/**
* 读取文件代码
* @param filePath 文件路径