【新增】 当没有做选择题得时候,也进行累计,更新试题分数
This commit is contained in:
@@ -12,9 +12,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSchemeMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.student.StuPaperScoreMapper;
|
||||
import pc.exam.pp.module.exam.service.question.IExamQuestionService;
|
||||
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
|
||||
@@ -33,6 +38,7 @@ import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
||||
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||
import pc.exam.pp.module.judgement.utils.JudgementCUtils;
|
||||
import pc.exam.pp.module.judgement.utils.multipartFile.CustomMultipartFile;
|
||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxSlidesVo;
|
||||
import pc.exam.pp.module.judgement.utils.zipfile.FolderZipper;
|
||||
|
||||
import java.io.*;
|
||||
@@ -42,9 +48,7 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
@@ -78,6 +82,14 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
private JudgementWpsExcelService judgementWpsExcelService;
|
||||
@Autowired
|
||||
private EndStuMonitorUtils endStuMonitorUtils;
|
||||
@Resource
|
||||
EducationPaperQuMapper educationPaperQuMapper;
|
||||
@Resource
|
||||
ExamQuestionMapper examQuestionMapper;
|
||||
@Resource
|
||||
EducationPaperSchemeMapper educationPaperSchemeMapper;
|
||||
@Resource
|
||||
EducationPaperMapper educationPaperMapper;
|
||||
@Override
|
||||
public String downloadStudentFile(String fileUrl, String filePath) {
|
||||
try {
|
||||
@@ -185,6 +197,20 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
stuPaperFileDO = stuPaperFileDOs;
|
||||
}
|
||||
}
|
||||
List<ExamQuestion> quList = new ArrayList<>();
|
||||
List<String> quIds = educationPaperQuMapper.selectPaperQuByPaperId(paperId);
|
||||
List<ExamQuestion> examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds);
|
||||
List<EducationPaperScheme> educationPaperSchemeList = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(educationPaperMapper.selectTaskIdByPaperId(paperId));
|
||||
// 筛选出非选择题和选择题
|
||||
for (ExamQuestion examQuestion : examQuestionList) {
|
||||
for (EducationPaperScheme educationPaperScheme : educationPaperSchemeList) {
|
||||
if (examQuestion.getSubjectName().equals(educationPaperScheme.getSpName())) {
|
||||
examQuestion.setQuScores(educationPaperScheme.getQuScores());
|
||||
quList.add(examQuestion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断选择题文件是否存在
|
||||
if (noZipFileDO != null) {
|
||||
// 1-1、 穿插选择题判分
|
||||
@@ -196,21 +222,33 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
Stu stu = stringToJson(select_string);
|
||||
if(stu!=null){
|
||||
// 1-1-3、进行选择题判分
|
||||
for (String key : stu.getQuestionResultMap().keySet()) {
|
||||
// 查询该题的成绩
|
||||
StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, key);
|
||||
// 判断是否做过该题
|
||||
boolean isNull = false;
|
||||
if (stuPaperScoreDO == null) {
|
||||
stuPaperScoreDO = new StuPaperScoreDO();
|
||||
stuPaperScoreDO.setStuId(stuId);
|
||||
stuPaperScoreDO.setQuId(key);
|
||||
stuPaperScoreDO.setPaperId(paperId);
|
||||
isNull = true;
|
||||
for (ExamQuestion examQuestion : quList) {
|
||||
if ("选择题".equals(examQuestion.getSubjectName())) {
|
||||
for (String key : stu.getQuestionResultMap().keySet()) {
|
||||
Optional<ExamQuestion> result = quList.stream().filter(quLists -> quLists.getQuId().equals(key)).findFirst();
|
||||
ExamQuestion examQuestions = result.get();
|
||||
// 查询该题的成绩
|
||||
StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, key);
|
||||
// 判断是否做过该题
|
||||
boolean isNull = false;
|
||||
if (stuPaperScoreDO == null) {
|
||||
stuPaperScoreDO = new StuPaperScoreDO();
|
||||
stuPaperScoreDO.setStuId(stuId);
|
||||
stuPaperScoreDO.setQuId(key);
|
||||
stuPaperScoreDO.setPaperId(paperId);
|
||||
isNull = true;
|
||||
}
|
||||
if (examQuestions != null) {
|
||||
String value = stu.getQuestionResultMap().get(key);
|
||||
double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), key, value, stuPaperScoreDO, isNull);
|
||||
score += selectScore;
|
||||
} else {
|
||||
// 说明学生没有答题,直接给零分
|
||||
double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), key, "", stuPaperScoreDO, isNull);
|
||||
score += selectScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
String value = stu.getQuestionResultMap().get(key);
|
||||
double selectScore = judgementChoiceService.programmingChoice(2.0, key, value, stuPaperScoreDO, isNull);
|
||||
score += selectScore;
|
||||
}
|
||||
}
|
||||
// 1-1-4、删除文件
|
||||
@@ -257,6 +295,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
for (File one_file : cs_file_list) {
|
||||
// 6、根据试题ID查询试题详情
|
||||
String qu_id = file.getName();
|
||||
Optional<ExamQuestion> result = quList.stream().filter(quLists -> quLists.getQuId().equals(qu_id)).findFirst();
|
||||
String quScore = result.get().getQuScores();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(qu_id);
|
||||
if (examQuestion != null) {
|
||||
// 7、进行对应得判分
|
||||
@@ -279,13 +319,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
isNull = true;
|
||||
}
|
||||
if ("编程题".equals(one_file.getName().split("\\.")[0])) {
|
||||
double c_score = judgementService.ProgrammingC(15.0, one_file.getPath(), file_one.getName(), examQuestion);
|
||||
double c_score = judgementService.ProgrammingC(Double.parseDouble(quScore), one_file.getPath(), file_one.getName(), examQuestion);
|
||||
score += c_score;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(c_score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (c_score == 15.0) {
|
||||
if (c_score == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (c_score == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -305,13 +345,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
}
|
||||
// wps 类型存在多级文文件夹,需要个性化设置
|
||||
if ("文字".equals(one_file.getName().split("\\.")[0])) {
|
||||
double wps_word_score = judgementWpsWordService.judgementWpsWord(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
double wps_word_score = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
score += wps_word_score;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(wps_word_score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (wps_word_score == 15.0) {
|
||||
if (wps_word_score == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (wps_word_score == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -330,13 +370,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
break;
|
||||
}
|
||||
if ("演示".equals(one_file.getName().split("\\.")[0])) {
|
||||
double wps_pptx_score = judgementWpsPptxService.judgementWpsPptx(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
double wps_pptx_score = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
score += wps_pptx_score;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(wps_pptx_score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (wps_pptx_score == 15.0) {
|
||||
if (wps_pptx_score == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (wps_pptx_score == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -355,13 +395,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
break;
|
||||
}
|
||||
// if ("表格".equals(one_file.getName().split("\\.")[0])) {
|
||||
// double wps_excel_score = judgementWpsExcelService.judgementWpsXlsx(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
// double wps_excel_score = judgementWpsExcelService.judgementWpsXlsx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion);
|
||||
// score += wps_excel_score;
|
||||
// stuPaperScoreDO.setScore(new BigDecimal(wps_excel_score));
|
||||
// // 原始正确分数
|
||||
// stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
// stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// // 判断题是否正确
|
||||
// if (wps_excel_score == 15.0) {
|
||||
// if (wps_excel_score == Double.parseDouble(quScore)) {
|
||||
// stuPaperScoreDO.setIsTrue(0);
|
||||
// } else if (wps_excel_score == 0) {
|
||||
// stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -382,13 +422,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
//windows文件处理
|
||||
if ("文件处理".equals(one_file.getName().split("\\.")[0])) {
|
||||
File win_file = new File(one_file.getPath());
|
||||
double win_file_score = fileServerice.run_file_point(20.0,win_file, examQuestion);
|
||||
double win_file_score = fileServerice.run_file_point(Double.parseDouble(quScore),win_file, examQuestion);
|
||||
score += win_file_score;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(win_file_score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (win_file_score == 20.0) {
|
||||
if (win_file_score == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (win_file_score == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -411,13 +451,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
if ("网络题".equals(one_file.getName().split("\\.")[0])) {
|
||||
System.out.println(one_file);
|
||||
File edge_file = new File(one_file.getPath());
|
||||
double browse_score= browserServerice.Judgement(20.0,edge_file,examQuestion);
|
||||
double browse_score= browserServerice.Judgement(Double.parseDouble(quScore),edge_file,examQuestion);
|
||||
score += browse_score;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(browse_score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (browse_score == 20.0) {
|
||||
if (browse_score == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (browse_score == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
@@ -439,13 +479,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
if ("程序设计".equals(one_file.getName().split("\\.")[0])) {
|
||||
System.out.println(one_file);
|
||||
File mysql_file = new File(one_file.getPath());
|
||||
double judgement = mysqlServerice.Judgement(20.0,mysql_file, examQuestion);
|
||||
double judgement = mysqlServerice.Judgement(Double.parseDouble(quScore),mysql_file, examQuestion);
|
||||
score+=judgement;
|
||||
stuPaperScoreDO.setScore(new BigDecimal(judgement));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal("15.0"));
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
|
||||
// 判断题是否正确
|
||||
if (judgement == 20.0) {
|
||||
if (judgement == Double.parseDouble(quScore)) {
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
} else if (judgement == 0) {
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
|
@@ -36,30 +36,47 @@ public class JudgementChoiceServiceImpl implements JudgementChoiceService
|
||||
public double programmingChoice(double score, String quId, String answerId, StuPaperScoreDO stuPaperScoreDO, boolean isNull) {
|
||||
ExamQuestionAnswer answer = new ExamQuestionAnswer();
|
||||
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId);
|
||||
// 获取选择题的标准答案
|
||||
// 找到对应正确题的答案ID
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestion.getAnswerList()) {
|
||||
// 判断正确答案
|
||||
if ("0".equals(examQuestionAnswer.getIsRight())) {
|
||||
answer = examQuestionAnswer;
|
||||
break;
|
||||
if (!answerId.isEmpty()) {
|
||||
// 获取选择题的标准答案
|
||||
// 找到对应正确题的答案ID
|
||||
for (ExamQuestionAnswer examQuestionAnswer : examQuestion.getAnswerList()) {
|
||||
// 判断正确答案
|
||||
if ("0".equals(examQuestionAnswer.getIsRight())) {
|
||||
answer = examQuestionAnswer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (answer.getAnswerId().equals(answerId)) {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreDO.setScore(new BigDecimal(score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(score));
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName());
|
||||
if (isNull) {
|
||||
// 如果之前没做过,则插入该题的分数
|
||||
stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
|
||||
if (answer.getAnswerId().equals(answerId)) {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreDO.setScore(new BigDecimal(score));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(score));
|
||||
stuPaperScoreDO.setIsTrue(0);
|
||||
stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName());
|
||||
if (isNull) {
|
||||
// 如果之前没做过,则插入该题的分数
|
||||
stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
|
||||
} else {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
|
||||
}
|
||||
return score;
|
||||
} else {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
|
||||
stuPaperScoreDO.setScore(new BigDecimal(0));
|
||||
// 原始正确分数
|
||||
stuPaperScoreDO.setTrueScore(new BigDecimal(score));
|
||||
stuPaperScoreDO.setIsTrue(1);
|
||||
stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName());
|
||||
if (isNull) {
|
||||
// 如果之前没做过,则插入该题的分数
|
||||
stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
|
||||
} else {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return score;
|
||||
} else {
|
||||
// 如果之前做过,则更新该题的分数
|
||||
stuPaperScoreDO.setScore(new BigDecimal(0));
|
||||
|
Reference in New Issue
Block a user