考证辅导 考题,未完

beetlsql3-dev
Mlxa0324 2 years ago
parent f0c7ca4d59
commit 30802fee9f

@ -397,7 +397,7 @@ CREATE TABLE `general_resources_question_snapshot` (
`general_resources_question_snapshot_id` bigint(20) NOT NULL COMMENT '通用题目快照ID',
`general_question_setting_id` bigint(20) NOT NULL COMMENT '通用题目配置ID',
`business_course_info_id` bigint(20) DEFAULT NULL COMMENT '业务课程ID',
`business_course_info_type` bigint(20) DEFAULT NULL COMMENT '业务课程类型',
`business_course_info_type` varchar(30) DEFAULT NULL COMMENT '业务课程类型(枚举 BusinessCourseInfoEnum',
`question_type` int(2) DEFAULT NULL COMMENT '题型(1单选 2多选 3判断 4填空 5分析)',
`question_score` decimal(3,1) DEFAULT NULL COMMENT '分值',
`question_stem` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题干',

@ -21,7 +21,7 @@ public interface GeneralQuestionSettingDao extends BaseMapper<GeneralQuestionSet
PageQuery<GeneralQuestionSetting> queryByCondition(PageQuery query);
PageQuery<GeneralQuestionSetting> queryByConditionQuery(PageQuery query);
@Update
void deleteGeneralQuestionSettingByIds(String ids);
void logicDeleteGeneralQuestionLogBySettingIds(String ids);
@Update
void deleteByIds(String ids);
@Update

@ -1,6 +1,7 @@
package com.ibeetl.jlw.dao;
import com.ibeetl.jlw.entity.GeneralResourcesQuestionSnapshot;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.web.query.GeneralResourcesQuestionSnapshotQuery;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.mapper.BaseMapper;
@ -23,9 +24,19 @@ public interface GeneralResourcesQuestionSnapshotDao extends BaseMapper<GeneralR
@Update
void deleteGeneralResourcesQuestionSnapshotByIds(String ids);
@Update
int deleteByTeacherOpenCourseQuestionSettingIds(String settingIds);
@Update
int updateGivenByIds(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery);
List<GeneralResourcesQuestionSnapshot> getByIds(String ids);
List<GeneralResourcesQuestionSnapshot> getValuesByQuery(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery);
List<GeneralResourcesQuestionSnapshot> getValuesByQueryNotWithPermission(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery);
List<Map<String,Object>>getExcelValues(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery);
/**
*
* @param questionSettingOption
* @return
*/
List<GeneralResourcesQuestionSnapshot> getQuestionBySettingOptionDTO(QuestionSettingDTO questionSettingOption);
}

@ -26,4 +26,5 @@ public interface ResourcesQuestionDao extends BaseMapper<ResourcesQuestion>{
List<ResourcesQuestion> getByIds (String resourcesQuestionIds);
List<ResourcesQuestion> getValuesByQuery (ResourcesQuestionQuery resourcesQuestionQuery);
List<CourseInfo> getValuesToCourseInfo(CourseInfoQuery courseInfoQuery);
List<ResourcesQuestion> getValuesByQueryNotWithPermission(ResourcesQuestionQuery resourcesQuestionQuery);
}

@ -1,7 +1,7 @@
package com.ibeetl.jlw.dao;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeResourcesQuestion;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionSettingVO;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeResourcesQuestionQuery;
import org.beetl.sql.core.engine.PageQuery;
@ -39,14 +39,14 @@ public interface TeacherOpenCourseMergeResourcesQuestionDao extends BaseMapper<T
* @param questionSettingDTO
* @return
*/
List<TeacherOpenCourseMergeResourcesQuestion> getRandomMergeResourcesQuestionList(TeacherOpenCourseQuestionSettingDTO questionSettingDTO);
List<TeacherOpenCourseMergeResourcesQuestion> getRandomMergeResourcesQuestionList(QuestionSettingDTO questionSettingDTO);
/**
* ID
* @param questionSettingDTO
* @return
*/
List<TeacherOpenCourseMergeResourcesQuestion> getRandomMergeResourcesQuestionListBySystem(TeacherOpenCourseQuestionSettingDTO questionSettingDTO);
List<TeacherOpenCourseMergeResourcesQuestion> getRandomMergeResourcesQuestionListBySystem(QuestionSettingDTO questionSettingDTO);
/**
* ID

@ -3,6 +3,7 @@ package com.ibeetl.jlw.entity;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.ibeetl.jlw.enums.BusinessCourseInfoEnum;
import lombok.*;
import lombok.experimental.Accessors;
import org.beetl.sql.annotation.entity.AssignID;
@ -39,7 +40,7 @@ public class GeneralResourcesQuestionSnapshot extends BaseEntity{
//业务课程类型
private Long businessCourseInfoType ;
private BusinessCourseInfoEnum businessCourseInfoType ;
//题型(1单选 2多选 3判断 4填空 5分析)

@ -6,7 +6,7 @@ import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.annotation.DictEnum;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import lombok.Data;
@ -204,7 +204,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
)
@UpdateIgnore
@InsertIgnore
private List<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions;
private List<QuestionSettingDTO> questionSettingOptions;
/**
*

@ -25,7 +25,7 @@ import java.math.BigDecimal;
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class TeacherOpenCourseQuestionSettingDTO {
public class QuestionSettingDTO {
/**
*

@ -0,0 +1,22 @@
package com.ibeetl.jlw.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.beetl.sql.annotation.entity.EnumMapping;
/**
*
* @author lx
*/
@Getter
@AllArgsConstructor
@EnumMapping("name")
public enum BusinessCourseInfoEnum {
SYSTEM_QUESTION("系统题库"),
OPEN_COURSE_QUESTION( "开课题库");
private String text;
}

@ -28,6 +28,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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;
@ -58,7 +59,8 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
@Autowired private GeneralQuestionLogDao generalQuestionLogDao;
@Autowired private StudentDao studentDao;
@Autowired private GeneralQuestionSettingService generalQuestionSettingService;
@Autowired @Lazy
private GeneralQuestionSettingService generalQuestionSettingService;
public PageQuery<GeneralQuestionLog>queryByCondition(PageQuery query){
PageQuery ret = generalQuestionLogDao.queryByCondition(query);
@ -464,6 +466,8 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
final Student student = studentDao.getByUserId(getUserId());
GeneralQuestionSetting info = generalQuestionSettingService.getInfo(questionSettingId);
Assert.notNull(info, "题目配置ID有误");
switch(info.getGeneralQuestionSettingType()) {
case HOMEWORK_FILE: {
addFileRelatedLog(join(questionLogMap.values().toArray(), ","), questionSettingId, student);
@ -519,7 +523,7 @@ public class GeneralQuestionLogService extends CoreBaseService<GeneralQuestionLo
.build();
List<GeneralQuestionLog> logList = generalQuestionLogDao.getValuesByQuery(questionLogQuery);
Assert.notEmpty(logList, "未查询到题目");
Assert.notEmpty(logList, "未查询到题目信息");
// 处理答案和分数
logList.forEach(questionLog -> {
// 学生提交的答案

@ -14,6 +14,7 @@ import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.GeneralQuestionLogDao;
import com.ibeetl.jlw.dao.GeneralQuestionSettingDao;
import com.ibeetl.jlw.dao.GeneralResourcesQuestionSnapshotDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
@ -54,9 +55,11 @@ import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.HOMEWOR
public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuestionSetting>{
@Autowired private GeneralQuestionSettingDao generalQuestionSettingDao;
@Autowired private GeneralResourcesQuestionSnapshotDao generalResourcesQuestionSnapshotDao;
@Autowired private GeneralQuestionLogDao generalQuestionLogDao;
@Autowired private GeneralQuestionLogService generalQuestionLogService;
@Autowired private GeneralResourcesQuestionSnapshotService generalResourcesQuestionSnapshotService;
@Autowired private ResourcesQuestionService resourcesQuestionService;
public PageQuery<GeneralQuestionSetting>queryByCondition(PageQuery query){
PageQuery ret = generalQuestionSettingDao.queryByCondition(query);
@ -81,9 +84,16 @@ public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuesti
}
}
public void deleteGeneralQuestionSetting(String ids){
public void logicDeleteGeneralQuestionLogBySettingIds(String ids){
try {
generalQuestionSettingDao.deleteGeneralQuestionSettingByIds(ids);
generalQuestionSettingDao.logicDeleteGeneralQuestionLogBySettingIds(ids);
} catch (Exception e) {
throw new PlatformException("批量删除通用题目配置失败", e);
}
}
public void deleteByIds(String ids){
try {
generalQuestionSettingDao.deleteByIds(ids);
} catch (Exception e) {
throw new PlatformException("批量删除通用题目配置失败", e);
}
@ -490,5 +500,76 @@ public class GeneralQuestionSettingService extends CoreBaseService<GeneralQuesti
return resourcesQuestionSnapshots;
}
public void deleteSettingAndSnapByIds(@NotEmpty String settingIds) {
generalQuestionSettingDao.deleteByIds(settingIds);
generalResourcesQuestionSnapshotService.deleteGeneralResourcesQuestionSnapshot(settingIds);
}
/**
*
*
* <p>
*
*
*
* @param settingQuery
* @return
*/
// public void addSettingBySystemCourse(@Validated(ValidateConfig.ADD.class) GeneralQuestionSettingQuery settingQuery, Map<Long, Long> courseInfoIdPair ) {
//
// if (null == settingQuery.getGeneralQuestionSettingStatus()) {
// settingQuery.setGeneralQuestionSettingStatus(1);
// }
// if (null == settingQuery.getGeneralQuestionSettingPushStatus()) {
// settingQuery.setGeneralQuestionSettingPushStatus(UN_PUSH);
// }
//
// // 添加到作业主表中
// add(settingQuery);
//
// // 插入快照
// final Long teacherOpenCourseQuestionSettingId = settingQuery.getGeneralQuestionSettingId();
// List<QuestionSettingDTO> questionSettingOptions = settingQuery.getQuestionSettingOptions();
//
// List<GeneralResourcesQuestionSnapshot> list = generalResourcesQuestionSnapshotService
// .getQuestionBySettingOptionDTOList(questionSettingOptions, courseInfoIdPair);
//
// list.forEach(item -> {
// item.setGeneralQuestionSettingId(teacherOpenCourseQuestionSettingId);
// item.setBusinessCourseInfoId(settingQuery.getBussinessId());
// item.setBusinessCourseInfoType(SYSTEM_QUESTION);
// });
//
// // 传入的开课题目IDS
// String resourcesQuestionIdPlural = settingQuery.getResourcesQuestionIdPlural();
// // 题目类型区分
// Collection<QuestionSettingDTO> settingDTOList = null;
//
// if(ObjectUtil.isNotEmpty(resourcesQuestionIdPlural)) {
// TeacherOpenCourseMergeResourcesQuestionQuery questionQuery = new TeacherOpenCourseMergeResourcesQuestionQuery();
// questionQuery.setQuestionStatus(1);
// questionQuery.setTeacherOpenCourseMergeResourcesQuestionIdPlural(resourcesQuestionIdPlural);
// List<TeacherOpenCourseMergeResourcesQuestion> list =
// resourcesQuestionService.getValuesByQueryNotWithPermission(questionQuery);
//
// // 无差别题目IDS转换成类型区分的集合
// Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> map =
// teacherOpenCourseMergeResourcesQuestionService.buildSettingDtoListByNoDiffQuestionList(list);
//
// // 设置分值
// settingQuery.getQuestionSettingOptions().forEach(item -> {
// QuestionSettingDTO settingDTO = map.get(item.getQuestionType());
// if(ObjectUtil.isAllNotEmpty(settingDTO, item.getSingleScore())) {
// settingDTO.setSingleScore(item.getSingleScore());
// }
// });
//
// if (ObjectUtil.isNotEmpty(map)) { settingDTOList = map.values(); }
// } else {
// settingDTOList = settingQuery.getQuestionSettingOptions();
// }
//
// generalResourcesQuestionSnapshotDao.insertBatch(list);
// }
}

@ -1,5 +1,7 @@
package com.ibeetl.jlw.service;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -11,6 +13,8 @@ import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.GeneralResourcesQuestionSnapshotDao;
import com.ibeetl.jlw.entity.FileEntity;
import com.ibeetl.jlw.entity.GeneralResourcesQuestionSnapshot;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.BusinessCourseInfoEnum;
import com.ibeetl.jlw.web.query.GeneralResourcesQuestionSnapshotQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -18,6 +22,7 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.assertj.core.util.Lists;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,6 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Nullable;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
@ -73,6 +79,14 @@ public class GeneralResourcesQuestionSnapshotService extends CoreBaseService<Gen
throw new PlatformException("批量删除通用题目快照失败", e);
}
}
public void deleteByTeacherOpenCourseQuestionSettingIds(String ids){
try {
generalResourcesQuestionSnapshotDao.deleteByTeacherOpenCourseQuestionSettingIds(ids);
} catch (Exception e) {
throw new PlatformException("批量删除通用题目快照失败", e);
}
}
public String addAll(GeneralResourcesQuestionSnapshotQuery generalResourcesQuestionSnapshotQuery){
String msg = "";
@ -329,7 +343,7 @@ public class GeneralResourcesQuestionSnapshotService extends CoreBaseService<Gen
GeneralResourcesQuestionSnapshot generalResourcesQuestionSnapshot = new GeneralResourcesQuestionSnapshot();
generalResourcesQuestionSnapshot.setGeneralQuestionSettingId(Long.parseLong(generalQuestionSettingId));
generalResourcesQuestionSnapshot.setBusinessCourseInfoId(Long.parseLong(businessCourseInfoId));
generalResourcesQuestionSnapshot.setBusinessCourseInfoType(Long.parseLong(businessCourseInfoType));
generalResourcesQuestionSnapshot.setBusinessCourseInfoType(EnumUtil.likeValueOf(BusinessCourseInfoEnum.class, businessCourseInfoType));
generalResourcesQuestionSnapshot.setQuestionType(Integer.parseInt(questionType));
generalResourcesQuestionSnapshot.setQuestionScore(new BigDecimal(questionScore));
generalResourcesQuestionSnapshot.setQuestionStem(questionStem);
@ -362,5 +376,46 @@ public class GeneralResourcesQuestionSnapshotService extends CoreBaseService<Gen
return generalResourcesQuestionSnapshotDao.getExcelValues(generalResourcesQuestionSnapshotQuery);
}
/**
* IDID
*
* @param insertList
* @param courseInfoIdPair
*/
public void setNewCourseInfoId(Collection<GeneralResourcesQuestionSnapshot> insertList, Map<Long, Long> courseInfoIdPair) {
if (ObjectUtil.isAllNotEmpty(insertList, courseInfoIdPair)) {
insertList.forEach(item -> {
Long courseMergeCourseInfoId = item.getBusinessCourseInfoId();
item.setBusinessCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
});
}
}
/**
*
*
* @param questionSettingOptions
* @param courseInfoIdPair ID
*/
public List<GeneralResourcesQuestionSnapshot> getQuestionBySettingOptionDTOList(@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
List<GeneralResourcesQuestionSnapshot> result = new ArrayList<>();
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
// 数据库动态设置分数,并获取题目列表
List<GeneralResourcesQuestionSnapshot> insertList =
generalResourcesQuestionSnapshotDao.getQuestionBySettingOptionDTO(questionSettingOption);
if (ObjectUtil.isNotEmpty(insertList)) {
setNewCourseInfoId(insertList, courseInfoIdPair);
result.addAll(insertList);
}
}
return result;
}
return Lists.emptyList();
}
}

@ -16,7 +16,7 @@ import com.ibeetl.jlw.entity.CourseInfo;
import com.ibeetl.jlw.entity.FileEntity;
import com.ibeetl.jlw.entity.ResourcesQuestion;
import com.ibeetl.jlw.entity.UniversitiesCollegesJurisdictionExperimentalSystem;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.ResourcesQuestionTypeEnum;
import com.ibeetl.jlw.web.query.CourseInfoQuery;
import com.ibeetl.jlw.web.query.ResourcesQuestionQuery;
@ -150,6 +150,9 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
public List<ResourcesQuestion> getValuesByQuery (ResourcesQuestionQuery resourcesQuestionQuery){
return resourcesQuestionDao.getValuesByQuery(resourcesQuestionQuery);
}
public List<ResourcesQuestion> getValuesByQueryNotWithPermission (ResourcesQuestionQuery resourcesQuestionQuery){
return resourcesQuestionDao.getValuesByQueryNotWithPermission(resourcesQuestionQuery);
}
public List<ResourcesQuestion> getValues (Object paras){
return sqlManager.select(SqlId.of("jlw.resourcesQuestion.getResourcesQuestionValues"),ResourcesQuestion.class,paras);
@ -675,7 +678,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
* @param noDiffResourcesQuestionIdPlural IDResourcesQuestion
* @return
*/
public Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> buildSettingDtoListByNoDiffQuestionIds(
public Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> buildSettingDtoListByNoDiffQuestionIds(
@NotEmpty(message = "系统题目ID不能为空") String noDiffResourcesQuestionIdPlural) {
// 只查询正常状态的题目列表
@ -694,7 +697,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
* @param resourcesQuestionList
* @return
*/
public <T extends ResourcesQuestion> Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
public <T extends ResourcesQuestion> Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
List<T> resourcesQuestionList) {
return buildSettingDtoListByNoDiffQuestionList(resourcesQuestionList, ResourcesQuestion::getResourcesQuestionId);
}
@ -706,7 +709,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
* @param resourcesQuestionList
* @return
*/
public <T extends ResourcesQuestion> Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
public <T extends ResourcesQuestion> Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
List<T> resourcesQuestionList, Function<T, Long> function) {
if (ObjectUtil.isEmpty(resourcesQuestionList)) {
@ -714,40 +717,40 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
}
// 先构建初始的属性
Function<T, TeacherOpenCourseQuestionSettingDTO> buildFunc =
item -> TeacherOpenCourseQuestionSettingDTO.builder()
Function<T, QuestionSettingDTO> buildFunc =
item -> QuestionSettingDTO.builder()
.questionType(EnumUtil.likeValueOf(ResourcesQuestionTypeEnum.class, item.getQuestionType()))
.resourcesQuestionIdPlural(function.apply(item).toString())
.singleScore(item.getQuestionScore())
.build();
// 根据类型分组
Map<ResourcesQuestionTypeEnum, List<TeacherOpenCourseQuestionSettingDTO>> groupMap =
resourcesQuestionList.stream().map(buildFunc).collect(groupingBy(TeacherOpenCourseQuestionSettingDTO::getQuestionType));
Map<ResourcesQuestionTypeEnum, List<QuestionSettingDTO>> groupMap =
resourcesQuestionList.stream().map(buildFunc).collect(groupingBy(QuestionSettingDTO::getQuestionType));
Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> result = new ConcurrentHashMap<>(5);
Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> result = new ConcurrentHashMap<>(5);
// 分组后的数据,再处理
groupMap.forEach((key, value) -> {
// resourcesQuestionIdPlural 上面暂存的是单个题目ID这里将所有的题目ID处理成逗号隔开的字符
String questionIds = value.stream()
.map(TeacherOpenCourseQuestionSettingDTO::getResourcesQuestionIdPlural).collect(joining(","));
.map(QuestionSettingDTO::getResourcesQuestionIdPlural).collect(joining(","));
// 查询到的题目的数量
Integer selectCount = ObjectUtil.defaultIfNull(value, Lists.emptyList()).size();
// 设置其他属性,如果集合长度不为空的话
if (selectCount > 0) {
TeacherOpenCourseQuestionSettingDTO teacherOpenCourseQuestionSettingDTO = value.get(0);
QuestionSettingDTO questionSettingDTO = value.get(0);
// 该类型下,单个题目的分数
BigDecimal singleScore = teacherOpenCourseQuestionSettingDTO.getSingleScore();
teacherOpenCourseQuestionSettingDTO.setResourcesQuestionIdPlural(questionIds)
BigDecimal singleScore = questionSettingDTO.getSingleScore();
questionSettingDTO.setResourcesQuestionIdPlural(questionIds)
.setSingleTypeTotalScore(NumberUtil.mul(singleScore, selectCount))
.setSelectCount(selectCount);
// 放入结果集中
result.put(key, teacherOpenCourseQuestionSettingDTO);
result.put(key, questionSettingDTO);
}
});
return result;

@ -14,7 +14,7 @@ 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.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionTestDetailVO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionTestSimpleInfoVO;
import com.ibeetl.jlw.web.query.ResourcesQuestionSnapshotQuery;
@ -199,7 +199,7 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
* @param courseInfoIdPair
*/
public void insertBatchByOpenResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 在插入之前,先清空列表。这种情况下,支持题目配置还在,重置题目列表的操作。
@ -222,7 +222,7 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
* @param courseInfoIdPair
*/
public void insertBatchBySystemResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 在插入之前,先清空列表。这种情况下,支持题目配置还在,重置题目列表的操作。
deleteByTeacherOpenCourseQuestionSettingIds(teacherOpenCourseQuestionSettingId.toString());
@ -249,7 +249,7 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
* @param courseInfoIdPair
*/
public List<ResourcesQuestionSnapshot> getByOpenCourseResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 数据库动态设置分数,并获取题目列表
@ -270,7 +270,7 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
* @param courseInfoIdPair
*/
public List<ResourcesQuestionSnapshot> getBySystemResourcesQuestion(@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@Nullable Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 题目设置,来动态获取题目
if(ObjectUtil.isNotEmpty(questionSettingOptions)) {
// 数据库动态设置分数,并获取题目列表
@ -284,6 +284,8 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
return Lists.emptyList();
}
/**
* IDID
*
@ -291,10 +293,12 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
* @param courseInfoIdPair
*/
public void setNewCourseInfoId(@NotNull Collection<ResourcesQuestionSnapshot> insertList, @NotNull Map<Long, Long> courseInfoIdPair) {
insertList.forEach(item -> {
Long courseMergeCourseInfoId = item.getTeacherOpenCourseMergeCourseInfoId();
item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
});
if (ObjectUtil.isAllNotEmpty(insertList, courseInfoIdPair)) {
insertList.forEach(item -> {
Long courseMergeCourseInfoId = item.getTeacherOpenCourseMergeCourseInfoId();
item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.getOrDefault(courseMergeCourseInfoId, courseMergeCourseInfoId));
});
}
}
/**
@ -389,11 +393,11 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
*/
public List<ResourcesQuestionSnapshot> getOpenResourcesQuestionSnapListBySettingOptions (
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目设置不能为空!") Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@NotBlank(message = "题目设置不能为空!") Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
List<ResourcesQuestionSnapshot> result = new ArrayList<>();
for (TeacherOpenCourseQuestionSettingDTO questionSettingOption : questionSettingOptions) {
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
// 根据配置随机出题。这里直接设置题目的分值。
List<TeacherOpenCourseMergeResourcesQuestion> randomMergeResourcesQuestionList =
teacherOpenCourseMergeResourcesQuestionDao.getRandomMergeResourcesQuestionList(questionSettingOption);
@ -417,11 +421,11 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService<ResourcesQ
*/
public List<ResourcesQuestionSnapshot> getMergeResourcesQuestionSnapListByQuestionSettingOptionsBySystem (
@NotNull(message = "开课题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotBlank(message = "题目设置不能为空!") Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@NotBlank(message = "题目设置不能为空!") Collection<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
List<ResourcesQuestionSnapshot> result = new ArrayList<>();
for (TeacherOpenCourseQuestionSettingDTO questionSettingOption : questionSettingOptions) {
for (QuestionSettingDTO questionSettingOption : questionSettingOptions) {
// 根据配置随机出题。这里直接设置题目的分值。
List<TeacherOpenCourseMergeResourcesQuestion> randomMergeResourcesQuestionList =
teacherOpenCourseMergeResourcesQuestionDao.getRandomMergeResourcesQuestionListBySystem(questionSettingOption);

@ -23,7 +23,7 @@ import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeCourseInfoDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeCourseInfoQuery;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@ -170,7 +170,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
.map(TeacherOpenCourseMergeCourseInfo::getTeacherOpenCourseMergeCourseInfoId).collect(toSet());
if(ObjectUtil.isNotEmpty(idSet)) {
teacherOpenCourseQuestionSettingService.deleteWithQuestionSnapByIds(join(idSet.toArray(), ","));
teacherOpenCourseQuestionSettingService.deleteSettingAndSnapByIds(join(idSet.toArray(), ","));
}
}
teacherOpenCourseMergeCourseInfoDao.deleteTeacherOpenCourseMergeCourseInfoByIds(ids);
@ -240,7 +240,7 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
*/
public JsonResult addCourseAndQuestionWithQuestionSnap(@Validated(ValidateConfig.ADD.class) @NotNull(message = "开课题目信息不能为空!")
TeacherOpenCourseMergeCourseInfoQuery teacherOpenCourseMergeCourseInfoQuery,
@Nullable List<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
@Nullable List<QuestionSettingDTO> questionSettingOptions, Map<Long, Long> courseInfoIdPair) {
// 添加开课课程表
JsonResult jsonResult = add(teacherOpenCourseMergeCourseInfoQuery);

@ -20,7 +20,7 @@ import com.ibeetl.jlw.entity.CourseInfo;
import com.ibeetl.jlw.entity.FileEntity;
import com.ibeetl.jlw.entity.ResourcesQuestion;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeResourcesQuestion;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.entity.vo.TeacherOpenCourseQuestionSettingVO;
import com.ibeetl.jlw.enums.ResourcesQuestionTypeEnum;
import com.ibeetl.jlw.web.query.ResourcesQuestionQuery;
@ -532,7 +532,7 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
* @param resourcesQuestionList
* @return
*/
public <T extends TeacherOpenCourseMergeResourcesQuestion> Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
public <T extends TeacherOpenCourseMergeResourcesQuestion> Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
List<T> resourcesQuestionList) {
return buildSettingDtoListByNoDiffQuestionList(resourcesQuestionList, TeacherOpenCourseMergeResourcesQuestion::getTeacherOpenCourseMergeResourcesQuestionId);
}
@ -544,7 +544,7 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
* @param resourcesQuestionList
* @return
*/
public <T extends TeacherOpenCourseMergeResourcesQuestion> Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
public <T extends TeacherOpenCourseMergeResourcesQuestion> Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> buildSettingDtoListByNoDiffQuestionList(
List<T> resourcesQuestionList, Function<T, Long> function) {
if (ObjectUtil.isEmpty(resourcesQuestionList)) {
@ -552,40 +552,40 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
}
// 先构建初始的属性
Function<T, TeacherOpenCourseQuestionSettingDTO> buildFunc =
item -> TeacherOpenCourseQuestionSettingDTO.builder()
Function<T, QuestionSettingDTO> buildFunc =
item -> QuestionSettingDTO.builder()
.questionType(EnumUtil.likeValueOf(ResourcesQuestionTypeEnum.class, item.getQuestionType()))
.resourcesQuestionIdPlural(function.apply(item).toString())
.singleScore(item.getQuestionScore())
.build();
// 根据类型分组
Map<ResourcesQuestionTypeEnum, List<TeacherOpenCourseQuestionSettingDTO>> groupMap =
resourcesQuestionList.stream().map(buildFunc).collect(groupingBy(TeacherOpenCourseQuestionSettingDTO::getQuestionType));
Map<ResourcesQuestionTypeEnum, List<QuestionSettingDTO>> groupMap =
resourcesQuestionList.stream().map(buildFunc).collect(groupingBy(QuestionSettingDTO::getQuestionType));
Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> result = new ConcurrentHashMap<>(5);
Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> result = new ConcurrentHashMap<>(5);
// 分组后的数据,再处理
groupMap.forEach((key, value) -> {
// resourcesQuestionIdPlural 上面暂存的是单个题目ID这里将所有的题目ID处理成逗号隔开的字符
String questionIds = value.stream()
.map(TeacherOpenCourseQuestionSettingDTO::getResourcesQuestionIdPlural).collect(joining(","));
.map(QuestionSettingDTO::getResourcesQuestionIdPlural).collect(joining(","));
// 查询到的题目的数量
Integer selectCount = ObjectUtil.defaultIfNull(value, Collections.emptyList()).size();
// 设置其他属性,如果集合长度不为空的话
if (selectCount > 0) {
TeacherOpenCourseQuestionSettingDTO teacherOpenCourseQuestionSettingDTO = value.get(0);
QuestionSettingDTO questionSettingDTO = value.get(0);
// 该类型下,单个题目的分数
BigDecimal singleScore = teacherOpenCourseQuestionSettingDTO.getSingleScore();
teacherOpenCourseQuestionSettingDTO.setResourcesQuestionIdPlural(questionIds)
BigDecimal singleScore = questionSettingDTO.getSingleScore();
questionSettingDTO.setResourcesQuestionIdPlural(questionIds)
.setSingleTypeTotalScore(NumberUtil.mul(singleScore, selectCount))
.setSelectCount(selectCount);
// 放入结果集中
result.put(key, teacherOpenCourseQuestionSettingDTO);
result.put(key, questionSettingDTO);
}
});
return result;

@ -278,6 +278,8 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
final Student student = studentDao.getByUserId(getUserId());
TeacherOpenCourseQuestionSetting info = teacherOpenCourseQuestionSettingService.getInfo(questionSettingId);
Assert.notNull(info, "题目配置ID有误");
switch(info.getTeacherOpenCourseQuestionSettingType()) {
case HOMEWORK_FILE: {
addFileRelatedLog(join(questionLogMap.values().toArray(), ","), questionSettingId, student);
@ -333,7 +335,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
.build();
List<TeacherOpenCourseQuestionLog> logList = teacherOpenCourseQuestionLogDao.getValuesByQuery(questionLogQuery);
Assert.notEmpty(logList, "未查询到题目");
Assert.notEmpty(logList, "未查询到题目信息");
// 处理答案和分数
logList.forEach(questionLog -> {
// 学生提交的答案

@ -19,7 +19,7 @@ import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionSettingDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.CopyFromEnum;
import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
@ -100,7 +100,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
teacherOpenCourseQuestionSettingDao.deleteByIds(ids);
}
public void deleteWithQuestionSnapByIds(@NotEmpty String settingIds) {
public void deleteSettingAndSnapByIds(@NotEmpty String settingIds) {
teacherOpenCourseQuestionSettingDao.deleteByIds(settingIds);
resourcesQuestionSnapshotService.deleteByTeacherOpenCourseQuestionSettingIds(settingIds);
}
@ -130,8 +130,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
teacherOpenCourseQuestionSetting.setUserId(teacherOpenCourseQuestionSettingQuery.getUserId());
teacherOpenCourseQuestionSetting.setOrgId(teacherOpenCourseQuestionSettingQuery.getOrgId());
// 验证唯一
verifyUnique(teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseId(),
teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseQuestionSettingName());
verifyUniqueChapterExercise(teacherOpenCourseQuestionSettingQuery);
}
insertBatch(teacherOpenCourseQuestionSettingList);
}
@ -143,8 +142,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
TeacherOpenCourseQuestionSetting teacherOpenCourseQuestionSetting = teacherOpenCourseQuestionSettingQuery.pojo();
// 验证唯一
verifyUnique(teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseId(),
teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseQuestionSettingName());
verifyUniqueChapterExercise(teacherOpenCourseQuestionSettingQuery);
teacherOpenCourseQuestionSettingDao.insert(teacherOpenCourseQuestionSetting);
teacherOpenCourseQuestionSettingQuery.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSetting.getTeacherOpenCourseQuestionSettingId());
@ -158,8 +156,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
public String edit(TeacherOpenCourseQuestionSettingQuery teacherOpenCourseQuestionSettingQuery){
// 验证唯一
verifyUnique(teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseId(),
teacherOpenCourseQuestionSettingQuery.getTeacherOpenCourseQuestionSettingName());
verifyUniqueChapterExercise(teacherOpenCourseQuestionSettingQuery);
String msg = "";
TeacherOpenCourseQuestionSetting teacherOpenCourseQuestionSetting = teacherOpenCourseQuestionSettingQuery.pojo();
@ -178,7 +175,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param teacherOpenCourseQuestionSettingName
* @return
*/
public void verifyUnique(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
public void verifyUniqueName(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
@NotEmpty(message = "题目配置名称不能为空!") String teacherOpenCourseQuestionSettingName ) {
// 数据库设计稍微有点不严谨暂时用名字来作为关联的条件所以这里只能保证同一个开课ID下的名字是唯一的
TeacherOpenCourseQuestionSettingQuery settingQuery = new TeacherOpenCourseQuestionSettingQuery();
@ -191,6 +188,37 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
}
}
/**
* ID +
*
*
* ID
*
* @param query
* @return
*/
public void verifyUniqueChapterExercise(@NotNull TeacherOpenCourseQuestionSettingQuery query) {
ResourcesQuestionSnapshotFromTypeEnum settingType = query.getTeacherOpenCourseQuestionSettingType();
// 只验证章节练习
if (CHAPTER_EXERCISE.equals(settingType) && settingType != null) {
// 数据库设计稍微有点不严谨暂时用名字来作为关联的条件所以这里只能保证同一个开课ID下的名字是唯一的
TeacherOpenCourseQuestionSettingQuery settingQuery = new TeacherOpenCourseQuestionSettingQuery();
settingQuery.setTeacherOpenCourseQuestionSettingName(query.getTeacherOpenCourseQuestionSettingName());
settingQuery.setTeacherOpenCourseId(query.getTeacherOpenCourseId());
List<TeacherOpenCourseQuestionSetting> oneList = getValuesByQuery(settingQuery);
// 考虑到编辑的时候,要排除自身
if (ObjectUtil.isNotEmpty(query.getTeacherOpenCourseQuestionSettingId())) {
oneList.removeIf(s -> s.getTeacherOpenCourseQuestionSettingId().equals(query.getTeacherOpenCourseQuestionSettingId()));
}
if(ObjectUtil.isNotEmpty(oneList)) {
throw new PlatformException("当前开课下的题目配置名称重复,请重新设置!");
}
}
}
public String updateGivenByIds(TeacherOpenCourseQuestionSettingQuery teacherOpenCourseQuestionSettingQuery){
String msg = "";
if(StringUtils.isNotBlank(teacherOpenCourseQuestionSettingQuery.get_given())){
@ -244,13 +272,13 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
*
*/
public void addFrom(@Validated(ValidateConfig.ADD.class) TeacherOpenCourseMergeCourseInfoQuery teacherOpenCourseMergeCourseInfoQuery,
@Nullable Collection<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions, CopyFromEnum copyFrom, Map<Long, Long> courseInfoIdPair) {
@Nullable Collection<QuestionSettingDTO> questionSettingOptions, CopyFromEnum copyFrom, Map<Long, Long> courseInfoIdPair) {
Long teacherOpenCourseId = teacherOpenCourseMergeCourseInfoQuery.getTeacherOpenCourseId();
TeacherOpenCourseQuestionSettingQuery settingQuery = new TeacherOpenCourseQuestionSettingQuery();
// 设置章节练习的默认配置并设置开课ID
settingQuery.setCourseTestDefault().setTeacherOpenCourseId(teacherOpenCourseId);
settingQuery.setChapterExerciseDefault().setTeacherOpenCourseId(teacherOpenCourseId);
settingQuery.setTeacherOpenCourseQuestionSettingName(teacherOpenCourseMergeCourseInfoQuery.getCourseInfoName());
settingQuery.setQuestionSettingOptions(new ArrayList<>(questionSettingOptions));
@ -283,7 +311,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
// 编辑操作
if(ObjectUtil.isNotEmpty(settingQuery.getTeacherOpenCourseQuestionSettingId())) {
String editSettingIds = settingQuery.getTeacherOpenCourseQuestionSettingId().toString();
deleteWithQuestionSnapByIds(editSettingIds);
deleteSettingAndSnapByIds(editSettingIds);
// 删除主键,用于下面的保存方法
settingQuery.setTeacherOpenCourseQuestionSettingId(null);
}
@ -296,7 +324,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
// 传入的开课题目IDS
String resourcesQuestionIdPlural = settingQuery.getResourcesQuestionIdPlural();
// 题目类型区分
Collection<TeacherOpenCourseQuestionSettingDTO> settingDTOList = null;
Collection<QuestionSettingDTO> settingDTOList = null;
if(ObjectUtil.isNotEmpty(resourcesQuestionIdPlural)) {
TeacherOpenCourseMergeResourcesQuestionQuery questionQuery = new TeacherOpenCourseMergeResourcesQuestionQuery();
@ -306,12 +334,12 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
teacherOpenCourseMergeResourcesQuestionService.getValuesByQueryNotWithPermission(questionQuery);
// 无差别题目IDS转换成类型区分的集合
Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> map =
Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> map =
teacherOpenCourseMergeResourcesQuestionService.buildSettingDtoListByNoDiffQuestionList(list);
// 设置分值
settingQuery.getQuestionSettingOptions().forEach(item -> {
TeacherOpenCourseQuestionSettingDTO settingDTO = map.get(item.getQuestionType());
QuestionSettingDTO settingDTO = map.get(item.getQuestionType());
if(ObjectUtil.isAllNotEmpty(settingDTO, item.getSingleScore())) {
settingDTO.setSingleScore(item.getSingleScore());
}
@ -350,7 +378,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
// 插入快照
Long teacherOpenCourseQuestionSettingId = settingQuery.getTeacherOpenCourseQuestionSettingId();
List<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions = settingQuery.getQuestionSettingOptions();
List<QuestionSettingDTO> questionSettingOptions = settingQuery.getQuestionSettingOptions();
resourcesQuestionSnapshotService.insertBatchBySystemResourcesQuestion(teacherOpenCourseQuestionSettingId, questionSettingOptions, courseInfoIdPair);
}
@ -366,7 +394,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param courseInfoIdWithQuestionSettingOptions KeyValueID
*/
public void addSettingByOpenCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
@Nullable Map<TeacherOpenCourseMergeCourseInfo, Collection<TeacherOpenCourseQuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@Nullable Map<TeacherOpenCourseMergeCourseInfo, Collection<QuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@NotNull Map<Long, Long> courseInfoIdPair) {
addSettingByOpenCourse(teacherOpenCourseId, courseInfoIdWithQuestionSettingOptions, Integer.valueOf(2), TeacherOpenCourseMergeCourseInfo::getCourseInfoType, courseInfoIdPair);
}
@ -387,11 +415,11 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param courseInfoIdPair
*/
public void addSettingByOpenCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
@Nullable Map<TeacherOpenCourseMergeCourseInfo, Collection<TeacherOpenCourseQuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@Nullable Map<TeacherOpenCourseMergeCourseInfo, Collection<QuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@NotNull Object eq, @NotNull Func1<TeacherOpenCourseMergeCourseInfo, Integer> func1, @NotNull Map<Long, Long> courseInfoIdPair) {
TeacherOpenCourseQuestionSettingQuery settingQuery = new TeacherOpenCourseQuestionSettingQuery();
// 设置章节练习的默认配置并设置开课ID
settingQuery.setCourseTestDefault().setTeacherOpenCourseId(teacherOpenCourseId);
settingQuery.setChapterExerciseDefault().setTeacherOpenCourseId(teacherOpenCourseId);
courseInfoIdWithQuestionSettingOptions.forEach((courseInfo, settingDtoList) -> {
// 判断,添加交给外部来控制
@ -417,7 +445,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param courseInfoIdWithQuestionSettingOptions KeyValueID
*/
public void addSettingBySystemCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
@Nullable Map<CourseInfo, Collection<TeacherOpenCourseQuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@Nullable Map<CourseInfo, Collection<QuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@NotNull Map<Long, Long> courseInfoIdPair) {
addSettingBySystemCourse(teacherOpenCourseId, courseInfoIdWithQuestionSettingOptions, Integer.valueOf(2), CourseInfo::getCourseInfoType, courseInfoIdPair);
}
@ -437,11 +465,11 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param courseInfoIdPair
*/
public void addSettingBySystemCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId,
@Nullable Map<CourseInfo, Collection<TeacherOpenCourseQuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@Nullable Map<CourseInfo, Collection<QuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions,
@NotNull Object eq, @NotNull Func1<CourseInfo, Integer> func1, @NotNull Map<Long, Long> courseInfoIdPair) {
TeacherOpenCourseQuestionSettingQuery settingQuery = new TeacherOpenCourseQuestionSettingQuery();
// 设置章节练习的默认配置并设置开课ID
settingQuery.setCourseTestDefault().setTeacherOpenCourseId(teacherOpenCourseId);
settingQuery.setChapterExerciseDefault().setTeacherOpenCourseId(teacherOpenCourseId);
courseInfoIdWithQuestionSettingOptions.forEach((courseInfo, settingDtoList) -> {
// 判断,添加交给外部来控制
@ -530,8 +558,8 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
// 有题目才继续执行
if(ObjectUtil.isNotEmpty(questionList)) {
Map<ResourcesQuestionTypeEnum, TeacherOpenCourseQuestionSettingDTO> map = resourcesQuestionService.buildSettingDtoListByNoDiffQuestionList(questionList);
Map<CourseInfo, Collection<TeacherOpenCourseQuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions = new HashMap<>(1);
Map<ResourcesQuestionTypeEnum, QuestionSettingDTO> map = resourcesQuestionService.buildSettingDtoListByNoDiffQuestionList(questionList);
Map<CourseInfo, Collection<QuestionSettingDTO>> courseInfoIdWithQuestionSettingOptions = new HashMap<>(1);
courseInfoIdWithQuestionSettingOptions.put(courseInfo, map.values());
addSettingBySystemCourse(teacherOpenCourseId, courseInfoIdWithQuestionSettingOptions, courseInfoIdPair);
}
@ -577,7 +605,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
teacherOpenCourseMergeResourcesQuestionService.getValuesByQueryNotWithPermission(questionQuery);
TeacherOpenCourseQuestionSettingQuery questionSettingQuery = new TeacherOpenCourseQuestionSettingQuery();
questionSettingQuery.setCourseTestDefault()
questionSettingQuery.setChapterExerciseDefault()
.setTeacherOpenCourseQuestionSettingName(chapter.getCourseInfoName())
.setTeacherOpenCourseId(teacherOpenCourseId);
// 添加到章节练习题目配置主表

@ -17,7 +17,6 @@ import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import com.ibeetl.jlw.service.GeneralQuestionSettingService;
import com.ibeetl.jlw.web.query.GeneralQuestionSettingQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseQuestionSettingQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -29,7 +28,10 @@ import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
@ -38,7 +40,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -104,18 +105,18 @@ public class GeneralQuestionSettingController{
* @param coreUser
* @return
*/
@PostMapping(API + "/addQuestionByType.do")
public JsonResult addQuestionByType(@RequestBody TeacherOpenCourseQuestionSettingQuery generalQuestionSettingQuery,
BindingResult result, @SCoreUser CoreUser coreUser) {
if (result.hasErrors()) {
return JsonResult.failMessage(result);
}
Assert.notNull(coreUser, "请登录后再操作");
generalQuestionSettingQuery.setUserId(coreUser.getId());
generalQuestionSettingQuery.setOrgId(coreUser.getOrgId());
generalQuestionSettingService.addSettingByOpenCourse(generalQuestionSettingQuery, new HashMap<>(1));
return JsonResult.success();
}
// @PostMapping(API + "/addQuestionByType.do")
// public JsonResult addQuestionByType(@RequestBody TeacherOpenCourseQuestionSettingQuery generalQuestionSettingQuery,
// BindingResult result, @SCoreUser CoreUser coreUser) {
// if (result.hasErrors()) {
// return JsonResult.failMessage(result);
// }
// Assert.notNull(coreUser, "请登录后再操作");
// generalQuestionSettingQuery.setUserId(coreUser.getId());
// generalQuestionSettingQuery.setOrgId(coreUser.getOrgId());
// generalQuestionSettingService.addSettingByOpenCourse(generalQuestionSettingQuery, new HashMap<>(1));
// return JsonResult.success();
// }
/**
* --
@ -150,11 +151,10 @@ public class GeneralQuestionSettingController{
*/
@PostMapping(API + "/logicDelete.do")
public JsonResult logicDeleteDo(String ids) {
generalQuestionSettingService.logicDeleteTeacherOpenCourseQuestionSetting(ids);
generalQuestionSettingService.logicDeleteGeneralQuestionLogBySettingIds(ids);
return JsonResult.success();
}
/* 后台页面 */
@GetMapping(MODEL + "/index.do")
@ -268,7 +268,7 @@ public class GeneralQuestionSettingController{
@Function("generalQuestionSetting.delete")
@ResponseBody
public JsonResult delete(String ids) {
generalQuestionSettingService.deleteGeneralQuestionSetting(ids);
generalQuestionSettingService.deleteSettingAndSnapByIds(ids);
return JsonResult.success();
}

@ -141,7 +141,7 @@ public class TeacherOpenCourseQuestionSettingController{
*/
@PostMapping(API + "/delete.do")
public JsonResult deleteDo(String ids) {
teacherOpenCourseQuestionSettingService.deleteWithQuestionSnapByIds(ids);
teacherOpenCourseQuestionSettingService.deleteSettingAndSnapByIds(ids);
return JsonResult.success();
}
@ -274,7 +274,7 @@ public class TeacherOpenCourseQuestionSettingController{
@Function("teacherOpenCourseQuestionSetting.delete")
@ResponseBody
public JsonResult delete(String ids) {
teacherOpenCourseQuestionSettingService.deleteWithQuestionSnapByIds(ids);
teacherOpenCourseQuestionSettingService.deleteSettingAndSnapByIds(ids);
return JsonResult.success();
}

@ -1,9 +1,12 @@
package com.ibeetl.jlw.web.query;
import cn.hutool.core.date.DateField;
import cn.jlw.validate.ValidateConfig;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
import com.ibeetl.jlw.entity.GeneralQuestionSetting;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeResourcesQuestion;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import lombok.*;
@ -11,6 +14,11 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import static cn.hutool.core.date.DateUtil.offset;
import static com.ibeetl.jlw.enums.GlobalPushStatusEnum.UN_PUSH;
import static com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum.CHAPTER_EXERCISE;
/**
*
@ -64,6 +72,19 @@ public class GeneralQuestionSettingQuery extends PageParam {
@Query(name = "用户ID", display = false)
private Long userId;
/**
*
*
*/
private List<QuestionSettingDTO> questionSettingOptions;
/**
* ID,
* {@link TeacherOpenCourseMergeResourcesQuestion#getTeacherOpenCourseMergeCourseInfoId()}
*
*/
private String resourcesQuestionIdPlural;
private String generalQuestionSettingIdPlural;
private String bussinessIdPlural;
private String generalQuestionSettingStatusPlural;
@ -98,4 +119,49 @@ public class GeneralQuestionSettingQuery extends PageParam {
pojo.setUserId(this.getUserId());
return pojo;
}
/**
*
* @param setting
*/
public static void setDefault(GeneralQuestionSettingQuery setting) {
setting.setGeneralQuestionSettingStatus(1);
setting.setGeneralQuestionSettingAddTime(new Date());
setting.setGeneralQuestionSettingOptionNoOrder(1);
setting.setGeneralQuestionSettingQuestionNoOrder(1);
setting.setGeneralQuestionSettingEndShowTrueFalse(1);
setting.setGeneralQuestionSettingEndShowQa(1);
setting.setGeneralQuestionSettingDoCount(20);
setting.setGeneralQuestionSettingSchoolClassIds("ALL");
}
/**
*
* @param setting
*/
public static void setChapterExerciseDefault(GeneralQuestionSettingQuery setting) {
setting.setGeneralQuestionSettingStatus(1);
setting.setGeneralQuestionSettingAddTime(new Date());
setting.setGeneralQuestionSettingOptionNoOrder(1);
setting.setGeneralQuestionSettingQuestionNoOrder(1);
setting.setGeneralQuestionSettingEndShowTrueFalse(1);
setting.setGeneralQuestionSettingEndShowQa(1);
setting.setGeneralQuestionSettingDoCount(1000);
setting.setGeneralQuestionSettingType(CHAPTER_EXERCISE);
setting.setGeneralQuestionSettingSchoolClassIds("ALL");
setting.setGeneralQuestionSettingPushStatus(UN_PUSH);
setting.setGeneralQuestionStartTime(new Date());
// 结束时间设置为20年后
setting.setGeneralQuestionEndTime(offset(new Date(), DateField.YEAR, 20));
}
public GeneralQuestionSettingQuery setChapterExerciseDefault() {
setChapterExerciseDefault(this);
return this;
}
public GeneralQuestionSettingQuery setDefault() {
setDefault(this);
return this;
}
}

@ -4,6 +4,7 @@ import cn.jlw.validate.ValidateConfig;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
import com.ibeetl.jlw.entity.GeneralResourcesQuestionSnapshot;
import com.ibeetl.jlw.enums.BusinessCourseInfoEnum;
import lombok.*;
import lombok.experimental.Accessors;
@ -28,7 +29,7 @@ public class GeneralResourcesQuestionSnapshotQuery extends PageParam {
@Query(name = "业务课程ID", display = false)
private Long businessCourseInfoId;
@Query(name = "业务课程类型", display = false)
private Long businessCourseInfoType;
private BusinessCourseInfoEnum businessCourseInfoType;
@Query(name = "题型(1单选 2多选 3判断 4填空 5分析)", display = false)
private Integer questionType;
@Query(name = "分值", display = false)

@ -6,7 +6,7 @@ import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
import com.ibeetl.jlw.entity.TeacherOpenCourseMergeResourcesQuestion;
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionSetting;
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseQuestionSettingDTO;
import com.ibeetl.jlw.entity.dto.QuestionSettingDTO;
import com.ibeetl.jlw.enums.GlobalPushStatusEnum;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import lombok.Data;
@ -78,7 +78,7 @@ public class TeacherOpenCourseQuestionSettingQuery extends PageParam {
*
*
*/
private List<TeacherOpenCourseQuestionSettingDTO> questionSettingOptions;
private List<QuestionSettingDTO> questionSettingOptions;
/**
* ID,
@ -140,7 +140,7 @@ public class TeacherOpenCourseQuestionSettingQuery extends PageParam {
*
* @param setting
*/
public static void setCourseTestDefault(TeacherOpenCourseQuestionSettingQuery setting) {
public static void setChapterExerciseDefault(TeacherOpenCourseQuestionSettingQuery setting) {
setting.setTeacherOpenCourseQuestionSettingStatus(1);
setting.setTeacherOpenCourseQuestionSettingAddTime(new Date());
setting.setTeacherOpenCourseQuestionSettingOptionNoOrder(1);
@ -156,8 +156,8 @@ public class TeacherOpenCourseQuestionSettingQuery extends PageParam {
setting.setTeacherOpenCourseQuestionEndTime(offset(new Date(), DateField.YEAR, 20));
}
public TeacherOpenCourseQuestionSettingQuery setCourseTestDefault() {
setCourseTestDefault(this);
public TeacherOpenCourseQuestionSettingQuery setChapterExerciseDefault() {
setChapterExerciseDefault(this);
return this;
}

@ -180,9 +180,7 @@ queryByConditionQuery
@}
deleteGeneralQuestionSettingByIds
logicDeleteGeneralQuestionLogBySettingIds
===
* 批量删除(假删除)

@ -177,6 +177,13 @@ deleteGeneralResourcesQuestionSnapshotByIds
delete from general_resources_question_snapshot where find_in_set(general_resources_question_snapshot_id,#ids#)
deleteByTeacherOpenCourseQuestionSettingIds
===
* 批量删除通过题目配置IDs
delete from general_resources_question_snapshot where find_in_set(general_question_setting_id,#settingIds#)
getByIds
@ -727,3 +734,46 @@ getExcelValues
)
)t
getQuestionBySettingOptionDTO
===
* 根据题目设置随机出题(从系统的题库获取)
select
@if(!isEmpty(singleScore)){
'' as general_resources_question_snapshot_id,
'' as general_question_setting_id,
'' as business_course_info_type,
t.course_info_id as business_course_info_id,
t.question_type,
t.question_stem,
t.question_option_a,
t.question_option_b,
t.question_option_c,
t.question_option_d,
t.question_option_e,
t.question_answer,
#singleScore# as question_score,
t.question_analysis,
t.question_status,
t.user_id,
t.org_id
@} else {
t.*,
t.course_info_id as business_course_info_id
@}
from resources_question t
where 1=1
and t.question_status = 1
@// 题目ID优先级高
@if(!isEmpty(resourcesQuestionIdPlural)) {
and find_in_set(t.resources_question_id, #resourcesQuestionIdPlural#)
@} else {
@// 随机抽题,根据题目配置动态抽取题目。会存在题库抽不够数的情况。
@if(!isEmpty(questionType)){
and find_in_set(t.question_type, #questionType#)
@}
@if(!isEmpty(selectCount)){
ORDER BY RAND()
limit #selectCount#
@}
@}
Loading…
Cancel
Save