mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
feat:添加学生章节级别学习记录分页查询接口,并补全学习时长字段
This commit is contained in:
@@ -490,17 +490,21 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
courseStudyVo.setContentName(s.getName()+"--"+c.getContentName());
|
||||
courseStudyVo.setStatus(1);
|
||||
courseStudyVo.setStudyDuration(0);
|
||||
// 学习时长默认为0
|
||||
courseStudyVo.setLearningDuration(0);
|
||||
courseStudyVos.add(courseStudyVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
// DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
if(courseStudyVos!=null && !courseStudyVos.isEmpty()){
|
||||
if (!courseStudyVos.isEmpty()) {
|
||||
for (StudyCourseItem study:studyItem) {
|
||||
for (CourseStudyVo cv:courseStudyVos) {
|
||||
if(study.getContentId().equals(cv.getContentId())){
|
||||
|
||||
// 25.11.26标记 这就能硬set么,这俩是一个值么
|
||||
cv.setStudyDuration(study.getProgress());
|
||||
// 25.11.26新增,添加学习时长字段
|
||||
// 数据库存储的秒,前端会转为分钟
|
||||
cv.setLearningDuration(study.getStudyDuration());
|
||||
//针对考试,文档一类
|
||||
if(study.getStatus()==null) {
|
||||
if(study.getProgress()!=null){
|
||||
@@ -511,16 +515,7 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
//音视频
|
||||
}else{
|
||||
cv.setStatus(study.getStatus());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// if(study.getStudyDuration()!=null){
|
||||
//// Float duration= Float.valueOf(study.getProgress());
|
||||
//// duration=duration/60;
|
||||
//
|
||||
// cv.setStudyDuration();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,6 +523,88 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
|
||||
return success(courseStudyVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取课程章节学习进度
|
||||
* 25.11.26新增
|
||||
*
|
||||
* @param pager 分页参数
|
||||
* @param courseId 课程id
|
||||
* @param aid 用户id
|
||||
* @return 课程内容学习进度集合
|
||||
*/
|
||||
@GetMapping("/detail-study-page")
|
||||
public JsonResponse<PageList<CourseStudyVo>> detailStudyPage(Pagination pager, String courseId, String aid) {
|
||||
if (StringUtil.isBlank(courseId)) {
|
||||
return badRequest("参数异常,未指定课程");
|
||||
}
|
||||
if (StringUtil.isBlank(aid)) {
|
||||
return badRequest("参数异常,未指定用户");
|
||||
}
|
||||
PageList<CourseStudyVo> courseStudyVoPage = new PageList<>();
|
||||
List<CourseStudyVo> courseStudyVos = new ArrayList<>();
|
||||
// 课程章节
|
||||
List<CourseSection> sectionlist = sectionService.getByCourseId(courseId);
|
||||
// 获取课程章节id集合备用
|
||||
List<String> sectionIdList = sectionlist.stream().map(CourseSection::getId).collect(Collectors.toList());
|
||||
if (sectionIdList.isEmpty()) {
|
||||
log.error("【分页获取课程章节学习进度】课程章节为空");
|
||||
return success(courseStudyVoPage);
|
||||
}
|
||||
// 课程内容(分页),只查询满足课程章节id条件的数据
|
||||
PageList<CourseContent> courseContentPageList = contentService.getByCourseIdPage(pager.getPageIndex(), pager.getPageSize(), courseId, sectionIdList);
|
||||
List<CourseContent> courseContentlist = courseContentPageList.getList();
|
||||
// 查出课程当前人学习进度
|
||||
StudyCourse studyCourse = studyCourseService.findByCourseIdAndAid(courseId, aid);
|
||||
// 查出对应章节学习进度
|
||||
List<StudyCourseItem> studyItem = studyCourseService.findStudyItem(studyCourse.getId(), aid);
|
||||
// 先遍历课程章节
|
||||
// 然后遍历课程内容
|
||||
for (CourseContent courseContent : courseContentlist) {
|
||||
CourseStudyVo courseStudyVo = new CourseStudyVo();
|
||||
courseStudyVo.setContentId(courseContent.getId());
|
||||
for (CourseSection s : sectionlist) {
|
||||
if (courseContent.getCsectionId().equals(s.getId())) {
|
||||
courseStudyVo.setContentName(s.getName() + "--" + courseContent.getContentName());
|
||||
}
|
||||
}
|
||||
courseStudyVo.setStatus(1);
|
||||
courseStudyVo.setStudyDuration(0);
|
||||
// 学习时长默认为0
|
||||
courseStudyVo.setLearningDuration(0);
|
||||
courseStudyVos.add(courseStudyVo);
|
||||
}
|
||||
if (!courseStudyVos.isEmpty()) {
|
||||
for (StudyCourseItem study : studyItem) {
|
||||
for (CourseStudyVo cv : courseStudyVos) {
|
||||
if (study.getContentId().equals(cv.getContentId())) {
|
||||
// 25.11.26标记 这就能硬set么,这俩是一个值么
|
||||
cv.setStudyDuration(study.getProgress());
|
||||
// 25.11.26新增,添加学习时长字段
|
||||
// 数据库存储的秒,前端会转为分钟
|
||||
cv.setLearningDuration(study.getStudyDuration());
|
||||
//针对考试,文档一类
|
||||
if (study.getStatus() == null) {
|
||||
if (study.getProgress() != null) {
|
||||
if (study.getProgress() == 100) {
|
||||
cv.setStatus(9);
|
||||
}
|
||||
}
|
||||
//音视频
|
||||
} else {
|
||||
cv.setStatus(study.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 拼接为分页格式
|
||||
courseStudyVoPage.setList(courseStudyVos);
|
||||
courseStudyVoPage.setCount(courseContentPageList.getCount());
|
||||
courseStudyVoPage.setPageSize(courseContentPageList.getPageSize());
|
||||
return success(courseStudyVoPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据课程id查出对应的教师id
|
||||
* */
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.xboe.module.course.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.course.dto.CourseContentDto;
|
||||
import com.xboe.module.course.dto.SortItem;
|
||||
import com.xboe.module.course.entity.CourseAssess;
|
||||
@@ -9,6 +8,8 @@ import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseExam;
|
||||
import com.xboe.module.course.entity.CourseHomeWork;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 课程内容,当前是分着处理,之后看是否与课程服务合并在一起
|
||||
* */
|
||||
@@ -54,7 +55,19 @@ public interface ICourseContentService{
|
||||
* @return
|
||||
*/
|
||||
List<CourseContent> getByCourseId(String courseId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据课程id、章节id得到课程所有目录(即章节,分页),顺序按orderIndex 从小到大的顺序
|
||||
* 25.11.26新增
|
||||
*
|
||||
* @param pageIndex 页码
|
||||
* @param pageSize 每页数量
|
||||
* @param courseId 课程id
|
||||
* @param sectionIdList 章节id集合
|
||||
* @return 课程章节信息集合分页
|
||||
*/
|
||||
PageList<CourseContent> getByCourseIdPage(int pageIndex, int pageSize, String courseId, List<String> sectionIdList);
|
||||
|
||||
/**
|
||||
* 更新内容顺序
|
||||
* @param courseId
|
||||
|
||||
@@ -5,11 +5,12 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.cache.IXaskCache;
|
||||
import com.xboe.core.cache.XaskCacheProvider;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.dto.CourseContentDto;
|
||||
@@ -141,6 +142,27 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据课程id、章节id得到课程所有目录(即章节,分页),顺序按orderIndex 从小到大的顺序
|
||||
* 25.11.26新增
|
||||
*
|
||||
* @param pageIndex 页码
|
||||
* @param pageSize 每页数量
|
||||
* @param courseId 课程id
|
||||
* @param sectionIdList 章节id集合
|
||||
* @return 课程章节信息集合分页
|
||||
*/
|
||||
@Override
|
||||
public PageList<CourseContent> getByCourseIdPage(int pageIndex, int pageSize, String courseId, List<String> sectionIdList) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("courseId", courseId));
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
if (sectionIdList != null && !sectionIdList.isEmpty()) {
|
||||
filters.add(FieldFilters.in("csectionId", sectionIdList));
|
||||
}
|
||||
return ccDao.findPage(pageIndex, pageSize, OrderCondition.asc("sortIndex"), filters.toArray(new IFieldFilter[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseHomeWork getHomework(String ccid) {
|
||||
CourseHomeWork hw=homeworkDao.findOne(FieldFilters.eq("contentId", ccid));
|
||||
|
||||
@@ -8,13 +8,32 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CourseStudyVo {
|
||||
|
||||
/**
|
||||
* 内容id
|
||||
*/
|
||||
private String contentId;
|
||||
|
||||
/**
|
||||
* 内容名称
|
||||
*/
|
||||
private String contentName;
|
||||
|
||||
/**
|
||||
* 学习状态( 1-未学习,2-学习中,9-学习完成)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
/**
|
||||
* 学习时长
|
||||
* 25.11.26新增
|
||||
* studyDuration字段被占用了,换一个
|
||||
*/
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 学习进度(理论上来说这个字段应该是学习时长,但是原接口如此,暂时保留此字段)
|
||||
*/
|
||||
private Integer studyDuration;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user