Commit 1a4811e1 authored by 和慭琛's avatar 和慭琛

考试 启用真实数据字段

parent cda8946c
......@@ -8,21 +8,23 @@
{
"path": "pages/video/index",
"path": "pages/exam/index",
"style": {
"navigationBarTitleText": "培训&考试"
"navigationBarTitleText": "入驻考试"
}
},
{
"path": "pages/exam/index",
"path": "pages/video/index",
"style": {
"navigationBarTitleText": "入驻考试"
"navigationBarTitleText": "培训&考试"
}
},
{
"path": "pages/index/index",
"style": {
......
......@@ -18,9 +18,9 @@
<view class="topicView">
<text class="topicText">{{currentItem.topic}}</text>
</view>
<view class="itemView" v-for="(item,ikey) in currentItem.list":key="ikey">
<view class="itemView" v-for="(item,ikey) in currentItem.answerList":key="ikey">
<text :class="item.isSelect ? 'itemText selectedColor' : 'itemText defaultColor' "
@click="itemClick(item,ikey)">{{item.answer}}</text>
@click="itemClick(item,ikey)">{{item.content}}</text>
</view>
<view class="answerBottomView">
<image class="timeIcon" src="" mode=""></image>
......@@ -39,6 +39,8 @@
data() {
return {
examId:1,
userExamId:1,
userAnswerIds:'',
isStart:false,
currentNumber:1,
currentItem:null,
......@@ -175,32 +177,70 @@
getData: function () {
this.currentItem = {
'topic':'这是第一道题的题目这是第一道题的题目',
'list':[
{
'answer':'这是选项一这是选项一这是选项一这是选项一',
'isSelect':false,
},
{
'answer':'这是选项二这是选项二这是选项二这是选项二',
'isSelect':false,
},
{
'answer':'这是选项三这是选项三这是选项三这是选项三',
'isSelect':false,
},
],
'isMulti':true,
"isQuestion":true,
"answerResult":false,
"examScore":0,
"examLevelDisc":"",
"examLevelResult":"",
"progress":"1/3",
"question": {
"id":3,
"content":"题目3",
"score":100,
"orderNumber":3,
"rightAnswerIds":"",
"answerType":1,
"excamId":1
},
"answerList": [
{
"id":1,
"content":"答案A",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
},
{
"id":2,
"content":"答案B",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
},
{
"id":3,
"content":"答案C",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
}
]
}
this.handleData()
this.startCounting()
},
handleData: function () {
this.currentItem.answerList.forEach(item => {
item.isSelect = false
})
console.log(this.currentItem)
},
startCounting : function () {
this.currentTime = this.currentTime - 1
......@@ -218,15 +258,16 @@
itemClick: function (currentItem , ikey) {
this.isSelect = true
//answerType 题目类型,1单选,2多选,3简答,
for (let i = 0; i < this.currentItem.list.length; i++) {
var item = this.currentItem.list[i]
for (let i = 0; i < this.currentItem.answerList.length; i++) {
var item = this.currentItem.answerList[i]
if(this.currentItem.isMulti){
if(this.currentItem.answerType == 2){//多选
if(ikey == i){
item.isSelect = !item.isSelect
}
}else{
}else{//单选/简答
if(ikey == i){
item.isSelect = !item.isSelect
}else{
......@@ -237,12 +278,13 @@
}
var isSelect = false
this.currentItem.list.forEach(item => {
this.currentItem.answerList.forEach(item => {
if(item.isSelect){
isSelect = true
}
})
//有选答案
this.isSelect = isSelect
......@@ -251,8 +293,50 @@
//下一题
nextClick: function () {
this.currentNumber = this.currentNumber + 1
this.getData()
this.getNext()
//this.getData()
this.handleAnswer()
//this.getNext()
},
//所选答案
handleAnswer: function () {
/*
userAnswerIds
本题回答。
多选题时id按从小到大排序,并英文逗号,分隔;
简答题时直接存问题答案。
如果是第一次答题,不需要传。
*/
// var idList = []
// idList.push(item.id)
this.currentItem.answerList.forEach(item => {
// if(this.currentItem.answerType == 2){//多选}
if(item.isSelect){
//this.userAnswerIds = item.id + ',' + this.userAnswerIds
///*
if(this.userAnswerIds.length == 0){
this.userAnswerIds = item.id
}else{ // if(this.userAnswerIds.length == 1)
this.userAnswerIds = item.id + ',' + this.userAnswerIds
}
//*/
}
})
console.log('所选答案:')
console.log(this.userAnswerIds)
this.getNext()
},
//获取下一题
......@@ -269,7 +353,9 @@
+getApp().globalData.token+'/serviceRule/next',
method: 'POST',
data: {
examId:this.examId,
userExamId:this.userExamId,
questionId:this.currentItem.question.id,
userAnswerIds:this.userAnswerIds,
},
success: (res) => {
uni.hideLoading()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment