做题日志,记录详情查询

beetlsql3-dev
Mlxa0324 2 years ago
parent cdb1a104ae
commit 0322c8e4e6

@ -25,4 +25,5 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper<TeacherOpenC
List<TeacherOpenCourseQuestionLog> getByIds(String ids); List<TeacherOpenCourseQuestionLog> getByIds(String ids);
List<TeacherOpenCourseQuestionLog> getValuesByQuery(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery); List<TeacherOpenCourseQuestionLog> getValuesByQuery(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery);
PageQuery<TeacherOpenCourseQuestionLog> studentScoreList(PageQuery query);
} }

@ -5,16 +5,20 @@ import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig; import com.ibeetl.admin.core.util.ValidateConfig;
import lombok.Data; import lombok.Data;
import org.beetl.sql.annotation.entity.AssignID; 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 javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.Map;
/* /*
* -- * --
* gen by Spring Boot2 Admin 2022-10-05 * gen by Spring Boot2 Admin 2022-10-05
*/ */
@Data @Data
@Fetch
public class TeacherOpenCourseQuestionLog extends BaseEntity{ public class TeacherOpenCourseQuestionLog extends BaseEntity{
//学生做题日志ID //学生做题日志ID
@ -55,6 +59,9 @@ public class TeacherOpenCourseQuestionLog extends BaseEntity{
private Long studentId ; 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<String, String> studentInfo;
//学生得分 //学生得分
private BigDecimal studentScore ; private BigDecimal studentScore ;

@ -383,7 +383,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
* @param questionSnapshotIds * @param questionSnapshotIds
* @return * @return
*/ */
public Map<Long, List<ResourcesQuestionSnapshot>> questionAnalysis(@NotEmpty final TreeSet<Long> questionSnapshotIds) { public Map<Long, List<ResourcesQuestionSnapshot>> questionAnalysis(@NotEmpty(message = "请上传题目快照ID和答案") final TreeSet<Long> questionSnapshotIds) {
// 查询题目快照列表 // 查询题目快照列表
List<ResourcesQuestionSnapshot> questionSnapshots = resourcesQuestionSnapshotDao.getByIds(join(questionSnapshotIds.toArray(), ",")); List<ResourcesQuestionSnapshot> questionSnapshots = resourcesQuestionSnapshotDao.getByIds(join(questionSnapshotIds.toArray(), ","));
@ -408,4 +408,19 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
return resourcesQuestionSnapshot; return resourcesQuestionSnapshot;
}).collect(groupingBy(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId)); }).collect(groupingBy(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId));
} }
/**
*
*
*
* @param query
*/
public PageQuery<TeacherOpenCourseQuestionLog> studentScoreList(PageQuery query) {
PageQuery ret = teacherOpenCourseQuestionLogDao.studentScoreList(query);
queryListAfter(ret.getList());
return ret;
}
public void questionLogStudentDetail(PageQuery page) {
}
} }

@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;
@ -195,7 +195,9 @@ public class TeacherOpenCourseQuestionLogController {
} }
/** /**
* - * -
*
*
* @param teacherOpenCourseQuestionSettingId ID * @param teacherOpenCourseQuestionSettingId ID
* @param fromTypeEnum * @param fromTypeEnum
* @return * @return
@ -209,13 +211,13 @@ public class TeacherOpenCourseQuestionLogController {
} }
/** /**
* - * -
* * <li></li>
* "/", * "/",
* *
* @param questionLogMap <ID, []> {"10086": ["D", "A", "B", "A"]} * @param questionLogMap <ID, []> {"10086": ["D", "A", "B", "A"]}
* @param questionSettingId ID * @param questionSettingId ID
* @param coreUser Service * @param coreUser Service
* @return * @return
*/ */
@PostMapping(MODEL + "/addQuestionLog.json") @PostMapping(MODEL + "/addQuestionLog.json")
@ -233,9 +235,7 @@ public class TeacherOpenCourseQuestionLogController {
} }
/** /**
* - * -
*
* "/",
* *
* @param questionSnapshotIds [ID] * @param questionSnapshotIds [ID]
* @param coreUser Service * @param coreUser Service
@ -245,7 +245,7 @@ public class TeacherOpenCourseQuestionLogController {
@Function("teacherOpenCourseQuestionLog.query") @Function("teacherOpenCourseQuestionLog.query")
@ResponseBody @ResponseBody
public JsonResult questionAnalysis( public JsonResult questionAnalysis(
@RequestBody @NotEmpty(message = "请上传题目快照ID和答案") @RequestBody
TreeSet<Long> questionSnapshotIds, TreeSet<Long> questionSnapshotIds,
@SCoreUser @SCoreUser
CoreUser coreUser) { CoreUser coreUser) {
@ -253,4 +253,22 @@ public class TeacherOpenCourseQuestionLogController {
return JsonResult.success(teacherOpenCourseQuestionLogService.questionAnalysis(questionSnapshotIds)); return JsonResult.success(teacherOpenCourseQuestionLogService.questionAnalysis(questionSnapshotIds));
} }
/**
* --
*
* @param condition ID
* @return
*/
@PostMapping(MODEL + "/studentScoreList.json")
@Function("teacherOpenCourseQuestionLog.query")
@ResponseBody
public JsonResult<PageQuery> studentScoreList(
@NotNull(message = "查询条件不能为空!") TeacherOpenCourseQuestionLogQuery condition){
PageQuery page = condition.getPageQuery();
teacherOpenCourseQuestionLogService.studentScoreList(page);
return JsonResult.success(page);
}
} }

@ -45,6 +45,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam {
@Query(name = "用户ID", display = false) @Query(name = "用户ID", display = false)
private Long userId; private Long userId;
private BigDecimal studentScore;
//课程ID //课程ID
private Long courseInfoId ; private Long courseInfoId ;
@ -89,6 +90,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam {
private String teacherOpenCourseQuestionSettingIdPlural; private String teacherOpenCourseQuestionSettingIdPlural;
private String resourcesQuestionSnapshotIdPlural; private String resourcesQuestionSnapshotIdPlural;
private String teacherOpenCourseQuestionLogStatusPlural; private String teacherOpenCourseQuestionLogStatusPlural;
private String questionTypePlural;
private String studentIdPlural; private String studentIdPlural;
private String orgIdPlural; private String orgIdPlural;
private String userIdPlural; private String userIdPlural;
@ -107,6 +109,7 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam {
pojo.setTeacherOpenCourseQuestionLogAddTime(this.getTeacherOpenCourseQuestionLogAddTime()); pojo.setTeacherOpenCourseQuestionLogAddTime(this.getTeacherOpenCourseQuestionLogAddTime());
pojo.setTeacherOpenCourseQuestionLogStatus(this.getTeacherOpenCourseQuestionLogStatus()); pojo.setTeacherOpenCourseQuestionLogStatus(this.getTeacherOpenCourseQuestionLogStatus());
pojo.setStudentId(this.getStudentId()); pojo.setStudentId(this.getStudentId());
pojo.setStudentScore(this.getStudentScore());
pojo.setOrgId(this.getOrgId()); pojo.setOrgId(this.getOrgId());
pojo.setUserId(this.getUserId()); pojo.setUserId(this.getUserId());
pojo.setCourseInfoId(this.getCourseInfoId()); pojo.setCourseInfoId(this.getCourseInfoId());

@ -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;
}

@ -1,7 +1,6 @@
queryByCondition queryByCondition
=== ===
* 根据不为空的参数进行分页查询 * 根据不为空的参数进行分页查询
select select
@pageTag(){ @pageTag(){
t.* t.*
@ -52,6 +51,39 @@ queryByCondition
@if(!isEmpty(studentIdPlural)){ @if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#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)){ @if(!isEmpty(orgId)){
and t.org_id =#orgId# and t.org_id =#orgId#
@} @}
@ -69,7 +101,6 @@ queryByCondition
queryByConditionQuery queryByConditionQuery
=== ===
* 根据不为空的参数进行分页查询(无权限) * 根据不为空的参数进行分页查询(无权限)
select select
@pageTag(){ @pageTag(){
t.* t.*
@ -118,6 +149,39 @@ queryByConditionQuery
@if(!isEmpty(studentIdPlural)){ @if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#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)){ @if(!isEmpty(orgId)){
and t.org_id =#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 deleteTeacherOpenCourseQuestionLogByIds

@ -6,8 +6,10 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao; import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao;
import com.ibeetl.jlw.dao.StudentDao; import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionSettingDao; import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionSettingDao;
import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot; import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot;
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog;
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionSetting; import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionSetting;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import org.junit.Assert; import org.junit.Assert;
@ -23,6 +25,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static cn.hutool.json.JSONUtil.toJsonStr; 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 com.ibeetl.admin.test.util.test.RandomUtils.randomSet;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.join; import static org.apache.commons.lang3.StringUtils.join;
@ -40,6 +43,8 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao; ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao;
@Resource @Resource
TeacherOpenCourseQuestionSettingDao teacherOpenCourseQuestionSettingDao; TeacherOpenCourseQuestionSettingDao teacherOpenCourseQuestionSettingDao;
@Resource
TeacherOpenCourseQuestionLogDao teacherOpenCourseQuestionLogDao;
private static ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum; private static ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum;
private static Long teacherOpenCourseQuestionSettingId; private static Long teacherOpenCourseQuestionSettingId;
@ -201,4 +206,32 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
clearEnvLoginInfo(); clearEnvLoginInfo();
} }
} }
@Test
void studentScoreList() throws Exception {
try {
// 随机取一个学生的登录信息
List<TeacherOpenCourseQuestionLog> 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;
}
}
} }
Loading…
Cancel
Save