diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java index eb38daf3..c6983b3f 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java @@ -44,8 +44,12 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { // 题目总数量 - @FetchSql("select count(1) from resources_question_snapshot t " + - "where t.question_status = 1 " + + @FetchSql("select count(1) from teacher_open_course_question_log t " + + "where 1 = 1 " + + "and t.teacher_open_course_question_log_status = 1 \n" + + "@if(!isEmpty(studentId)) { \n" + + "and t.student_id = #studentId# \n" + + "@} \n" + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " ) private int questionTotalCount; @@ -53,51 +57,46 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { // 答对数量 @FetchSql("select count(1) from teacher_open_course_question_log t " + - "left join resources_question_snapshot ta on ta.resources_question_snapshot_id = t.resources_question_snapshot_id " + "where 1 = 1 " + - "and t.teacher_open_course_question_log_status = 1 \n" + - "and ta.question_status = 1 \n" + + "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + - "and (CONCAT(t.teacher_open_course_question_log_answer, ',') = ta.question_answer or t.teacher_open_course_question_log_answer = ta.question_answer)" + "and t.teacher_open_course_question_log_answer = t.question_answer " ) private int correctCount; // 答错数量 @FetchSql("select count(1) from teacher_open_course_question_log t " + - "left join resources_question_snapshot ta on ta.resources_question_snapshot_id = t.resources_question_snapshot_id " + - "where t.teacher_open_course_question_log_status = 1 \n" + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + - "and CONCAT(t.teacher_open_course_question_log_answer, ',') != ta.question_answer" + "and t.teacher_open_course_question_log_answer != t.question_answer " ) private int wrongCount; // 总得分 - @FetchSql("select sum(IFNULL(ta.question_score, 0)) as total_score " + + @FetchSql("select sum(IFNULL(t.question_score, 0)) as total_score " + "from teacher_open_course_question_log t " + - "left join resources_question_snapshot ta on ta.resources_question_snapshot_id = t.resources_question_snapshot_id " + - "where t.teacher_open_course_question_log_status = 1 \n" + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + - "and CONCAT(t.teacher_open_course_question_log_answer, ',') != ta.question_answer" + "and t.teacher_open_course_question_log_answer = t.question_answer " ) private float totalScore; // 正确率 最大100 // 自动计算得到 - private int correctRate; + private float correctRate; @FetchSql(value = "SELECT t.* " + "FROM teacher_open_course_question_log t " + - "LEFT JOIN resources_question_snapshot ta ON ta.resources_question_snapshot_id = t.resources_question_snapshot_id " + - "WHERE t.teacher_open_course_question_log_status = 1 \n" + + "WHERE t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + @@ -132,8 +131,8 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { // 计算正确率, 取小数点后2位数 // 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100 this.setCorrectRate(NumberUtil - .round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 0) - .intValue()); + .round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 2) + .floatValue()); } } } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionSetting.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionSetting.java index 378e73d4..29b33567 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionSetting.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionSetting.java @@ -118,7 +118,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { // 附件题目的得分和评语 @FetchSql("select t.student_score, t.teacher_open_course_question_log_reply from teacher_open_course_question_log t " + - "where t.teacher_open_course_question_log_status = 1 " + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + "and #teacherOpenCourseQuestionSettingType# = 'HOMEWORK_FILE' ") @UpdateIgnore @@ -136,7 +136,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { // 平均答对数量 @FetchSql("select sum(t.student_score > 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" + "from teacher_open_course_question_log t \n" + - "where t.teacher_open_course_question_log_status = 1 " + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " + " AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ") @UpdateIgnore @InsertIgnore @@ -145,7 +145,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { // 平均答错数量 @FetchSql("select sum(t.student_score = 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" + "from teacher_open_course_question_log t \n" + - "where t.teacher_open_course_question_log_status = 1 " + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " + " AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ") @UpdateIgnore @InsertIgnore @@ -159,7 +159,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { // 平均得分 @FetchSql("select sum(t.student_score) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" + "from teacher_open_course_question_log t \n" + - "where t.teacher_open_course_question_log_status = 1 " + + "where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " + " AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ") @UpdateIgnore @InsertIgnore @@ -183,7 +183,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { private String teacherOpenCourseQuestionSettingSchoolClassNames; // 快照ID - @FetchSql("select * " + + @FetchSql("select t.*, null as question_answer " + "from resources_question_snapshot t where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# \n" + "and t.question_status = 1 \n" ) @@ -233,12 +233,21 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity { */ @UpdateIgnore @InsertIgnore - // 题目ID集合 @FetchSql("select max(ifnull(t.teacher_open_course_question_log_finish_time , 0)) from teacher_open_course_question_log t " + "where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + - "and t.teacher_open_course_question_log_status = 1 ") + "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT'") private long finishTime; + /** + * 我的得分 + */ + @UpdateIgnore + @InsertIgnore + @FetchSql("select round(sum(ifnull(t.student_score , 0)), 1) from teacher_open_course_question_log t " + + "where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + + "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' ") + private String myScore; + public void setAvgSuccessCount(Integer avgSuccessCount) { this.avgSuccessCount = avgSuccessCount; tryToUpdateAvgSuccessRate(); diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java index 6ffe6d48..cba19878 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java @@ -566,7 +566,7 @@ public class GeneralQuestionLogService extends CoreBaseService list = getValuesByQueryNotWithPermission(logQuery); diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java index 098c7ac6..42bd820f 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java @@ -43,6 +43,7 @@ import static cn.jlw.util.CacheUserUtil.getStudent; import static com.ibeetl.admin.core.util.ExcelUtil.convertData; import static com.ibeetl.admin.core.util.ExcelUtil.write; import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; +import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.FINALLY_SUBMIT; /** * 题目日志 我的课程-题库-做题日志 接口 @@ -204,15 +205,15 @@ public class TeacherOpenCourseQuestionLogController { /** * 批量收藏题目 / 取消收藏 * @param questionSettingId 题目配置ID - * @param questionSnapshotIds 题目快照IDs + * @param questionSnapIds 题目快照IDs * @param isTuck 是否收藏:true, false * @return */ @PostMapping(API + "/tuck.do") - public JsonResult tuck(Long questionSettingId, String questionSnapshotIds, boolean isTuck) { + public JsonResult tuck(Long questionSettingId, String questionSnapIds, boolean isTuck) { Student student = getStudent(); Assert.notNull(student, "该接口只能学生操作!"); - teacherOpenCourseQuestionLogService.tuck(questionSettingId, questionSnapshotIds, isTuck, student); + teacherOpenCourseQuestionLogService.tuck(questionSettingId, questionSnapIds, isTuck, student); return JsonResult.success(); } @@ -240,7 +241,8 @@ public class TeacherOpenCourseQuestionLogController { Assert.notNull(student, "非学生身份,无法获取收藏的题目!"); PageQuery query = new PageQuery(pageParam.getPage().longValue(), pageParam.getLimit().longValue()); query.setPara("studentId", student.getStudentId()); - query.setPara("teacherOpenCourseQuestionLogStatus", 1); + // 只查询已经做完的题目,因为有的人万一做到一半,去看收藏夹的答案,再来做题,就很离谱 + query.setPara("questionLogAddType", FINALLY_SUBMIT.name()); // 只查询收藏的题目 query.setPara("isTuck", true); return JsonResult.success(teacherOpenCourseQuestionLogService.queryByConditionQuery(query)); @@ -258,18 +260,6 @@ public class TeacherOpenCourseQuestionLogController { return JsonResult.success(); } - - /** - * 查询分数详细信息 - * @param query 题目分数查询实体 - * @return - */ - @PostMapping(API + "/scoreDetailInfo.do") - public JsonResult scoreDetailInfo(@Validated TeacherOpenCourseQuestionLogScoreDetailsInfoQuery query) { - teacherOpenCourseQuestionLogService.getQuestionLogScoreDetailsInfo(query.getPageQuery()); - return JsonResult.success(); - } - /** * 查询错题集(错题库) * @return @@ -280,12 +270,24 @@ public class TeacherOpenCourseQuestionLogController { Assert.notNull(student, "非学生身份,无法获取题目分析!"); PageQuery query = new PageQuery(pageParam.getPage().longValue(), pageParam.getLimit().longValue()); query.setPara("studentId", student.getStudentId()); - query.setPara("teacherOpenCourseQuestionLogStatus", 1); + // 只查询已经做完的题目,因为有的人万一做到一半,去看错题库的答案,再来做题,就很离谱 + query.setPara("questionLogAddType", FINALLY_SUBMIT.name()); // 只查询收藏到错题库的题目 query.setPara("isErrorFavorite", true); return JsonResult.success(teacherOpenCourseQuestionLogService.queryByConditionQuery(query)); } + /** + * 查询分数详细信息 + * @param query 题目分数查询实体 + * @return + */ + @PostMapping(API + "/scoreDetailInfo.do") + public JsonResult scoreDetailInfo(@Validated TeacherOpenCourseQuestionLogScoreDetailsInfoQuery query) { + teacherOpenCourseQuestionLogService.getQuestionLogScoreDetailsInfo(query.getPageQuery()); + return JsonResult.success(); + } + /** * 教师端-做题日志导出 * @param condition 日志记录查询条件 diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md index 0c09b6ce..d0cbd223 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md @@ -97,6 +97,9 @@ queryByCondition @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -208,6 +211,9 @@ queryByConditionQuery @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -327,6 +333,9 @@ studentScoreList @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -521,6 +530,9 @@ getTeacherOpenCourseQuestionLogValues @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -592,6 +604,9 @@ getValuesByQuery @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -669,6 +684,9 @@ getValuesByQueryNotWithPermission @if(!isEmpty(isErrorFavorite)){ and (t.is_error_favorite =#isErrorFavorite# or t.student_score != t.question_score) @} + @if(!isEmpty(questionLogAddType)){ + and t.question_log_add_type =#questionLogAddType# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @}