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 363e9509..5b8eb276 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java @@ -25,4 +25,5 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper getByIds(String ids); List getValuesByQuery(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery); + PageQuery studentScoreList(PageQuery query); } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java index c6aaf97e..94c054af 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java @@ -5,16 +5,20 @@ import com.ibeetl.admin.core.entity.BaseEntity; import com.ibeetl.admin.core.util.ValidateConfig; import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; +import org.beetl.sql.fetch.annotation.Fetch; +import org.beetl.sql.fetch.annotation.FetchSql; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.Date; +import java.util.Map; /* * 我的课程-题库-做题日志 * gen by Spring Boot2 Admin 2022-10-05 */ @Data +@Fetch public class TeacherOpenCourseQuestionLog extends BaseEntity{ //学生做题日志ID @@ -55,6 +59,9 @@ public class TeacherOpenCourseQuestionLog extends BaseEntity{ private Long studentId ; + @FetchSql("select t.student_name, t.student_sn from student t where t.student_id = #studentId# and t.student_status = 1") + private Map studentInfo; + //学生得分 private BigDecimal studentScore ; diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java index bb4569b6..503b0298 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java @@ -383,7 +383,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService> questionAnalysis(@NotEmpty final TreeSet questionSnapshotIds) { + public Map> questionAnalysis(@NotEmpty(message = "请上传题目快照ID和答案!") final TreeSet questionSnapshotIds) { // 查询题目快照列表 List questionSnapshots = resourcesQuestionSnapshotDao.getByIds(join(questionSnapshotIds.toArray(), ",")); @@ -408,4 +408,19 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService studentScoreList(PageQuery query) { + PageQuery ret = teacherOpenCourseQuestionLogDao.studentScoreList(query); + queryListAfter(ret.getList()); + return ret; + } + + public void questionLogStudentDetail(PageQuery page) { + } } 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 a69b2682..6680ca79 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.List; import java.util.Map; import java.util.TreeSet; @@ -195,7 +195,9 @@ public class TeacherOpenCourseQuestionLogController { } /** - * 学生端-根绝题目配置信息,获取相关的题目 + * 学生端-根据题目配置信息,获取相关的题目 + * 每次获取 + * * @param teacherOpenCourseQuestionSettingId 配置ID * @param fromTypeEnum 来源类型 * @return @@ -209,13 +211,13 @@ public class TeacherOpenCourseQuestionLogController { } /** - * 学生端-和题目有关的做题提交方法 - * 支持附件上传。不支持简答题上传, - * 答案集合中,会包含"/"字符串,则代表是路径地址,则是附件类型的答案 + * 学生端-和题目有关的提交方法 (章节测试、考试、作业) + *
  • 支持附件上传
  • + * 答案集合中,会包含"/"字符串,则代表是路径地址,则是附件类型的答案 * - * @param questionLogMap <题目快照ID, [数组:前端传递过来不需要考虑排序和重复问题]> 例: {"10086": ["D", "A", "B", "A"]} - * @param questionSettingId 题目配置ID - * @param coreUser 用来验证用户登录,为了解耦不会传递到Service层 + * @param questionLogMap <题目快照ID, [数组:前端传递过来不需要考虑排序和重复问题]> 例: {"10086": ["D", "A", "B", "A"]} + * @param questionSettingId 题目配置ID 简单理解,区分属于哪套卷子:章节测试、考试、作业 目前支持这三种类型。作业中,又区分题目作业,和附件作业。 + * @param coreUser 用来验证用户登录,为了解耦不会传递到Service层 * @return */ @PostMapping(MODEL + "/addQuestionLog.json") @@ -233,9 +235,7 @@ public class TeacherOpenCourseQuestionLogController { } /** - * 学生端-和题目有关的做题提交方法 - * 支持附件上传。不支持简答题上传, - * 答案集合中,会包含"/"字符串,则代表是路径地址,则是附件类型的答案 + * 学生端-答题后显示答案、和分析 * * @param questionSnapshotIds [题目快照ID] * @param coreUser 用来验证用户登录,为了解耦不会传递到Service层 @@ -245,7 +245,7 @@ public class TeacherOpenCourseQuestionLogController { @Function("teacherOpenCourseQuestionLog.query") @ResponseBody public JsonResult questionAnalysis( - @RequestBody @NotEmpty(message = "请上传题目快照ID和答案!") + @RequestBody TreeSet questionSnapshotIds, @SCoreUser CoreUser coreUser) { @@ -253,4 +253,22 @@ public class TeacherOpenCourseQuestionLogController { return JsonResult.success(teacherOpenCourseQuestionLogService.questionAnalysis(questionSnapshotIds)); } + + /** + * 学生端-教师端-学生总得分列表 + * + * @param condition 题目配置ID + * @return + */ + @PostMapping(MODEL + "/studentScoreList.json") + @Function("teacherOpenCourseQuestionLog.query") + @ResponseBody + public JsonResult studentScoreList( + @NotNull(message = "查询条件不能为空!") TeacherOpenCourseQuestionLogQuery condition){ + PageQuery page = condition.getPageQuery(); + teacherOpenCourseQuestionLogService.studentScoreList(page); + return JsonResult.success(page); + } + + } diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java index 5552d4f9..a35ab0ab 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java @@ -45,6 +45,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam { @Query(name = "用户ID", display = false) private Long userId; + private BigDecimal studentScore; //课程ID private Long courseInfoId ; @@ -89,6 +90,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam { private String teacherOpenCourseQuestionSettingIdPlural; private String resourcesQuestionSnapshotIdPlural; private String teacherOpenCourseQuestionLogStatusPlural; + private String questionTypePlural; private String studentIdPlural; private String orgIdPlural; private String userIdPlural; @@ -107,6 +109,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam { pojo.setTeacherOpenCourseQuestionLogAddTime(this.getTeacherOpenCourseQuestionLogAddTime()); pojo.setTeacherOpenCourseQuestionLogStatus(this.getTeacherOpenCourseQuestionLogStatus()); pojo.setStudentId(this.getStudentId()); + pojo.setStudentScore(this.getStudentScore()); pojo.setOrgId(this.getOrgId()); pojo.setUserId(this.getUserId()); pojo.setCourseInfoId(this.getCourseInfoId()); diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogStudentDetailQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogStudentDetailQuery.java new file mode 100644 index 00000000..113acf04 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogStudentDetailQuery.java @@ -0,0 +1,39 @@ +package com.ibeetl.jlw.web.query; + +import com.ibeetl.admin.core.web.query.PageParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; + +/** + *题目日志查询-学生详情查询条件 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@Validated +@SuppressWarnings("ALL") +public class TeacherOpenCourseQuestionLogStudentDetailQuery extends PageParam { + + @NotNull(message = "题目配置ID不能为空!") + private Long teacherOpenCourseQuestionSettingId; + + // 学生ID + private Long studentId ; + + // 学生编号 + private String studentSn; + + // 复数 + private String teacherOpenCourseQuestionSettingIdPlural; + private String studentSnPlural; + private String studentIdPlural; + +} diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md index 8aa2bb6f..f0d37e69 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md @@ -1,7 +1,6 @@ queryByCondition === * 根据不为空的参数进行分页查询 - select @pageTag(){ t.* @@ -52,6 +51,39 @@ queryByCondition @if(!isEmpty(studentIdPlural)){ and find_in_set(t.student_id,#studentIdPlural#) @} + @if(!isEmpty(studentScore)){ + and t.student_score =#studentScore# + @} + @if(!isEmpty(questionType)){ + and t.question_type =#questionType# + @} + @if(!isEmpty(questionTypePlural)){ + and find_in_set(t.question_type,#questionTypePlural#) + @} + @if(!isEmpty(questionScore)){ + and t.question_score =#questionScore# + @} + @if(!isEmpty(questionStem)){ + and t.question_stem =#questionStem# + @} + @if(!isEmpty(questionOptionA)){ + and t.question_option_a =#questionOptionA# + @} + @if(!isEmpty(questionOptionB)){ + and t.question_option_b =#questionOptionB# + @} + @if(!isEmpty(questionOptionC)){ + and t.question_option_c =#questionOptionC# + @} + @if(!isEmpty(questionOptionD)){ + and t.question_option_d =#questionOptionD# + @} + @if(!isEmpty(questionOptionE)){ + and t.question_option_e =#questionOptionE# + @} + @if(!isEmpty(questionAnswer)){ + and t.question_answer =#questionAnswer# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -69,7 +101,6 @@ queryByCondition queryByConditionQuery === * 根据不为空的参数进行分页查询(无权限) - select @pageTag(){ t.* @@ -118,6 +149,39 @@ queryByConditionQuery @if(!isEmpty(studentIdPlural)){ and find_in_set(t.student_id,#studentIdPlural#) @} + @if(!isEmpty(studentScore)){ + and t.student_score =#studentScore# + @} + @if(!isEmpty(questionType)){ + and t.question_type =#questionType# + @} + @if(!isEmpty(questionTypePlural)){ + and find_in_set(t.question_type,#questionTypePlural#) + @} + @if(!isEmpty(questionScore)){ + and t.question_score =#questionScore# + @} + @if(!isEmpty(questionStem)){ + and t.question_stem =#questionStem# + @} + @if(!isEmpty(questionOptionA)){ + and t.question_option_a =#questionOptionA# + @} + @if(!isEmpty(questionOptionB)){ + and t.question_option_b =#questionOptionB# + @} + @if(!isEmpty(questionOptionC)){ + and t.question_option_c =#questionOptionC# + @} + @if(!isEmpty(questionOptionD)){ + and t.question_option_d =#questionOptionD# + @} + @if(!isEmpty(questionOptionE)){ + and t.question_option_e =#questionOptionE# + @} + @if(!isEmpty(questionAnswer)){ + and t.question_answer =#questionAnswer# + @} @if(!isEmpty(orgId)){ and t.org_id =#orgId# @} @@ -132,6 +196,116 @@ queryByConditionQuery @} +studentScoreList +=== +* 根据不为空的参数进行分页查询(无权限) 查询得分总和 + select + @pageTag(){ + tz.* + @} + from ( + select + t.student_id, + ta.student_sn, + ta.student_name, + t.teacher_open_course_question_setting_id, + sum(t.student_score) as sum_student_score + from teacher_open_course_question_log t + left join student ta on ta.student_id = t.student_id + where 1=1 + @if(!isEmpty(teacherOpenCourseQuestionLogId)){ + and t.teacher_open_course_question_log_id =#teacherOpenCourseQuestionLogId# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogIdPlural)){ + and find_in_set(t.teacher_open_course_question_log_id,#teacherOpenCourseQuestionLogIdPlural#) + @} + @if(!isEmpty(teacherOpenCourseQuestionSettingId)){ + and t.teacher_open_course_question_setting_id =#teacherOpenCourseQuestionSettingId# + @} + @if(!isEmpty(teacherOpenCourseQuestionSettingIdPlural)){ + and find_in_set(t.teacher_open_course_question_setting_id,#teacherOpenCourseQuestionSettingIdPlural#) + @} + @if(!isEmpty(resourcesQuestionSnapshotId)){ + and t.resources_question_snapshot_id =#resourcesQuestionSnapshotId# + @} + @if(!isEmpty(resourcesQuestionSnapshotIdPlural)){ + and find_in_set(t.resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) + @} + @if(!isEmpty(teacherOpenCourseQuestionLogAnswer)){ + and t.teacher_open_course_question_log_answer =#teacherOpenCourseQuestionLogAnswer# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogUploadFile)){ + and t.teacher_open_course_question_log_upload_file =#teacherOpenCourseQuestionLogUploadFile# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogAddTime)){ + and t.teacher_open_course_question_log_add_time =#teacherOpenCourseQuestionLogAddTime# + @} + @if(isEmpty(teacherOpenCourseQuestionLogStatus) && isEmpty(teacherOpenCourseQuestionLogStatusPlural)){ + and t.teacher_open_course_question_log_status != 2 + @}else{ + @if(!isEmpty(teacherOpenCourseQuestionLogStatus)){ + and t.teacher_open_course_question_log_status =#teacherOpenCourseQuestionLogStatus# + @}else if(!isEmpty(teacherOpenCourseQuestionLogStatusPlural)){ + and find_in_set(t.teacher_open_course_question_log_status,#teacherOpenCourseQuestionLogStatusPlural#) + @} + @} + @if(!isEmpty(studentId)){ + and t.student_id =#studentId# + @} + @if(!isEmpty(studentIdPlural)){ + and find_in_set(t.student_id,#studentIdPlural#) + @} + @if(!isEmpty(studentScore)){ + and t.student_score =#studentScore# + @} + @if(!isEmpty(questionType)){ + and t.question_type =#questionType# + @} + @if(!isEmpty(questionTypePlural)){ + and find_in_set(t.question_type,#questionTypePlural#) + @} + @if(!isEmpty(questionScore)){ + and t.question_score =#questionScore# + @} + @if(!isEmpty(questionStem)){ + and t.question_stem =#questionStem# + @} + @if(!isEmpty(questionOptionA)){ + and t.question_option_a =#questionOptionA# + @} + @if(!isEmpty(questionOptionB)){ + and t.question_option_b =#questionOptionB# + @} + @if(!isEmpty(questionOptionC)){ + and t.question_option_c =#questionOptionC# + @} + @if(!isEmpty(questionOptionD)){ + and t.question_option_d =#questionOptionD# + @} + @if(!isEmpty(questionOptionE)){ + and t.question_option_e =#questionOptionE# + @} + @if(!isEmpty(questionAnswer)){ + and t.question_answer =#questionAnswer# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + group by + t.student_id, + ta.student_sn, + ta.student_name, + t.teacher_open_course_question_setting_id + )tz deleteTeacherOpenCourseQuestionLogByIds diff --git a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java index 1f11890f..05e475b6 100644 --- a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java +++ b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java @@ -6,8 +6,10 @@ import cn.hutool.core.util.RandomUtil; import cn.hutool.json.JSONUtil; import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao; import com.ibeetl.jlw.dao.StudentDao; +import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao; import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionSettingDao; import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot; +import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog; import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionSetting; import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import org.junit.Assert; @@ -23,6 +25,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import static cn.hutool.json.JSONUtil.toJsonStr; +import static com.ibeetl.admin.core.util.BeanUtil.toMultiMap; import static com.ibeetl.admin.test.util.test.RandomUtils.randomSet; import static java.util.stream.Collectors.toList; import static org.apache.commons.lang3.StringUtils.join; @@ -40,6 +43,8 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest { ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao; @Resource TeacherOpenCourseQuestionSettingDao teacherOpenCourseQuestionSettingDao; + @Resource + TeacherOpenCourseQuestionLogDao teacherOpenCourseQuestionLogDao; private static ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum; private static Long teacherOpenCourseQuestionSettingId; @@ -201,4 +206,32 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest { clearEnvLoginInfo(); } } + + @Test + void studentScoreList() throws Exception { + try { + // 随机取一个学生的登录信息 + List questionSnapshots = teacherOpenCourseQuestionLogDao.execute( + "select t.teacher_open_course_question_setting_id " + + "from teacher_open_course_question_log t " + + "ORDER BY RAND() limit 1 "); + // 断言 + Assert.assertTrue(ObjectUtil.isNotEmpty(questionSnapshots)); + + //构造请求参数 + RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/studentScoreList.json") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .params(toMultiMap(questionSnapshots.get(0))); + + //发送请求,验证返回结果 + String result = mvc.perform(rb) + .andExpect(status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0")) + .andReturn().getResponse().getContentAsString(); + + System.out.println(result); + }catch (Exception e) { + throw e; + } + } } \ No newline at end of file