From 0023b28d2e4274bb2ac3d32519dffe5748e8c9ba Mon Sep 17 00:00:00 2001 From: daihh Date: Thu, 22 Dec 2022 18:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=80=83=E8=AF=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Course/catalogCourseware.vue | 176 ++++---------- src/components/Course/courseExam.vue | 257 +++++++++++--------- 2 files changed, 193 insertions(+), 240 deletions(-) diff --git a/src/components/Course/catalogCourseware.vue b/src/components/Course/catalogCourseware.vue index 520a90a1..29812ada 100644 --- a/src/components/Course/catalogCourseware.vue +++ b/src/components/Course/catalogCourseware.vue @@ -151,56 +151,16 @@
- - + 重新选择 +
+ + +
@@ -297,7 +257,6 @@ import chooseCourseFile from '@/components/Course/chooseCourseFile.vue' import courseHomework from '@/components/Course/courseHomework.vue' import courseExam from '@/components/Course/courseExam.vue' - import simplePaper from "@/components/Course/simpleTestPaper.vue"; import WxEditor from "@/components/Editor/indexCourse.vue"; import fileUpload from '@/components/FileUpload/index.vue'; import apiCourse from '../../api/modules/course.js'; @@ -333,7 +292,7 @@ default:1 } }, - components:{chooseCourseFile,WxEditor,courseHomework,courseExam,simplePaper,fileUpload,pdfPreview,audioPlayer,videoPlayer}, + components:{chooseCourseFile,WxEditor,courseHomework,courseExam,fileUpload,pdfPreview,audioPlayer,videoPlayer}, // inject: [ "informationDetails" ], data(){ return { @@ -369,29 +328,6 @@ }, homework:{courseId: '', name:'', content:'', file:'', deadTime: '', submitMode: 3}, homeworkChange:{}, - exam:{ - courseId:'', - contentId:'', - testName:this.course.name, - testDuration:30, - showAnalysis:false, - showAnswer:false, - times:1, - qnum:0,//试题数量,只是模式是随机生成试题时才会有 - arrange:0, - scoringType:1, - passLine:60, - randomMode:false, - percentScore:true,//默认是百分制 - paperType:1,//自定义试卷 - paperId:'',//试卷的id,只有paperType为2的时间才会有值 - info:'',//考试说明 - paperContent:'',//试题的json字符串 - }, - examChange:{}, - onlyQuestion:true, - examPaperChange:{}, - examPaper:{items:[]}, assess:{ countType:'权重配置', countText:'(问题1)*80%+(问题2)*10%+(问题3)*10%', @@ -443,8 +379,8 @@ //作业 this.loadHomeworkInfo(); }else if(newVal.contentType==61){ - //考试 - this.loadExamInfo(); + //考试,已经移到组件中 + //this.loadExamInfo(); }else if(newVal.contentType==62){ //评估 this.loadAssessInfo(); @@ -470,14 +406,6 @@ this.curPdfPath=''; this.scormUrl=''; this.curCFile={}; - this.exam.contentId=''; - this.exam.paperContent=''; - this.exam.info=''; - this.exam.id='';//一定要重置id - this.exam.qnum=''; - this.exam.paperId=''; - this.exam.passLine=60; - this.examPaper={items:[]}; this.curriculumData={ url:'', isDrag:true, @@ -533,20 +461,6 @@ } }) }, - loadExamInfo(){ - apiCourse.getExam(this.content.id).then(res=>{ - if(res.status==200){ - this.exam=res.result; - this.examPaper=JSON.parse(res.result.paperContent); - this.examChange = deepClone(res.result); - this.examPaperChange = deepClone(JSON.parse(res.result.paperContent)); - }else if(res.status==404){ - //没有找到作业信息 - }else{ - this.$message.error(res.message); - } - }) - }, loadAssessInfo(){ if(this.content.content!='' && this.content.content.length>10){ this.assess=JSON.parse(this.content.content); @@ -596,31 +510,7 @@ if(this.content.contentType==60){ jsonData.homework=this.homework; }else if(this.content.contentType==61){ - //检查内容的完整性 - if(this.examPaper.items.length==0){ - this.$message.error("您还没有添加考试的试题"); - return; - } - let pass=true; - this.examPaper.items.forEach(qitem=>{ - if(qitem.options.length==0){ - pass=false; - }else{ - let hasAnswer=qitem.options.some(opt=>{ - return opt.answer; - }); - if(!hasAnswer){ - pass=false; - } - } - }); - if(!pass){ - this.$message.error("试卷试题请填写完整,每个试题必须要有答案"); - return; - } - - this.exam.paperContent=JSON.stringify(this.examPaper); - jsonData.exam=this.exam; + //考试保存已经独立出去,不在这里处理了 }else if(this.content.contentType==62){ this.content.content=JSON.stringify(this.assess); @@ -635,6 +525,47 @@ } }) }, + saveExam(examInfo){ + console.log('保存考试配置'); + //这里只是61考试 + this.content.courseId=this.course.id; + this.content.sortIndex=this.addOrder; + let jsonData={ + content:this.content, + exam:examInfo + } + apiCourse.saveContent(jsonData).then(rs=>{ + if(rs.status === 200) { + this.$message.success('保存成功!'); + this.$refs.comExam.reloadExam(); + // this.content=rs.result.content; + this.$emit('save',rs.result.content); + }else{ + this.$message.error(rs.message) + } + }) + }, + deleteExam(examInfo){ + if(this.content.id==''){ + this.content.contentType=0; + this.content.content=''; + return; + } + let params={ + id:this.content.id, + ctype:this.content.contentType, + erasable:this.course.erasable + } + apiCourse.delContent(params).then(rs=>{ + if(rs.status === 200) { + this.$message.success('删除成功!'); + this.$emit('remove'); + this.$refs.comExam.reloadExam(); + }else{ + this.$message.error(rs.message) + } + }) + }, delData(id){ //需要调用外部方法完成 if(this.content.id==''){ @@ -654,6 +585,7 @@ } }) }, + toReChoose(){ let $this=this; if(this.content.id.length>1){ diff --git a/src/components/Course/courseExam.vue b/src/components/Course/courseExam.vue index 23227c5c..c4f5423d 100644 --- a/src/components/Course/courseExam.vue +++ b/src/components/Course/courseExam.vue @@ -1,19 +1,13 @@ -