You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tianze-pro/web/src/main/java/com/ibeetl/jlw/service/ResourcesQuestionSnapshotSe...

563 lines
27 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao;
import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeResourcesQuestionDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionTestSimpleInfoDTO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionTestDetailVO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionTestSimpleInfoVO;
import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum;
import com.ibeetl.jlw.web.query.ResourcesQuestionSnapshotQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseQuestionSettingQuery;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.beetl.sql.core.SQLReady;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Nullable;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static cn.hutool.core.util.ArrayUtil.join;
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.jlw.util.CacheUserUtil.getStudent;
import static com.ibeetl.jlw.enums.QuestionLogAddTypeEnum.FINALLY_SUBMIT;
/**
* 题目快照 Service
* 当分布式ID开启后请勿使用insert(*,true)
*/
@Service
@Transactional
@Validated
@Slf4j
public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQuestionSnapshot> implements DeleteResourcesBy{
@Autowired private ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao;
@Autowired private StudentDao studentDao;
@Autowired private TeacherOpenCourseMergeResourcesQuestionDao teacherOpenCourseMergeResourcesQuestionDao;
@Autowired @Lazy
private TeacherOpenCourseQuestionSettingService teacherOpenCourseQuestionSettingService;
public PageQuery<ResourcesQuestionSnapshot>queryByCondition(PageQuery query){
PageQuery ret = resourcesQuestionSnapshotDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public PageQuery<ResourcesQuestionSnapshot>queryByConditionQuery(PageQuery query){
PageQuery ret = resourcesQuestionSnapshotDao.queryByConditionQuery(query);
queryListAfter(ret.getList());
return ret;
}
public void deleteByList(List list){
String ids = "";
ToolUtils.deleteNullList(list);
for(int i=0;null != list && i<list.size();i++){
ids += list.get(i).toString()+(i==list.size()-1?"":",");
}
if(StringUtils.isNotBlank(ids)){
resourcesQuestionSnapshotDao.deleteResourcesQuestionSnapshotByIds(ids);
}
}
public void deleteResourcesQuestionSnapshot(String ids){
try {
resourcesQuestionSnapshotDao.deleteResourcesQuestionSnapshotByIds(ids);
} catch (Exception e) {
throw new PlatformException("批量删除题目快照失败", e);
}
}
/**
* 批量删除(通过题目配置ID)
* @param settingIds
*/
public void deleteBySettingIds(String settingIds){
try {
resourcesQuestionSnapshotDao.deleteBySettingIds(settingIds);
} catch (Exception e) {
throw new PlatformException("批量删除题目快照失败", e);
}
}
public String addAll(ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
String msg = "";
List<ResourcesQuestionSnapshot> resourcesQuestionSnapshotList = new ArrayList<>();
try {
resourcesQuestionSnapshotList = JSON.parseArray(resourcesQuestionSnapshotQuery.getResourcesQuestionSnapshotJsonStr(), ResourcesQuestionSnapshot.class);
} catch (Exception e) {
try {
resourcesQuestionSnapshotList.add(JSONObject.parseObject(resourcesQuestionSnapshotQuery.getResourcesQuestionSnapshotJsonStr(), ResourcesQuestionSnapshot.class));
} catch (Exception e1) {}
}
ToolUtils.deleteNullList(resourcesQuestionSnapshotList);
if(null != resourcesQuestionSnapshotList && resourcesQuestionSnapshotList.size()>0){
for(int i=0;i<resourcesQuestionSnapshotList.size();i++){
ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotList.get(i);
resourcesQuestionSnapshot.setUserId(resourcesQuestionSnapshotQuery.getUserId());
resourcesQuestionSnapshot.setOrgId(resourcesQuestionSnapshotQuery.getOrgId());
}
insertBatch(resourcesQuestionSnapshotList);
}
return msg;
}
public JsonResult add(ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
String msg = "";
ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotQuery.pojo();
resourcesQuestionSnapshotDao.insert(resourcesQuestionSnapshot);
resourcesQuestionSnapshotQuery.setResourcesQuestionSnapshotId(resourcesQuestionSnapshot.getResourcesQuestionSnapshotId());
JsonResult jsonResult = new JsonResult();
jsonResult.setData(resourcesQuestionSnapshot.getResourcesQuestionSnapshotId());//自增的ID丢进去
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
jsonResult.setMsg(msg);
return jsonResult;
}
public String edit(ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
String msg = "";
ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotQuery.pojo();
resourcesQuestionSnapshotDao.updateTemplateById(resourcesQuestionSnapshot);
return msg;
}
public String updateGivenByIds(ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
String msg = "";
if(StringUtils.isNotBlank(resourcesQuestionSnapshotQuery.get_given())){
boolean flag = resourcesQuestionSnapshotDao.updateGivenByIds(resourcesQuestionSnapshotQuery) > 0;
if(!flag){
msg = "更新指定参数失败";
}
}else{
msg = "指定参数为空";
}
return msg;
}
public List<ResourcesQuestionSnapshot> getValues (Object paras){
return sqlManager.select(SqlId.of("jlw.resourcesQuestionSnapshot.getResourcesQuestionSnapshotValues"), ResourcesQuestionSnapshot.class, paras);
}
public List<ResourcesQuestionSnapshot> getValuesByQuery (ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
return resourcesQuestionSnapshotDao.getValuesByQuery(resourcesQuestionSnapshotQuery);
}
public List<ResourcesQuestionSnapshot> getValuesByQueryNotWithPermission (ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
return resourcesQuestionSnapshotDao.getValuesByQueryNotWithPermission(resourcesQuestionSnapshotQuery);
}
public ResourcesQuestionSnapshot getInfo (Long resourcesQuestionSnapshotId){
ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery = new ResourcesQuestionSnapshotQuery();
resourcesQuestionSnapshotQuery.setResourcesQuestionSnapshotId(resourcesQuestionSnapshotId);
List<ResourcesQuestionSnapshot> list = resourcesQuestionSnapshotDao.getValuesByQuery(resourcesQuestionSnapshotQuery);
if(null != list && list.size()>0){
return list.get(0);
}else{
return null;
}
}
public ResourcesQuestionSnapshot getInfo (ResourcesQuestionSnapshotQuery resourcesQuestionSnapshotQuery){
List<ResourcesQuestionSnapshot> list = resourcesQuestionSnapshotDao.getValuesByQuery(resourcesQuestionSnapshotQuery);
if(null != list && list.size()>0){
return list.get(0);
}else{
return null;
}
}
/**
* 根据题目配置批量导入
* 从开课题库中导入
*
* @param teacherOpenCourseQuestionSettingId 开课题目配置ID
* @param questionSettingOptions 根据题型动态分配题目
* @param courseInfoIdPair 根据题型动态分配题目
*/
public void insertBatchByOpenResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 在插入之前,先清空列表。这种情况下,支持题目配置还在,重置题目列表的操作。
deleteBySettingIds(teacherOpenCourseQuestionSettingId.toString());
// 数据库动态设置分数,并获取题目列表
List<ResourcesQuestionSnapshot> insertList = getOpenResourcesQuestionSnapListBySettingOptions(
teacherOpenCourseQuestionSettingId, questionSettingOptions, courseInfoIdPair);
resourcesQuestionSnapshotDao.insertBatch(insertList);
}
}
/**
* 传入题目ID 批量导入到快照表中
* 从系统题库导入
*
* @param teacherOpenCourseQuestionSettingId 开课题目配置ID
* @param questionSettingOptions 根据题型动态分配题目
* @param courseInfoIdPair 根据题型动态分配题目
*/
public void insertBatchBySystemResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 在插入之前,先清空列表。这种情况下,支持题目配置还在,重置题目列表的操作。
deleteBySettingIds(teacherOpenCourseQuestionSettingId.toString());
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 数据库动态设置分数,并获取题目列表
List<ResourcesQuestionSnapshot> insertList = getMergeResourcesQuestionSnapListByQuestionSettingOptionsBySystem(
teacherOpenCourseQuestionSettingId, questionSettingOptions, courseInfoIdPair);
insertList.forEach(item -> item.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSettingId));
setNewCourseInfoId(insertList, courseInfoIdPair);
resourcesQuestionSnapshotDao.insertBatch(insertList);
}
}
/**
* 从开课题库中获取题目。可以单独设置类型下的分数
*
* @param teacherOpenCourseQuestionSettingId 开课题目配置ID
* @param questionSettingOptions 根据题型动态分配题目
* @param courseInfoIdPair 根据题型动态分配题目
*/
public List<ResourcesQuestionSnapshot> getByOpenCourseResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 数据库动态设置分数,并获取题目列表
List<ResourcesQuestionSnapshot> insertList = getOpenResourcesQuestionSnapListBySettingOptions(
teacherOpenCourseQuestionSettingId, questionSettingOptions, courseInfoIdPair);
setNewCourseInfoId(insertList, courseInfoIdPair);
return insertList;
}
return Lists.emptyList();
}
/**
* 从系统题库中获取题目。可以单独设置类型下的分数
*
* @param teacherOpenCourseQuestionSettingId 开课题目配置ID
* @param questionSettingOptions 根据题型动态分配题目
* @param courseInfoIdPair 根据题型动态分配题目
*/
public List<ResourcesQuestionSnapshot> getBySystemResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 数据库动态设置分数,并获取题目列表
List<ResourcesQuestionSnapshot> insertList = getMergeResourcesQuestionSnapListByQuestionSettingOptionsBySystem(
teacherOpenCourseQuestionSettingId, questionSettingOptions, courseInfoIdPair);
setNewCourseInfoId(insertList, courseInfoIdPair);
return insertList;
}
return Lists.emptyList();
}
/**
* 根据课程新旧ID片段集合设置新的课程ID
*
* @param insertList
* @param courseInfoIdPair
*/
public void setNewCourseInfoId(@NotNull Collection<ResourcesQuestionSnapshot> insertList, @NotNull Map<Long, Long> courseInfoIdPair) {
if (ObjectUtil.isAllNotEmpty(insertList, courseInfoIdPair)) {
insertList.forEach(item -> {
Long courseMergeCourseInfoId = item.getTeacherOpenCourseMergeCourseInfoId();
item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
});
}
}
/**
* 根据课程新旧ID片段集合设置新的课程ID
*
* @param insertList
* @param courseInfoIdPair
*/
public void setRQNewCourseInfoId(@NotNull Collection<TeacherOpenCourseMergeResourcesQuestion> insertList, @NotNull Map<Long, Long> courseInfoIdPair) {
insertList.forEach(item -> {
Long courseMergeCourseInfoId = item.getTeacherOpenCourseMergeCourseInfoId();
item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
});
}
/**
* 根据题目ID集合
* 获取题目快照列表。并配置题目配置ID
*
* @param teacherOpenCourseQuestionSettingId 题目配置ID
* @param questionIdPlural 题目ID复数
* @param otherConsumer 其他消费操作
* @return
*/
public List<ResourcesQuestionSnapshot> getResourcesQuestionSnapshotListByQuestionIds(
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目ID列表不能为空") String questionIdPlural, Consumer<ResourcesQuestionSnapshot> otherConsumer) {
// 批量插入快照表
List<TeacherOpenCourseMergeResourcesQuestion> questionList = teacherOpenCourseMergeResourcesQuestionDao.getByIds(questionIdPlural);
Consumer<ResourcesQuestionSnapshot> resourcesQuestionSnapshotConsumer = (e) -> {};
List<ResourcesQuestionSnapshot> resourcesQuestionSnapshotList = getResourcesQuestionSnapshotList(questionList, teacherOpenCourseQuestionSettingId, resourcesQuestionSnapshotConsumer);
resourcesQuestionSnapshotList
.forEach(resourcesQuestionSnapshotConsumer.andThen(otherConsumer));
return resourcesQuestionSnapshotList;
}
/**
* 根据题目ID集合
* 获取题目快照列表。并配置题目配置ID
*
* @param questionList 题目集合
* @param teacherOpenCourseQuestionSettingId 题目ID复数
* @param otherConsumer 其他消费操作
* @return
*/
public List<ResourcesQuestionSnapshot> getResourcesQuestionSnapshotList (
@NotEmpty(message = "开课题库列表不能为空!") final Collection<TeacherOpenCourseMergeResourcesQuestion> questionList,
@NotNull(message = "题目配置ID不能为空") Long teacherOpenCourseQuestionSettingId, Consumer<ResourcesQuestionSnapshot> otherConsumer) {
// 批量插入快照表
List<ResourcesQuestionSnapshot> snapshotList = BeanUtil.copyToList(questionList, ResourcesQuestionSnapshot.class);
Consumer<ResourcesQuestionSnapshot> resourcesQuestionSnapshotConsumer = snapshot -> {
snapshot.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSettingId);
};
Optional.ofNullable(snapshotList).orElse(Lists.emptyList())
.forEach(resourcesQuestionSnapshotConsumer.andThen(otherConsumer));
return snapshotList;
}
/**
* 根据题目ID集合
* 获取题目快照列表。并配置题目配置ID
*
* @param teacherOpenCourseQuestionSettingId 题目配置ID
* @param questionIdPlural 题目ID复数
* @param questionScore 统一给这些题目ID设置分数
* @return
*/
public List<ResourcesQuestionSnapshot> getResourcesQuestionSnapshotListByQuestionIds (
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目ID列表不能为空") String questionIdPlural,
@NotNull(message = "题目分数不能为空!") final BigDecimal questionScore) {
// 设置题目分数。这个操作也可以在SQL中来做
Consumer<ResourcesQuestionSnapshot> resourcesQuestionSnapshotConsumer = item -> {
item.setQuestionScore(questionScore);
};
return getResourcesQuestionSnapshotListByQuestionIds(
teacherOpenCourseQuestionSettingId, questionIdPlural, resourcesQuestionSnapshotConsumer);
}
/**
* 根据题目类型配置。从开课题库
* 获取题目快照列表。并配置题目配置ID
*
* @param teacherOpenCourseQuestionSettingId
* @param questionSettingOptions
* @return
*/
public List<ResourcesQuestionSnapshot> getOpenResourcesQuestionSnapListBySettingOptions (
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目设置不能为空!") Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
List<ResourcesQuestionSnapshot> result = new ArrayList<>();
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
// 根据配置随机出题。这里直接设置题目的分值。
List<TeacherOpenCourseMergeResourcesQuestion> randomMergeResourcesQuestionList =
teacherOpenCourseMergeResourcesQuestionDao.getRandomMergeResourcesQuestionList(questionSettingOption);
setRQNewCourseInfoId(randomMergeResourcesQuestionList, courseInfoIdPair);
// 放入最终的集合中
result.addAll(getResourcesQuestionSnapshotList(randomMergeResourcesQuestionList, teacherOpenCourseQuestionSettingId, e -> {}));
}
return result;
}
/**
* 根据题目类型配置。从系统题库获取
* 获取题目快照列表。并配置题目配置ID
* 导入课程,用此方法。
* 会从系统题库查找
*
* @param teacherOpenCourseQuestionSettingId
* @param questionSettingOptions
* @return
*/
public List<ResourcesQuestionSnapshot> getMergeResourcesQuestionSnapListByQuestionSettingOptionsBySystem (
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目设置不能为空!") Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
List<ResourcesQuestionSnapshot> result = new ArrayList<>();
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
// 根据配置随机出题。这里直接设置题目的分值。
List<TeacherOpenCourseMergeResourcesQuestion> randomMergeResourcesQuestionList =
teacherOpenCourseMergeResourcesQuestionDao.getRandomMergeResourcesQuestionListBySystem(questionSettingOption);
setRQNewCourseInfoId(randomMergeResourcesQuestionList, courseInfoIdPair);
// 放入最终的集合中
result.addAll(getResourcesQuestionSnapshotList(randomMergeResourcesQuestionList, teacherOpenCourseQuestionSettingId, e -> {}));
}
return result;
}
/**
* 学生端-开课相关
* 查询学生的得分信息
* 从题目日志中去算结果(会存在不准的情况)
* 替代函数{@link #getScoreInfo1}
*
* @param questionSettingId 开课题目配置ID
* @param questionLogAddType 题目提交类型
* @return
*/
@Deprecated
public TeacherOpenCourseQuestionLogScoreInfo getScoreInfo(
@NotNull(message = "开课题目配置ID不能为空") final Long questionSettingId,
@NotNull(message = "题目提交类型不能为空!") QuestionLogAddTypeEnum questionLogAddType) {
// 查询学生身份
Student student = getStudent();
Assert.notNull(student, "该接口只能学生访问");
Long studentId = student.getStudentId();
// teacherOpenCourseQuestionSettingService
// .validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// 给实体类传参数剩下来的交给Fetch 来处理
// 查询符合条件的实体
TeacherOpenCourseQuestionLogScoreInfo scoreInfo = sqlManager.executeQueryOne(
new SQLReady("SELECT ? as teacher_open_course_question_setting_id, ? as student_id, ? as question_log_add_type",
questionSettingId, studentId, questionLogAddType), TeacherOpenCourseQuestionLogScoreInfo.class);
dictParser(scoreInfo);
return scoreInfo;
}
/**
* 学生端-开课相关
* 查询学生的得分信息
*
* @param questionSettingId 开课题目配置ID
* @param questionLogAddType 题目提交类型
* @return
*/
public TeacherOpenCourseQuestionLogScoreInfo1 getScoreInfo1(
@NotNull(message = "开课题目配置ID不能为空") final Long questionSettingId,
@NotNull(message = "题目提交类型不能为空!") QuestionLogAddTypeEnum questionLogAddType) {
// 查询学生身份
Student student = getStudent();
Assert.notNull(student, "该接口只能学生访问");
Long studentId = student.getStudentId();
// teacherOpenCourseQuestionSettingService
// .validateFinallySubmitThrow(questionSettingId, studentId, "该试卷暂无题目!", "未交卷状态,无法查看成绩!");
// 给实体类传参数剩下来的交给Fetch 来处理
// 查询符合条件的实体
TeacherOpenCourseQuestionLogScoreInfo1 scoreInfo = sqlManager.executeQueryOne(
new SQLReady("SELECT ? as teacher_open_course_question_setting_id, ? as student_id, ? as question_log_add_type",
questionSettingId, studentId, questionLogAddType), TeacherOpenCourseQuestionLogScoreInfo1.class);
dictParser(scoreInfo);
return scoreInfo;
}
/**
* 简单获取题目的信息
* @param query 开课题目配置ID
* @return
*/
public PageQuery<TeacherOpenCourseQuestionTestSimpleInfoVO> getQuestionTestSimpleInfo(@NotNull TeacherOpenCourseQuestionTestSimpleInfoDTO query) {
Student student = getStudent();
Assert.notNull(student, "该接口只允许学生访问");
PageQuery pageQuery = query.getPageQuery(); pageQuery.setPara("studentId", student.getStudentId());
// 默认只查询普通最终提交
query.setQuestionLogAddType(defaultIfNull(query.getQuestionLogAddType(), FINALLY_SUBMIT));
PageQuery<TeacherOpenCourseQuestionTestSimpleInfoVO> questionTestSimpleInfo = resourcesQuestionSnapshotDao.getQuestionTestSimpleInfo(pageQuery);
dictParser(questionTestSimpleInfo.getList());
return questionTestSimpleInfo;
}
/**
* 题目测试后的结果
*
* @param query 分页
* @return
*/
public PageQuery<TeacherOpenCourseQuestionTestDetailVO> questionTestResults(@NotNull(message = "参数不能为空!") final PageQuery query) {
return resourcesQuestionSnapshotDao.questionTestResults(query);
}
/**
* @param teacherOpenCourseIds
* @param chapterIds
* @param teacherOpenCourseKnowledgePointsIds
* @return
*/
public Object bindKnowledgePoints(@NotBlank(message = "开课ID不能为空") String teacherOpenCourseIds,
@NotBlank(message = "章节ID不能为空") String chapterIds,
@NotEmpty(message = "知识点ID不能为空") Set<Long> teacherOpenCourseKnowledgePointsIds) {
return null;
}
@Override
public void resetOperationByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId) {
log.info("重置题目快照!");
TeacherOpenCourseQuestionSettingQuery teacherOpenCourseQuestionSettingQuery = new TeacherOpenCourseQuestionSettingQuery();
teacherOpenCourseQuestionSettingQuery.setTeacherOpenCourseId(teacherOpenCourseId);
List<TeacherOpenCourseQuestionSetting> valuesByQuery =
teacherOpenCourseQuestionSettingService.getValuesByQuery(teacherOpenCourseQuestionSettingQuery);
if (ObjectUtil.isNotEmpty(valuesByQuery)) {
Set<Long> settingIdSet = valuesByQuery.stream()
.map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toSet());
deleteBySettingIds(join(settingIdSet.toArray(), ","));
}
}
@Override
public void deleteTeacherOpenCourseAllRelatedByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId) {
log.info("需要实现删除操作!");
}
}