...
|
...
|
@@ -3,72 +3,34 @@ |
|
|
<!-- <div class="nodata" v-if="present_data==''">暂无考试内容</div> -->
|
|
|
<div>
|
|
|
<div class="texttitle">
|
|
|
考试题目一
|
|
|
<!-- {{ present_data.question_name }}({{
|
|
|
{{ present_data.question_name }}({{
|
|
|
present_data.type == 1 ? "单选" : "多选"
|
|
|
}}) -->
|
|
|
<!-- 单选 -->
|
|
|
}})
|
|
|
</div>
|
|
|
<!-- v-if="issure" -->
|
|
|
<div class="textlist">
|
|
|
<div class="textitem flex">
|
|
|
<div class="flex">
|
|
|
<!-- v-if="item.chose == true" -->
|
|
|
<div class="textitemleft">
|
|
|
<img src="../../../assets/meisel.png" alt="" />
|
|
|
|
|
|
<!-- <image src="../../static/meisel.png" mode="" v-else></image> -->
|
|
|
</div>
|
|
|
<div class="textitemright">
|
|
|
A。选项
|
|
|
<!-- {{ item.sel }}、{{ item.option_name }} -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="textitem flex">
|
|
|
<div class="flex">
|
|
|
<!-- v-if="item.chose == true" -->
|
|
|
<div class="textitemleft">
|
|
|
<img src="../../../assets/meisel.png" alt="" />
|
|
|
|
|
|
<!-- <image src="../../static/meisel.png" mode="" v-else></image> -->
|
|
|
</div>
|
|
|
<div class="textitemright">
|
|
|
B.选项
|
|
|
<!-- {{ item.sel }}、{{ item.option_name }} -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="textitem flex">
|
|
|
<div class="flex">
|
|
|
<!-- v-if="item.chose == true" -->
|
|
|
<div class="textitemleft">
|
|
|
<img src="../../../assets/meisel.png" alt="" />
|
|
|
|
|
|
<!-- <image src="../../static/meisel.png" mode="" v-else></image> -->
|
|
|
</div>
|
|
|
<div class="textitemright">
|
|
|
C。选项
|
|
|
<!-- {{ item.sel }}、{{ item.option_name }} -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="textitem flex">
|
|
|
<div class="textlist" v-if="issure">
|
|
|
<div
|
|
|
class="textitem flex"
|
|
|
v-for="(item, index) in present_data.option"
|
|
|
:key="index"
|
|
|
@click="selchose(index)"
|
|
|
>
|
|
|
<div class="flex">
|
|
|
<!-- v-if="item.chose == true" -->
|
|
|
<div class="textitemleft">
|
|
|
<img src="../../../assets/meisel.png" alt="" />
|
|
|
|
|
|
<!-- <image src="../../static/meisel.png" mode="" v-else></image> -->
|
|
|
<img
|
|
|
src="../../../assets/selright.png"
|
|
|
alt=""
|
|
|
v-if="item.chose == true"
|
|
|
/>
|
|
|
<img src="../../../assets/meisel.png" alt="" v-else />
|
|
|
</div>
|
|
|
<div class="textitemright">
|
|
|
D。选项
|
|
|
<!-- {{ item.sel }}、{{ item.option_name }} -->
|
|
|
{{ item.sel }}、{{ item.option_name }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- <div class="textlist" v-else>
|
|
|
|
|
|
<div class="textlist" v-else>
|
|
|
<div
|
|
|
class="textitem flex"
|
|
|
:class="
|
...
|
...
|
@@ -84,32 +46,32 @@ |
|
|
<div class="flex">
|
|
|
<div class="textitemleft">
|
|
|
<image
|
|
|
src="../../static/selright.png"
|
|
|
src="../../../assets/selright.png"
|
|
|
mode=""
|
|
|
v-if="item.answer == 1"
|
|
|
></image>
|
|
|
<image
|
|
|
src="../../static/slewrong.png"
|
|
|
src="../../../assets/slewrong.png"
|
|
|
mode=""
|
|
|
v-else-if="item.answer == 2 && item.chose == true"
|
|
|
></image>
|
|
|
<image src="../../static/meisel.png" mode="" v-else></image>
|
|
|
<image src="../../../assets/meisel.png" mode="" v-else></image>
|
|
|
</div>
|
|
|
<div class="textitemright">
|
|
|
{{ item.sel }}、{{ item.option_name }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="wrongimg" v-if="item.answer == 2 && item.chose == true">
|
|
|
<image src="../../static/wrong.png" mode=""></image>
|
|
|
<image src="../../../assets/wrong.png" mode=""></image>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div> -->
|
|
|
</div>
|
|
|
|
|
|
<div class="huiyuanbot boxsizing">
|
|
|
<!-- v-if="issure" -->
|
|
|
<div>
|
|
|
<div class="behuiyuanbtn">确认</div>
|
|
|
<div v-if="issure">
|
|
|
<div class="behuiyuanbtn" @click="sureti">确认</div>
|
|
|
</div>
|
|
|
<!-- <div v-else>
|
|
|
<div v-else>
|
|
|
<div
|
|
|
class="behuiyuanbtn"
|
|
|
@click="nextquestion"
|
...
|
...
|
@@ -121,14 +83,248 @@ |
|
|
<div v-else>
|
|
|
<div class="behuiyuanbtn" v-if="showfinish">完成</div>
|
|
|
<div class="behuiyuanbtn" @click="sure" v-else>完成</div>
|
|
|
</div> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {};
|
|
|
import { Toast } from 'vant';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
questionnaire_id: '',
|
|
|
present_data: '',
|
|
|
last_data: '',
|
|
|
next_data: '',
|
|
|
question_id: '',
|
|
|
score: 0,
|
|
|
selitem: 0,
|
|
|
//是否在上一题返回的下一题
|
|
|
islast: 0,
|
|
|
present_datakarr: [],
|
|
|
issure: true,
|
|
|
showfinish: false
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.questionnaire_id = this.$route.query.id;
|
|
|
this.getqusetion();
|
|
|
},
|
|
|
methods: {
|
|
|
getqusetion() {
|
|
|
let that = this;
|
|
|
var url = '/api/question/get_question';
|
|
|
var params = {
|
|
|
questionnaire_id: that.questionnaire_id,
|
|
|
question_id: that.question_id
|
|
|
}
|
|
|
console.log(params)
|
|
|
that.$axios.post(url, params).then((res) => {
|
|
|
console.log(res);
|
|
|
console.log(res.data.present_data)
|
|
|
that.present_data = res.data.present_data;
|
|
|
that.present_data.canchose = 0;
|
|
|
that.present_data.option.forEach(function (value, index, array) {
|
|
|
value.chose = false;
|
|
|
switch (index) {
|
|
|
case 0:
|
|
|
value.sel = 'A';
|
|
|
break;
|
|
|
case 1:
|
|
|
value.sel = 'B';
|
|
|
break;
|
|
|
case 2:
|
|
|
value.sel = 'C';
|
|
|
break;
|
|
|
case 3:
|
|
|
value.sel = 'D';
|
|
|
break;
|
|
|
}
|
|
|
})
|
|
|
that.present_data = that.present_data;
|
|
|
that.last_data = res.data.last_data;
|
|
|
that.next_data = res.data.next_data;
|
|
|
// 查看题目答案是否正确t("present_datakarr");
|
|
|
let newpresent_datakarr = JSON.parse(localStorage.getItem("present_datakarr"));
|
|
|
if (newpresent_datakarr != null) {
|
|
|
console.log(newpresent_datakarr)
|
|
|
newpresent_datakarr.forEach(function (value, index, array) {
|
|
|
// console.log(348934,value)
|
|
|
// console.log('1111',that.present_data)
|
|
|
if (value.id == that.present_data.id) {
|
|
|
that.present_data = value;
|
|
|
// console.log(that.present_data)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 选择题目
|
|
|
selchose(index) {
|
|
|
let that = this;
|
|
|
that.selitem++;
|
|
|
that.present_data.canchose++;
|
|
|
console.log('选中的题数', that.present_data.canchose)
|
|
|
that.present_data.option.forEach(function (value, indexk, array) {
|
|
|
if (that.present_data.correct_number == 1) {
|
|
|
if (index == indexk) {
|
|
|
value.chose = true;
|
|
|
// value.canchose++;
|
|
|
that.$forceUpdate();
|
|
|
} else {
|
|
|
value.chose = false;
|
|
|
that.$forceUpdate();
|
|
|
}
|
|
|
} else {
|
|
|
if (index == indexk) {
|
|
|
value.chose = true;
|
|
|
that.$forceUpdate();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
that.present_data = that.present_data;
|
|
|
if (that.present_data.correct_number == 1) {
|
|
|
that.present_data.option.forEach(function (value, index, array) {
|
|
|
if (value.chose == true && value.answer == 1) {
|
|
|
that.score = that.score + that.present_data.score;
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
let arr = []
|
|
|
that.present_data.option.forEach(function (value, index, array) {
|
|
|
if (value.chose == true && value.answer == 1) {
|
|
|
arr.push(1)
|
|
|
}
|
|
|
if (arr.length == that.present_data.correct_number) {
|
|
|
that.score = that.score + that.present_data.score;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
console.log(that.present_data)
|
|
|
console.log('考试得分', that.score)
|
|
|
localStorage.setItem("present_datak", JSON.stringify(that.present_data))
|
|
|
localStorage.setItem("last_datak", JSON.stringify(that.last_data));
|
|
|
localStorage.setItem("next_datak", JSON.stringify(that.next_data));
|
|
|
|
|
|
|
|
|
this.present_datakarr.push(this.present_data);
|
|
|
|
|
|
console.log(this.present_datakarr)
|
|
|
localStorage.setItem("present_datakarr", JSON.stringify(this.present_datakarr));
|
|
|
|
|
|
console.log('xiaadsk', that.next_data)
|
|
|
},
|
|
|
|
|
|
//下一题
|
|
|
nextquestion() {
|
|
|
let that = this;
|
|
|
this.question_id = this.next_data.id;
|
|
|
console.log('判断是否答题', that.selitem);
|
|
|
// 判断是否答题
|
|
|
if (that.selitem == 0) {
|
|
|
Toast("请答题")
|
|
|
} else {
|
|
|
that.selitem = 0;
|
|
|
that.getqusetion();
|
|
|
that.issure = true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 上一题
|
|
|
prequestion() {
|
|
|
// this.present_data=uni.getStorageSync("present_data");
|
|
|
// this.last_data=uni.getStorageSync("last_data");
|
|
|
// this.next_data=uni.getStorageSync("next_data");
|
|
|
|
|
|
this.question_id = this.last_data.id;
|
|
|
this.islast = 1;
|
|
|
this.getqusetion();
|
|
|
|
|
|
},
|
|
|
|
|
|
// 上一题
|
|
|
prequestion() {
|
|
|
// this.present_data=uni.getStorageSync("present_data");
|
|
|
// this.last_data=uni.getStorageSync("last_data");
|
|
|
// this.next_data=uni.getStorageSync("next_data");
|
|
|
|
|
|
this.question_id = this.last_data.id;
|
|
|
this.islast = 1;
|
|
|
this.getqusetion();
|
|
|
|
|
|
},
|
|
|
|
|
|
sureti() {
|
|
|
console.log(343348989)
|
|
|
let that = this;
|
|
|
let arr = []
|
|
|
console.log(that.present_data.option);
|
|
|
that.present_data.option.forEach(function (value, indexk, array) {
|
|
|
if (value.chose == false) {
|
|
|
arr.push(1)
|
|
|
}
|
|
|
})
|
|
|
console.log(arr)
|
|
|
|
|
|
if (arr.length == that.present_data.option.length) {
|
|
|
Toast('请答题')
|
|
|
return false
|
|
|
}
|
|
|
this.issure = false
|
|
|
this.question_id = this.present_data.id;
|
|
|
this.getqusetion()
|
|
|
},
|
|
|
|
|
|
sure() {
|
|
|
let that = this;
|
|
|
that.showfinish = true
|
|
|
var url = '/api/question/submit_answer';
|
|
|
var params = {
|
|
|
questionnaire_id: that.questionnaire_id,
|
|
|
score: that.score
|
|
|
}
|
|
|
console.log('7766554', params)
|
|
|
that.$axios.post(url, params).then((res) => {
|
|
|
console.log(res);
|
|
|
console.log(that.score)
|
|
|
Toast('提交成功')
|
|
|
localStorage.setItem("present_datak", null)
|
|
|
|
|
|
localStorage.setItem("present_datakarr", null);
|
|
|
|
|
|
this.$router.push({
|
|
|
path: '/kaoshiresult',
|
|
|
query: {
|
|
|
score: that.score,
|
|
|
id: that.questionnaire_id,
|
|
|
is_pass: res.data.is_pass
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}).catch((err) => {
|
|
|
console.log(err)
|
|
|
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
...
|
...
|
|