mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
修改课程复制的bug,优化学习记录
This commit is contained in:
@@ -260,6 +260,11 @@ public class CourseFileApi extends ApiBaseController {
|
||||
file.setDecoder(m.getVideo().getDecoder());
|
||||
file.setVideoHeight(m.getVideo().getSize().getHeight());
|
||||
file.setVideoWidth(m.getVideo().getSize().getWidth());
|
||||
|
||||
if(StringUtils.isBlank(file.getDecoder()) || !file.getDecoder().equals("h264")) {
|
||||
log.error("编码格式不是h264,不能上传");
|
||||
return error("编码格式不是h264,请先转码再上传","");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("读取视频时长错误");
|
||||
|
||||
@@ -831,7 +831,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
}
|
||||
CurrentUser cuser=getCurrent();
|
||||
try {
|
||||
String mess = courseService.copyCourse(id,refId,refType);
|
||||
String mess = courseService.copyCourse(id,refId,refType,cuser.getAccountId(),cuser.getName());
|
||||
if(StringUtils.isBlank(mess)){
|
||||
return success(true);
|
||||
}else{
|
||||
|
||||
@@ -135,6 +135,10 @@ public class Course extends BaseEntity {
|
||||
@Column(name = "org_id",length = 20)
|
||||
private String orgId;
|
||||
|
||||
/**复制的课程的来源id*/
|
||||
@Column(name = "copy_id",length = 20)
|
||||
private String copyId;
|
||||
|
||||
/**
|
||||
* 企业ID, 多企业使用
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,7 @@ public class CourseFile extends BaseEntity {
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 编码格式
|
||||
* 编码格式,目前只限 h264
|
||||
* */
|
||||
@Column(name = "decoder",length = 20)
|
||||
private String decoder;
|
||||
|
||||
@@ -130,8 +130,13 @@ public interface ICourseService {
|
||||
/**
|
||||
* 复制课程
|
||||
* @param id
|
||||
* @param refId
|
||||
* @param refType
|
||||
* @param aid
|
||||
* @param aname
|
||||
* @return
|
||||
*/
|
||||
String copyCourse(String id,String refId,String refType);
|
||||
String copyCourse(String id,String refId,String refType,String aid,String aname);
|
||||
|
||||
/**
|
||||
* 更新课程内容,是否记录修改日志
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -21,6 +22,7 @@ import com.xboe.TempFilterConfig;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
@@ -1494,7 +1496,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
@Override
|
||||
public String copyCourse(String id,String refId,String refType) {
|
||||
public String copyCourse(String id,String refId,String refType,String aid,String aname) {
|
||||
//复制课程,boe_course,boe_course_content,boe_course_homework,boe_course_section,boe_course_teacher,boe_course_exam
|
||||
// insert info select
|
||||
List<CourseSection> sectionList = courseSectionDao.findList("courseId", id);
|
||||
@@ -1512,18 +1514,19 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
String newId = IDGenerator.generate();
|
||||
String courseName = this.courseName(id);
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
String mess=null;
|
||||
if(courseName.length()<96) {
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
String sql = "insert into boe_course(id,ref_id,ref_type,visible,sys_create_aid,sys_create_by,sys_create_time,deleted,sys_update_by," +
|
||||
|
||||
String sql = "insert into boe_course(id,org_id,copy_id,ref_id,ref_type,visible,sys_create_aid,sys_create_by,sys_create_time,deleted,sys_update_by," +
|
||||
"sys_update_time,sys_version,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,favorites,for_scene,for_users,is_top,keywords,name,open_object," +
|
||||
"overview,pass_formula,praises,publish_time,published,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,shares,source,study_time,studys,summary," +
|
||||
"sys_type1,sys_type2,sys_type3,tags,top_time,trample_count,type,value,views," +
|
||||
"order_study,status)" +
|
||||
"select '" + newId + "','"+refId+"','"+refType+"',"+visible+",sys_create_aid,sys_create_by,'" + time + "',deleted,sys_update_by," +
|
||||
"'" + time + "',sys_version,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"select '" + newId + "',org_id,'"+id+"','"+refId+"','"+refType+"',"+visible+",'"+aid+"','"+aname+"','" + time + "',0,'"+aname+"'," +
|
||||
"'" + time + "',1,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,0,for_scene,for_users,0,keywords,'" + courseName + "(1)" + "',open_object," +
|
||||
"overview,pass_formula,0,publish_time,0,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,0,source,study_time,0,summary," +
|
||||
@@ -1532,19 +1535,47 @@ public class CourseServiceImpl implements ICourseService {
|
||||
courseDao.sqlUpdate(sql, id);
|
||||
|
||||
//课程章节复制,因为微课是没有章的,所以这里要判断
|
||||
LocalDateTime contentTime = LocalDateTime.now();
|
||||
|
||||
if(sectionList.isEmpty()) {
|
||||
//课程内容复制
|
||||
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select UUID_SHORT(),sys_create_aid,sys_create_by,'" + contentTime + "'," +
|
||||
"deleted,sys_update_by,'" + contentTime + "',sys_version,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','',duration,sort_index " +
|
||||
"from boe_course_content where course_id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent, id);
|
||||
//查出所有的内容,然后再一个一个复制(因为要复制关联的内容)
|
||||
List<?> contentIds= courseContentDao.findListField("id",FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(Object obj :contentIds) {
|
||||
String oldId=(String)obj;
|
||||
String newContentId=IDGenerator.generate();
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select '"+newContentId+"','"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',1,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','',duration,sort_index " +
|
||||
"from boe_course_content where id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent, oldId);
|
||||
|
||||
//课程作业复制
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,content,content_id,course_id,dead_time," +
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content,'"+newContentId+"','" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork, oldId);
|
||||
|
||||
//课程考试信息复制
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,arrange,content_id," +
|
||||
"course_id,info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum,random_mode," +
|
||||
"scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times)" +
|
||||
"select UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "',deleted,'"+aname+"','" + time + "'," +
|
||||
"1,arrange,'"+newContentId+"'," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where content_id=?1";
|
||||
courseExamDao.sqlUpdate(sqlExam, oldId);
|
||||
}
|
||||
}else {
|
||||
List<KeyValue> contentIdSectionIds= courseContentDao.findKeyValueList("id","csectionId", FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(CourseSection csection : sectionList) {
|
||||
//生成新的章的id
|
||||
String newSectionId = IDGenerator.generate();
|
||||
@@ -1555,50 +1586,55 @@ public class CourseServiceImpl implements ICourseService {
|
||||
courseSectionDao.sqlUpdate(sqlSection, csection.getId());
|
||||
|
||||
//课程内容复制
|
||||
for(KeyValue kv : contentIdSectionIds) {
|
||||
if(!kv.getValue().equals(csection.getId())) {
|
||||
continue;
|
||||
}
|
||||
String newContentId=IDGenerator.generate();
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select '"+newContentId+"','"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','"+newSectionId+"',duration,sort_index " +
|
||||
"from boe_course_content where id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent,kv.getKey());
|
||||
|
||||
//课程作业复制
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,content,content_id,course_id,dead_time," +
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content,'"+newContentId+"','" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1 and course_id=?2";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork,kv.getKey(),id);
|
||||
|
||||
//课程考试信息复制
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,arrange,content_id," +
|
||||
"course_id,info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum,random_mode," +
|
||||
"scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times)" +
|
||||
"select UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "',deleted,'"+aname+"','" + time + "'," +
|
||||
"1,arrange,'"+newContentId+"'," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where content_id=?1 and course_id=?2";
|
||||
courseExamDao.sqlUpdate(sqlExam,kv.getKey(),id);
|
||||
}
|
||||
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select UUID_SHORT(),sys_create_aid,sys_create_by,'" + contentTime + "'," +
|
||||
"deleted,sys_update_by,'" + contentTime + "',sys_version,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','"+newSectionId+"',duration,sort_index " +
|
||||
"from boe_course_content where course_id=?1 and csection_id=?2";
|
||||
courseContentDao.sqlUpdate(sqlContent, id,csection.getId());
|
||||
}
|
||||
}
|
||||
|
||||
//课程作业复制
|
||||
LocalDateTime homeWordTime = LocalDateTime.now();
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,content,content_id,course_id,dead_time," +
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),sys_create_aid,sys_create_by,'" + homeWordTime + "'," +
|
||||
"deleted,sys_update_by,'" + homeWordTime + "',sys_version,content,content_id,'" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where course_id=?1";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork, id);
|
||||
|
||||
//课程任课教师复制
|
||||
LocalDateTime teacherTime = LocalDateTime.now();
|
||||
String sqlTeacher = "insert into boe_course_teacher(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"course_id,teacher_id,teacher_name)" +
|
||||
"SELECT UUID_SHORT(),sys_create_aid,sys_create_by," +
|
||||
"'" + teacherTime + "','" + newId + "',teacher_id," +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "','" + newId + "',teacher_id," +
|
||||
"teacher_name from boe_course_teacher where course_id=?1";
|
||||
courseTeacherDao.sqlUpdate(sqlTeacher, id);
|
||||
// 课程考试信息复制
|
||||
LocalDateTime examTime = LocalDateTime.now();
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,arrange,content_id," +
|
||||
"course_id,info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum,random_mode," +
|
||||
"scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times)" +
|
||||
"select UUID_SHORT(),sys_create_aid,sys_create_by," +
|
||||
"'" + examTime + "',deleted,sys_update_by,'" + examTime + "'," +
|
||||
"sys_version,arrange,content_id," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where course_id=?1";
|
||||
courseExamDao.sqlUpdate(sqlExam, id);
|
||||
|
||||
}
|
||||
else{
|
||||
mess="长度超出范围";
|
||||
|
||||
@@ -245,18 +245,22 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if(StringUtils.isBlank(sci.getContentId())){
|
||||
return error("参数错误:内容");
|
||||
}
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
// LocalDateTime now=LocalDateTime.now();
|
||||
CurrentUser cuser=getCurrent();
|
||||
|
||||
StudyTime st=new StudyTime();
|
||||
st.setContentId(sci.getContentId());
|
||||
st.setCourseId(sci.getCourseId());
|
||||
st.setDuration(5);//增加5秒的学习时长
|
||||
st.setEndTime(now);
|
||||
st.setStartTime(now);
|
||||
st.setStudentId(cuser.getAccountId());
|
||||
st.setStudentName(cuser.getName());
|
||||
st.setStudyId(sci.getStudyId());
|
||||
if(sci.getDuration()==null) {
|
||||
sci.setDuration(1);//增加5秒的学习时长,因方法是每5秒调用一次的
|
||||
}
|
||||
|
||||
// StudyTime st=new StudyTime();
|
||||
// st.setContentId(sci.getContentId());
|
||||
// st.setCourseId(sci.getCourseId());
|
||||
// st.setDuration(5);//增加5秒的学习时长,因方法是每5秒调用一次的
|
||||
// st.setEndTime(now);
|
||||
// st.setStartTime(now);
|
||||
// st.setStudentId(cuser.getAccountId());
|
||||
// st.setStudentName(cuser.getName());
|
||||
// st.setStudyId(sci.getStudyId());
|
||||
|
||||
//检查是否已存在
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
@@ -266,7 +270,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
||||
}
|
||||
//追加学习时长
|
||||
studyService.appendStudyDuration(st);
|
||||
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||
return success(item.getId());
|
||||
}
|
||||
|
||||
@@ -283,7 +287,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
studyService.saveStudyInfo(sci);
|
||||
//学习记录成功后处理
|
||||
studyService.appendStudyDuration(st);
|
||||
studyService.appendStudyDuration(sci.getStudyId(),sci.getStudyItemId(),sci.getContentId(),sci.getDuration());
|
||||
return success(sci.getStudyItemId());
|
||||
}catch(Exception e) {
|
||||
log.error("记录学习情况错误",e);
|
||||
@@ -292,6 +296,30 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
//更新时长
|
||||
|
||||
/**追加学习时长*/
|
||||
@PostMapping("/study-append-duration")
|
||||
public JsonResponse<Boolean> appendStudyDuration(String studyId,String studyItemId,String contentId,Integer duration){
|
||||
if(StringUtils.isBlank(studyId)){
|
||||
return error("参数错误");
|
||||
}
|
||||
if(StringUtils.isBlank(studyItemId) && StringUtils.isBlank(contentId)){
|
||||
return error("未指定学习内容");
|
||||
}
|
||||
if(duration==null){
|
||||
return error("无学习时长");
|
||||
}
|
||||
try {
|
||||
studyService.appendStudyDuration(studyId, studyItemId,contentId,duration);
|
||||
return success(true);
|
||||
}catch(Exception e) {
|
||||
log.error("追加学习时长错误",e);
|
||||
return error("追加学习时长失败",e.getMessage(),false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 学习完成一项课程内容,针对于所有课程内容,不只是音视频,还有scorm及其它的内容
|
||||
* @param sci
|
||||
@@ -308,36 +336,23 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
// LocalDateTime now=LocalDateTime.now();
|
||||
CurrentUser cuser=getCurrent();
|
||||
|
||||
//下面的学习时长应该去掉了,不需要
|
||||
// StudyTime st=new StudyTime();
|
||||
// st.setContentId(sci.getContentId());
|
||||
// st.setCourseId(sci.getCourseId());
|
||||
// st.setDuration(5);//增加5秒的学习时长
|
||||
// st.setEndTime(now);
|
||||
// st.setStartTime(now);
|
||||
// st.setStudentId(cuser.getAccountId());
|
||||
// st.setStudentName(cuser.getName());
|
||||
// st.setStudyId(sci.getStudyId());
|
||||
|
||||
//检查是否已存在
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
if(item!=null) {
|
||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
||||
if(item.getProgress()<100) {
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100);
|
||||
}
|
||||
//追加学习时长
|
||||
//追加学习时长,学习时长是单独的记录,这里不再进行记录
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(item.getId());
|
||||
}
|
||||
|
||||
//如果不存在,就创建
|
||||
try {
|
||||
sci.setAid(cuser.getAccountId());
|
||||
sci.setAname(cuser.getName());
|
||||
sci.setProgress(100);
|
||||
studyService.saveStudyInfo(sci);
|
||||
//学习记录成功后处理
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(sci.getStudyItemId());
|
||||
}catch(Exception e) {
|
||||
log.error("记录学习课程内容完成错误",e);
|
||||
|
||||
@@ -33,6 +33,9 @@ public class StudyContentDto {
|
||||
/**内容的总数量*/
|
||||
private Integer contentTotal;
|
||||
|
||||
/**学习时长*/
|
||||
private Integer duration;
|
||||
|
||||
private String aid;
|
||||
|
||||
private String aname;
|
||||
|
||||
@@ -62,11 +62,21 @@ public interface IStudyService {
|
||||
void finishVideoStudyItem(String itemId,String studyId,String courseId,Integer cnum);
|
||||
|
||||
/**
|
||||
* 追加学习持续时长
|
||||
* 追加学习持续时长,此处理是一期的,有追加记录,二期后追加记录在stat服务中,这里不需要再记录了,所以不建议使用此方法
|
||||
* @param st
|
||||
*/
|
||||
@Deprecated
|
||||
void appendStudyDuration(StudyTime st);
|
||||
|
||||
/**
|
||||
* 追加学习时长,通用,无追加记录
|
||||
* @param studyId 学习id
|
||||
* @param studyItemId 学习内容id
|
||||
* @param courseContentId 课程的内容id
|
||||
* @param duration 学习时长
|
||||
*/
|
||||
void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration);
|
||||
|
||||
/**
|
||||
* 根据学习id,得到章节的学习记录情况
|
||||
* @param studyId
|
||||
|
||||
@@ -72,6 +72,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setStudyId(dto.getStudyId());
|
||||
sci.setContentId(dto.getContentId());
|
||||
sci.setContentName(dto.getContentName());
|
||||
sci.setStudyDuration(0);
|
||||
sci.setCourseId(dto.getCourseId());
|
||||
sci.setCsectionId(dto.getCsectionId());
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setProgress(1);
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
}else if(dto.getProgress().intValue()==100) {
|
||||
sci.setFinishTime(ldt);
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||
sci.setProgress(100);
|
||||
}else {
|
||||
@@ -87,7 +89,6 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setProgress(dto.getProgress());
|
||||
}
|
||||
//sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setFinishTime(ldt);
|
||||
sci.setLastTime(ldt);
|
||||
scItemDao.saveOrUpdate(sci);
|
||||
|
||||
@@ -96,6 +97,28 @@ public class StudyServiceImpl implements IStudyService{
|
||||
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration) {
|
||||
|
||||
//增加内容的学习时长
|
||||
if(StringUtils.isNotBlank(studyItemId)) {
|
||||
//直接根据id更新
|
||||
scItemDao.updateMultiFieldById(studyItemId, UpdateBuilder.create("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
}else {
|
||||
//根据学习id和课程内容id更新
|
||||
scItemDao.update(UpdateBuilder.from(StudyCourseItem.class)
|
||||
.addUpdateField("studyDuration", "studyDuration"+duration,FieldUpdateType.EXPRESSION)
|
||||
.addFilter(FieldFilters.eq("studyId", studyId))
|
||||
.addFilter(FieldFilters.eq("contentId", courseContentId))
|
||||
.builder());
|
||||
}
|
||||
|
||||
//追加课程的学习时长
|
||||
scDao.updateMultiFieldById(studyId, UpdateBuilder.create("totalDuration", "totalDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -243,7 +266,6 @@ public class StudyServiceImpl implements IStudyService{
|
||||
}
|
||||
|
||||
//以下是针对于视频课件的处理
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveVideoStudyItem(StudyCourseItem sci) {
|
||||
@@ -252,6 +274,9 @@ public class StudyServiceImpl implements IStudyService{
|
||||
if(sci.getStatus()==null) {
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
}
|
||||
if(sci.getStudyDuration()==null) {
|
||||
sci.setStudyDuration(0);
|
||||
}
|
||||
scItemDao.save(sci);
|
||||
//更新课程学习的进度
|
||||
scDao.updateProgress(sci.getStudyId(),sci.getProgress().floatValue());
|
||||
|
||||
@@ -77,6 +77,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
sc.setCourseId(signup.getCourseId());
|
||||
sc.setCourseName(signup.getCourseName());
|
||||
sc.setCourseType(signup.getCourseType());
|
||||
sc.setStartTime(now);
|
||||
sc.setFinishTime(null);
|
||||
sc.setLastScore(0f);
|
||||
sc.setProgress(0f);
|
||||
|
||||
Reference in New Issue
Block a user