【修改】 C语言关键字判断
This commit is contained in:
@@ -95,7 +95,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
item.put("success", keyword_run);
|
||||
item.put("score_rate", examQuestionKeyword.getScoreRate());
|
||||
// LogFileUtils.writeLine("✅ 关键字比对:" + examQuestionKeyword.getKeyword() + "--" + (keyword_run ? "正确" : "错误"));
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 关键字比对:" + examQuestionKeyword.getKeyword() + "--" + (keyword_run ? "正确" : "错误"));
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 关键字比对:" + examQuestionKeyword.getKeyword() + " -- " + (keyword_run ? "正确" : "错误"));
|
||||
weight += Integer.parseInt(examQuestionKeyword.getScoreRate());
|
||||
key_list.add(item);
|
||||
}
|
||||
@@ -119,27 +119,8 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 关键字临界得分值
|
||||
int todo_key_percentage = Integer.parseInt(examQuestion.getQuestionScores().getKeywordCutoff());
|
||||
if (key_score > keyword_score * ((double) todo_key_percentage / 100) ) {
|
||||
// 编译代码运行
|
||||
if (is_pass) {
|
||||
// 如果使用程序编译,进行程序编译
|
||||
// LogFileUtils.writeLine("✅ 使用c99标准进行编译...");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 使用c99标准进行编译...");
|
||||
|
||||
// 使用C99 运行并得出结果
|
||||
String code_return = JudgementCUtils.run_code(pathC,code,null,"-std=c99", "编译通过运行");
|
||||
if (!code_return.contains("error")) {
|
||||
// 编译没有报错,加上编译分数
|
||||
totalScore += pass_score;
|
||||
// LogFileUtils.writeLine("✅ 编译通过得分:" + pass_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 编译通过得分:" + pass_score);
|
||||
|
||||
} else {
|
||||
// LogFileUtils.writeLine("❌ 编译未通过。");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 编译未通过。");
|
||||
}
|
||||
}
|
||||
// 进行判断测试用例
|
||||
// 测试用例
|
||||
// 测试用例(比编译通过提前)
|
||||
// 判断是否要程序结果 ,需要程序结果的,就需要测试用例
|
||||
if (is_compile) {
|
||||
// 先运行程序,再将测试用例进行比对
|
||||
@@ -148,12 +129,25 @@ public class JudgementServiceImpl implements JudgementService
|
||||
List<Boolean> runList = new ArrayList<>();
|
||||
// LogFileUtils.writeLine("✅ 使用c99标准进行测试用例编译...");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 使用c99标准进行测试用例编译...");
|
||||
boolean isPassIndex = false;
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestion.getAnswerList()) {
|
||||
// 使用C99 运行并得出结果
|
||||
String code_return = JudgementCUtils.run_code(pathC,code, examQuestionAnswer.getContentIn(),"-std=c99",null);
|
||||
if (!isPassIndex && !code_return.contains("error")) {
|
||||
// 编译没有报错,加上编译分数
|
||||
totalScore += pass_score;
|
||||
// LogFileUtils.writeLine("✅ 编译通过得分:" + pass_score);
|
||||
isPassIndex = true;
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 编译通过得分:" + pass_score);
|
||||
|
||||
} else if (!isPassIndex) {
|
||||
// LogFileUtils.writeLine("❌ 编译未通过。");
|
||||
isPassIndex = true;
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 编译未通过。");
|
||||
}
|
||||
String actual = code_return.trim();
|
||||
String expected = examQuestionAnswer.getContent().trim();
|
||||
if (actual.equals(expected)) {
|
||||
if (actual.contains(expected)) {
|
||||
// 判断测试用例结果是否正确
|
||||
runList.add(true);
|
||||
// 获取测试用例临界值,并进行判断
|
||||
@@ -189,8 +183,25 @@ public class JudgementServiceImpl implements JudgementService
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 测试用例数量:"+ test_case_number + ",正确数量:" + true_test_case_number + ",得分:" + compile_score);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (is_pass) {
|
||||
// 编译代码运行
|
||||
// 如果使用程序编译,进行程序编译
|
||||
// LogFileUtils.writeLine("✅ 使用c99标准进行编译...");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 使用c99标准进行编译...");
|
||||
|
||||
// 使用C99 运行并得出结果
|
||||
String code_return = JudgementCUtils.run_code(pathC,code,null,"-std=c99", "编译通过运行");
|
||||
if (!code_return.contains("error")) {
|
||||
// 编译没有报错,加上编译分数
|
||||
totalScore += pass_score;
|
||||
// LogFileUtils.writeLine("✅ 编译通过得分:" + pass_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 编译通过得分:" + pass_score);
|
||||
|
||||
} else {
|
||||
// LogFileUtils.writeLine("❌ 编译未通过。");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 编译未通过。");
|
||||
}
|
||||
}
|
||||
// 总分 = 总分 + 测试用例得分
|
||||
totalScore += compile_score;
|
||||
if (compile_score > 0) {
|
||||
|
Reference in New Issue
Block a user