mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-12 12:26:44 +08:00
课程内考试,支持选择试卷
This commit is contained in:
@@ -119,6 +119,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import apiStudy from '@/api/modules/courseStudy.js';
|
import apiStudy from '@/api/modules/courseStudy.js';
|
||||||
import apiCourse from '@/api/modules/course.js';
|
import apiCourse from '@/api/modules/course.js';
|
||||||
|
import apiExamPaper from '@/api/modules/paper.js';
|
||||||
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
||||||
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
||||||
export default {
|
export default {
|
||||||
@@ -168,7 +169,11 @@ export default {
|
|||||||
records:[] ,//考试记录
|
records:[] ,//考试记录
|
||||||
allowSubmit:true,//是否允许考试,尝试次数达到后不能再考试,暂时未使用
|
allowSubmit:true,//是否允许考试,尝试次数达到后不能再考试,暂时未使用
|
||||||
detailShow:false,
|
detailShow:false,
|
||||||
detailItems:[]
|
detailItems:[],
|
||||||
|
examPaper:{
|
||||||
|
json:{},//试题的json格式
|
||||||
|
items:[],//试题内容
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -217,8 +222,6 @@ export default {
|
|||||||
this.total=paper.items.length;
|
this.total=paper.items.length;
|
||||||
this.paper =paper;
|
this.paper =paper;
|
||||||
//console.log(this.paper);
|
//console.log(this.paper);
|
||||||
|
|
||||||
|
|
||||||
this.viewTest =paper.items;
|
this.viewTest =paper.items;
|
||||||
}
|
}
|
||||||
if(!this.showTest && this.showRecord){
|
if(!this.showTest && this.showRecord){
|
||||||
@@ -260,30 +263,78 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//独立考试的试题转化为课内考试的试题
|
||||||
|
convertToItems(questions){
|
||||||
|
let qitems=[];
|
||||||
|
questions.forEach(item=>{
|
||||||
|
let q={
|
||||||
|
id:item.id,
|
||||||
|
type:item.type==1? 101:item.type==2? 102:103,
|
||||||
|
score:item.defaultScore,
|
||||||
|
checked:false,
|
||||||
|
userAnswer:'',
|
||||||
|
optShow:true,
|
||||||
|
content:item.title,
|
||||||
|
options:[]
|
||||||
|
}
|
||||||
|
item.optionList.forEach(opt=>{
|
||||||
|
q.options.push({
|
||||||
|
id:opt.id,
|
||||||
|
content:opt.content,
|
||||||
|
answer:opt.isAnswer,
|
||||||
|
checked:false
|
||||||
|
})
|
||||||
|
});
|
||||||
|
if(q.type==102){
|
||||||
|
q.userAnswer=[];
|
||||||
|
}
|
||||||
|
qitems.push(q);
|
||||||
|
});
|
||||||
|
return qitems;
|
||||||
|
},
|
||||||
startTest(){
|
startTest(){
|
||||||
let paper= JSON.parse(this.info.paperContent);
|
if(this.info.paperType==2){
|
||||||
paper.items.forEach(item=>{
|
apiExamPaper.getPaperContent(this.info.paperId).then(rs=>{
|
||||||
//console.log(item);
|
if(rs.status=200){
|
||||||
if(item.type==101){
|
this.examPaper.json=JSON.parse(rs.result);
|
||||||
item.userAnswer='';
|
//console.log(this.examPaper.json,'this.examPaper.json');
|
||||||
}else if(item.type==102){
|
let qitems=this.convertToItems(this.examPaper.json);
|
||||||
item.userAnswer=[];
|
this.paper ={items:qitems};
|
||||||
}else{
|
this.total=qitems.length;
|
||||||
item.userAnswer=''
|
this.curItem=qitems[this.curIndex];
|
||||||
}
|
this.startTime=new Date();//记录开始时间
|
||||||
item.options.forEach(opt=>{
|
this.timerValue=this.info.testDuration;
|
||||||
opt.checked=false;
|
this.timer=setInterval(this.changeTimer,60000);
|
||||||
|
this.testStart=true;
|
||||||
|
}else{
|
||||||
|
this.$message.error('加载试卷内容失败,请与管理员联系,试卷是否已删除');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
}else{
|
||||||
this.total=paper.items.length;
|
let paper= JSON.parse(this.info.paperContent);
|
||||||
this.paper =paper;
|
paper.items.forEach(item=>{
|
||||||
//console.log(this.paper);
|
//console.log(item);
|
||||||
|
if(item.type==101){
|
||||||
|
item.userAnswer='';
|
||||||
|
}else if(item.type==102){
|
||||||
|
item.userAnswer=[];
|
||||||
|
}else{
|
||||||
|
item.userAnswer=''
|
||||||
|
}
|
||||||
|
item.options.forEach(opt=>{
|
||||||
|
opt.checked=false;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.total=paper.items.length;
|
||||||
|
this.paper =paper;
|
||||||
|
//console.log(this.paper);
|
||||||
|
|
||||||
this.curItem=paper.items[this.curIndex];
|
this.curItem=paper.items[this.curIndex];
|
||||||
this.startTime=new Date();//记录开始时间
|
this.startTime=new Date();//记录开始时间
|
||||||
this.timerValue=this.info.testDuration;
|
this.timerValue=this.info.testDuration;
|
||||||
this.timer=setInterval(this.changeTimer,60000);
|
this.timer=setInterval(this.changeTimer,60000);
|
||||||
this.testStart=true;
|
this.testStart=true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
chooseOption(opt){
|
chooseOption(opt){
|
||||||
if(this.curItem.type==101 || this.curItem.type==103){
|
if(this.curItem.type==101 || this.curItem.type==103){
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<div v-if="cware.content.contentRefId==''">
|
<div v-if="cware.content.contentRefId==''">
|
||||||
<div style="padding-top: 0px;">
|
<div style="padding-top: 0px;">
|
||||||
<!-- <div> -->
|
<!-- <div> -->
|
||||||
<choose-course-file ref="coursewarePanel" :resType="cware.content.contentType" @choose="chooseFile"></choose-course-file>
|
<choose-course-file :orgId="course.orgId" :orgName="course.orgName" ref="coursewarePanel" :resType="cware.content.contentType" @choose="chooseFile"></choose-course-file>
|
||||||
|
|
||||||
<!-- <file-upload
|
<!-- <file-upload
|
||||||
:fileType="getFileTypes(cware.content.contentType)"
|
:fileType="getFileTypes(cware.content.contentType)"
|
||||||
@@ -417,7 +417,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="padding-top: 10px;">
|
<div style="padding-top: 10px;">
|
||||||
<el-form size="small" label-width="80px">
|
<el-form size="small" label-width="80px">
|
||||||
<el-form-item label="考试时长">
|
<el-form-item label="试卷类型">
|
||||||
|
{{exam.info.paperType==1? '自定义试卷':'使用考试试卷: '+usePaper.paperName}}
|
||||||
|
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="考试时长">
|
||||||
<el-col :span="6">{{exam.info.passScore}}分钟</el-col>
|
<el-col :span="6">{{exam.info.passScore}}分钟</el-col>
|
||||||
<!-- <el-col :span="9">
|
<!-- <el-col :span="9">
|
||||||
<el-form-item label="尝试次数">{{exam.info.times}}</el-form-item>
|
<el-form-item label="尝试次数">{{exam.info.times}}</el-form-item>
|
||||||
@@ -890,7 +894,18 @@
|
|||||||
apiCourse.getExam(this.exam.content.id).then(res=>{
|
apiCourse.getExam(this.exam.content.id).then(res=>{
|
||||||
if(res.status==200){
|
if(res.status==200){
|
||||||
this.exam.info=res.result;
|
this.exam.info=res.result;
|
||||||
this.exam.paperJson=JSON.parse(res.result.paperContent);
|
if(res.result.paperType==1){
|
||||||
|
this.exam.paperJson=JSON.parse(res.result.paperContent);
|
||||||
|
}else{
|
||||||
|
apiExamPaper.detail(this.exam.info.paperId).then(rs=>{
|
||||||
|
if(rs.status==200){
|
||||||
|
this.usePaper.paperId=rs.result.id;
|
||||||
|
this.usePaper.paperName=rs.result.testName;
|
||||||
|
this.usePaper.counts=rs.result.counts;
|
||||||
|
//this.usePaper.paperJson= rs.result.paperContent;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
this.exam.show=9;
|
this.exam.show=9;
|
||||||
this.examChange = deepClone(this.exam);
|
this.examChange = deepClone(this.exam);
|
||||||
}else if(res.status==404){
|
}else if(res.status==404){
|
||||||
@@ -1035,30 +1050,38 @@
|
|||||||
this.homeworkChange = deepClone(this.homework)
|
this.homeworkChange = deepClone(this.homework)
|
||||||
}else if(index==3){
|
}else if(index==3){
|
||||||
postData.content=this.exam.content;
|
postData.content=this.exam.content;
|
||||||
//检查是不是所有的试题都有了答案
|
//console.log(this.exam,'this.exam');
|
||||||
if(this.exam.paperJson.items.length==0){
|
if(this.exam.info.paperType==2){
|
||||||
this.$message.error("您还没有添加考试的试题");
|
if(!this.exam.info.paperId){
|
||||||
return;
|
this.$message.error("您还未选择任何试卷");
|
||||||
}
|
return;
|
||||||
let pass=true;
|
}
|
||||||
this.exam.paperJson.items.forEach(qitem=>{
|
}else{
|
||||||
if(qitem.options.length==0){
|
//检查是不是所有的试题都有了答案
|
||||||
pass=false;
|
if(this.exam.paperJson.items.length==0){
|
||||||
}else{
|
this.$message.error("您还没有添加考试的试题");
|
||||||
let hasAnswer=qitem.options.some(opt=>{
|
return;
|
||||||
return opt.answer;
|
}
|
||||||
});
|
let pass=true;
|
||||||
if(!hasAnswer){
|
this.exam.paperJson.items.forEach(qitem=>{
|
||||||
|
if(qitem.options.length==0){
|
||||||
pass=false;
|
pass=false;
|
||||||
|
}else{
|
||||||
|
let hasAnswer=qitem.options.some(opt=>{
|
||||||
|
return opt.answer;
|
||||||
|
});
|
||||||
|
if(!hasAnswer){
|
||||||
|
pass=false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
if(!pass){
|
||||||
if(!pass){
|
this.$message.error("试卷试题请填写完整,每个试题必须要有答案");
|
||||||
this.$message.error("试卷试题请填写完整,每个试题必须要有答案");
|
this.loading=false;
|
||||||
this.loading=false;
|
return;
|
||||||
return;
|
}
|
||||||
|
this.exam.info.paperContent=JSON.stringify(this.exam.paperJson);
|
||||||
}
|
}
|
||||||
this.exam.info.paperContent=JSON.stringify(this.exam.paperJson);
|
|
||||||
postData.exam=this.exam.info;
|
postData.exam=this.exam.info;
|
||||||
this.examChange = deepClone(this.exam);
|
this.examChange = deepClone(this.exam);
|
||||||
}else if(index==4){
|
}else if(index==4){
|
||||||
@@ -1265,15 +1288,15 @@
|
|||||||
},
|
},
|
||||||
openCusExam(){ //自定义考试
|
openCusExam(){ //自定义考试
|
||||||
this.exam.show=3;
|
this.exam.show=3;
|
||||||
this.exam.paperType=1;
|
this.exam.info.paperType=1;
|
||||||
this.exam.paperId='';
|
this.exam.info.paperId='';
|
||||||
this.usePaper.pageIndex=1;
|
this.usePaper.pageIndex=1;
|
||||||
this.usePaper.keyword="";
|
this.usePaper.keyword="";
|
||||||
},
|
},
|
||||||
openChoosePaper(){
|
openChoosePaper(){
|
||||||
this.exam.show=2;
|
this.exam.show=2;
|
||||||
this.exam.paperType=3;
|
this.exam.info.paperType=2; //选择试卷
|
||||||
this.exam.paperId='';
|
this.exam.info.paperId='';
|
||||||
},
|
},
|
||||||
findExamPapers(){ //查询已有的考试试卷
|
findExamPapers(){ //查询已有的考试试卷
|
||||||
this.usePaper.pageIndex=1;
|
this.usePaper.pageIndex=1;
|
||||||
@@ -1319,6 +1342,7 @@
|
|||||||
if(rs.status==200){
|
if(rs.status==200){
|
||||||
this.usePaper.paperId=rs.result.id;
|
this.usePaper.paperId=rs.result.id;
|
||||||
this.usePaper.paperName=rs.result.testName;
|
this.usePaper.paperName=rs.result.testName;
|
||||||
|
this.usePaper.counts=rs.result.counts;
|
||||||
//this.usePaper.paperJson= rs.result.paperContent;
|
//this.usePaper.paperJson= rs.result.paperContent;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user