luoweijian 6 days ago
parent
commit
aa64ea08e8
  1. 17
      src/main/java/com/project/exam/domain/service/impl/BuildExamRecordDomainServiceImpl.java

17
src/main/java/com/project/exam/domain/service/impl/BuildExamRecordDomainServiceImpl.java

@ -36,15 +36,7 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
if (Objects.nonNull(dto.getTaskDTO())) {
dto.getAnswerSnapshotDTOList().forEach(answerSnapshotDTO -> {
// 拥有admin权限且请求头有特殊标识才在此接口返回答案和解析
boolean isDebugMode = SecurityUtils.hasRole(UserRoleEnum.ROLE_ADMIN.name())
&& StrUtil.equals(X_DEBUG_MODE_VALUE , ServletUtils.getHeader(X_DEBUG_MODE_HEADER));
boolean isSubmitted = Objects.nonNull(dto.getSubmitTime());
boolean canShowDetails = isDebugMode || isSubmitted;
if (!canShowDetails) {
answerSnapshotDTO.setRightAnswer(null);
answerSnapshotDTO.setAnalysis(null);
}
if (QuestionTypeEnum.SINGLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())) {
answerSnapshotDTO.setScore(dto.getTaskDTO().getSingleChoiceScore());
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
@ -65,6 +57,15 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
}
AtomicInteger index = new AtomicInteger(0);
dto.getAnswerSnapshotDTOList().forEach(answerSnapshotDTO -> {
boolean isDebugMode = SecurityUtils.hasRole(UserRoleEnum.ROLE_ADMIN.name())
&& StrUtil.equals(X_DEBUG_MODE_VALUE , ServletUtils.getHeader(X_DEBUG_MODE_HEADER));
boolean isSubmitted = Objects.nonNull(dto.getSubmitTime());
boolean canShowDetails = isDebugMode || isSubmitted;
if (!canShowDetails) {
answerSnapshotDTO.setRightAnswer(null);
answerSnapshotDTO.setAnalysis(null);
}
answerSnapshotDTO.setIndex(index.incrementAndGet());
if (Objects.isNull(answerSnapshotDTO.getHasAppealed())) {
answerSnapshotDTO.setHasAppealed(Boolean.FALSE);

Loading…
Cancel
Save