|
|
|
@ -4,10 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.ReUtil;
|
|
|
|
|
import cn.hutool.core.util.*;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
@ -582,6 +580,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
/**
|
|
|
|
|
* 跟题目相关的题目日志提交方法
|
|
|
|
|
* 附件类型的需要单独,拆分除去
|
|
|
|
|
* 提交试卷 试卷提交
|
|
|
|
|
*
|
|
|
|
|
* @param questionLogAddDTO 题目信息
|
|
|
|
|
* @param questionSetting 题目配置信息
|
|
|
|
@ -612,8 +611,14 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList());
|
|
|
|
|
Assert.notEmpty(logList, "未查询到题目信息!");
|
|
|
|
|
|
|
|
|
|
// 题目日志IDs汇总
|
|
|
|
|
String logsIds = logList.stream().map(item -> item.getGeneralQuestionLogId().toString()).collect(joining(","));
|
|
|
|
|
|
|
|
|
|
// 当前时间, 存储要更新的题目日志集合
|
|
|
|
|
Date now = new Date(); List<GeneralQuestionLog> updateList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 代表填空题和分析题的类型
|
|
|
|
|
List<Integer> questionType = Arrays.asList(4, 5);
|
|
|
|
|
// 处理答案和分数
|
|
|
|
|
logList.forEach(questionLog -> {
|
|
|
|
|
// 验证最新的提交时间,防止网络延迟
|
|
|
|
@ -623,16 +628,54 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
// 验证提交类型
|
|
|
|
|
validateQuestionLogAddTypeThrow(questionLog.getQuestionLogAddType(), questionLogAddDTO.getQuestionLogAddType());
|
|
|
|
|
// 学生提交的答案
|
|
|
|
|
String answersText = join(questionLogMap.get(questionLog.getGeneralResourcesQuestionSnapshotId().toString()).split(","), ",");
|
|
|
|
|
String answer = questionLogMap.get(questionLog.getGeneralQuestionLogId().toString());
|
|
|
|
|
|
|
|
|
|
// 默认0分
|
|
|
|
|
questionLog.setStudentScore(BigDecimal.valueOf(0));
|
|
|
|
|
|
|
|
|
|
// 学生提交的答案处理
|
|
|
|
|
String answersText = null;
|
|
|
|
|
if (questionType.contains(questionLog.getQuestionType())) {
|
|
|
|
|
|
|
|
|
|
answersText = answer;
|
|
|
|
|
|
|
|
|
|
// 学生答案和正确答案集合
|
|
|
|
|
cn.hutool.json.JSONObject studentAnswerArr = JSONUtil.parseObj(answersText);
|
|
|
|
|
cn.hutool.json.JSONObject questionAnswerArr = JSONUtil.parseObj(questionLog.getQuestionAnswer());
|
|
|
|
|
// 每题分数
|
|
|
|
|
BigDecimal eachScore = NumberUtil.div(questionLog.getQuestionScore(), questionAnswerArr.size(), 1);
|
|
|
|
|
|
|
|
|
|
BigDecimal studentScore = new BigDecimal("0");
|
|
|
|
|
for (Map.Entry<String, Object> map : questionAnswerArr.entrySet()) {
|
|
|
|
|
Object questionAns = map.getValue();
|
|
|
|
|
String k = map.getKey();
|
|
|
|
|
String studentAns = studentAnswerArr.getStr(k, "");
|
|
|
|
|
|
|
|
|
|
// 比对答案
|
|
|
|
|
if (studentAns.equalsIgnoreCase(questionAns.toString()) && StrUtil.isAllNotBlank(questionAns.toString(), studentAns)) {
|
|
|
|
|
studentScore.add(eachScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 填空题和分析题计算分数
|
|
|
|
|
// 计算该题目学生的得分情况
|
|
|
|
|
questionLog.setStudentScore(studentScore);
|
|
|
|
|
// 是否是错题
|
|
|
|
|
questionLog.setIsErrorFavorite(NumberUtil.isLess(studentScore, questionLog.getQuestionScore()));
|
|
|
|
|
}else {
|
|
|
|
|
answersText = join(answer.split(","), ",");
|
|
|
|
|
// 是否是正确答案
|
|
|
|
|
Boolean isCorrectAnswer = questionLog.getQuestionAnswer().equalsIgnoreCase(answersText);
|
|
|
|
|
|
|
|
|
|
// 学生得分
|
|
|
|
|
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : ZERO);
|
|
|
|
|
questionLog.setIsErrorFavorite(!isCorrectAnswer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 完成时间
|
|
|
|
|
long finishSecondTime = DateUtil.between(questionLog.getGeneralQuestionLogAddTime(), now, SECOND);
|
|
|
|
|
|
|
|
|
|
// 填充属性
|
|
|
|
|
// 计算该题目学生的得分情况
|
|
|
|
|
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : BigDecimal.valueOf(0));
|
|
|
|
|
questionLog.setIsErrorFavorite(isCorrectAnswer);
|
|
|
|
|
questionLog.setGeneralQuestionLogUpdateTime(now);
|
|
|
|
|
questionLog.setGeneralQuestionLogFinishTime(finishSecondTime);
|
|
|
|
|
questionLog.setGeneralQuestionLogAnswer(answersText);
|
|
|
|
@ -653,7 +696,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
// 学生做的题目的答案与日志关联
|
|
|
|
|
updateBatchTemplate(updateList);
|
|
|
|
|
// 添加到题目日志汇总中
|
|
|
|
|
addQuestionLogSummary(updateList, student,
|
|
|
|
|
addQuestionLogSummary(logsIds, updateList, student,
|
|
|
|
|
questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -738,6 +781,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
* 功能描述: <br>
|
|
|
|
|
* 题目日志信息,分析汇总到某张表里
|
|
|
|
|
*
|
|
|
|
|
* @param logsIds 题目日志IDs保存
|
|
|
|
|
* @param logList 某个questionSettingId对应的题目日志列表
|
|
|
|
|
* @param student 学生
|
|
|
|
|
* @param questionSettingName 题目配置的名称(试卷名称)
|
|
|
|
@ -747,7 +791,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
* @Date: 2022/12/4 20:16
|
|
|
|
|
*/
|
|
|
|
|
public void addQuestionLogSummary(
|
|
|
|
|
@NotEmpty(message = "学生题目日志不能为空!") List<GeneralQuestionLog> logList,
|
|
|
|
|
String logsIds, @NotEmpty(message = "学生题目日志不能为空!") List<GeneralQuestionLog> logList,
|
|
|
|
|
@NotNull Student student, @NotBlank String questionSettingName, @NotNull QuestionBusinessTypeEnum fromType,
|
|
|
|
|
@NotNull ResourcesQuestionSnapshotFromTypeEnum snapshotFromTypeEnum) {
|
|
|
|
|
// 构建实体
|
|
|
|
@ -790,7 +834,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
questionLogSummary.setQuestionSettingTotalScore(questionTotalScore);
|
|
|
|
|
questionLogSummary.setQuestionLogSummaryStudentTotalScore(myTotalScore);
|
|
|
|
|
questionLogSummary.setPersonId(student.getStudentId());
|
|
|
|
|
questionLogSummary.setQuestionLogIds(join(idsSet.toArray(), ","));
|
|
|
|
|
questionLogSummary.setQuestionLogIds(logsIds);
|
|
|
|
|
questionLogSummary.setQuestionLogSummaryQuestionTotalCount(questionTotalCount);
|
|
|
|
|
questionLogSummary.setQuestionLogSummaryStudentDoCount(sumDoCount);
|
|
|
|
|
questionLogSummary.setQuestionLogSummarySuccessCount(sumSuccessCount);
|
|
|
|
@ -850,7 +894,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
// 不是强制发题,则不覆盖现有的题目日志,则继续做题
|
|
|
|
|
// 验证题目日志,是否已经存在试卷
|
|
|
|
|
if(!isReSend) {
|
|
|
|
|
long logCount = generalQuestionLogDao.getCountByQuestionLogAddType(questionSettingId, studentId, PRE_SUBMIT.name(), null);
|
|
|
|
|
long logCount = generalQuestionLogDao.getNotSubmitQuestionLogsCount(studentId, questionSettingId);
|
|
|
|
|
|
|
|
|
|
// 如果题目日志里存在预先布置的题目,则直接返回
|
|
|
|
|
if (logCount > 0) {
|
|
|
|
@ -884,6 +928,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
insertBatch(generalQuestionLogs);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|