mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 03:46:44 +08:00
课程内考试,支持选择试卷
This commit is contained in:
@@ -119,6 +119,7 @@
|
||||
<script>
|
||||
import apiStudy from '@/api/modules/courseStudy.js';
|
||||
import apiCourse from '@/api/modules/course.js';
|
||||
import apiExamPaper from '@/api/modules/paper.js';
|
||||
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
||||
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
||||
export default {
|
||||
@@ -168,7 +169,11 @@ export default {
|
||||
records:[] ,//考试记录
|
||||
allowSubmit:true,//是否允许考试,尝试次数达到后不能再考试,暂时未使用
|
||||
detailShow:false,
|
||||
detailItems:[]
|
||||
detailItems:[],
|
||||
examPaper:{
|
||||
json:{},//试题的json格式
|
||||
items:[],//试题内容
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@@ -217,8 +222,6 @@ export default {
|
||||
this.total=paper.items.length;
|
||||
this.paper =paper;
|
||||
//console.log(this.paper);
|
||||
|
||||
|
||||
this.viewTest =paper.items;
|
||||
}
|
||||
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(){
|
||||
let paper= JSON.parse(this.info.paperContent);
|
||||
paper.items.forEach(item=>{
|
||||
//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;
|
||||
if(this.info.paperType==2){
|
||||
apiExamPaper.getPaperContent(this.info.paperId).then(rs=>{
|
||||
if(rs.status=200){
|
||||
this.examPaper.json=JSON.parse(rs.result);
|
||||
//console.log(this.examPaper.json,'this.examPaper.json');
|
||||
let qitems=this.convertToItems(this.examPaper.json);
|
||||
this.paper ={items:qitems};
|
||||
this.total=qitems.length;
|
||||
this.curItem=qitems[this.curIndex];
|
||||
this.startTime=new Date();//记录开始时间
|
||||
this.timerValue=this.info.testDuration;
|
||||
this.timer=setInterval(this.changeTimer,60000);
|
||||
this.testStart=true;
|
||||
}else{
|
||||
this.$message.error('加载试卷内容失败,请与管理员联系,试卷是否已删除');
|
||||
}
|
||||
})
|
||||
});
|
||||
this.total=paper.items.length;
|
||||
this.paper =paper;
|
||||
//console.log(this.paper);
|
||||
}else{
|
||||
let paper= JSON.parse(this.info.paperContent);
|
||||
paper.items.forEach(item=>{
|
||||
//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.startTime=new Date();//记录开始时间
|
||||
this.timerValue=this.info.testDuration;
|
||||
this.timer=setInterval(this.changeTimer,60000);
|
||||
this.testStart=true;
|
||||
this.curItem=paper.items[this.curIndex];
|
||||
this.startTime=new Date();//记录开始时间
|
||||
this.timerValue=this.info.testDuration;
|
||||
this.timer=setInterval(this.changeTimer,60000);
|
||||
this.testStart=true;
|
||||
}
|
||||
},
|
||||
chooseOption(opt){
|
||||
if(this.curItem.type==101 || this.curItem.type==103){
|
||||
|
||||
Reference in New Issue
Block a user