|
|
|
@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.MultiValueMapAdapter;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
@ -703,7 +704,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
// 学生做的题目的答案与日志关联
|
|
|
|
|
updateBatchTemplate(updateList);
|
|
|
|
|
// 添加到题目日志汇总中
|
|
|
|
|
addQuestionLogSummary(student, questionSetting.getGeneralQuestionSettingId());
|
|
|
|
|
addQuestionLogSummary(student, questionSetting.getGeneralQuestionSettingId(), updateList);
|
|
|
|
|
// 最终提交以后,将日志更改为2 删除状态,仅用于查看
|
|
|
|
|
deleteGeneralQuestionLog(listJoin(updateList, GeneralQuestionLog::getGeneralQuestionLogId));
|
|
|
|
|
}
|
|
|
|
@ -734,13 +735,16 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
// 一条日志记录,属于一道题
|
|
|
|
|
if (oneQuestion) {
|
|
|
|
|
boolean isTrue = allNotEmpty && studentAnswer.equalsIgnoreCase(questionAnswer);
|
|
|
|
|
// 正确题目的数量
|
|
|
|
|
Integer isTrueInteger = BooleanUtil.toInteger(isTrue);
|
|
|
|
|
final BigDecimal mySimpleScore = isTrue ? questionScore: ZERO;
|
|
|
|
|
// 计算学生最后的得分
|
|
|
|
|
questionLog.setStudentScore(mySimpleScore);
|
|
|
|
|
questionLog.setSuccessCount(isTrueInteger);
|
|
|
|
|
questionLog.setErrorCount(1 - isTrueInteger);
|
|
|
|
|
|
|
|
|
|
if (isTrue) {
|
|
|
|
|
questionLog.setSuccessCount(1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
questionLog.setErrorCount(1);
|
|
|
|
|
}
|
|
|
|
|
// 错题标记
|
|
|
|
|
questionLog.setIsErrorFavorite(!isTrue);
|
|
|
|
|
}
|
|
|
|
@ -791,7 +795,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
* @param student
|
|
|
|
|
* @param questionSettingId
|
|
|
|
|
*/
|
|
|
|
|
private void addQuestionLogSummary(Student student, Long questionSettingId) {
|
|
|
|
|
private void addQuestionLogSummary(Student student, Long questionSettingId, List<GeneralQuestionLog> updateList) {
|
|
|
|
|
if (student == null || questionSettingId == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -799,12 +803,34 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
|
|
|
|
|
List<GeneralQuestionLog> logList = getValuesBySettingIds(questionSettingId.toString());
|
|
|
|
|
GeneralQuestionSetting questionSetting = generalQuestionSettingService.getInfo(questionSettingId);
|
|
|
|
|
|
|
|
|
|
setErrorSuccessCountField(updateList, logList);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(logList) && questionSetting != null) {
|
|
|
|
|
String logIds = logList.stream().map(GeneralQuestionLog::getGeneralQuestionLogId).map(Objects::toString).collect(joining(","));
|
|
|
|
|
addQuestionLogSummary(logIds, logList, student, questionSetting.getGeneralQuestionSettingName(), questionSetting.getBusinessType(), questionSetting.getGeneralQuestionSettingType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拷贝正确错误的字段
|
|
|
|
|
*
|
|
|
|
|
* @param updateList
|
|
|
|
|
* @param logList
|
|
|
|
|
*/
|
|
|
|
|
private void setErrorSuccessCountField(List<GeneralQuestionLog> updateList, List<GeneralQuestionLog> logList) {
|
|
|
|
|
Map<Long, List<GeneralQuestionLog>> listMap = updateList.stream()
|
|
|
|
|
.collect(groupingBy(GeneralQuestionLog::getGeneralQuestionLogId));
|
|
|
|
|
MultiValueMapAdapter<Long, GeneralQuestionLog> mapAdapter = new MultiValueMapAdapter<>(listMap);
|
|
|
|
|
|
|
|
|
|
logList.forEach(item -> {
|
|
|
|
|
GeneralQuestionLog first = mapAdapter.getFirst(item.getGeneralQuestionLogId());
|
|
|
|
|
if (first != null) {
|
|
|
|
|
item.setErrorCount(first.getErrorCount());
|
|
|
|
|
item.setSuccessCount(first.getSuccessCount());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<GeneralQuestionLog> getValuesBySettingIds(String settingIds) {
|
|
|
|
|
GeneralQuestionLogQuery logQuery = new GeneralQuestionLogQuery();
|
|
|
|
|
logQuery.setGeneralQuestionSettingIdPlural(settingIds);
|
|
|
|
|