【修改】 wps c语言点击标准答案后,无法获取到真正的文档
This commit is contained in:
@@ -55,6 +55,10 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File one_file : csFileList) {
|
||||
String name = one_file.getName();
|
||||
if ("网络题".equals(name)) {
|
||||
|
@@ -52,12 +52,14 @@ public class AutoForCServiceImpl implements AutoForCService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File csFile : csFileList) {
|
||||
String name = csFile.getName();
|
||||
if ("编程题".equals(name)) {
|
||||
File[] cs_file_list = csFiles.listFiles();
|
||||
String lastFilePath = cs_file_list[0].getPath();
|
||||
File[] lastFiles = cs_file_list[0].listFiles();
|
||||
File[] cs_file_list = csFile.listFiles();
|
||||
// 3、根据题号进行查询试题的相关信息
|
||||
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
|
||||
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
|
||||
@@ -66,13 +68,15 @@ public class AutoForCServiceImpl implements AutoForCService {
|
||||
EducationPaperQu educationPaperQu = results.get();
|
||||
String quScore = educationPaperScheme.getQuScores();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
|
||||
for (File lastFile : lastFiles) {
|
||||
for (File lastFile : cs_file_list) {
|
||||
String judgementStr = "<p>-----------------------------------------------------------</p>";
|
||||
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
|
||||
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
|
||||
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
|
||||
judgementStr += "<p>试题名称:" + name + "</p>";
|
||||
SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), lastFilePath, lastFile.getName(), examQuestion, judgementStr);
|
||||
// 获取不带文件名称的路径
|
||||
String filePaths = lastFile.getParent();
|
||||
SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), filePaths, lastFile.getName(), examQuestion, judgementStr);
|
||||
judgementStr = cpojo.getText();
|
||||
BigDecimal dangSource = new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||
judgementStr += "<p>试题得分:" + dangSource + "</p>";
|
||||
|
@@ -61,6 +61,10 @@ public class AutoForFileServiceImpl implements AutoForFileService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File one_file : csFileList) {
|
||||
String name = one_file.getName();
|
||||
if ("文件处理".equals(name)) {
|
||||
|
@@ -55,6 +55,10 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File one_file : csFileList) {
|
||||
String name = one_file.getName();
|
||||
if ("程序设计".equals(name)) {
|
||||
|
@@ -50,6 +50,10 @@ public class AutoForPsServiceImpl implements AutoForPsService{
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
String name = csFileList[0].getName();
|
||||
if ("图像处理".equals(name)) {
|
||||
File[] cs_file_list = csFiles.listFiles();
|
||||
|
@@ -65,16 +65,16 @@ public class JudgementServiceImpl implements JudgementService
|
||||
double pass_score = score * is_pass_score;
|
||||
|
||||
// 创建log文件txt,用于记录
|
||||
LogFileUtils.createFile(pathC + "/log.txt");
|
||||
// LogFileUtils.createFile(pathC + "/log.txt");
|
||||
String code = JudgementCUtils.readFile(pathC, fileName);
|
||||
LogFileUtils.writeLine("✅ 系统开始读取学生考试文件:" + code);
|
||||
// LogFileUtils.writeLine("✅ 系统开始读取学生考试文件:" + code);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 系统开始读取学生考试文件:" + code);
|
||||
if (code == "") {
|
||||
// 如果没有读到源码
|
||||
LogFileUtils.writeLine("❌ 系统没有读取到学生考试文件。");
|
||||
// LogFileUtils.writeLine("❌ 系统没有读取到学生考试文件。");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 系统没有读取到学生考试文件。");
|
||||
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
// 该题不得分,直接算成0分
|
||||
sourceAndText.setScore(0);
|
||||
sourceAndText.setText(judgementStr);
|
||||
@@ -94,7 +94,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("success", keyword_run);
|
||||
item.put("score_rate", examQuestionKeyword.getScoreRate());
|
||||
LogFileUtils.writeLine("✅ 关键字比对:" + examQuestionKeyword.getKeyword() + "--" + (keyword_run ? "正确" : "错误"));
|
||||
// LogFileUtils.writeLine("✅ 关键字比对:" + examQuestionKeyword.getKeyword() + "--" + (keyword_run ? "正确" : "错误"));
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 关键字比对:" + examQuestionKeyword.getKeyword() + "--" + (keyword_run ? "正确" : "错误"));
|
||||
weight += Integer.parseInt(examQuestionKeyword.getScoreRate());
|
||||
key_list.add(item);
|
||||
@@ -109,7 +109,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 每个选项分值 = 总分 / 总权重
|
||||
true_number += 1;
|
||||
key_score += one_keyword_score * Integer.parseInt((String) item.get("score_rate"));
|
||||
LogFileUtils.writeLine("✅ 关键字得分:" + key_score);
|
||||
// LogFileUtils.writeLine("✅ 关键字得分:" + key_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 关键字得分:" + key_score);
|
||||
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 编译代码运行
|
||||
if (is_pass) {
|
||||
// 如果使用程序编译,进行程序编译
|
||||
LogFileUtils.writeLine("✅ 使用c99标准进行编译...");
|
||||
// LogFileUtils.writeLine("✅ 使用c99标准进行编译...");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 使用c99标准进行编译...");
|
||||
|
||||
// 使用C99 运行并得出结果
|
||||
@@ -130,11 +130,11 @@ public class JudgementServiceImpl implements JudgementService
|
||||
if (!code_return.contains("error")) {
|
||||
// 编译没有报错,加上编译分数
|
||||
totalScore += pass_score;
|
||||
LogFileUtils.writeLine("✅ 编译通过得分:" + pass_score);
|
||||
// LogFileUtils.writeLine("✅ 编译通过得分:" + pass_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 编译通过得分:" + pass_score);
|
||||
|
||||
} else {
|
||||
LogFileUtils.writeLine("❌ 编译未通过。");
|
||||
// LogFileUtils.writeLine("❌ 编译未通过。");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 编译未通过。");
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 运行完成后在判断是否需要进行关键字比对
|
||||
boolean run_code = false;
|
||||
List<Boolean> runList = new ArrayList<>();
|
||||
LogFileUtils.writeLine("✅ 使用c99标准进行测试用例编译...");
|
||||
// LogFileUtils.writeLine("✅ 使用c99标准进行测试用例编译...");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 使用c99标准进行测试用例编译...");
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestion.getAnswerList()) {
|
||||
// 使用C99 运行并得出结果
|
||||
@@ -175,9 +175,9 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 1、如果完全相等,说明完全正确,直接给满分
|
||||
if (test_case_number == true_test_case_number) {
|
||||
// 满分,该题多少分就是多少分
|
||||
LogFileUtils.writeLine("✅ 测试用例全部正确:"+ score);
|
||||
// LogFileUtils.writeLine("✅ 测试用例全部正确:"+ score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 测试用例全部正确:"+ score);
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
sourceAndText.setScore(score);
|
||||
sourceAndText.setText(judgementStr);
|
||||
return sourceAndText;
|
||||
@@ -185,7 +185,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
// 2、测试用例没有完全正确,对多少个就是多少分
|
||||
// 公式:测试用例总分数 / 测试用例数量 * 正确测试用例数量
|
||||
compile_score += (double) ((score * is_compile_score) / test_case_number) * true_test_case_number;
|
||||
LogFileUtils.writeLine("✅ 测试用例数量:"+ test_case_number + ",正确数量:" + true_test_case_number + ",得分:" + compile_score);
|
||||
// LogFileUtils.writeLine("✅ 测试用例数量:"+ test_case_number + ",正确数量:" + true_test_case_number + ",得分:" + compile_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 测试用例数量:"+ test_case_number + ",正确数量:" + true_test_case_number + ",得分:" + compile_score);
|
||||
|
||||
}
|
||||
@@ -199,21 +199,21 @@ public class JudgementServiceImpl implements JudgementService
|
||||
if (is_result) {
|
||||
// 总分 = 总分 + 结果得分
|
||||
totalScore += result_score;
|
||||
LogFileUtils.writeLine("✅ 结果得分:" + result_score);
|
||||
// LogFileUtils.writeLine("✅ 结果得分:" + result_score);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 结果得分:" + result_score);
|
||||
}
|
||||
}
|
||||
totalScore += key_score;
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
sourceAndText.setScore(totalScore);
|
||||
sourceAndText.setText(judgementStr);
|
||||
return sourceAndText;
|
||||
} else {
|
||||
// 关键字对几个给几分,没有达到临界值的情况下
|
||||
totalScore += key_score;
|
||||
LogFileUtils.writeLine("❌ 关键字没有达到临界值,正确数量:"+ true_number);
|
||||
// LogFileUtils.writeLine("❌ 关键字没有达到临界值,正确数量:"+ true_number);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ 关键字没有达到临界值,正确数量:"+ true_number);
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
sourceAndText.setScore(totalScore);
|
||||
sourceAndText.setText(judgementStr);
|
||||
return sourceAndText;
|
||||
|
@@ -10,6 +10,8 @@ import com.example.exam.exam.utils.c.LogFileUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -26,8 +28,8 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
|
||||
|
||||
// 拼接同级目录下的目标文件路径
|
||||
String targetFilePath = new File(parentDir, "WPS_Xlsx判分过程.txt").getPath();
|
||||
LogFileUtils.createFile(targetFilePath);
|
||||
LogFileUtils.writeLine("✅ 开始WPS_Xlsx判分");
|
||||
// LogFileUtils.createFile(targetFilePath);
|
||||
// LogFileUtils.writeLine("✅ 开始WPS_Xlsx判分");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Xlsx判分");
|
||||
double wpsXlsxScore = 0;
|
||||
List<WpsPptxJudgementDto> margins = WpsExcelUtils.wpsExcel(path, "0");
|
||||
@@ -55,19 +57,19 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
|
||||
}
|
||||
wpsXlsxScore += one_sorce;
|
||||
if (flag) {
|
||||
LogFileUtils.writeLine("✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
// LogFileUtils.writeLine("✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP));
|
||||
} else {
|
||||
LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
// LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
}
|
||||
}
|
||||
LogFileUtils.writeLine("✅ 结束WPS_Xlsx判分,试题得分:" + wpsXlsxScore);
|
||||
// LogFileUtils.writeLine("✅ 结束WPS_Xlsx判分,试题得分:" + wpsXlsxScore);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 结束WPS_Xlsx判分,试题得分:" + wpsXlsxScore);
|
||||
sourceAndText.setText(judgementStr);
|
||||
sourceAndText.setScore(wpsXlsxScore);
|
||||
// 关闭已经打开得文件
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
return sourceAndText;
|
||||
}
|
||||
}
|
||||
|
@@ -56,13 +56,14 @@ public class JudgementForExcelServiceImpl implements JudgementForExcelService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File csFile : csFileList) {
|
||||
String name = csFile.getName();
|
||||
if ("表格".equals(name)) {
|
||||
File[] cs_file_list = csFiles.listFiles();
|
||||
String lastFilePath = cs_file_list[0].getPath();
|
||||
File[] lastFiles = cs_file_list[0].listFiles();
|
||||
File[] cs_file_list = csFile.listFiles();
|
||||
// 3、根据题号进行查询试题的相关信息
|
||||
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
|
||||
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
|
||||
@@ -71,14 +72,14 @@ public class JudgementForExcelServiceImpl implements JudgementForExcelService {
|
||||
EducationPaperQu educationPaperQu = results.get();
|
||||
String quScore = educationPaperScheme.getQuScores();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
|
||||
for (File lastFile : lastFiles) {
|
||||
for (File lastFile : cs_file_list) {
|
||||
if (lastFile.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>";
|
||||
SourceAndText excelpojo = judgementWpsExcelService.judgementWpsXlsx(Double.parseDouble(quScore), lastFilePath, lastFile.getPath(), examQuestion, judgementStr);
|
||||
SourceAndText excelpojo = judgementWpsExcelService.judgementWpsXlsx(Double.parseDouble(quScore), lastFile.getPath(), lastFile.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);
|
||||
|
@@ -7,6 +7,8 @@ import com.example.exam.exam.utils.HtmlAppender;
|
||||
import com.example.exam.exam.utils.c.LogFileUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,8 +22,8 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService {
|
||||
public SourceAndText judgementWpsPptx(double sorce, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception {
|
||||
SourceAndText sourceAndText = new SourceAndText();
|
||||
// 创建log文件txt,用于记录
|
||||
LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt");
|
||||
LogFileUtils.writeLine("✅ 开始WPS_Pptx判分");
|
||||
// LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt");
|
||||
// LogFileUtils.writeLine("✅ 开始WPS_Pptx判分");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Pptx判分");
|
||||
double wpsPptScore = 0;
|
||||
List<JudgementReqVo> judgementReq = new ArrayList<>();
|
||||
@@ -62,16 +64,16 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService {
|
||||
}
|
||||
wpsPptScore += one_sorce;
|
||||
if (flag) {
|
||||
LogFileUtils.writeLine("✅" + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
// LogFileUtils.writeLine("✅" + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP));
|
||||
} else {
|
||||
LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
// LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
}
|
||||
}
|
||||
LogFileUtils.writeLine("✅ 结束WPS_Pptx判分,试题得分:" + wpsPptScore);
|
||||
// LogFileUtils.writeLine("✅ 结束WPS_Pptx判分,试题得分:" + wpsPptScore);
|
||||
// 关闭已经打开得文件
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
sourceAndText.setScore(wpsPptScore);
|
||||
sourceAndText.setText(judgementStr);
|
||||
return sourceAndText;
|
||||
|
@@ -57,28 +57,30 @@ public class JudgementForPptxServiceImpl implements JudgementForPptxService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File csFile : csFileList) {
|
||||
String name = csFile.getName();
|
||||
if ("演示".equals(name)) {
|
||||
File[] cs_file_list = csFiles.listFiles();
|
||||
String lastFilePath = cs_file_list[0].getPath();
|
||||
File[] lastFiles = cs_file_list[0].listFiles();
|
||||
File[] cs_file_list = csFile.listFiles();
|
||||
// 3、根据题号进行查询试题的相关信息
|
||||
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
|
||||
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
|
||||
|
||||
EducationPaperScheme educationPaperScheme = result.get();
|
||||
EducationPaperQu educationPaperQu = results.get();
|
||||
String quScore = educationPaperScheme.getQuScores();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
|
||||
for (File lastFile : lastFiles) {
|
||||
if (lastFile.getName().contains("文档")) {
|
||||
for (File lastFile : cs_file_list) {
|
||||
String fileNames = lastFile.getName();
|
||||
if (fileNames.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>";
|
||||
SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), lastFilePath, lastFile.getPath(), examQuestion, judgementStr);
|
||||
SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), lastFile.getPath(), lastFile.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);
|
||||
|
@@ -9,6 +9,8 @@ import com.example.exam.exam.utils.c.LogFileUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,8 +24,8 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||
public SourceAndText judgementWpsWord(double sorce, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception {
|
||||
SourceAndText sourceAndText = new SourceAndText();
|
||||
// 创建log文件txt,用于记录
|
||||
LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt");
|
||||
LogFileUtils.writeLine("✅ 开始WPS_Word判分");
|
||||
// LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt");
|
||||
// LogFileUtils.writeLine("✅ 开始WPS_Word判分");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Word判分");
|
||||
double wps_word_sorce = 0;
|
||||
// 2、docx文件读取并返回考点及说明信息
|
||||
@@ -76,18 +78,18 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||
}
|
||||
wps_word_sorce += one_sorce;
|
||||
if (flag) {
|
||||
LogFileUtils.writeLine("✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
// LogFileUtils.writeLine("✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + one_sorce);
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + examQuestionAnswer.getContentIn() + " 得分成功,得分:" + new BigDecimal(one_sorce).setScale(1, RoundingMode.HALF_UP));
|
||||
|
||||
} else {
|
||||
LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
// LogFileUtils.writeLine("❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ " + examQuestionAnswer.getContentIn() + " 得分失败");
|
||||
|
||||
}
|
||||
}
|
||||
LogFileUtils.writeLine("✅ 结束WPS_Word判分,试题得分:" + wps_word_sorce);
|
||||
// LogFileUtils.writeLine("✅ 结束WPS_Word判分,试题得分:" + wps_word_sorce);
|
||||
// 关闭已经打开得文件
|
||||
LogFileUtils.close();
|
||||
// LogFileUtils.close();
|
||||
sourceAndText.setScore(wps_word_sorce);
|
||||
sourceAndText.setText(judgementStr);
|
||||
return sourceAndText;
|
||||
|
@@ -54,12 +54,14 @@ public class JudgementForWordServiceImpl implements JudgementForWordService {
|
||||
File csFiles = new File(file.getPath());
|
||||
String quId = csFiles.getName();
|
||||
File[] csFileList = csFiles.listFiles();
|
||||
if (csFileList == null) {
|
||||
System.err.println("子目录读取失败: " + csFiles.getAbsolutePath());
|
||||
continue;
|
||||
}
|
||||
for (File csFile : csFileList) {
|
||||
String name = csFile.getName();
|
||||
if ("文字".equals(name)) {
|
||||
File[] cs_file_list = csFiles.listFiles();
|
||||
String lastFilePath = cs_file_list[0].getPath();
|
||||
File[] lastFiles = cs_file_list[0].listFiles();
|
||||
File[] cs_file_list = csFile.listFiles();
|
||||
// 3、根据题号进行查询试题的相关信息
|
||||
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
|
||||
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
|
||||
@@ -68,14 +70,14 @@ public class JudgementForWordServiceImpl implements JudgementForWordService {
|
||||
EducationPaperQu educationPaperQu = results.get();
|
||||
String quScore = educationPaperScheme.getQuScores();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
|
||||
for (File lastFile : lastFiles) {
|
||||
for (File lastFile : cs_file_list) {
|
||||
if (lastFile.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>";
|
||||
SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), lastFilePath, lastFile.getPath(), examQuestion, judgementStr);
|
||||
SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), lastFile.getPath(), lastFile.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);
|
||||
|
@@ -213,7 +213,7 @@ public class JudgementCUtils
|
||||
System.out.println(" " + line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogFileUtils.writeLine("❗ 无法读取文件: " + path);
|
||||
// LogFileUtils.writeLine("❗ 无法读取文件: " + path);
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user