【修改】 判分逻辑修改(文件夹路径补全),GCC逻辑判分修改,Word判分修改
This commit is contained in:
@@ -33,8 +33,8 @@ public class WpsWordController {
|
||||
* @return 判分
|
||||
*/
|
||||
@GetMapping("/run_wps_word")
|
||||
public CommonResult<List<WordVO>> run_wps_word() throws Exception {
|
||||
return CommonResult.success(judgementWpsWordService.ProgrammingWpsWord("1"));
|
||||
public CommonResult<List<WordVO>> run_wps_word(String path) throws Exception {
|
||||
return CommonResult.success(judgementWpsWordService.ProgrammingWpsWord(path));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class AutoToolsController {
|
||||
private AutoToolsService autoToolsService;
|
||||
|
||||
@GetMapping("/get")
|
||||
public CommonResult<Double> get(StuPaperReqVo stuPaperReqVo) {
|
||||
public CommonResult<Double> get(StuPaperReqVo stuPaperReqVo) throws Exception {
|
||||
return autoToolsService.judgementScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
||||
}
|
||||
}
|
||||
|
@@ -32,5 +32,5 @@ public interface AutoToolsService {
|
||||
* @param paperId 试卷ID
|
||||
* @return 分数
|
||||
*/
|
||||
CommonResult<Double> judgementScore(Long stuId, String paperId);
|
||||
CommonResult<Double> judgementScore(Long stuId, String paperId) throws Exception;
|
||||
}
|
||||
|
@@ -11,8 +11,10 @@ import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService;
|
||||
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||
import pc.exam.pp.module.judgement.service.c_programming.JudgementService;
|
||||
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
@@ -29,6 +31,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
IExamQuestionService examQuestionService;
|
||||
@Resource
|
||||
JudgementService judgementService;
|
||||
@Resource
|
||||
JudgementWpsWordService judgementWpsWordService;
|
||||
|
||||
@Override
|
||||
public String downloadStudentFile(String fileUrl, String filePath) {
|
||||
@@ -114,7 +118,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Double> judgementScore(Long stuId, String paperId) {
|
||||
public CommonResult<Double> judgementScore(Long stuId, String paperId) throws Exception {
|
||||
double score = 0;
|
||||
// 1、通过学号,试卷ID查询文件路径
|
||||
StuPaperFileDO stuPaperFileDO = stuPaperFileService.findByStuIDAndPaperId(stuId, paperId);
|
||||
@@ -145,7 +149,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
if (filess.length > 1) return CommonResult.error(100037, "5、试卷文件上传,目录不正确!");
|
||||
if (!filess[0].isDirectory()) return CommonResult.error(100038, "6、试卷文件上传,目录不正确!");
|
||||
// 判断学号是否正确
|
||||
if (!files[0].getName().equals(paperId)) return CommonResult.error(100039, "文件与试卷匹配异常");
|
||||
if (!filess[0].getName().equals(paperId)) return CommonResult.error(100039, "文件与试卷匹配异常");
|
||||
// 5.3、查询出来所有试题
|
||||
File qu_files = new File(filess[0].getPath());
|
||||
// 所有试题文件夹
|
||||
@@ -157,21 +161,30 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
// 7、进行对应得判分
|
||||
// --- 7.1、查询试题文件
|
||||
File qu_file = new File(file.getPath());
|
||||
File[] qu_file_list = qu_files.listFiles();
|
||||
File[] qu_file_list = qu_file.listFiles();
|
||||
if (qu_file_list == null) continue;
|
||||
// --- 7.2、通过文件名称进行判分
|
||||
for (File file_one : qu_file_list) {
|
||||
// 判断名称 类似于 C语言程序设计。
|
||||
if (file_one.getName().split("\\.")[0].equals(examQuestion.getCourseName()+examQuestion.getSubjectName())) {
|
||||
double c_score = judgementService.ProgrammingC(15.0, file.getPath(), file_one.getName(), examQuestion);
|
||||
score += c_score;
|
||||
break;
|
||||
double c_score = judgementService.ProgrammingC(15.0, file.getPath(), file_one.getName(), examQuestion);
|
||||
score += c_score;
|
||||
break;
|
||||
}
|
||||
// wps 类型存在多级文文件夹,需要个性化设置
|
||||
// if ()
|
||||
if (file_one.getName().equals("结果")) {
|
||||
// 进入到学生作答得文件,直接判断文件是否存在
|
||||
File wps_file = new File(file_one.getPath());
|
||||
File[] wps_file_list = wps_file.listFiles();
|
||||
if (wps_file_list == null) break;
|
||||
if (wps_file_list[0].getName().equals("结果.docx")) {
|
||||
// 开始调用wps_word判分
|
||||
double wps_word_score = judgementWpsWordService.judgementWpsWord(15.0, wps_file_list[0].getPath(), examQuestion);
|
||||
score += wps_word_score;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CommonResult.success(score);
|
||||
}
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ public class JudgementServiceImpl implements JudgementService
|
||||
LogFileUtils.createFile(pathC + "/log.txt");
|
||||
String code = JudgementCUtils.readFile(pathC, fileName);
|
||||
LogFileUtils.writeLine("✅ 系统开始读取文件:" + code);
|
||||
if (code == null) {
|
||||
if (code == "") {
|
||||
// 如果没有读到源码
|
||||
LogFileUtils.writeLine("❌ 系统没有读取到文件。");
|
||||
LogFileUtils.close();
|
||||
|
@@ -31,5 +31,5 @@ public interface JudgementWpsWordService {
|
||||
* @return 得分
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public BigDecimal judgementWpsWord(BigDecimal sorce, String path, ExamQuestion examQuestion) throws Exception;
|
||||
public double judgementWpsWord(double sorce, String path, ExamQuestion examQuestion) throws Exception;
|
||||
}
|
||||
|
@@ -51,8 +51,8 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal judgementWpsWord(BigDecimal sorce, String path, ExamQuestion examQuestion) throws Exception {
|
||||
BigDecimal wps_word_sorce = new BigDecimal(0);
|
||||
public double judgementWpsWord(double sorce, String path, ExamQuestion examQuestion) throws Exception {
|
||||
double wps_word_sorce = 0;
|
||||
// 1、查询Word考点tree
|
||||
WordListReqVO wordListReqVO = new WordListReqVO();
|
||||
wordListReqVO.setBelongTo(0);
|
||||
@@ -64,11 +64,21 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||
// 4、进行关联判断
|
||||
for (ExamQuestionAnswer examQuestionAnswer : answerList) {
|
||||
for (WordVO wordVO : margins1) {
|
||||
for (String str : wordVO.getExamKeynote()) {
|
||||
if (str.equals(examQuestionAnswer.getContent())) {
|
||||
// 得分 根据权重进行得分 每个选项分值 = 总分 / 总权重
|
||||
BigDecimal one_sorce = sorce.multiply(new BigDecimal(examQuestionAnswer.getScoreRate())).setScale(2, RoundingMode.HALF_UP);
|
||||
wps_word_sorce = wps_word_sorce.add(one_sorce);
|
||||
if (wordVO.getExamKeynote() != null) {
|
||||
for (String str : wordVO.getExamKeynote()) {
|
||||
int index = 0;
|
||||
if ((index+str).equals(examQuestionAnswer.getContent())) {
|
||||
double one_sorce = 0;
|
||||
// 得分 根据权重进行得分 每个选项分值 = 总分 / 总权重
|
||||
if (examQuestionAnswer.getScoreRate().equals("1")) {
|
||||
// 说明权重相等,直接平分分数
|
||||
one_sorce = sorce / answerList.size();
|
||||
} else {
|
||||
one_sorce = sorce * Double.parseDouble(examQuestionAnswer.getScoreRate());
|
||||
}
|
||||
wps_word_sorce += one_sorce;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package pc.exam.pp.module.judgement.utils;
|
||||
|
||||
|
||||
import pc.exam.pp.module.exam.utils.file.LogFileUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -67,7 +69,7 @@ public class JudgementCUtils
|
||||
public static String run_code(String code, String input, String standard, String text) {
|
||||
try {
|
||||
boolean hasInput = code.contains("scanf") || code.contains("fgets") || code.contains("getchar");
|
||||
|
||||
System.out.println(System.getenv("PATH"));
|
||||
// 写入 C 源码到文件
|
||||
File file = new File("program.c");
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
@@ -232,7 +234,7 @@ public class JudgementCUtils
|
||||
|
||||
// 判断路径是否存在
|
||||
if (!Files.exists(folderPath)) {
|
||||
// LogFileUtils.writeLine("❗ 文件夹路径不存在: " + folderPath.toString());
|
||||
LogFileUtils.writeLine("❗ 文件夹路径不存在: " + folderPath.toString());
|
||||
return null; // 或者 return null,或者 throw new RuntimeException(...),看你的函数定义
|
||||
}
|
||||
|
||||
@@ -241,9 +243,9 @@ public class JudgementCUtils
|
||||
|
||||
try (Stream<Path> paths = Files.walk(folderPath)) {
|
||||
paths.filter(Files::isRegularFile)
|
||||
.filter(path -> path.toString().toLowerCase().endsWith(fileName))
|
||||
.filter(path -> path.getFileName().toString().equalsIgnoreCase(fileName))
|
||||
.forEach(path -> {
|
||||
// LogFileUtils.writeLine("📄 文件: " + path);
|
||||
LogFileUtils.writeLine("📄 文件: " + path);
|
||||
try {
|
||||
List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
|
||||
for (String line : lines) {
|
||||
@@ -251,7 +253,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