From d0ec97d182b3c61f8427d83a97f2f8b584114eda Mon Sep 17 00:00:00 2001 From: daihh Date: Wed, 6 Jul 2022 15:08:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=A4=E4=B8=AA=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/portal/course/microPreview.vue | 419 +---------------------- src/views/portal/course/rePreview.vue | 204 ++--------- 2 files changed, 46 insertions(+), 577 deletions(-) diff --git a/src/views/portal/course/microPreview.vue b/src/views/portal/course/microPreview.vue index dacd0b61..b2e31440 100644 --- a/src/views/portal/course/microPreview.vue +++ b/src/views/portal/course/microPreview.vue @@ -96,12 +96,9 @@
上传作业
-
- 作业附件请点击下面的提交 -
+
选择文件并上传 -
@@ -208,7 +205,6 @@ - @@ -302,7 +298,7 @@
- +
@@ -550,8 +546,7 @@ export default { $this.loadAssessInfo(); } }); - //study info - // this.loadStudyInfo(); + } else { this.$message.error(rs.message); } @@ -605,21 +600,6 @@ export default { //console.log("当前播放11"+itme); let intTime=parseInt(itme); this.videoPlayingTime=intTime; - let saveTime=Math.floor(intTime%10); - if(intTime>10 && saveTime==0 && this.coursewareInfo.studyItemId!=''){ - //记录播放时间 - //console.log('记录播放时间:'+intTime); - let postData={ - itemId:this.coursewareInfo.studyItemId, - videoTime:intTime - } - apicourseStudy.studyVideoTime(postData).then(rs=>{ - if(rs.status!=200){ - console.log('记录播放时间错误'); - } - }) - } - }, audioPlaying(item){ //console.log("当前播放22"+item); @@ -651,11 +631,7 @@ export default { studyId: this.studyId, contentId: this.homeworkInfo.content.id }; - // apicourseStudy.myHomeworkList(params).then(rs => { - // if (rs.status == 200) { - // this.homeworkInfo.records = rs.result; - // } - // }); + } } else if (tab.name == "test") { if (this.examInfo.records.length == 0) { @@ -663,17 +639,6 @@ export default { studyId: this.studyId, contentId: this.examInfo.content.id }; - apicourseStudy.myExamList2(params).then(examRs => { - if (examRs.status == 200) { - this.examInfo.records = examRs.result; - let len = examRs.result.length; - if (this.examInfo.info.times > len) { - this.examInfo.allowSubmit = true; - } else { - this.examInfo.allowSubmit = false; - } - } - }); } } else if (tab.name == "assess") { //console.log('加载评估信息');,评估只会有一个,所以主直接取 @@ -681,22 +646,8 @@ export default { studyId: this.studyId, contentId: this.assessInfo.content.id }; - // apicourseStudy.myAssessList(params).then(res => { - // if (res.status == 200) { - // if (res.result.length > 0) { - // this.assessInfo.allowSubmit = false; - // this.assessInfo.info = JSON.parse(res.result[0].asContent); - // } - // } else { - // this.$message.error(res.message); - // } - // }); } else { - //在课件页面,记录开始时间 - //console.log('记录课件学习信息'); - if(!this.coursewareInfo.finish){ - setTimeout(() => {$this.saveStudyInfo();}, 5000); - } + } }, saveStudyInfo() { @@ -708,102 +659,20 @@ export default { if (this.coursewareInfo.finish) { return; } - // let params = { - // studyId: this.studyId, //学习id, - // courseId: this.coursewareInfo.content.courseId, //课程id, - // contentId: this.coursewareInfo.content.id, //内容id, - // contentName: this.coursewareInfo.content.contentName, //内容名称 - // progress: 100, - // contentTotal: this.totalContent - // }; - // apicourseStudy.studyContent(params).then(res => { - // if (res.status == 200) { - // this.coursewareInfo.finish = true; //课件内容已学习,记录状态 - // } else { - // console.log("记录学习失败:" + res.message + "," + res.error); - // } - // }); + }, startTest() { this.examInfo.startTime = new Date(); this.testStart = true; }, - countTest() { - //计算课程的分数 - let scoreNum = null; - this.examInfo.paper.items.forEach(item => { - let isFind = true; - if (item.type != 102) { - item.options.forEach(it => { - if (it.answer == true && item.userAnswer == it.id) { - scoreNum += item.score; - } - }); - } else { - item.options.forEach(it => { - if (it.answer == false && it.isCheck && it.isCheck == true) { - isFind = false; - } - if (it.answer == true && it.isCheck && it.isCheck == true) { - if (isFind) { - scoreNum += item.score; - } - } - }); - } - }); - if (scoreNum === null) scoreNum = 0; - return scoreNum; - }, // 提交考试 submitTest() { - let now = new Date(); - let testScore = this.countTest(); - let postData = { - studyId: this.studyId, //这个哪传来的? - studyItemId: this.examInfo.studyItemId, //前面已经给了 - courseId: this.examInfo.info.courseId, - contentId: this.examInfo.info.contentId, - testId: this.examInfo.info.id, - testName: this.courseInfo.name, //应该是课程的名称 + 内容的名称 - testDuration: 0, - score: testScore, - arrange: this.examInfo.info.arrange, - passLine: this.examInfo.info.passLine, - randomMode: this.examInfo.info.randomMode, - paperJson: JSON.stringify({ items: this.examInfo.paper.items }) //原来是对象,这里要也要对象 - //startTime:formatDate(this.examInfo.startTime),//此时间需要格式化,格式化时间可以放在util中 - //endTime:formatDate(now), - }; - //计划考试的时长 - var dateDiff = now.getTime() - this.examInfo.startTime.getTime(); //时间差的毫秒数 - var minutes = Math.floor(dateDiff / 1000); //计算相差秒数,原来是分钟不行 - postData.testDuration = minutes; - apicourseStudy.saveExam(postData).then(res => { - if (res.status == 200) { - this.examInfo.records.push(res.result); - this.examInfo.studyItemId = res.result.studyItemId; //设置考试的学习记录id - this.testStart = false; - let len = this.examInfo.records.length; - if (this.examInfo.info.times > len) { - this.examInfo.allowSubmit = true; - } else { - this.examInfo.allowSubmit = false; - } - } else { - this.$message.error(res.message); - } - }); }, showExamAnswer(item) { //显示试卷的答卷信息 this.examInfo.detailShow=true; - apicourseStudy.myExamPaper(item.id).then(rs=>{ - if(rs.status==200){ - this.examInfo.detailItems=JSON.parse(rs.result.paper).items - } - }); + }, testType(type) { //此方法移到tools中 @@ -826,145 +695,9 @@ export default { this.homeworkInfo.filePath = res.result.filePath; }, removeHomeworkFile() { - this.$confirm("您确定要删除已上传的附件吗?", "提示", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" - }).then(() => { - this.homeworkInfo.filePath = ""; - //从服务器端删除 - this.$message({ type: "success", message: "删除成功!" }); - }); + }, submitHomework() { - //提交作业 - if (this.homeworkInfo.content.submitMode == 1) { - if (this.homeworkInfo.filePath == "") { - this.$message.error("请上传作业内容"); - return; - } - } else if (this.homeworkInfo.content.submitMode == 2) { - if (this.homeworkInfo.answer == "") { - this.$message.error("请先填写作业内容"); - return; - } - } else { - if ( - this.homeworkInfo.answer == "" && - this.homeworkInfo.filePath == "" - ) { - this.$message.error("请填写或上传作业"); - return; - } - } - - let pamars = { - studyItemId: this.homeworkInfo.studyItemId, //学习内容记录id, - studyId: this.studyId, //学习id, - courseId: this.courseInfo.id, //课程id, - contentId: this.homeworkInfo.content.id, //内容id, - hwId: this.homeworkInfo.info.id, //作业的id - hwName: this.homeworkInfo.info.name, //作业的名称 - //hwContent: this.homeworkInfo.info.content,//作业的内容,先不要此字段了 - filePath: this.homeworkInfo.filePath, //文件的路径,可以为空, - hwAnswer: this.homeworkInfo.answer, //文本提交的信息 - score: 0 - }; - apicourseStudy.saveHomework(pamars).then(res => { - if (res.status == 200) { - this.$message.success("作业已提交"); - this.homeworkInfo.filePath = ""; - this.homeworkInfo.answer = ""; - this.homeworkInfo.records.push(res.result); - } else { - this.$message.error(res.message); - } - }); - }, - appendStudyTime() { - if(this.studyId==''){ - return; - } - //追加学习时间 - let $this = this; - if (this.appendStartTime == null) { - this.appendStartTime = new Date(); - setTimeout(function() { - $this.appendStudyTime(); - }, 60000); - return; - } - - let now = new Date(); - let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 - let sen = parseInt(m / 1000); //计算秒数 - if (sen > 0) { - let postData = { - studyId: this.studyId, - courseId: this.courseInfo.id, - contentId: this.coursewareInfo.content.id, - studyInfo: - this.courseInfo.name + - "-" + - this.coursewareInfo.content.contentName, - duration: sen - }; - apicourseStudy.appendStudyTime(postData).then(rs => { - if (rs.status == 200) { - $this.appendStartTime = new Date(); //重置开始时间,10秒后再记录一次 - setTimeout(function() { - $this.appendStudyTime(); - }, 60000); - } else { - console.log(rs.message); - } - }); - } else { - setTimeout(function() { - $this.appendStudyTime(); - }, 60000); - } - }, - loadStudyInfo() { - //获取学习信息 - let $this = this; - this.loadScorePraiseAndTrample(); - apicourseStudy.studyInfo(this.courseInfo.id).then(res => { - if (res.status == 200) { - res.result.signup ? (this.enrollStutas = 2) : (this.enrollStutas = 1); - if(res.result.signup) { - //this.loadScorePraiseAndTrample(); - this.appendStudyTime(); - this.studyId = res.result.studyId; //设置学习id - //需要判断此内容是否已学习完成,如果已学习完成,不需要再请不说了 - res.result.contents.forEach(con => { - if (con.contentId == $this.coursewareInfo.content.id) { - $this.coursewareInfo.finish = true; //课件已学习 - $this.coursewareInfo.studyItemId=con.id; - if(con.lastStudyTime!='' && con.lastStudyTime>0){ - //当前视频学习的时间 - $this.videoPlayingTime=con.lastStudyTime; - //如果视频已经播放完了 - } - //console.log() - }else if (con.contentId == $this.homeworkInfo.content.id) { - $this.homeworkInfo.studyItemId = con.id; - }else if (con.contentId ==$this.examInfo.content.id) { - $this.examInfo.studyItemId = con.id; - }else if (con.contentId == $this.assessInfo.content.id) { - $this.assessInfo.studyItemId = con.id; - } - }); - if (!$this.coursewareInfo.finish) { - setTimeout(() => { - $this.saveStudyInfo(); - }, 5000); //5秒后记录学习 - } - } - } else { - this.$message.error(res.message); - } - }); }, loadHomeworkInfo() { apiCourse.getHomework(this.homeworkInfo.content.id).then(res => { @@ -1018,137 +751,19 @@ export default { signType: 1, signInfo: "" }; - let $this = this; - // apicourseStudy.signup(pamars).then(res => { - // if (res.status == 200) { - // this.$message({ type: "success", message: "报名成功" }); - // this.enrollStutas = 2; - // this.appendStudyTime(); //报名成功记录开始时间 - // //报名成功后,就直接记录课件学习情况,5秋后 - // setTimeout(() => { - // $this.saveStudyInfo(); - // }, 5000); - // } else { - // this.$message.error(res.message); - // } - // }); - }, - assessSubmitFun() { - let dataJson = JSON.stringify(this.assessInfo.info); - //计算评估得分 - let countStr = this.assessInfo.info.resultCount; - let countScore = 0; - let pass = true; - this.assessInfo.info.items.forEach((item, idx) => { - if (item.qType == 1) { - if (item.answer == 0) { - pass = false; - } - var str = "[q" + (idx + 1) + "]"; - countStr = countStr.replace(str, item.answer); - } - }); - if (!pass) { - this.$message.error("请填写完整再提交"); - return; - } - //console.log(countStr); - countScore = eval(countStr); - //console.log(countScore,"countScore"); - let pamars = { - studyItemId: this.assessInfo.studyItemId, //学习内容记录id, - studyId: this.studyId, //学习id, - courseId: this.courseInfo.id, //课程id, - contentId: this.assessInfo.content.id, //内容id, - asContent: dataJson, //内容 - asScore: countScore //评估得分 - }; - apicourseStudy.saveAssess(pamars).then(res => { - if (res.status == 200) { - this.assessInfo.allowSubmit = false; - this.$message.success("提交成功,谢谢您的评估"); - } else { - this.$message.error(res.message); - } - }); + this.enrollStutas = 2; }, loadScorePraiseAndTrample() { - //加载是否打过分 - //if(this.enrollStutas>1){ - apiCourseGrade.has(this.courseInfo.id).then(rs => { - if (rs.status == 200 && rs.result) { - this.scoreInfo.has = true; - } - }); - //} - apiPraises.has(1, this.courseInfo.id).then(rs => { - if (rs.status == 200 && rs.result) { - this.isPraise = true; - } - }); - apiTrample.has(this.courseInfo.id).then(rs => { - if (rs.status == 200 && rs.result) { - this.isTrample = true; - } - }); + }, addScore() { - let postData = { - courseId: this.courseInfo.id, - studyId: this.studyId, - score: this.scoreInfo.score - }; - if (this.scoreInfo.score > 0) { - apiCourseGrade.grade(postData).then(rs => { - if (rs.status == 200) { - this.$message.success("打分成功,谢谢您的打分"); - this.scoreInfo.has = true; - } else { - this.$message.error("打分处理失败,请稍后再试"); - } - }); - } + }, praiseContent() { - if(this.enrollStutas==1){ - this.$message.error("报名学习之后才可以点赞"); - return; - } - if(this.isTrample){ - this.$message.error("您已踩过了,不能再赞了"); - return; - } - let postData = { - objType: 1, - objId: this.courseInfo.id, - title: this.courseInfo.name - }; - apiPraises.save(postData).then(rs => { - if (rs.status == 200) { - this.$message.success("点赞成功"); - this.isPraise = true; - } else { - this.$message.error("点赞失败,请稍后再试"); - } - }); + }, treadContent() { - if(this.enrollStutas==1){ - this.$message.error("只有报名学习后才可以踩"); - return; - } - if(this.isPraise){ - this.$message.error("您已赞过了,不能再踩了"); - return; - } - apiTrample.trample(this.courseInfo.id).then(rs => { - if (rs.status == 200) { - this.$message.success("已踩"); - this.isTrample = true; - } else { - this.$message.error("踩失败,请稍后再试"); - } - }); + }, loadAuthorInfo(list,ids){ //加载作者信息,头像,机构信息 if(ids.length==0){ @@ -1164,13 +779,13 @@ export default { // this.tearsex = item.sex; console.log(this.tearsex) console.log(author.sex,item.sex,'sexs') - + // console.log(item.sex) if(author.avatar){ item.avatar=this.fileBaseUrl + author.avatar; - + } - + return true; }else{ @@ -1432,7 +1047,7 @@ export default { .num { color: #444444; font-size: 16px; - + } margin-bottom: 15px; } diff --git a/src/views/portal/course/rePreview.vue b/src/views/portal/course/rePreview.vue index e270f2e3..9a99e3e6 100644 --- a/src/views/portal/course/rePreview.vue +++ b/src/views/portal/course/rePreview.vue @@ -58,7 +58,7 @@ 新窗口打开
- +
--> @@ -265,26 +265,26 @@ export default { //console.log("播放结束"); }, onPlayerPlaying(itme){ - //console.log("当前播放"+itme); - //console.log("当前播放11"+itme); - if(this.contentData.contentType && this.contentData.contentType==10){ - let intTime=parseInt(itme); - this.contentData.lastStudyTime=intTime; - let saveTime=Math.floor(intTime%10); - if(intTime>10 && saveTime==0 && this.contentData.studyItemId!=''){ - //记录播放时间 - //console.log('记录播放时间:'+intTime); - let postData={ - itemId:this.contentData.studyItemId, - videoTime:intTime - } - apiStudy.studyVideoTime(postData).then(rs=>{ - if(rs.status!=200){ - console.log('记录播放时间错误'); - } - }) - } - } + // //console.log("当前播放"+itme); + // //console.log("当前播放11"+itme); + // if(this.contentData.contentType && this.contentData.contentType==10){ + // let intTime=parseInt(itme); + // this.contentData.lastStudyTime=intTime; + // let saveTime=Math.floor(intTime%10); + // if(intTime>10 && saveTime==0 && this.contentData.studyItemId!=''){ + // //记录播放时间 + // //console.log('记录播放时间:'+intTime); + // let postData={ + // itemId:this.contentData.studyItemId, + // videoTime:intTime + // } + // apiStudy.studyVideoTime(postData).then(rs=>{ + // if(rs.status!=200){ + // console.log('记录播放时间错误'); + // } + // }) + // } + // } }, audioPlaying(item){ @@ -327,88 +327,12 @@ export default { } this.contentList=rs.result.contents; this.totalContent=rs.result.contents.length; - //加载学习的数据 - this.loadStudyData(); + }else{ this.$message.error(rs.message); } }) }, - loadStudyData() { - let $this=this; - apiStudy.studyInfo(this.courseId).then(res=>{ - if(res.status == 200) { - if(res.result.signup){ - // this.loadScorePraiseAndTrample(); - this.studyId = res.result.studyId; - //对已学习的内容进行比对,重要的字段, 学习内容id,在后缀的 - let playIndex=-1; - this.contentList.forEach((con,conIdx)=>{ - res.result.contents.forEach((scon,sconIdx)=>{ - if(scon.contentId==con.id){ - //定位显示的内容 - if($this.initContentId!='' && $this.initContentId==scon.contentId){ - //定位当前学习的内容,是上一次学习的内容 - playIndex=conIdx; - }else{ - if(sconIdx==0 && con.contentType<52){ - playIndex=conIdx; - } - } - //console.log(scon.contentId,con.id); - con.lastStudyTime=scon.lastStudyTime; - con.status=9;//因为现在是只要有学习过的,就代表已学习完成,所以直接设置学习完成状态, - con.studyItemId=scon.id;//这个就是学习内容(条目)的id - //console.log(scon.id,"scon.id"); - //console.log(con,"scon.id"); - } - }) - }); - //如果没有,就定位第一项内容 - if(playIndex==-1){ - this.showRes(this.contentList[0]); - }else{ - this.showRes(this.contentList[playIndex]); - } - }else{ - // this.$message.error('您还未报名'); - // if(this.courseInfo.type==10){ - // location.href = this.webBaseUrl + "/course/micro?id="+this.courseId; - // }else{ - // location.href = this.webBaseUrl + "/course/detail?id="+this.courseId; - // } - } - } else { - this.$message.error(res.message); - } - }) - }, - saveStudyInfo() { //记录课件学习信息 - if(this.contentData.contentType>=60){ - //只有在课件页面停留超过5秒才会记录 - return; - } - if(this.contentData.status==9){ - //已学习完的,不用再添加 - return; - } - let params ={ - studyId: this.studyId,//学习id, - courseId: this.courseId,//课程id, - contentId: this.contentData.id,//内容id, - contentName: this.contentData.contentName,//内容名称 - progress: 100, - contentTotal:this.totalContent - } - apiStudy.studyContent(params).then(res=>{ - if(res.status == 200) { - this.contentData.status=9;//完成 - this.contentData.studyItemId=res.result;//学习记录id - }else{ - console.log('记录学习失败:'+res.message+','+res.error); - } - }) - }, ctabChange(e) { console.log(e); }, @@ -439,91 +363,21 @@ export default { } } - // else if(r.contentType == 61) {// 考试 - - // }else if(r.contentType == 60) {// 作业 - - // }else if(r.contentType == 62) {// 评估 - // //评估不需要查找,因为内容就是content中 - // console.log('评估处理'); - // } - this.contentData = r; - // setTimeout(function(){$this.saveStudyInfo();},5000);//5秒后记录学习完成 - + this.contentData = r; }, videoEnd() { - //视频播放完成后的处理 }, handleChange(val) { console.log(val); }, - // loadScorePraiseAndTrample(){ - // //加载是否请过分 - // apiCourseGrade.has(this.courseId).then(rs=>{ - // if(rs.status==200 && rs.result){ - // this.scoreInfo.has=true; - // } - // }); - // apiPraises.has(1,this.courseId).then(rs=>{ - // if(rs.status==200 && rs.result){ - // this.isPraise=true; - // } - // }); - // apiTrample.has(this.courseId).then(rs=>{ - // if(rs.status==200 && rs.result){ - // this.isTrample=true; - // } - // }); - // }, addScore(){ - let postData={ - courseId:this.courseInfo.id, - studyId:this.studyId, - score:this.scoreInfo.score - } - if(this.scoreInfo.score>0){ - apiCourseGrade.grade(postData).then(rs=>{ - if(rs.status==200){ - this.$message.success('打分成功,谢谢您的打分'); - this.scoreInfo.has=true; - }else{ - this.$message.error('打分处理失败,请稍后再试'); - } - }); - } + }, praiseContent(){ - if(this.isTrample){ - this.$message.error("您已踩过了,不能再赞了"); - return; - } - let postData={ - objType:1, - objId:this.courseId, - title:this.courseInfo.name - } - apiPraises.save(postData).then(rs=>{ - if(rs.status==200){ - this.$message.success('点赞成功'); - this.isPraise=true; - }else{ - this.$message.error('点赞失败,请稍后再试'); - } - }) + }, treadContent(){ - if(this.isPraise){ - this.$message.error("您已赞过了,不能再踩了"); - return; - } - apiTrample.trample(this.courseId).then(rs=>{ - if(rs.status==200){ - this.$message.success('已踩'); - this.isTrample=true; - }else{ - this.$message.error('踩失败,请稍后再试'); - } - }) + }, loadAuthorInfo(list,ids){ //加载作者信息,头像,机构信息 if(ids.length==0){ @@ -564,7 +418,7 @@ img{ white-space: nowrap; word-break: break-all; text-overflow: ellipsis; - // display: -webkit-box; + // display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; /* 这里是超出几行省略 */ } @@ -615,7 +469,7 @@ word-break:break-all; } } .collapse-title { - + flex: 1 0 90%; order: 1; } @@ -746,7 +600,7 @@ justify-content: space-between; padding-left: 20px; color: #5c5c5c; span{ - + } } }