|
@@ -4,7 +4,7 @@
|
|
<el-row :gutter="20">
|
|
<el-row :gutter="20">
|
|
<el-col :span="16" :loading="loading">
|
|
<el-col :span="16" :loading="loading">
|
|
<div class="exam-content">
|
|
<div class="exam-content">
|
|
- <el-card class="box-card" v-for="(currentQuestion, aindex) in questionList" :key="aindex" v-show="aindex==cindex">
|
|
|
|
|
|
+ <el-card class="box-card" v-for="(currentQuestion, aindex) in questionList" :key="aindex" v-if="aindex==cindex">
|
|
<div slot="header" class="clearfix">
|
|
<div slot="header" class="clearfix">
|
|
<span>第{{aindex+1}}题({{currentQuestion.type|getType}})</span>
|
|
<span>第{{aindex+1}}题({{currentQuestion.type|getType}})</span>
|
|
|
|
|
|
@@ -50,7 +50,7 @@
|
|
{{cidx+1}}小题: <span v-html="child.title"></span>
|
|
{{cidx+1}}小题: <span v-html="child.title"></span>
|
|
|
|
|
|
<div class="answer" v-if="child.type==3">
|
|
<div class="answer" v-if="child.type==3">
|
|
- <el-checkbox-group v-model="currentQuestion.child[cidx].answer" @change="(e)=>{selectCheckBox(e,cidx)}">
|
|
|
|
|
|
+ <el-checkbox-group v-model="answers['answer'+cidx]" @change="(e)=>{selectCheckBox(e,cidx)}">
|
|
<el-checkbox
|
|
<el-checkbox
|
|
:label="index"
|
|
:label="index"
|
|
v-for="(item,index) in child.choice"
|
|
v-for="(item,index) in child.choice"
|
|
@@ -62,7 +62,7 @@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="answer" v-else>
|
|
<div class="answer" v-else>
|
|
- <el-radio-group v-model="currentQuestion.child[cidx].answer" @change="(e)=>{selectRadio(e, cidx)}">
|
|
|
|
|
|
+ <el-radio-group v-model="answers['answer'+cidx]" @change="(e)=>{selectRadio(e, cidx)}">
|
|
<el-radio class="answer-item" v-for="(item,index) in child.choice"
|
|
<el-radio class="answer-item" v-for="(item,index) in child.choice"
|
|
:label="index+1"
|
|
:label="index+1"
|
|
:key="index">
|
|
:key="index">
|
|
@@ -159,7 +159,7 @@ import md5 from 'js-md5';
|
|
import { getTime, packTime, time2str, saveExam, getExam,getSelect,delExam } from "./components/util.js";
|
|
import { getTime, packTime, time2str, saveExam, getExam,getSelect,delExam } from "./components/util.js";
|
|
import headline from "./components/headline.vue";
|
|
import headline from "./components/headline.vue";
|
|
import myDialog from "./components/my-dialog.vue";
|
|
import myDialog from "./components/my-dialog.vue";
|
|
-const defAnswer = [false,false,false,false,false];
|
|
|
|
|
|
+const defAnswer = {id:'', answer:0, type:1, child:[{answer:0, answer:0}, {answer:0}, {answer:0},{answer:0}]};
|
|
|
|
|
|
export default {
|
|
export default {
|
|
components:{
|
|
components:{
|
|
@@ -185,13 +185,18 @@ export default {
|
|
cindex:0,
|
|
cindex:0,
|
|
loading: false,
|
|
loading: false,
|
|
isAnli: false,
|
|
isAnli: false,
|
|
- questionList: [],
|
|
|
|
- answers:{},
|
|
|
|
|
|
+ questionList: [defAnswer],
|
|
|
|
+ answers:{
|
|
|
|
+ answer:'',
|
|
|
|
+ answer0:'',
|
|
|
|
+ answer1:'',
|
|
|
|
+ answer2:'',
|
|
|
|
+ answer3:'',
|
|
|
|
+ answer4:'',
|
|
|
|
+ },
|
|
questionLen: 0,
|
|
questionLen: 0,
|
|
questionType: '单选题',
|
|
questionType: '单选题',
|
|
textarea: "",
|
|
textarea: "",
|
|
- radio: "",
|
|
|
|
- checked:defAnswer,
|
|
|
|
getSelect,
|
|
getSelect,
|
|
time2str,
|
|
time2str,
|
|
questionId: 0,
|
|
questionId: 0,
|
|
@@ -243,10 +248,12 @@ export default {
|
|
let mkey = "answer"+i
|
|
let mkey = "answer"+i
|
|
if(item[mkey] ) item.choice.push( item[mkey] );
|
|
if(item[mkey] ) item.choice.push( item[mkey] );
|
|
}
|
|
}
|
|
|
|
+ this.answers.answer = item.answer;
|
|
if( item.type == 4){
|
|
if( item.type == 4){
|
|
for ( let i in item.child){
|
|
for ( let i in item.child){
|
|
let child = item.child[i]
|
|
let child = item.child[i]
|
|
child.choice = [];
|
|
child.choice = [];
|
|
|
|
+ this.answers['answer'+i] = child.answer;
|
|
for( let i=0;i<6;i++){
|
|
for( let i=0;i<6;i++){
|
|
let mkey = "answer"+i
|
|
let mkey = "answer"+i
|
|
if(child[mkey] ) child.choice.push( child[mkey] );
|
|
if(child[mkey] ) child.choice.push( child[mkey] );
|
|
@@ -255,13 +262,12 @@ export default {
|
|
}else{
|
|
}else{
|
|
item.child = []
|
|
item.child = []
|
|
}
|
|
}
|
|
- console.log("index", index, item.type, item.radio, item.answer)
|
|
|
|
this.questionList[index] = item
|
|
this.questionList[index] = item
|
|
},
|
|
},
|
|
loadQuestion( index ) {
|
|
loadQuestion( index ) {
|
|
let item = this.questionList[index];
|
|
let item = this.questionList[index];
|
|
item.index = index;
|
|
item.index = index;
|
|
- if( !item.title ){
|
|
|
|
|
|
+ if( !item.isLoad ){
|
|
let {id} = item;
|
|
let {id} = item;
|
|
this.loading= true;
|
|
this.loading= true;
|
|
httpServer("course.loadAnswer", {id} ).then(res => {
|
|
httpServer("course.loadAnswer", {id} ).then(res => {
|
|
@@ -271,7 +277,8 @@ export default {
|
|
let childs = res.data.child;
|
|
let childs = res.data.child;
|
|
if( item.type == 4){
|
|
if( item.type == 4){
|
|
item.child = childs.map( v=>{
|
|
item.child = childs.map( v=>{
|
|
- if( v.type == 3){ v.answer = [false,false,false,false,false]
|
|
|
|
|
|
+ if( v.type == 3){
|
|
|
|
+ v.answer = [false,false,false,false,false]
|
|
}else{ v.answer=0 }
|
|
}else{ v.answer=0 }
|
|
return v
|
|
return v
|
|
})
|
|
})
|
|
@@ -280,6 +287,7 @@ export default {
|
|
}else{
|
|
}else{
|
|
item.answer = 0;
|
|
item.answer = 0;
|
|
}
|
|
}
|
|
|
|
+ item.isLoad = true
|
|
this.doLoadQuestion( index, item )
|
|
this.doLoadQuestion( index, item )
|
|
})
|
|
})
|
|
}else{
|
|
}else{
|
|
@@ -335,12 +343,13 @@ export default {
|
|
let item = this.questionList[i];
|
|
let item = this.questionList[i];
|
|
if(item.type!= 4){
|
|
if(item.type!= 4){
|
|
let select = getSelect(item.answer);
|
|
let select = getSelect(item.answer);
|
|
- if( select) param.result[item.id] =select ;
|
|
|
|
|
|
+ if( select) param.result[item.answerId] =select ;
|
|
}else{
|
|
}else{
|
|
|
|
+ console.log("anli", item.child)
|
|
for( let j in item.child){
|
|
for( let j in item.child){
|
|
- if(!item.child[j] || !item.child[j].id) continue;
|
|
|
|
|
|
+ if(!item.child[j] || !item.child[j].answerId) continue;
|
|
let select = getSelect(item.child[j].answer);
|
|
let select = getSelect(item.child[j].answer);
|
|
- if(select) param.result[item.child[j].id] = select;
|
|
|
|
|
|
+ if(select) param.result[item.child[j].answerId] = select;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -378,14 +387,13 @@ export default {
|
|
this.isAnli = true;
|
|
this.isAnli = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
this.loadQuestion(0);
|
|
this.loadQuestion(0);
|
|
this.startTime = info.startTime;
|
|
this.startTime = info.startTime;
|
|
saveExam( this.info, this.questionList );
|
|
saveExam( this.info, this.questionList );
|
|
- // this.initTimer();
|
|
|
|
|
|
+ this.initTimer();
|
|
},
|
|
},
|
|
selectRadio( value, cidx ){
|
|
selectRadio( value, cidx ){
|
|
- let index = this.index;
|
|
|
|
|
|
+ let index = this.cindex;
|
|
let curAnswer = this.questionList[index];
|
|
let curAnswer = this.questionList[index];
|
|
if( curAnswer.type == 4 ){
|
|
if( curAnswer.type == 4 ){
|
|
this.questionList[index].child[cidx].answer = value;
|
|
this.questionList[index].child[cidx].answer = value;
|
|
@@ -395,7 +403,8 @@ export default {
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
},
|
|
},
|
|
selectCheckBox(value, cidx){
|
|
selectCheckBox(value, cidx){
|
|
- let index = this.index;
|
|
|
|
|
|
+ let index = this.cindex;
|
|
|
|
+ console.log("selectCheckBox", cidx, value )
|
|
let curAnswer= this.questionList[index];
|
|
let curAnswer= this.questionList[index];
|
|
if( curAnswer.type == 4 ){
|
|
if( curAnswer.type == 4 ){
|
|
this.questionList[index].child[cidx].answer = value;
|
|
this.questionList[index].child[cidx].answer = value;
|
|
@@ -426,7 +435,13 @@ export default {
|
|
let that = this;
|
|
let that = this;
|
|
//
|
|
//
|
|
httpServer("course.StartExamTest", {courseId, groupId} ).then(res => {
|
|
httpServer("course.StartExamTest", {courseId, groupId} ).then(res => {
|
|
- if( res.code != 200) return;
|
|
|
|
|
|
+ if( res.code != 200){
|
|
|
|
+ setTimeout( ()=>{
|
|
|
|
+ this.$router.go(-1);
|
|
|
|
+ }, 2000)
|
|
|
|
+ return
|
|
|
|
+ };
|
|
|
|
+ let answer = 0
|
|
let info = res.data||{}
|
|
let info = res.data||{}
|
|
info.questionList = info.answers.map( v =>{
|
|
info.questionList = info.answers.map( v =>{
|
|
v.marked = false
|
|
v.marked = false
|