diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java index c36dc63c..3a640f2f 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java @@ -621,4 +621,31 @@ public class GeneralQuestionSettingService extends CoreBaseService + * 验证学生是否提交试卷 + * + * @param questionSettingId 题目配置ID + * @param studentId 学生ID + * @param throwMessage 异常的信息外部定义 + * @Author: lx + * @Date: 2022/11/30 23:51 + */ + public void validateFinallySubmitThrow(Long questionSettingId, Long studentId, String throwMessage) { + boolean isZeroCount = false; + if (!ObjectUtil.isAllNotEmpty(questionSettingId, studentId)) { + // 查询未提交题目数量, + long notSubmitCount = generalQuestionLogDao.createLambdaQuery() + .andEq(GeneralQuestionLog::getGeneralQuestionSettingId, questionSettingId) + .andNotEq(GeneralQuestionLog::getQuestionLogAddType, FINALLY_SUBMIT) + .andEq(GeneralQuestionLog::getGeneralQuestionLogStatus, 1) + .andEq(GeneralQuestionLog::getStudentId, studentId) + .count(); + // 为空代表,试卷是完全提交的状态,这样判断比较保险一些 + isZeroCount = notSubmitCount == 0; + } + // 异常的消息,交给调用方来定义 + Assert.isTrue(isZeroCount, throwMessage); + } + } diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralResourcesQuestionSnapshotService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralResourcesQuestionSnapshotService.java index a9077fa4..ccf8558f 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralResourcesQuestionSnapshotService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralResourcesQuestionSnapshotService.java @@ -56,6 +56,7 @@ import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue; public class GeneralResourcesQuestionSnapshotService extends CoreBaseService{ @Autowired private GeneralResourcesQuestionSnapshotDao generalResourcesQuestionSnapshotDao; + @Autowired private GeneralQuestionSettingService generalQuestionSettingService; public PageQueryqueryByCondition(PageQuery query){ PageQuery ret = generalResourcesQuestionSnapshotDao.queryByCondition(query); @@ -452,17 +453,18 @@ public class GeneralResourcesQuestionSnapshotService extends CoreBaseService + * 验证学生是否提交试卷 + * + * @param questionSettingId 题目配置ID + * @param studentId 学生ID + * @param throwMessage 异常的信息外部定义 + * @Author: lx + * @Date: 2022/11/30 23:51 + */ + public void validateFinallySubmitThrow(Long questionSettingId, Long studentId, String throwMessage) { + boolean isZeroCount = false; + if (!ObjectUtil.isAllNotEmpty(questionSettingId, studentId)) { + // 查询未提交题目数量, + long notSubmitCount = teacherOpenCourseQuestionLogDao.createLambdaQuery() + .andEq(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionSettingId, questionSettingId) + .andNotEq(TeacherOpenCourseQuestionLog::getQuestionLogAddType, FINALLY_SUBMIT) + .andEq(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionLogStatus, 1) + .andEq(TeacherOpenCourseQuestionLog::getStudentId, studentId) + .count(); + // 为空代表,试卷是完全提交的状态,这样判断比较保险一些 + isZeroCount = notSubmitCount == 0; + } + // 异常的消息,交给调用方来定义 + Assert.isTrue(isZeroCount, throwMessage); + } }