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

考试 启用真实数据字段

parent cda8946c
...@@ -8,21 +8,23 @@ ...@@ -8,21 +8,23 @@
{ {
"path": "pages/video/index", "path": "pages/exam/index",
"style": { "style": {
"navigationBarTitleText": "培训&考试" "navigationBarTitleText": "入驻考试"
} }
}, },
{ {
"path": "pages/exam/index", "path": "pages/video/index",
"style": { "style": {
"navigationBarTitleText": "入驻考试" "navigationBarTitleText": "培训&考试"
} }
}, },
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
<view class="topicView"> <view class="topicView">
<text class="topicText">{{currentItem.topic}}</text> <text class="topicText">{{currentItem.topic}}</text>
</view> </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' " <text :class="item.isSelect ? 'itemText selectedColor' : 'itemText defaultColor' "
@click="itemClick(item,ikey)">{{item.answer}}</text> @click="itemClick(item,ikey)">{{item.content}}</text>
</view> </view>
<view class="answerBottomView"> <view class="answerBottomView">
<image class="timeIcon" src="" mode=""></image> <image class="timeIcon" src="" mode=""></image>
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
data() { data() {
return { return {
examId:1, examId:1,
userExamId:1,
userAnswerIds:'',
isStart:false, isStart:false,
currentNumber:1, currentNumber:1,
currentItem:null, currentItem:null,
...@@ -175,32 +177,70 @@ ...@@ -175,32 +177,70 @@
getData: function () { getData: function () {
this.currentItem = { this.currentItem = {
'topic':'这是第一道题的题目这是第一道题的题目', "isQuestion":true,
'list':[ "answerResult":false,
"examScore":0,
"examLevelDisc":"",
"examLevelResult":"",
"progress":"1/3",
"question": {
"id":3,
"content":"题目3",
"score":100,
"orderNumber":3,
"rightAnswerIds":"",
"answerType":1,
"excamId":1
},
"answerList": [
{ {
'answer':'这是选项一这是选项一这是选项一这是选项一', "id":1,
'isSelect':false, "content":"答案A",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
}, },
{ {
'answer':'这是选项二这是选项二这是选项二这是选项二', "id":2,
'isSelect':false, "content":"答案B",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
}, },
{ {
'answer':'这是选项三这是选项三这是选项三这是选项三', "id":3,
'isSelect':false, "content":"答案C",
"type":1,
"orderNumber":1,
"questionId":3,
"isRight":false
}
]
},
],
'isMulti':true,
} }
this.handleData()
this.startCounting() this.startCounting()
}, },
handleData: function () {
this.currentItem.answerList.forEach(item => {
item.isSelect = false
})
console.log(this.currentItem)
},
startCounting : function () { startCounting : function () {
this.currentTime = this.currentTime - 1 this.currentTime = this.currentTime - 1
...@@ -218,15 +258,16 @@ ...@@ -218,15 +258,16 @@
itemClick: function (currentItem , ikey) { itemClick: function (currentItem , ikey) {
this.isSelect = true this.isSelect = true
//answerType 题目类型,1单选,2多选,3简答,
for (let i = 0; i < this.currentItem.list.length; i++) { for (let i = 0; i < this.currentItem.answerList.length; i++) {
var item = this.currentItem.list[i] var item = this.currentItem.answerList[i]
if(this.currentItem.isMulti){ if(this.currentItem.answerType == 2){//多选
if(ikey == i){ if(ikey == i){
item.isSelect = !item.isSelect item.isSelect = !item.isSelect
} }
}else{ }else{//单选/简答
if(ikey == i){ if(ikey == i){
item.isSelect = !item.isSelect item.isSelect = !item.isSelect
}else{ }else{
...@@ -237,12 +278,13 @@ ...@@ -237,12 +278,13 @@
} }
var isSelect = false var isSelect = false
this.currentItem.list.forEach(item => { this.currentItem.answerList.forEach(item => {
if(item.isSelect){ if(item.isSelect){
isSelect = true isSelect = true
} }
}) })
//有选答案
this.isSelect = isSelect this.isSelect = isSelect
...@@ -251,8 +293,50 @@ ...@@ -251,8 +293,50 @@
//下一题 //下一题
nextClick: function () { nextClick: function () {
this.currentNumber = this.currentNumber + 1 this.currentNumber = this.currentNumber + 1
this.getData() //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() this.getNext()
}, },
//获取下一题 //获取下一题
...@@ -269,7 +353,9 @@ ...@@ -269,7 +353,9 @@
+getApp().globalData.token+'/serviceRule/next', +getApp().globalData.token+'/serviceRule/next',
method: 'POST', method: 'POST',
data: { data: {
examId:this.examId, userExamId:this.userExamId,
questionId:this.currentItem.question.id,
userAnswerIds:this.userAnswerIds,
}, },
success: (res) => { success: (res) => {
uni.hideLoading() 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