diff --git a/doc/sql/mysql/tianze-pro.sql b/doc/sql/mysql/tianze-pro.sql index 7a59fb20..be7a656f 100644 --- a/doc/sql/mysql/tianze-pro.sql +++ b/doc/sql/mysql/tianze-pro.sql @@ -28750,7 +28750,7 @@ create table teacher_open_course_question_setting teacher_open_course_question_setting_name varchar(100) comment '开课题目-名称', teacher_open_course_question_start_time datetime comment '题目开始时间', teacher_open_course_question_end_time datetime comment '题目结束时间', - teacher_open_course_question_setting_type varchar(100) comment '类型 枚举(TeacherOpenCourseQuestionSettingTypeEnum)', + teacher_open_course_question_setting_type varchar(100) comment '类型 枚举(ResourcesQuestionSnapshotFromTypeEnum)', teacher_open_course_question_setting_file varchar(1000) comment '附件,老师上传附件(单文件)', teacher_open_course_question_setting_push_status int comment '发布状态。 1发布,2未发布', teacher_open_course_question_setting_status int comment '状态 (1正常 2删除)', diff --git a/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java index 46234daf..0d785c5e 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java @@ -3,6 +3,8 @@ package com.ibeetl.jlw.dao; import com.ibeetl.jlw.entity.GeneralQuestionLog; import com.ibeetl.jlw.entity.GeneralQuestionLogScoreDetailsInfo; import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog; +import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum; +import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import com.ibeetl.jlw.web.query.GeneralQuestionLogQuery; import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.mapper.BaseMapper; @@ -66,5 +68,16 @@ public interface GeneralQuestionLogDao extends BaseMapper { * @return */ boolean validateQuestionLogAddTimeLatest(Long questionSettingId, String questionSnapshotIds, Long studentId, Date addTime); + + /** + * 验证是否需要重新发题 + * @param questionSettingId 题目配置ID + * @param studentId 学生ID + * @param questionSettingType 题目配置类型 + * @param questionLogAddType 题目日志添加类型(用于判断是否交卷) + * @return boolean + */ + boolean verifyLogAddTypeIsReSend(Long questionSettingId, Long studentId, ResourcesQuestionSnapshotFromTypeEnum questionSettingType, QuestionLogAddTypeEnum questionLogAddType); + } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java index 690a273a..54fe3397 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java @@ -2,6 +2,8 @@ package com.ibeetl.jlw.dao; import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog; import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLogScoreDetailsInfo; +import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum; +import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import com.ibeetl.jlw.web.query.TeacherOpenCourseQuestionLogQuery; import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.mapper.BaseMapper; @@ -71,4 +73,14 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper existsList = getValuesByQueryNotWithPermission(questionLogQuery); + + // 如果题目日志里存在预先布置的题目,则直接返回 + if (CollectionUtil.isNotEmpty(existsList)) { + return; + } + } + // generalQuestionSettingId:类似试卷ID,题目日志里会出现重复的试卷ID // 逻辑删除之前的题目日志,防止学生做题统计数据异常 // 保证试卷是最新的 // 考试逻辑删除记录,作业或者章节测试都是直接删除记录。 -// if (setting.getGeneralQuestionSettingType().equals(EXAM)) { -// logicDeleteBySettingIds(setting.getGeneralQuestionSettingId().toString()); -// } -// else { -// deleteBySettingIds(setting.getGeneralQuestionSettingId().toString()); -// } + Long teacherOpenCourseQuestionSettingId = setting.getGeneralQuestionSettingId(); + // 强制发题 + if (isReSend) { + if (setting.getGeneralQuestionSettingType().equals(EXAM)) { + logicDeleteBySettingIds(teacherOpenCourseQuestionSettingId.toString()); + } + } // 断言 Assert.notBlank(resourcesQuestionSnapshots.get(0).getQuestionAnswer(), "题目快照选项不能为空!"); @@ -764,4 +784,26 @@ public class GeneralQuestionLogService extends CoreBaseService getQuestionLogScoreDetailsInfo(PageQuery query) { return generalQuestionLogDao.getQuestionLogScoreDetailsInfo(query); } + + /** + * 验证是否需要重新发题,则返回重新发题的标记 + * @param questionSettingId 题目配置ID + * @param studentId 学生ID + * @param questionSettingType 题目配置类型 + * @param questionLogAddType 题目日志添加类型(用于判断是否交卷) + * @return boolean + */ + public boolean verifyLogAddTypeIsReSend(Long questionSettingId, + Long studentId, ResourcesQuestionSnapshotFromTypeEnum questionSettingType, + QuestionLogAddTypeEnum questionLogAddType) { + // 只有章节练习,才能进行重发试题的操作 + if (!questionSettingType.equals(CHAPTER_EXERCISE)) { + return false; + } + if (ObjectUtil.isAllNotEmpty(questionSettingId, studentId, questionSettingType, questionLogAddType)) { + return generalQuestionLogDao.verifyLogAddTypeIsReSend(questionSettingId, studentId, questionSettingType, questionLogAddType); + } + + return false; + } } 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 35dfff2f..0e53fd2d 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionSettingService.java @@ -49,6 +49,7 @@ import static cn.jlw.util.CacheUserUtil.getStudent; import static cn.jlw.util.QuestionUtil.shuffleQuestion; import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue; import static com.ibeetl.jlw.enums.BusinessCourseInfoEnum.SYSTEM_QUESTION; +import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.FINALLY_SUBMIT; import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.CHAPTER_EXERCISE; import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_FILE; @@ -465,7 +466,8 @@ public class GeneralQuestionSettingService extends CoreBaseService resourcesQuestionSnapshots; @@ -480,7 +482,7 @@ public class GeneralQuestionSettingService extends CoreBaseService 1, "作答次数设置有误,请联系管理员!"); // 数据库查询该学生已经做过的次数 GeneralQuestionLog generalQuestionLog = new GeneralQuestionLog(); - generalQuestionLog.setStudentId(student.getStudentId()); + generalQuestionLog.setStudentId(studentId); long doCount = generalQuestionLogDao.templateCount(generalQuestionLog); // 断言判断最大作答次数 Assert.isTrue(doCount < generalQuestionSettingSettingDoCount, "已超过最大作答次数!"); @@ -520,8 +522,10 @@ public class GeneralQuestionSettingService extends CoreBaseService resourcesQuestionSnapshots; @@ -671,7 +673,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService 1, "作答次数设置有误,请联系管理员!"); // 数据库查询该学生已经做过的次数 TeacherOpenCourseQuestionLog teacherOpenCourseQuestionLog = new TeacherOpenCourseQuestionLog(); - teacherOpenCourseQuestionLog.setStudentId(student.getStudentId()); + teacherOpenCourseQuestionLog.setStudentId(studentId); long doCount = teacherOpenCourseQuestionLogDao.templateCount(teacherOpenCourseQuestionLog); // 断言判断最大作答次数 Assert.isTrue(doCount < teacherOpenCourseQuestionSettingSettingDoCount, "已超过最大作答次数!"); @@ -680,7 +682,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService 0 + FROM + general_question_setting t + LEFT JOIN general_question_log ta ON ta.general_question_setting_id = t.general_question_setting_id + AND t.general_question_setting_status = 1 + AND t.general_question_setting_type = #questionSettingType# + AND t.general_question_setting_id = #questionSettingId# + AND ta.general_question_log_status = 1 + AND ta.student_id = #studentId# + AND ta.question_log_add_type = #questionLogAddType# + LIMIT 1 \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md index 3b6e31d9..7a6094fd 100644 --- a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md +++ b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md @@ -594,7 +594,9 @@ getQuestionTestSimpleInfo ( SELECT sum( - IFNULL( ta.student_score, 0 )) + @ // 已经交卷的状态才算分 + CASE WHEN ta.question_log_add_type = 'FINALLY_SUBMIT' THEN IFNULL( ta.student_score, 0 ) ELSE 0 END + ) FROM teacher_open_course_question_log ta WHERE diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md index 4f26f0dc..607f0051 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md @@ -737,6 +737,7 @@ getQuestionLogScoreDetailsInfo validateQuestionLogAddTimeLatest === * 验证前端传递过来的添加时间是否是最新的 + select if(t.teacher_open_course_question_log_update_time is null, true, t.teacher_open_course_question_log_update_time < #addTime#) from @@ -748,3 +749,21 @@ validateQuestionLogAddTimeLatest and t.teacher_open_course_question_log_status = 1 order by teacher_open_course_question_log_add_time desc limit 1 + + +verifyLogAddTypeIsReSend +=== +* 如果查询题目日志,只要是交卷的状态 则返回重新发题的标记 + + SELECT + COUNT(1) > 0 + FROM + teacher_open_course_question_setting t + LEFT JOIN teacher_open_course_question_log ta ON ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id + AND t.teacher_open_course_question_setting_status = 1 + AND t.teacher_open_course_question_setting_type = #questionSettingType# + AND t.teacher_open_course_question_setting_id = #questionSettingId# + AND ta.teacher_open_course_question_log_status = 1 + AND ta.student_id = #studentId# + AND ta.question_log_add_type = #questionLogAddType# + LIMIT 1 \ No newline at end of file