v3.0.6
This commit is contained in:
104
source/wx/xzs-student/pages/exam/do/index.js
Normal file
104
source/wx/xzs-student/pages/exam/do/index.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import {
|
||||
formatSeconds
|
||||
} from '../../../utils/util.js'
|
||||
|
||||
let app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
spinShow: false,
|
||||
paperId: null,
|
||||
form: {},
|
||||
timer: null,
|
||||
doTime: 0,
|
||||
remainTime: 0,
|
||||
remainTimeStr: '',
|
||||
modalShow: false,
|
||||
result: 0,
|
||||
timeOutShow: false
|
||||
},
|
||||
onLoad: function(options) {
|
||||
let paperId = options.id
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/exampaper/select/' + paperId, null)
|
||||
.then(res => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
if (res.code === 1) {
|
||||
_this.setData({
|
||||
form: res.response,
|
||||
paperId: paperId,
|
||||
remainTime: res.response.suggestTime * 60
|
||||
});
|
||||
_this.timeReduce()
|
||||
}
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
},
|
||||
timeReduce() {
|
||||
let _this = this
|
||||
let timer = setInterval(function() {
|
||||
let remainTime = _this.data.remainTime
|
||||
if (remainTime <= 0) {
|
||||
_this.timeOut()
|
||||
} else {
|
||||
_this.setData({
|
||||
remainTime: remainTime - 1,
|
||||
remainTimeStr: formatSeconds(remainTime),
|
||||
doTime: _this.data.doTime + 1
|
||||
});
|
||||
}
|
||||
}, 1000)
|
||||
_this.setData({
|
||||
timer: timer
|
||||
});
|
||||
},
|
||||
onUnload() {
|
||||
clearInterval(this.data.timer)
|
||||
},
|
||||
returnRecord() {
|
||||
wx.reLaunch({
|
||||
url: '/pages/record/index',
|
||||
});
|
||||
},
|
||||
timeOut() {
|
||||
clearInterval(this.data.timer)
|
||||
this.setData({
|
||||
timeOutShow: true
|
||||
});
|
||||
},
|
||||
formSubmit: function(e) {
|
||||
let _this = this
|
||||
if (this.data.timer) {
|
||||
clearInterval(this.data.timer)
|
||||
}
|
||||
wx.showLoading({
|
||||
title: '提交中',
|
||||
mask: true
|
||||
})
|
||||
e.detail.value.id = this.data.paperId
|
||||
e.detail.value.doTime = this.data.doTime
|
||||
app.formPost('/api/wx/student/exampaper/answer/answerSubmit', e.detail.value)
|
||||
.then(res => {
|
||||
if (res.code === 1) {
|
||||
_this.setData({
|
||||
modalShow: true,
|
||||
result: res.response
|
||||
});
|
||||
} else {
|
||||
app.message(res.response, 'error')
|
||||
}
|
||||
wx.hideLoading()
|
||||
}).catch(e => {
|
||||
wx.hideLoading()
|
||||
app.message(e, 'error')
|
||||
})
|
||||
}
|
||||
})
|
||||
16
source/wx/xzs-student/pages/exam/do/index.json
Normal file
16
source/wx/xzs-student/pages/exam/do/index.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-panel": "/component/iView/panel/index",
|
||||
"i-cell-group": "/component/iView/cell-group/index",
|
||||
"i-cell": "/component/iView/cell/index",
|
||||
"i-radio-group": "/component/iView/radio-group/index",
|
||||
"i-radio": "/component/iView/radio/index",
|
||||
"i-row": "/component/iView/row/index",
|
||||
"i-col": "/component/iView/col/index",
|
||||
"i-input": "/component/iView/input/index",
|
||||
"i-action-sheet": "/component/iView/action-sheet/index",
|
||||
"i-modal": "/component/iView/modal/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index"
|
||||
}
|
||||
}
|
||||
80
source/wx/xzs-student/pages/exam/do/index.wxml
Normal file
80
source/wx/xzs-student/pages/exam/do/index.wxml
Normal file
@@ -0,0 +1,80 @@
|
||||
<view class="exam-page">
|
||||
<view class="view-wrap">
|
||||
<view class="exam-count-down">{{remainTimeStr}}</view>
|
||||
</view>
|
||||
<view class="view-wrap-hidden">
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view class="exam-name-title">
|
||||
<h1>{{form.name}}</h1>
|
||||
</view>
|
||||
<form bindsubmit='formSubmit'>
|
||||
<i-panel title="{{titleItem.name}}" wx:for="{{form.titleItems}}" wx:for-item="titleItem" wx:key="{{titleItem.name}}" i-class="exam-panel-title">
|
||||
<i-cell-group i-class="exam-cell">
|
||||
<i-cell wx:for="{{titleItem.questionItems}}" wx:key="{{titleItem.id}}" wx:for-item="questionItem">
|
||||
|
||||
<view wx:if="{{questionItem.questionType === 1}}">
|
||||
<rich-text nodes="{{questionItem.itemOrder}}. {{questionItem.title}}" />
|
||||
<radio-group class="radio-group" name="{{questionItem.itemOrder}}_{{questionItem.id}}_{{questionItem.questionType}}">
|
||||
<label class="radio" wx:for="{{questionItem.items}}" wx:key="{{questionItem.prefix}}" wx:for-item="radioItem" class="exam-radio-item-label">
|
||||
<radio color="#2d8cf0" value="{{radioItem.prefix}}" checked="{{radioItem.checked}}" class="exam-item-left" />
|
||||
<rich-text nodes="{{radioItem.prefix}}. {{radioItem.content}}" class="exam-item-left" />
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<view wx:elif="{{questionItem.questionType === 2}}">
|
||||
<rich-text nodes="{{questionItem.itemOrder}}. {{questionItem.title}}" class="exam-item-left" style="line-height:35px" />
|
||||
<checkbox-group class="exam-item-left" style="margin-left:10px" name="{{questionItem.itemOrder}}_{{questionItem.id}}_{{questionItem.questionType}}">
|
||||
<label wx:for="{{questionItem.items}}" wx:key="{{questionItem.prefix}}" wx:for-item="radioItem" class="exam-radio-item-label">
|
||||
<checkbox color="#2d8cf0" value="{{radioItem.prefix}}" checked="{{radioItem.checked}}" class="exam-item-left" />
|
||||
<rich-text nodes="{{radioItem.prefix}}. {{radioItem.content}}" class="exam-item-left" />
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
<view wx:elif="{{questionItem.questionType === 3}}">
|
||||
<rich-text nodes="{{questionItem.itemOrder}}. {{questionItem.title}}" class="exam-item-left" style="line-height:35px" />
|
||||
<radio-group class="radio-group" class="exam-item-left" style="margin-left:10px" name="{{questionItem.itemOrder}}_{{questionItem.id}}_{{questionItem.questionType}}">
|
||||
<label class="radio" wx:for="{{questionItem.items}}" wx:key="{{questionItem.prefix}}" wx:for-item="radioItem" class="exam-radio-item-label">
|
||||
<radio color="#2d8cf0" value="{{radioItem.prefix}}" checked="{{radioItem.checked}}" class="exam-item-left" />
|
||||
<rich-text nodes="{{radioItem.content}}" class="exam-item-left" />
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<view wx:elif="{{questionItem.questionType === 4}}">
|
||||
<rich-text nodes="{{questionItem.itemOrder}}. {{questionItem.title}}" />
|
||||
<view class="exam-input-contain" wx:for="{{questionItem.items}}" wx:key="{{questionItem.prefix}}" wx:for-item="inputItem" wx:for-index="idx">
|
||||
<view class="exam-input-contain-label">{{inputItem.prefix}}</view>
|
||||
<input class="exam-input-contain-content" maxlength="-1" name="{{questionItem.itemOrder}}_{{questionItem.id}}_{{questionItem.questionType}}_{{idx}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else>
|
||||
<rich-text nodes="{{questionItem.itemOrder}}. {{questionItem.title}}" />
|
||||
<view class="exam-textarea-contain">
|
||||
<textarea placeholder="答案" maxlength="-1" name="{{questionItem.itemOrder}}_{{questionItem.id}}_{{questionItem.questionType}}"></textarea>
|
||||
</view>
|
||||
</view>
|
||||
</i-cell>
|
||||
</i-cell-group>
|
||||
</i-panel>
|
||||
|
||||
<view>
|
||||
<button class="i-btn i-btn-primary i-btn-square" form-type='submit'>提交</button>
|
||||
</view>
|
||||
|
||||
<i-action-sheet visible="true" visible="{{timeOutShow}}" mask-closable="{{ false }}">
|
||||
<view slot="header" style="padding: 16px">
|
||||
<view class="exam-timeout-title">考试试卷结束,请提交试卷!</view>
|
||||
<button class="i-btn i-btn-primary i-btn-square" form-type='submit'>提交</button>
|
||||
</view>
|
||||
</i-action-sheet>
|
||||
</form>
|
||||
|
||||
<i-modal title="考试结果" visible="{{modalShow}}" bind:ok="returnRecord" bind:cancel="returnRecord">
|
||||
<view>得分:{{result}}</view>
|
||||
</i-modal>
|
||||
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
</view>
|
||||
</view>
|
||||
76
source/wx/xzs-student/pages/exam/do/index.wxss
Normal file
76
source/wx/xzs-student/pages/exam/do/index.wxss
Normal file
@@ -0,0 +1,76 @@
|
||||
.exam-page {
|
||||
background: white;
|
||||
}
|
||||
|
||||
.exam-count-down {
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
}
|
||||
|
||||
.view-wrap {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
background: #fff6f6;
|
||||
text-align: center;
|
||||
height: 35px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.view-wrap-hidden {
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.exam-name-title {
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.exam-panel-title {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.exam-radio-item-label {
|
||||
float: left;
|
||||
margin-left: 10px;
|
||||
line-height: 35px;
|
||||
}
|
||||
|
||||
.exam-item-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.exam-input-contain {
|
||||
margin: 10px 2px !important;
|
||||
border-width: 1px;
|
||||
border-color: #dddee1;
|
||||
border-style: solid;
|
||||
width: 95%;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.exam-input-contain-label {
|
||||
float: left;
|
||||
padding: 0px 15px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.exam-input-contain-content {
|
||||
float: left;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.exam-textarea-contain {
|
||||
margin: 10px 2px !important;
|
||||
border-width: 1px;
|
||||
border-color: #dddee1;
|
||||
border-style: solid;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.exam-timeout-title{
|
||||
font-size: 16px;
|
||||
color: red;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
Reference in New Issue
Block a user