|
|
|
@ -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 Key:课程名称,Value:题型和题目ID的组合列表
|
|
|
|
|
*/
|
|
|
|
|
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 Key:课程名称,Value:题型和题目ID的组合列表
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
// 添加到章节练习题目配置主表
|
|
|
|
|