html部分
<!--pages/answer/index.wxml-->
<view class='page pagewhite'>
<view class="topmian">
<view class="topdao">
<i-count-down
countdown-class="bigtime"
target="{{targetTime2}}"
bindcallback="myLinsterner"
clear-timer="{{clearTimer}}"
>
</i-count-down>
</view>
</view>
<!--题目-->
<view style='padding-bottom:44px;'>
<view class="question-list">
<view class="question-list-title">
<text class="questips">{{questionlist[questionCurrent]['typename']}}</text>
<text class='question-title'>{{questionlist[questionCurrent]['title']}}</text>
</view>
</view>
<!--答案选择 - 单选-->
<i-panel wx:if="{{questionlist[questionCurrent]['type']==1}}">
<i-radio-group current="{{current}}" bindchange="handleChange">
<i-radio color="#009B89" wx:for="{{questionlist[questionCurrent]['options']}}" wx:key="{{item.code}}" disabled="{{disabled}}" position="left" value="{{item.code + '. ' + item.content}}"></i-radio>
</i-radio-group>
</i-panel>
<!--答案选择 - 多选-->
<i-panel wx:if="{{questionlist[questionCurrent]['type']==2}}">
<i-checkbox-group
current="{{currentD}}"
wx:for="{{questionlist[questionCurrent]['options']}}"
wx:key="{{item.code}}"
data-id="{{item.code}}"
data-name="{{item.content}}"
bindchange="morechose">
<i-checkbox
color="#009B89"
disabled="{{disabled1}}"
wx:key="{{index}}"
position="left"
value="{{item. code + '. ' + item. content}}"
>
</i-checkbox>
</i-checkbox-group>
</i-panel>
<!--答案选择 - 判断-->
<i-panel wx:if="{{questionlist[questionCurrent]['type']==3}}">
<i-radio-group current="{{current}}" bindchange="panduan">
<i-radio color="#009B89" wx:for="{{questionlist[questionCurrent]['options']}}" wx:key="{{item.code}}" disabled="{{disabled}}" position="left" value="{{item.code + '. ' + item.content}}">
</i-radio>
</i-radio-group>
</i-panel>
<view class="pageview">
<view>
<!--slot="prev"-->
<view class="prewview {{indexnum == 1?'typeactive':''}}"
disabled="{{!questionlist[questionCurrent]['prev']['disabled']}}"
bindtap="laststep" >上一题</view>
</view>
<view>
<view class="nextview {{indexnum == questionlist.length?'typeactive':''}}" bindtap="nextstep" >下一题</view>
</view>
</view>
<!--
<view class="outresult">
<view>答题结果:
<text style="color:#FF1E55">错误</text>
<text style="color:#009B89">正确</text></view>
<view>正确答案:<text style="color:#009B89">A,B,C</text></view>
</view>
<!--底部栏-->
<view class='tab-bar'>
<i-row>
<i-col span="20" i-class="col-class">
<view class="i-action-header-left">
<!-->
<text>正确: <text style="font-weight: bold;color:#3D971C">{{questionOk}}</text></text>
<text>错误: <text style="font-weight: bold;color:#A01E32">{{questionErr}}</text></text>
<text>正确率: <text style="font-weight: bold;color:#18836b">{{percentage}}%</text></text>
-->
<view class="footer-defbtn" bindtap='handleOpen'>
<view class='footer-btn-text'>
<i-icon type="activity" size='20' color="#666666" class='footer-btn-text' />
<text>{{questionCurrent+1}}/{{total}}</text>
</view>
</view>
</view>
</i-col>
<i-col span="4" i-class="col-class">
<!--
<view class="i-action-header-r">
<button style="padding:0px;" bindtap="actionCancel" size="small">关闭</button>
</view>
-->
<view class="i-action-header-r tijiaoheader">
<button class="tijiao" style="padding:0px;" bindtap="handleSubmitOpen" size="small">提交答卷</button>
</view>
</i-col>
</i-row>
</view>
<!--下拉弹出-->
<i-action-sheet visible="{{ actionVisible }}" actions="" bind:cancel="actionCancel" bind:click="actionClickItem">
<view slot="header" style="padding:2px">
<view class="i-action-header">
<i-row>
<i-col span="20" i-class="col-class">
<view class="i-action-header-left">
<!-->
<text>正确: <text style="font-weight: bold;color:#3D971C">{{questionOk}}</text></text>
<text>错误: <text style="font-weight: bold;color:#A01E32">{{questionErr}}</text></text>
<text>正确率: <text style="font-weight: bold;color:#18836b">{{percentage}}%</text></text>
-->
<view class="footer-defbtn" bindtap='handleOpen'>
<view class='footer-btn-text'>
<i-icon type="activity" size='20' color="#666666" class='footer-btn-text' />
<text>{{questionCurrent+1}}/{{total}}</text>
</view>
</view>
</view>
</i-col>
<i-col span="4" i-class="col-class">
<view class="i-action-header-r tijiaoheader">
<button class="tijiao" style="padding:0px;" bindtap="handleSubmitOpen" size="small">提交答卷</button>
</view>
</i-col>
</i-row>
</view>
<scroll-view>
<view class='i-action-ico'>
<view wx:for="{{result}}" class="i-action-ico-bor" data-index="{{index}}" wx:key="i" bindtap="goindex">
<view
class="{{index==currentPage-1?'def':''}} {{item.judge==1?'succ':item.judge==0?'err':''}}"
data-index="index"
>
<!--
<i-icon type="right" color="#3D971C" wx:if="{{item.judge==1}}" size="14" />
<i-icon type="close" color="#A01E32" wx:if="{{item.judge==0}}" size="14" />
-->
<text>{{index+1}}</text>
</view>
</view>
<!-- <view>1 </view> -->
</view>
</scroll-view>
</view>
</i-action-sheet>
<!--下拉弹出-->
<!--交卷对话框-->
<i-modal title="提交答卷" visible="{{ showanswer }}" actions="{{ actanswer }}" bind:click="handanswer">
<view wx:if="{{unanswered.length!=0}}">您还有{{unanswered}}道题未答完哦,</view>
<view>您确认提交答卷吗?</view>
</i-modal>
<!--考试合格弹出层
<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{goodshow}}"></view>
<view class="modalDlg" wx:if="{{goodshow}}">
<image class="goodimg" src="../../images/good3.png"></image>
<i-row i-class="outmain">
<i-col span="8" i-class="col-class">
<text style="font-weight:bold">55分</text>
<text>考试成绩</text>
</i-col>
<i-col span="8" i-class="col-class">
<text style="font-weight:bold;color:#009B89">89</text>
<text style="color:#009B89">正确题目数</text>
</i-col>
<i-col span="8" i-class="col-class">
<text style="font-weight:bold;color:red">523</text>
<text style="color:red" >错误题目数</text>
</i-col>
</i-row>
<i-row i-class="outmain outanswer">
<view style="float:left;color:#009B89;border:1px solid #009B89">查看答卷</view>
<view style="float:right;color:white;background:#009B89">结束考试</view>
</i-row>
</view>
-->
<!--考试不及格弹出层 -->
<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{badshow}}"></view>
<view class="modalDlg" wx:if="{{badshow}}">
<image class="goodimg" wx:if="{{examidResult.result==1}}" src="../../images/good3.png"></image>
<image class="goodimg" wx:if="{{examidResult.result==0}}" src="../../images/bad.png"></image>
<i-row i-class="outmain">
<i-col span="8" i-class="col-class">
<text style="font-weight:bold">{{examidResult.score}}分</text>
<text>考试成绩</text>
</i-col>
<i-col span="8" i-class="col-class">
<text style="font-weight:bold;color:#009B89">{{examidResult.question.right}}</text>
<text style="color:#009B89">正确题目数</text>
</i-col>
<i-col span="8" i-class="col-class">
<text style="font-weight:bold;color:red">{{examidResult.question.wrong}}</text>
<text style="color:red" >错误题目数</text>
</i-col>
</i-row>
<i-row i-class="outmain outanswer">
<view style="float:left;color:#009B89;border:1px solid #009B89" bindtap='examidView'>查看答卷</view>
<view wx:if="{{examidResult.result==1}}" style="float:right;color:white;background:#009B89" bindtap='examidEnd'>结束考试</view>
<view wx:if="{{hasshow == 1}}" style="float:right;color:white;background:#009B89" bindtap='examidNew'>开始补考</view>
</i-row>
</view>
<!--提交答卷
<i-modal title="提交答卷" visible="{{ showanswer }}" actions="{{ actanswer }}" bind:click="handanswer">
<view>您确认提交答卷吗?</view>
</i-modal>-->
<!--时间到交卷对话框-->
<i-modal title="提示" visible="{{visible2}}" actions="{{action2}}" bind:click="handleSubmit">
<view>时间已到,系统自动交卷</view>
</i-modal>
</view>
</view>
<i-message id="message" />
<i-toast id="toast" />
js部分
// pages/answer/index.js
const { $Toast } = require('../../dist/base/index');
var http = require('../../utils/httputils.js'); //相对路径
var app = getApp();// 调用全局变量
import { $wuxCountDown } from '../../wux/index'
const { $Message } = require('../../dist/base/index');
Page({
data: {
hasshow: 0,
unanswered: 0,
currentD: [],
currentDId: [],
examid: null,
paperid: null,
examidPaperid: null,
examidResult: null,
answerResult: [],
userid: null,
questionlist: [],
questionCurrent: 0,
pageCurrent: 1,
currentItem: 0,
badshow: false,
goodshow: false,
loading: false, //加载中
showanswer: false,
result: [], //题目
total: 0, //题目总总数
menu: '', //套题id
questionMenu: '', //套题名称
questionInfo: {},
percent: 0, //进度条百分比
time: 45, //时间
s: ['A. ', 'B. ', 'C. ', 'D. ', 'E. '],
index: 1, //第几题
current: "", //单选选中的答案
currentPage: 1,
type: '', //题目类型 1:单选 2:多选
disabled: false, //单选选中不可选
disabled1: false, //多选选中不可选
actionVisible: false, //弹出层
questionErr: 0, //错题个数
questionOk: 0, // 正确个数
percentage: 0,
visible1: false,
visible2: false,
visible3: false,
visible4: false,
action1: [{
name: '取消'
},
{
name: '确定',
color: '#2db7f5',
loading: false
}
],
action2: [{
name: '确定',
color: '#2db7f5',
loading: false
}],
actanswer: [{
name: '取消'
},
{
name: '确认',
color: '#19be6b'
},
],
action4: [{
name: '取消'
},
{
name: '确定',
color: '#2db7f5',
loading: false
}
],
showVideo: false,
answerEach: '',
answerMore: '',
ansChose: '',
questionIndex: '',
indexnum: 1,
clearTimer: false
},
onLoad(e) {
var that = this;
console.log(e.duration)
var time = Number(e.duration) * 1000
console.log(time)
console.log(6430000)
//var questionMenu = e.questionMenu;
this.setData({
targetTime2: new Date().getTime() + time,
examid: e.examid,
paperid: e.paperid,
userid: app.globalData.userInfo.userid,
})
wx.getSystemInfo({
success(res) {
that.setData({
windowWidth: res.windowWidth
})
}
})
that.getExamUserPaperProfile();
},
onUnload() {
this.setData({
clearTimer: true
});
},
//定时器自动交卷
myLinsterner(e) {
this.handleMask()
},
handleMask() {
var that = this;
$Toast({
content: '时间到,自动交卷',
icon: 'prompt',
duration: 0,
mask: false
});
setTimeout(() => {
$Toast.hide();
this.goontime()
}, 500);
},
goontime() {
var that = this;
var params = {
examid: this.data.examid,
paperid: this.data.examidPaperid,
userid: this.data.userid,
questionlist: this.data.answerResult
}
//人员考试-提交答卷-判定成绩
//debugger
http.postRequest(http.LING + "/wxapp/exam/user/paper/submit", params, function (res) {
console.log(res)
if (parseInt(res.error) === 0) {
console.log("提交成功")
$Toast({
content: '提交成功!',
type: 'success',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
that.setData({
hasshow: res.data.markup.has,
examid: res.data.markup.examid,
examidResult: res.data,
showanswer: false,
badshow: true
});
}, 200);
} else {
$Toast({
content: '提交失败!',
type: 'warning',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
}, 200);
}
}, function (err) {
$Toast({
content: '提交失败!',
type: 'warning',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
}, 200);
console.log(err)
})
},
nextques() {
$Toast({
content: '没有更多题目了',
type: 'warning'
});
},
itemClick(options) {
console.log(options)
var that = this;
var id = options.currentTarget.dataset.id;
console.log(id)
//设置当前样式
that.setData({
'currentItem': id
})
},
onReady(res) {
this.videoContext = wx.createVideoContext('myVideo')
},
/**
* 获取人员答卷详情
*/
getExamUserPaperProfile() {
var that = this;
var params = {
"examid": that.data.examid,
"userid": that.data.userid,
"paperid": that.data.paperid
}
http.getRequest(http.LING + "/wxapp/exam/user/paper/profile", params, function (res) {
console.log(res)
if (parseInt(res.error) === 0) {
var qlist = res.data.questionlist;
for (var i = 0; i < qlist.length; i++) {
qlist[i]['judge'] = null
}
console.log('qlist', qlist);
that.setData({
questionlist: res.data.questionlist,
total: res.data.qustionnum,
result: qlist,
examidPaperid: res.data.paperid,
});
} else {
that.setData({
questionlist: [],
total: 0
});
}
}, function (err) {
console.log(err)
that.setData({
questionlist: [],
total: 0
});
})
},
//上一题bbb
laststep() {
var that = this;
if (that.data.currentPage === 1) {
$Toast({
content: '这已经是第一题了',
type: 'warning'
});
return false
}
if (that.data.currentPage > 1) {
that.setData({
indexnum: that.data.indexnum - 1,
pageCurrent: that.data.pageCurrent - 1,
currentPage: that.data.pageCurrent - 1,
questionCurrent: that.data.questionCurrent - 1,
current: '',
answerEach: ''
});
}
console.log("currentPage" + that.data.currentPage)
console.log("indexnum" + that.data.indexnum)
var answerResult = JSON.parse(JSON.stringify(this.data.answerResult));
var index = answerResult.map(item => item.questionid).indexOf(this.data.result[this.data.currentPage - 1]['questionid']);
if (index > -1) {
var current = ""
var currentD = []
if (answerResult[index]['answer'].constructor === String) {
var resultOptions = this.data.result[this.data.currentPage - 1]['options']
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer']);
current = resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content']
}
console.log(resultOptions)
//debugger
console.log(resultOptions)
if (answerResult[index]['answer'].constructor === Array) {
var resultOptions = this.data.result[this.data.currentPage - 1]['options']
for (var i = 0; i < answerResult[index]['answer'].length; i++) {
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer'][i]);
currentD.push(resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content'])
}
}
this.setData({
answerEach: answerResult[index]['answer'],
current: current,
currentD: currentD,
currentDId: answerResult[index]['answer']
});
}else{
this.setData({
answerEach: '',
current: '',
currentD: [],
currentDId: []
});
}
},
//下一题nnn
nextstep() {
var that = this;
console.log("indexnum___" + that.data.indexnum)
if (that.data.indexnum === that.data.questionlist.length) {
$Toast({
content: '这已经是最后一题了',
type: 'warning'
});
return false
}
//未答题可跳过继续往下答题
if (!that.data.answerEach) {
that.setData({
indexnum: that.data.indexnum + 1,
pageCurrent: that.data.pageCurrent + 1,
currentPage: that.data.pageCurrent + 1,
questionCurrent: that.data.questionCurrent + 1,
//current: '',
//answerEach: ''
});
console.log("下一题第几题__" + that.data.questionCurrent)
console.log("currentPage" + that.data.currentPage)
console.log("indexnum" + that.data.indexnum)
var answerResult = JSON.parse(JSON.stringify(that.data.answerResult));
var index = answerResult.map(item => item.questionid).indexOf(that.data.result[that.data.currentPage - 1]['questionid']);
if (index > -1) {
var current = ""
var currentD = []
if (answerResult[index]['answer'].constructor === String) {
var resultOptions = that.data.result[that.data.currentPage - 1]['options']
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer']);
current = resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content']
}
if (answerResult[index]['answer'].constructor === Array) {
var resultOptions = that.data.result[that.data.currentPage - 1]['options']
for (var i = 0; i < answerResult[index]['answer'].length; i++) {
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer'][i]);
currentD.push(resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content'])
}
}
that.setData({
answerEach: answerResult[index]['answer'],
current: current,
currentD: currentD,
currentDId: answerResult[index]['answer']
});
} else {
that.setData({
answerEach: '',
current: '',
currentD: [],
currentDId: []
});
}
return false
}
var indexData = that.data.questionlist[that.data.questionCurrent]
var params = {
"examid": that.data.examid,
"paperid": that.data.examidPaperid,
"questionid": indexData.questionid,
"answer": that.data.answerEach,
"userid": that.data.userid
};
//debugger
http.postRequest(http.LING + "/wxapp/exam/user/paper/question/submit", params, function (res) {
console.log(res)
//debugger
if (parseInt(res.error) === 0) {
that.setData({
indexnum: that.data.indexnum + 1,
pageCurrent: that.data.pageCurrent + 1,
currentPage: that.data.pageCurrent + 1,
questionCurrent: that.data.questionCurrent + 1,
answerEach: '',
current: '',
currentD: [],
currentDId: []
});
console.log("currentPage" + that.data.currentPage)
console.log("indexnum" + that.data.indexnum)
var answerResult = JSON.parse(JSON.stringify(that.data.answerResult));
var index = answerResult.map(item => item.questionid).indexOf(that.data.result[that.data.currentPage - 1]['questionid']);
if (index > -1) {
var current = ""
var currentD = []
if (answerResult[index]['answer'].constructor === String) {
var resultOptions = that.data.result[that.data.currentPage - 1]['options']
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer']);
current = resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content']
}
if (answerResult[index]['answer'].constructor === Array) {
var resultOptions = that.data.result[that.data.currentPage - 1]['options']
for (var i = 0; i < answerResult[index]['answer'].length; i++) {
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer'][i]);
currentD.push(resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content'])
}
}
that.setData({
answerEach: answerResult[index]['answer'],
current: current,
currentD: currentD,
currentDId: answerResult[index]['answer']
});
} else {
that.setData({
answerEach: '',
current: '',
currentD: [],
currentDId: []
});
}
}
console.log("下一题第几题__" + that.data.questionCurrent)
}, function (err) {
console.log(err)
// that.setData({
// questionlist: [],
// total: 0
// });
})
},
//单选
handleChange({ detail = {}, target = {} }) {
let questionInfo = this.data.questionInfo;
var val = detail.value.substr(0, 1);
var answerResult = JSON.parse(JSON.stringify(this.data.answerResult));
console.log(answerResult)
var index = answerResult.map(item => item.questionid).indexOf(this.data.result[this.data.currentPage - 1]['questionid']);
if (index > -1) {
answerResult[index]['answer'] = val;
} else {
answerResult.push({
questionid: this.data.result[this.data.currentPage - 1]['questionid'],
answer: val
})
}
this.setData({
answerEach: val,
answerResult: answerResult,
// questionInfo: questionInfo,
current: detail.value
});
//获取答案
console.log(questionInfo)
console.log(detail.value)
var rsdata = JSON.parse(JSON.stringify(this.data.result));
console.log(rsdata)
if (rsdata[this.data.currentPage - 1]['judge'] != 1) {
rsdata[this.data.currentPage - 1]['judge'] = 1;
this.setData({
result: rsdata
});
}
},
//判断对错
panduan({ detail = {}, target = {} }) {
let questionInfo = this.data.questionInfo;
console.log(target.dataset.id)
//判断答案
// if (target.dataset.id) {
// console.log('ok')
// questionInfo.isOk = 1
// } else {
// questionInfo.isOk = 0
// }
var val = detail.value.substr(0, 1);
var answerResult = JSON.parse(JSON.stringify(this.data.answerResult));
var index = answerResult.map(item => item.questionid).indexOf(this.data.result[this.data.currentPage - 1]['questionid']);
if (index > -1) {
answerResult[index]['answer'] = val;
} else {
answerResult.push({
questionid: this.data.result[this.data.currentPage - 1]['questionid'],
answer: val
})
}
this.setData({
//questionInfo: questionInfo,
answerEach: val,
answerResult: answerResult,
current: detail.value
});
var rsdata = JSON.parse(JSON.stringify(this.data.result));
if (rsdata[this.data.currentPage - 1]['judge'] != 1) {
rsdata[this.data.currentPage - 1]['judge'] = 1;
this.setData({
result: rsdata
});
}
},
//多选
morechose(event) {
//let questionInfo = this.data.questionInfo;
//sconsole.log(this.data.currentD);
console.log(event.currentTarget.dataset)
var currentD = JSON.parse(JSON.stringify(this.data.currentD));
var val = event.currentTarget.dataset.id + '. ' + event.currentTarget.dataset.name
var index = currentD.indexOf(val);
index === -1 ? currentD.push(val) : currentD.splice(index, 1);
var currentDId = JSON.parse(JSON.stringify(this.data.currentDId));
var index = currentDId.indexOf(event.currentTarget.dataset.id);
index === -1 ? currentDId.push(event.currentTarget.dataset.id) : currentDId.splice(index, 1);
var answerResult = JSON.parse(JSON.stringify(this.data.answerResult));
var index = answerResult.map(item => item.questionid).indexOf(this.data.result[this.data.currentPage - 1]['questionid']);
if (index > -1) {
answerResult[index]['answer'] = currentDId;
} else {
answerResult.push({
questionid: this.data.result[this.data.currentPage - 1]['questionid'],
answer: currentDId
})
}
this.setData({
currentD: currentD,
answerEach: currentDId,
currentDId: currentDId,
answerResult: answerResult
});
console.log(this.data.currentD)
console.log(this.data.currentDId)
if (this.data.result[this.data.currentPage - 1]['judge'] != 1) {
var rsdata = JSON.parse(JSON.stringify(this.data.result));
rsdata[this.data.currentPage - 1]['judge'] = 1;
this.setData({
result: rsdata
});
}
},
//下标点击
goindex(target) {
var that = this;
this.setData({
indexnum: target.currentTarget.dataset.index + 1,
questionCurrent: target.currentTarget.dataset.index,
currentPage: target.currentTarget.dataset.index + 1,
pageCurrent: target.currentTarget.dataset.index + 1,
answerEach: '',
current: '',
currentD: [],
currentDId: []
})
/*
console.log("currentPage" + that.data.currentPage)
console.log("点击第几题__" + this.data.questionCurrent)
console.log(target.currentTarget.dataset.index);
console.log(this.data.answerResult);
*/
var answerResult = JSON.parse(JSON.stringify(this.data.answerResult));
console.log(answerResult)
var index = answerResult.map(item => item.questionid).indexOf(this.data.result[this.data.currentPage - 1]['questionid']);
if (index > -1) {
var current = ""
var currentD = []
if (answerResult[index]['answer'].constructor === String) {
var resultOptions = this.data.result[this.data.currentPage - 1]['options']
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer']);
current = resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content']
}
if (answerResult[index]['answer'].constructor === Array) {
var resultOptions = this.data.result[this.data.currentPage - 1]['options']
for (var i = 0; i < answerResult[index]['answer'].length; i++) {
var idx = resultOptions.map(item => item.code).indexOf(answerResult[index]['answer'][i]);
currentD.push(resultOptions[idx]['code'] + '. ' + resultOptions[idx]['content'])
}
}
this.setData({
answerEach: answerResult[index]['answer'],
current: current,
currentD: currentD,
currentDId: answerResult[index]['answer']
});
}
},
//交卷对话框
handleSubmitOpen() {
var rsdata = JSON.parse(JSON.stringify(this.data.result))
var len = 0;
for (var i = 0; i < rsdata.length; i++) {
if (rsdata[i]['judge'] != 1) {
len++;
}
}
this.setData({
showanswer: true,
unanswered: len
})
/*
this.stop();
this.setData({
visible1:true,
stopMin:this.data.min,
stopSec:this.data.sec
})
*/
},
//查看答卷
examidView() {
var that = this;
wx.navigateTo({
url: '/pages/viewscore/index?examid=' + that.data.examid + '&paperid=' + that.data.examidPaperid + '&userid' + that.data.userid,
})
},
//结束考试
examidEnd() {
wx.reLaunch({
url: '/pages/wrong/index',
})
},
//开始补考
examidNew() {
this.setData(
{
unanswered: 0,
currentD: [],
currentDId: [],
examidPaperid: null,
examidResult: null,
answerResult: [],
questionlist: [],
questionCurrent: 0,
pageCurrent: 1,
currentItem: 0,
badshow: false,
goodshow: false,
loading: false, //加载中
showanswer: false,
result: [], //题目
total: 0, //题目总总数
menu: '', //套题id
questionMenu: '', //套题名称
percent: 0, //进度条百分比
time: 45, //时间
index: 1, //第几题
current: "", //单选选中的答案
currentPage: 1,
type: '', //题目类型 1:单选 2:多选
disabled: false, //单选选中不可选
disabled1: false, //多选选中不可选
actionVisible: false, //弹出层
questionErr: 0, //错题个数
questionOk: 0, // 正确个数
percentage: 0,
visible1: false,
visible2: false,
visible3: false,
visible4: false,
answerEach: '',
answerMore: '',
ansChose: '',
questionIndex: '',
indexnum: 1
}
)
this.getExamUserPaperProfile();
},
//保存按钮
handanswer(e) {
var that = this;
if (e.detail.index == 0) {
this.setData({
showanswer: false
});
} else {
//debugger
var params = {
examid: this.data.examid,
paperid: this.data.examidPaperid,
userid: this.data.userid,
questionlist: this.data.answerResult
}
//人员考试-提交答卷-判定成绩
http.postRequest(http.LING + "/wxapp/exam/user/paper/submit", params, function (res) {
console.log(res)
if (parseInt(res.error) === 0) {
console.log("提交成功")
$Toast({
content: '提交成功!',
type: 'success',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
that.setData({
examidResult: res.data,
showanswer: false,
badshow: true
});
}, 200);
} else {
$Toast({
content: '提交失败!',
type: 'warning',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
}, 200);
}
}, function (err) {
$Toast({
content: '提交失败!',
type: 'warning',
duration: 0,
});
setTimeout(() => {
$Toast.hide();
}, 200);
console.log(err)
})
}
},
overclose() {
wx.reLaunch({
url: '/pages/wrong/index'
})
},
seeans() {
wx.navigateTo({
url: '/pages/viewscore/index'
})
},
handleSubmit() {
this.submit();
},
//时间到对话框
handleClick1() {
this.setData({
visible2: true
});
},
//弹出统计下拉层
handleOpen() {
//this.hideVideo()
this.setData({
actionVisible: true
})
},
//关闭统计下拉层
actionCancel() {
this.setData({
actionVisible: false
})
},
stop() {
this.Countdown.stop()
},
start() {
this.Countdown.start()
},
update(time) {
this.Countdown.update(+(new Date) + parseInt(time))
}
})
网友评论