result = educationPaperQus.stream().filter(strs -> Objects.equals(strs.getQuId(), examQuestion.getQuId())).findFirst();
+ if (!result.isEmpty()) {
+ examQuestion.setQuScores(educationPaperScheme.getQuScores());
+ examQuestion.setSort(result.get().getSort());
+ quList.add(examQuestion);
+ break;
+ }
}
}
}
@@ -246,6 +256,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{
stuPaperScoreDO.setStuId(stuId);
stuPaperScoreDO.setQuId(key);
stuPaperScoreDO.setPaperId(paperId);
+ stuPaperScoreDO.setSort(examQuestion.getSort());
isNull = true;
}
double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), key, value, stuPaperScoreDO, isNull);
@@ -259,6 +270,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{
stuPaperScoreDO.setStuId(stuId);
stuPaperScoreDO.setQuId(examQuestion.getQuId());
stuPaperScoreDO.setPaperId(paperId);
+ stuPaperScoreDO.setSort(examQuestion.getSort());
isNull = true;
}
// 说明学生没有答题,直接给零分
@@ -267,6 +279,26 @@ public class AutoToolsServiceImpl implements AutoToolsService{
}
}
}
+ } else {
+ // 如果结果是null的话,说明学生没有作答,直接全部0分
+ for (ExamQuestion examQuestion : quList) {
+ if ("选择题".equals(examQuestion.getSubjectName())) {
+ StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, examQuestion.getQuId());
+ // 判断是否做过该题
+ boolean isNull = false;
+ if (stuPaperScoreDO == null) {
+ stuPaperScoreDO = new StuPaperScoreDO();
+ stuPaperScoreDO.setStuId(stuId);
+ stuPaperScoreDO.setQuId(examQuestion.getQuId());
+ stuPaperScoreDO.setPaperId(paperId);
+ stuPaperScoreDO.setSort(examQuestion.getSort());
+ isNull = true;
+ }
+ // 说明学生没有答题,直接给零分
+ double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), examQuestion.getQuId(), "", stuPaperScoreDO, isNull);
+ score += selectScore;
+ }
+ }
}
// 1-1-4、删除文件
select_file.delete();
@@ -333,12 +365,15 @@ public class AutoToolsServiceImpl implements AutoToolsService{
stuPaperScoreDO.setStuId(stuId);
stuPaperScoreDO.setQuId(examQuestion.getQuId());
stuPaperScoreDO.setPaperId(paperId);
+ stuPaperScoreDO.setSort(result.get().getSort());
isNull = true;
}
if ("编程题".equals(one_file.getName().split("\\.")[0])) {
- SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), one_file.getPath(), file_one.getName(), examQuestion, judgementStr);
+ String judgementStr_C = "";
+ SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), one_file.getPath(), file_one.getName(), examQuestion, judgementStr_C);
double c_score = cpojo.getScore();
- judgementStr = cpojo.getText();
+ judgementStr += "-----------------------------------------------------------
";
+ judgementStr += cpojo.getText();
score += c_score;
stuPaperScoreDO.setScore(new BigDecimal(c_score));
// 原始正确分数
@@ -364,9 +399,11 @@ public class AutoToolsServiceImpl implements AutoToolsService{
}
// wps 类型存在多级文文件夹,需要个性化设置
if ("文字".equals(one_file.getName().split("\\.")[0])) {
- SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStr);
+ String judgementStrWord = "";
+ SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStrWord);
double wps_word_score = wordpojo.getScore();
- judgementStr = wordpojo.getText();
+ judgementStr += "-----------------------------------------------------------
";
+ judgementStr += wordpojo.getText();
score += wps_word_score;
stuPaperScoreDO.setScore(new BigDecimal(wps_word_score));
// 原始正确分数
@@ -391,9 +428,11 @@ public class AutoToolsServiceImpl implements AutoToolsService{
break;
}
if ("演示".equals(one_file.getName().split("\\.")[0])) {
- SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStr);
+ String judgementStrPptx = "";
+ SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStrPptx);
double wps_pptx_score = pptxpojo.getScore();
- judgementStr = pptxpojo.getText();
+ judgementStr += "-----------------------------------------------------------
";
+ judgementStr += pptxpojo.getText();
score += wps_pptx_score;
stuPaperScoreDO.setScore(new BigDecimal(wps_pptx_score));
// 原始正确分数
@@ -444,10 +483,12 @@ public class AutoToolsServiceImpl implements AutoToolsService{
// }
//windows文件处理
if ("文件处理".equals(one_file.getName().split("\\.")[0])) {
+ String judgementStrFile = "";
File win_file = new File(one_file.getPath());
- SourceAndText winfilepojo = fileServerice.run_file_point(Double.parseDouble(quScore),win_file, examQuestion, judgementStr);
+ SourceAndText winfilepojo = fileServerice.run_file_point(Double.parseDouble(quScore),win_file, examQuestion, judgementStrFile);
double win_file_score = winfilepojo.getScore();
- judgementStr = winfilepojo.getText();
+ judgementStr += "-----------------------------------------------------------
";
+ judgementStr += winfilepojo.getText();
score += win_file_score;
stuPaperScoreDO.setScore(new BigDecimal(win_file_score));
// 原始正确分数
@@ -474,11 +515,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
//浏览器操作
// if ("浏览器网络题".equals(examQuestion.getCourseName()+examQuestion.getSubjectName())){
if ("网络题".equals(one_file.getName().split("\\.")[0])) {
+ String judgementStrBrow = "";
System.out.println(one_file);
File edge_file = new File(one_file.getPath());
- SourceAndText browsepojo= browserServerice.Judgement(Double.parseDouble(quScore),edge_file,examQuestion, judgementStr);
+ SourceAndText browsepojo= browserServerice.Judgement(Double.parseDouble(quScore),edge_file,examQuestion, judgementStrBrow);
double browse_score = browsepojo.getScore();
- judgementStr = browsepojo.getText();
+ judgementStr += "-----------------------------------------------------------
";
+ judgementStr += browsepojo.getText();
score += browse_score;
stuPaperScoreDO.setScore(new BigDecimal(browse_score));
// 原始正确分数
@@ -503,35 +546,37 @@ public class AutoToolsServiceImpl implements AutoToolsService{
break;
}
- if ("程序设计".equals(one_file.getName().split("\\.")[0])) {
- System.out.println(one_file);
- File mysql_file = new File(one_file.getPath());
- SourceAndText judgementpojo = mysqlServerice.Judgement(Double.parseDouble(quScore),mysql_file, examQuestion, judgementStr);
- double judgement = judgementpojo.getScore();
- judgementStr = judgementpojo.getText();
- score+=judgement;
- stuPaperScoreDO.setScore(new BigDecimal(judgement));
- // 原始正确分数
- stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
- // 判断题是否正确
- if (judgement == Double.parseDouble(quScore)) {
- stuPaperScoreDO.setIsTrue(0);
- } else if (judgement == 0) {
- stuPaperScoreDO.setIsTrue(1);
- } else {
- stuPaperScoreDO.setIsTrue(2);
- }
- stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName());
- if (isNull) {
- // 如果之前没做过,则插入该题的分数
- stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
- } else {
- // 如果之前做过,则更新该题的分数
- stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
- }
- System.out.println(judgement+"mysql得分");
- break;
- }
+// if ("程序设计".equals(one_file.getName().split("\\.")[0])) {
+// String judgementStrMysql = "";
+// System.out.println(one_file);
+// File mysql_file = new File(one_file.getPath());
+// SourceAndText judgementpojo = mysqlServerice.Judgement(Double.parseDouble(quScore),mysql_file, examQuestion, judgementStrMysql);
+// double judgement = judgementpojo.getScore();
+// judgementStr += "-----------------------------------------------------------
";
+// judgementStr += judgementpojo.getText();
+// score+=judgement;
+// stuPaperScoreDO.setScore(new BigDecimal(judgement));
+// // 原始正确分数
+// stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
+// // 判断题是否正确
+// if (judgement == Double.parseDouble(quScore)) {
+// stuPaperScoreDO.setIsTrue(0);
+// } else if (judgement == 0) {
+// stuPaperScoreDO.setIsTrue(1);
+// } else {
+// stuPaperScoreDO.setIsTrue(2);
+// }
+// stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName());
+// if (isNull) {
+// // 如果之前没做过,则插入该题的分数
+// stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
+// } else {
+// // 如果之前做过,则更新该题的分数
+// stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
+// }
+// System.out.println(judgement+"mysql得分");
+// break;
+// }
}
}
}
@@ -544,9 +589,9 @@ public class AutoToolsServiceImpl implements AutoToolsService{
// 9、上传文件
MultipartFile file = new CustomMultipartFile(zipPath);
String path = null;
- if (noZipFileDO != null) {
- noZipFileDO.setContent(judgementStr);
- stuPaperFileService.updateStuPaperFile(noZipFileDO);
+ if (stuPaperFileDO != null) {
+ stuPaperFileDO.setContent(judgementStr);
+ stuPaperFileService.updateStuPaperFile(stuPaperFileDO);
}
fileService.createStuFile(stuId, paperId, file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()));
// 更新学生分数
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java
index b7270488..840031c5 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java
@@ -178,6 +178,7 @@ public class JudgementServiceImpl implements JudgementService
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 测试用例全部正确:"+ score);
LogFileUtils.close();
sourceAndText.setScore(score);
+ sourceAndText.setText(judgementStr);
return sourceAndText;
} else if (test_case_number > true_test_case_number) {
// 2、测试用例没有完全正确,对多少个就是多少分
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java
index a4850e7b..980567ae 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java
@@ -116,6 +116,8 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
wpsWordReqDto.setFunction(wordInfos[0]);
wpsWordReqDto.setIsExam("1");
wordReqDto.add(wpsWordReqDto);
+ System.out.println(examQuestionAnswer.getContentIn());
+ System.out.println(examQuestionAnswer.getContent());
List judgementDtos = WpsWordUtils.getWordInfo(wordReqDto);
boolean flag = false;
double one_sorce = 0;
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java
index da3bfa29..3fda9aad 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java
@@ -10,26 +10,26 @@ public class WpsPptxNameSpaces {
public static String getNameSpace(String xmlString) {
// 2、创建最全的命名空间
- Pattern pattern = Pattern.compile("xmlns:(\\w+)=\"([^\"]+)\"");
- Matcher matcher = pattern.matcher(xmlString);
- Map namespaces = new HashMap<>();
- while (matcher.find()) {
- // 如 w, wp, a
- String prefix = matcher.group(1);
- // 如 http://schemas.openxmlformats.org/...
- String uri = matcher.group(2);
- namespaces.put(prefix, uri);
- }
- StringBuilder xpathBuilder = new StringBuilder();
- namespaces.forEach((prefix, uri) ->
- xpathBuilder.append("declare namespace ")
- .append(prefix)
- .append("='")
- .append(uri)
- .append("' ")
- );
- // 2-1、获取出来最全的命名空间
- String allPathx = xpathBuilder.toString();
- return allPathx;
+// Pattern pattern = Pattern.compile("xmlns:(\\w+)='([^']+)'");
+// Matcher matcher = pattern.matcher(xmlString);
+// Map namespaces = new HashMap<>();
+// while (matcher.find()) {
+// // 如 w, wp, a
+// String prefix = matcher.group(1);
+// // 如 http://schemas.openxmlformats.org/...
+// String uri = matcher.group(2);
+// namespaces.put(prefix, uri);
+// }
+// StringBuilder xpathBuilder = new StringBuilder();
+// namespaces.forEach((prefix, uri) ->
+// xpathBuilder.append("declare namespace ")
+// .append(prefix)
+// .append("='")
+// .append(uri)
+// .append("' ")
+// );
+// // 2-1、获取出来最全的命名空间
+// String allPathx = xpathBuilder.toString();
+ return "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' declare namespace pic='http://schemas.openxmlformats.org/drawingml/2006/picture' declare namespace c='http://schemas.openxmlformats.org/drawingml/2006/chart' declare namespace dgm='http://schemas.openxmlformats.org/drawingml/2006/diagram' declare namespace lc='http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas' declare namespace v='urn:schemas-microsoft-com:vml' declare namespace o='urn:schemas-microsoft-com:office:office' declare namespace m='http://schemas.openxmlformats.org/officeDocument/2006/math' declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' declare namespace a15='http://schemas.microsoft.com/office/drawing/2012/main' declare namespace a16='http://schemas.microsoft.com/office/drawing/2014/main' declare namespace c14='http://schemas.microsoft.com/office/drawing/2007/8/chart' declare namespace p14='http://schemas.microsoft.com/office/powerpoint/2010/main' declare namespace p15='http://schemas.microsoft.com/office/powerpoint/2012/main' declare namespace p16='http://schemas.microsoft.com/office/powerpoint/2015/main' declare namespace pvml='urn:schemas-microsoft-com:office:powerpoint' declare namespace svg='http://schemas.microsoft.com/office/drawing/2016/SVG/main' declare namespace am3d='http://schemas.microsoft.com/office/drawing/2017/model3D' ";
}
}
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java
index 9a9fda95..42643cb2 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java
@@ -271,6 +271,8 @@ public class WpsPptxUtils {
}
}
+ } catch (IOException e) {
+ e.printStackTrace();
} catch (XmlException e) {
throw new RuntimeException(e);
}
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java
index 9f9dc6ae..19e65c37 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java
@@ -10,26 +10,26 @@ public class WpsWordNameSpaces {
public static String getNameSpace(String xmlString) {
// 2、创建最全的命名空间
- Pattern pattern = Pattern.compile("xmlns:(\\w+)=\"([^\"]+)\"");
- Matcher matcher = pattern.matcher(xmlString);
- Map namespaces = new HashMap<>();
- while (matcher.find()) {
- // 如 w, wp, a
- String prefix = matcher.group(1);
- // 如 http://schemas.openxmlformats.org/...
- String uri = matcher.group(2);
- namespaces.put(prefix, uri);
- }
- StringBuilder xpathBuilder = new StringBuilder();
- namespaces.forEach((prefix, uri) ->
- xpathBuilder.append("declare namespace ")
- .append(prefix)
- .append("='")
- .append(uri)
- .append("' ")
- );
- // 2-1、获取出来最全的命名空间
- String allPathx = xpathBuilder.toString();
- return allPathx;
+// Pattern pattern = Pattern.compile("xmlns:(\\w+)='([^']+)'");
+// Matcher matcher = pattern.matcher(xmlString);
+// Map namespaces = new HashMap<>();
+// while (matcher.find()) {
+// // 如 w, wp, a
+// String prefix = matcher.group(1);
+// // 如 http://schemas.openxmlformats.org/...
+// String uri = matcher.group(2);
+// namespaces.put(prefix, uri);
+// }
+// StringBuilder xpathBuilder = new StringBuilder();
+// namespaces.forEach((prefix, uri) ->
+// xpathBuilder.append("declare namespace ")
+// .append(prefix)
+// .append("='")
+// .append(uri)
+// .append("' ")
+// );
+// // 2-1、获取出来最全的命名空间
+// String allPathx = xpathBuilder.toString();
+ return "declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' declare namespace pic='http://schemas.openxmlformats.org/drawingml/2006/picture' declare namespace wp='http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing' declare namespace wp14='http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing' declare namespace w14='http://schemas.microsoft.com/office/word/2010/wordml' declare namespace w15='http://schemas.microsoft.com/office/word/2012/wordml' declare namespace w16='http://schemas.microsoft.com/office/word/2018/wordml' declare namespace w16cid='http://schemas.microsoft.com/office/word/2016/wordml/cid' declare namespace v='urn:schemas-microsoft-com:vml' declare namespace o='urn:schemas-microsoft-com:office:office' declare namespace m='http://schemas.openxmlformats.org/officeDocument/2006/math' declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' declare namespace wpg='http://schemas.microsoft.com/office/word/2010/wordprocessingGroup' declare namespace wpi='http://schemas.microsoft.com/office/word/2010/wordprocessingInk' declare namespace wps='http://schemas.microsoft.com/office/word/2010/wordprocessingShape' declare namespace c='http://schemas.openxmlformats.org/drawingml/2006/chart' declare namespace cx='http://schemas.microsoft.com/office/drawing/2014/chart' declare namespace dgm='http://schemas.openxmlformats.org/drawingml/2006/diagram' declare namespace lc='http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas' declare namespace svg='http://schemas.microsoft.com/office/drawing/2016/SVG/main' declare namespace aink='http://schemas.microsoft.com/office/drawing/2016/ink' declare namespace am3d='http://schemas.microsoft.com/office/drawing/2017/model3D' declare namespace wne='http://schemas.microsoft.com/office/word/2006/wordml' ";
}
}
diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java
index 80a93056..df79bdd5 100644
--- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java
+++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java
@@ -1,5 +1,8 @@
package pc.exam.pp.module.judgement.utils.wps_word;
+import org.apache.commons.io.IOUtils;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
@@ -14,6 +17,9 @@ import pc.exam.pp.module.judgement.utils.zipfile.ZipXmlUtils;
import javax.xml.namespace.QName;
import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -46,27 +52,28 @@ public class WpsWordUtils {
// 创建文件路径数组
List