提交修改

This commit is contained in:
daihh
2023-01-04 17:53:44 +08:00
parent 3af2d10631
commit cef100a2d4
5 changed files with 174 additions and 49 deletions

View File

@@ -12,13 +12,19 @@
</view>
<!--试题内容-->
<view class="qitem">
<view class="qitem-info">[{{getTypeName(curItem.type)}}]{{curItem.content}}</view>
<view class="qitem-info">
<view> [{{getTypeName(curItem.type)}}]{{curItem.content}}</view>
<view class="qimg" v-if="curItem.images"><img class="qimg-fit" :src="imageBaseUrl+curItem.images"/></view>
</view>
<view v-for="(opt,optIdx) in curItem.options" :key="optIdx">
<view class="qitem-opts">
<view class="qitem-opt" :class="{check:opt.checked}" @click="chooseOption(opt)">
{{toLetter(optIdx+1)}}.{{opt.content}}
<u-icon v-if="opt.checked" name="checkbox-mark" color="#00aa00"></u-icon>
</view>
<view v-if="opt.images" class="qimg">
<img class="qimg-fit" :src="imageBaseUrl+opt.images"/>
</view>
</view>
</view>
</view>
@@ -51,8 +57,10 @@
</template>
<script>
import config from '@/config/index.js'
import apiCourseStudy from '@/api/modules/courseStudy.js'
import apiCourse from '@/api/modules/course.js';
import apiExamPaper from '@/api/modules/paper.js';
import {formatDate,getQuestionType,correctJudgment,numberToLetter} from '@/utils/tools.js';
export default {
data() {
@@ -63,6 +71,7 @@
startTime:null,
toLetter:numberToLetter,
getTypeName:getQuestionType,
imageBaseUrl:config.fileUrl,
info:{},
stop:false,
paper:[],
@@ -100,28 +109,48 @@
apiCourse.getExam(this.examId).then(res=>{
if(res.status==200){
this.info=res.result;
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=res.result.testDuration;
this.timer=setInterval(this.changeTimer,60000);
this.loadStudyItemId();
if(this.info.paperType==2){
apiExamPaper.getPaperContent(this.info.paperId).then(rs=>{
if(rs.status==200){
//console.log(rs.result)
let paperItems=JSON.parse(rs.result);
//console.log(this.examPaper.json,'this.examPaper.json');
let qitems=this.convertToItems(paperItems);
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);
}else{
this.$message.error('加载试卷内容失败,请与管理员联系,试卷是否已删除');
}
})
}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=res.result.testDuration;
this.timer=setInterval(this.changeTimer,60000);
}
}else if(res.status==404){
//没有找到考试信息
}else{
@@ -129,6 +158,56 @@
}
})
},
//独立考试的试题转化为课内考试的试题
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,
images:item.images,
options:[]
}
if(item.type==3){
q.options.push({
id:item.id+'1',
images:'',
content:"正确",
answer:item.answer=='true'? true:false,
checked:false
});
q.options.push({
id:item.id+'2',
images:'',
content:"错误",
answer:item.answer=='true'? false:true,
checked:false
})
}else{
item.optionList.forEach(opt=>{
q.options.push({
id:opt.id,
images:opt.images,
content:opt.content,
answer:opt.isAnswer,
checked:false
})
});
}
if(q.type==102){
q.userAnswer=[];
}
qitems.push(q);
});
console.log(qitems,'qitems')
return qitems;
},
loadStudyItemId(){
//获取studyItemId;
apiCourseStudy.getStudyContentItem(this.studyId,this.info.contentId).then(rs=>{
@@ -363,5 +442,14 @@
display: flex;
justify-content: space-around;
}
.qimg{
//padding-left: 30px;
width:100%;
text-align: left;
.qimg-fit{
width:100%;
object-fit:scale-down
}
}
</style>