diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java index cba00ef0..2743a37c 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java @@ -314,10 +314,10 @@ public class MysqlServericeImpl implements IMysqlServerice { String sql3 = resultStu.get(entry.getKey()); if (table1Columns.equals(table2Columns)) { // - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql3,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql3,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql3, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql3, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } } @@ -331,7 +331,8 @@ public class MysqlServericeImpl implements IMysqlServerice { // 正则表达式匹配表名 Pattern pattern = Pattern.compile("INSERT INTO\\s+`?(\\w+)`?\\s*\\("); Matcher matcher = pattern.matcher(entry.getValue()); - + appendToFile(answerLogPath, "正确语句: " + entry.getValue()); + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "正确语句: " + entry.getValue()); if (matcher.find()) { String tableName = matcher.group(1).replace("`", ""); // 获取表名 String answerId=null; @@ -353,10 +354,10 @@ public class MysqlServericeImpl implements IMysqlServerice { boolean equals = sql1.equals(sql2); if (equals) { - double sr=accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr=accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } @@ -413,10 +414,10 @@ public class MysqlServericeImpl implements IMysqlServerice { //累加删除语句的所有权值 examQuestionKeywords累加scorerate appendToFile(answerLogPath, "验证通过:符合 DELETE 条件的记录已删除。"); judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "验证通过:符合 DELETE 条件的记录已删除。"); - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } } @@ -471,10 +472,10 @@ public class MysqlServericeImpl implements IMysqlServerice { // if (b) { - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } @@ -538,11 +539,11 @@ public class MysqlServericeImpl implements IMysqlServerice { if (isEquivalent) { //todo 得分 - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } @@ -629,10 +630,10 @@ public class MysqlServericeImpl implements IMysqlServerice { stmt.execute("DROP VIEW IF EXISTS " + viewName1); stmt.execute("DROP VIEW IF EXISTS " + viewName2); if (isEquivalent) { - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal); + double sw= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sw; } // } @@ -714,11 +715,11 @@ public class MysqlServericeImpl implements IMysqlServerice { if (flag) { //todo 得分 - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal+=sr; } else { //得分 - double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); + double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal,judgementStr); scoreTotal+=sw; } @@ -762,10 +763,10 @@ public class MysqlServericeImpl implements IMysqlServerice { boolean equals = normalizedTriggerSql1.equals(normalizedTriggerSql2); if (equals) { //todo 得分 - double sr= accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, sql2, totalKeyScore, score, answerId, scoreTotal); + double sr= accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, sql2, totalKeyScore, score, answerId, scoreTotal,judgementStr); scoreTotal+=sr; } else { - double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); + double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal,judgementStr); scoreTotal+=sw; @@ -810,9 +811,10 @@ public class MysqlServericeImpl implements IMysqlServerice { folder.delete(); // 删除空文件夹或文件 } //如果这个小题对了,直接累加对应的权值分 - private double accumulateScoreAndLog(List examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score,String answerId,double scoreTotal) { + private double accumulateScoreAndLog(List examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score,String answerId,double scoreTotal,String judgementStr) { if(StringUtils.isBlank(answerId)){ appendToFile(answerLogPath, "❌该语句找不到试题id,请检查出题内容!" ); + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌该语句找不到试题id,请检查出题内容!"); return 0.0; } //用answerid查对应答案的权值 。除以总权值 @@ -836,7 +838,7 @@ public class MysqlServericeImpl implements IMysqlServerice { System.out.println(scoreTotal); } - + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅学生语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore); appendToFile(answerLogPath, "✅学生语句" + sql2 + "正确,语句得分权值:" + scoreRateStr + ",得分" + singleScore); } catch (NumberFormatException e) { System.err.println("无效的totalKeyScore值:" + totalKeyScore); @@ -846,8 +848,9 @@ public class MysqlServericeImpl implements IMysqlServerice { } - public double calculateTotalScoreRate(String sql, List examQuestionKeywords, String totalKeyScore, double score,String answerId,double scoreTotal) { + public double calculateTotalScoreRate(String sql, List examQuestionKeywords, String totalKeyScore, double score,String answerId,double scoreTotal,String judgementStr) { if(StringUtils.isBlank(answerId)){ + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌该语句找不到试题id,请检查出题内容!"); appendToFile(answerLogPath, "❌该语句找不到试题id,请检查出题内容!" ); return 0.0; } @@ -912,6 +915,7 @@ public class MysqlServericeImpl implements IMysqlServerice { ((double) totalScoreRate / totalKeyScoreInt) * singleScore ).setScale(2, RoundingMode.HALF_UP).doubleValue(); } + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌学生语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore); appendToFile(answerLogPath,"❌学生语句"+sql+"不正确,语句权值:"+scoreRateStr+",关键权值:"+totalKeyScoreInt+",答对得分点为:"+matchedKeywords+",答对关键得分权值"+ totalScoreRate+ ",得分" + finalRoundedScore); return finalRoundedScore;