做题分数,统计异常修复

beetlsql3-dev
Mlxa0324 2 years ago
parent 42c560132c
commit c5fa0215c4

@ -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);

@ -461,8 +461,8 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
Assert.notNull(student, "该接口只能学生访问");
Long studentId = student.getStudentId();
teacherOpenCourseQuestionSettingService
.validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// teacherOpenCourseQuestionSettingService
// .validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// 给实体类传参数剩下来的交给Fetch 来处理
// 查询符合条件的实体
@ -490,8 +490,8 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
Assert.notNull(student, "该接口只能学生访问");
Long studentId = student.getStudentId();
teacherOpenCourseQuestionSettingService
.validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// teacherOpenCourseQuestionSettingService
// .validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// 给实体类传参数剩下来的交给Fetch 来处理
// 查询符合条件的实体

@ -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;
@ -339,7 +340,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
Student student = studentDao.getById(studentId);
if (ObjectUtil.isAllNotEmpty(student, questionLog)) {
addQuestionLogSummary(student, questionLog.getTeacherOpenCourseQuestionSettingId());
addQuestionLogSummary(student, questionLog.getTeacherOpenCourseQuestionSettingId(), updateList);
}
});
}
@ -556,7 +557,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
calculateScoreOnSubmit(updateList);
updateBatchTemplate(updateList);
// 添加到题目日志汇总中
addQuestionLogSummary(student, questionSettingId);
addQuestionLogSummary(student, questionSettingId, updateList);
// 批量插入错题集错题库方法内部自带分数判断。内部方法更新log中的错题标记。
teacherOpenCourseQuestionLogWrongService.insertBatchByQuestionLogList(updateList);
@ -650,15 +651,20 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
/**
*
*
* @param student
* @param questionSettingId
* @param updateList
*/
private void addQuestionLogSummary(Student student, Long questionSettingId) {
private void addQuestionLogSummary(Student student, Long questionSettingId, List<TeacherOpenCourseQuestionLog> updateList) {
if (student == null || questionSettingId == null) {
return;
}
List<TeacherOpenCourseQuestionLog> logList = getValuesBySettingIds(questionSettingId.toString());
setErrorSuccessCountField(updateList, logList);
TeacherOpenCourseQuestionSetting questionSetting = teacherOpenCourseQuestionSettingService.getInfo(questionSettingId);
if (CollectionUtil.isNotEmpty(logList) && questionSetting != null) {
@ -667,6 +673,26 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
}
}
/**
*
*
* @param updateList
* @param logList
*/
private void setErrorSuccessCountField(List<TeacherOpenCourseQuestionLog> updateList, List<TeacherOpenCourseQuestionLog> logList) {
Map<Long, List<TeacherOpenCourseQuestionLog>> listMap = updateList.stream()
.collect(groupingBy(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionLogId));
MultiValueMapAdapter<Long, TeacherOpenCourseQuestionLog> mapAdapter = new MultiValueMapAdapter<>(listMap);
logList.forEach(item -> {
TeacherOpenCourseQuestionLog first = mapAdapter.getFirst(item.getTeacherOpenCourseQuestionLogId());
if (first != null) {
item.setErrorCount(first.getErrorCount());
item.setSuccessCount(first.getSuccessCount());
}
});
}
/**
* : <br>
*

@ -115,6 +115,7 @@ public class TeacherOpenCourseQuestionSettingController{
/**
* --
*
*
*
* @param teacherOpenCourseQuestionSettingId ID
* @param fromTypeEnum

Loading…
Cancel
Save