exam_mp
This commit is contained in:
parent
9cf752bb1c
commit
9f2ac61439
|
@ -49,6 +49,10 @@ const install = (Vue, vm) => {
|
||||||
//考试有关
|
//考试有关
|
||||||
let getExamList = (params={})=>vm.$u.get('/exam/exam/', params);//考试列表
|
let getExamList = (params={})=>vm.$u.get('/exam/exam/', params);//考试列表
|
||||||
let startExam = (id)=>vm.$u.post(`/exam/exam/${id}/start/`);//开始考试
|
let startExam = (id)=>vm.$u.post(`/exam/exam/${id}/start/`);//开始考试
|
||||||
|
let submitExam = (id,params={})=>vm.$u.post(`/exam/examrecord/${id}/submit/`,params);//开始考试
|
||||||
|
let examRecord = (id,params={})=>vm.$u.get(`/exam/examrecord/self/`,params);//我的考试记录
|
||||||
|
let examRecordDetail = (id,params={})=>vm.$u.get(`/exam/examrecord/${id}/`,params);//我的考试记录
|
||||||
|
|
||||||
vm.$u.api = {getUserInfo,
|
vm.$u.api = {getUserInfo,
|
||||||
getCode,
|
getCode,
|
||||||
codeLogin,
|
codeLogin,
|
||||||
|
@ -72,7 +76,10 @@ const install = (Vue, vm) => {
|
||||||
putMyVideoView,
|
putMyVideoView,
|
||||||
|
|
||||||
getExamList,
|
getExamList,
|
||||||
startExam
|
startExam,
|
||||||
|
submitExam,
|
||||||
|
examRecord,
|
||||||
|
examRecordDetail
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,14 @@
|
||||||
"enablePullDownRefresh": false
|
"enablePullDownRefresh": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},{
|
||||||
|
"path" : "pages/exam/detail",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"navigationBarTitleText": "答题详情",
|
||||||
|
"enablePullDownRefresh": false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
@ -194,8 +202,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/exam/index",
|
"pagePath": "pages/exam/index",
|
||||||
"iconPath": "static/common/play.png",
|
"iconPath": "static/common/dati.png",
|
||||||
"selectedIconPath": "static/common/playc.png",
|
"selectedIconPath": "static/common/datic.png",
|
||||||
"text": "答题"
|
"text": "答题"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,326 @@
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<!-- 大标题 -->
|
||||||
|
<view class="header" id="header">
|
||||||
|
<span > {{currentExam.type}}</span>
|
||||||
|
</view>
|
||||||
|
<!-- 小标题栏 -->
|
||||||
|
<view class="sub-header">
|
||||||
|
<u-row>
|
||||||
|
<u-col span="4">
|
||||||
|
<view><text style="color:red">{{currentExam.total_score}}</text>分</view>
|
||||||
|
</u-col>
|
||||||
|
<u-col span="4">
|
||||||
|
<view style="text-align: center;"><span class="header-card">{{currentQuestion.type}}</span></view>
|
||||||
|
</u-col>
|
||||||
|
<u-col span="4">
|
||||||
|
<view style="text-align: right;"><span>第{{currentIndex+1}}/{{currentExam.questions_.length}} 题</span></view>
|
||||||
|
</u-col>
|
||||||
|
</u-row>
|
||||||
|
</view>
|
||||||
|
<scroll-view class="content" scroll-y="true" v-bind:style="{height:scollHeight+'px'}">
|
||||||
|
<view class="name">
|
||||||
|
<view><text style="margin-right: 10rpx;">{{currentIndex+1}} 、</text> {{currentQuestion.name}}</view>
|
||||||
|
<view v-if="currentQuestion.img">
|
||||||
|
{{currentQuestion.img}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="options">
|
||||||
|
<checkbox-group v-if="currentQuestion.type=='多选'">
|
||||||
|
<label class="option" v-for="item in currentOptions" :key="item.id" >
|
||||||
|
<view class="option-item1" >
|
||||||
|
<checkbox :value="item.value" :checked="item.checked" color="#2979ff" :disabled="item.disabled"/>
|
||||||
|
</view >
|
||||||
|
<view class="option-item2" >{{item.value}}.{{item.text}}</view>
|
||||||
|
</label>
|
||||||
|
</checkbox-group>
|
||||||
|
<radio-group v-else>
|
||||||
|
<label class="option" v-for="item in currentOptions" :key="item.id">
|
||||||
|
<view class="option-item1">
|
||||||
|
<radio :value="item.value" :checked="item.checked" color="#2979ff" :disabled="item.disabled"></radio>
|
||||||
|
</view>
|
||||||
|
<view class="option-item2">
|
||||||
|
{{item.value}}.{{item.text}}
|
||||||
|
</view>
|
||||||
|
</label>
|
||||||
|
</radio-group>
|
||||||
|
</view>
|
||||||
|
<view class="answer">
|
||||||
|
<view v-if="currentQuestion.type=='多选'">
|
||||||
|
<view>正确答案:{{currentQuestion.right.join("")}}</view>
|
||||||
|
<view v-if="currentQuestion.user_answer">您的答案:{{currentQuestion.user_answer.join("")}}</view>
|
||||||
|
<view v-else style="color:red">您未作答</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<view>正确答案:{{currentQuestion.right}}</view>
|
||||||
|
<view v-if="currentQuestion.user_answer">您的答案:{{currentQuestion.user_answer}}</view>
|
||||||
|
<view v-else style="color:red">您未作答</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="currentQuestion.user_answer">
|
||||||
|
<view v-if="currentQuestion.is_right" style="color:green;font-weight: bold;">回答正确!</view>
|
||||||
|
<view v-else style="color:red;font-weight: bold;">回答有误!</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view style="height:20rpx"></view>
|
||||||
|
</scroll-view>
|
||||||
|
<u-popup v-model="showM" mode="bottom" height="40%">
|
||||||
|
<view class="questionArea" style="display:flex">
|
||||||
|
<block v-for="(item, index) in currentExam.questions_" :key="index">
|
||||||
|
<view class="questionItem questionItem-select" v-if="item.user_answer&&item.is_right" @click="jumpQuestion(index)">{{index+1}}</view>
|
||||||
|
<view class="questionItem questionItem-wrong" v-else-if="item.user_answer&&!item.is_right" @click="jumpQuestion(index)">{{index+1}}</view>
|
||||||
|
<view class="questionItem questionItem-unselect" v-else @click="jumpQuestion(index)">{{index+1}}</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
|
<!-- 底部栏 -->
|
||||||
|
<view class="footer" id="footer">
|
||||||
|
<u-button @click='previousQ()' throttle-time="200" :plain="true" type="primary">上一题</u-button>
|
||||||
|
<u-button @click="showM = !showM" type="primary">答题卡</u-button>
|
||||||
|
<u-button @click='nextQ()' throttle-time="200" :plain="true" type="primary">下一题</u-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentExam:{},
|
||||||
|
currentIndex:0,
|
||||||
|
currentOptions:[],
|
||||||
|
currentQuestion:{question_:{}},
|
||||||
|
showM:false,
|
||||||
|
keyid:0,
|
||||||
|
start_time:null,
|
||||||
|
scollHeight:0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
this.currentExam = uni.getStorageSync('currentExam');
|
||||||
|
debugger;
|
||||||
|
console.log(this.currentExam)
|
||||||
|
let res = uni.getSystemInfoSync()
|
||||||
|
let ratio = 750 / res.windowWidth;
|
||||||
|
this.scollHeight = res.windowHeight*ratio - 230
|
||||||
|
this.initQuestion()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initQuestion(){
|
||||||
|
var currentQuestion = this.currentExam.questions_[this.currentIndex]
|
||||||
|
this.currentQuestion = currentQuestion
|
||||||
|
let options_ = []
|
||||||
|
let origin = currentQuestion.options
|
||||||
|
this.currentOptions = []
|
||||||
|
for (let key in origin) {
|
||||||
|
let option = {
|
||||||
|
value:key,
|
||||||
|
text:origin[key],
|
||||||
|
id: this.keyid++,
|
||||||
|
checked:false,
|
||||||
|
disabled:true,
|
||||||
|
}
|
||||||
|
if (currentQuestion.user_answer) {
|
||||||
|
if (key == currentQuestion.user_answer || currentQuestion.user_answer.indexOf(key) != -1) {
|
||||||
|
option.checked = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
option.checked = false
|
||||||
|
}
|
||||||
|
options_.push(option)
|
||||||
|
}
|
||||||
|
this.currentOptions = options_;
|
||||||
|
},
|
||||||
|
nextQ(){
|
||||||
|
let index = this.currentIndex + 1
|
||||||
|
if(index<this.currentExam.questions_.length){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
previousQ(){
|
||||||
|
let index = this.currentIndex - 1
|
||||||
|
if(index >= 0){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
jumpQuestion(index){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
this.showM = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $u-bg-color;
|
||||||
|
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
margin-top:8rpx;
|
||||||
|
margin-bottom: 120rpx;
|
||||||
|
.name {
|
||||||
|
font-size:34rpx;
|
||||||
|
padding: 8rpx 20rpx;
|
||||||
|
color:$u-content-color;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
.options {
|
||||||
|
margin-top:8rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
.option {
|
||||||
|
padding: 10rpx 0rpx;
|
||||||
|
display: flex;
|
||||||
|
font-size: 36rpx;
|
||||||
|
.option-item1{
|
||||||
|
justify-content: flex-start
|
||||||
|
}
|
||||||
|
.option-item2{
|
||||||
|
justify-content: flex-start;
|
||||||
|
color:$u-main-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.answer{
|
||||||
|
margin-top:8rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
.resolution{
|
||||||
|
margin-top:8rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sub-header {
|
||||||
|
//width: 750rpx;
|
||||||
|
// position: fixed;
|
||||||
|
// margin-top: 130rpx;
|
||||||
|
padding: 4rpx 20rpx;
|
||||||
|
color: #000;
|
||||||
|
font-size: 33rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
.header-card {
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
// border: 1px solid $u-type-primary-dark;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: $u-type-primary-dark;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
width: 750rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
padding: 30rpx 60rpx;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #4c8af3;
|
||||||
|
box-shadow: 0 0 5px 1px #eee;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
|
&-card {
|
||||||
|
padding: 10rpx 20rpx;
|
||||||
|
border: 1px solid $theme-color;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: $theme-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// .header{
|
||||||
|
// display: flex;
|
||||||
|
// height: 70rpx;
|
||||||
|
// background-color: orange;
|
||||||
|
// font-size: 36rpx;
|
||||||
|
// .content {
|
||||||
|
// align-self: center;
|
||||||
|
// .text{
|
||||||
|
// margin-left:10rpx
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// .rbutton {
|
||||||
|
// margin-left: auto;
|
||||||
|
// align-self: center;
|
||||||
|
// margin-right: 10rpx
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
.header {
|
||||||
|
width: 750rpx;
|
||||||
|
//position: fixed;
|
||||||
|
//position: relative;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 60rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $theme-color;
|
||||||
|
// letter-spacing: 10rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
|
&-button {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
position: absolute;
|
||||||
|
top: 4rpx;
|
||||||
|
right: 10rpx;
|
||||||
|
padding: 10rpx 20rpx;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
letter-spacing: 2rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: $u-type-error;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scoreText {
|
||||||
|
color: #00b060;
|
||||||
|
font-size: 35rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.questionArea {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
|
.questionItem {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
margin: 10rpx 22rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
font-size: 35rpx;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.questionItem-select {
|
||||||
|
// color: #FFFFFF;
|
||||||
|
background-color: $theme-color;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.questionItem-unselect {
|
||||||
|
// color: #FFFFFF;
|
||||||
|
background-color: #bbbbbb;
|
||||||
|
}
|
||||||
|
.questionItem-wrong {
|
||||||
|
// color: #FFFFFF;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
|
@ -1,6 +1,70 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
|
<!-- 大标题 -->
|
||||||
|
<view class="header" id="header">
|
||||||
|
<span class="header-button">第{{currentIndex+1}}/{{currentExam.questions_.length}} 题</span>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<!-- 小标题栏 -->
|
||||||
|
<view class="sub-header">
|
||||||
|
<u-row>
|
||||||
|
<u-col span="4">
|
||||||
|
<u-count-down :timestamp="currentExam.paper_.limit*60" :show-days="false" @end="end" border-color="#2979ff">
|
||||||
|
</u-count-down>
|
||||||
|
</u-col>
|
||||||
|
<u-col span="4">
|
||||||
|
<view style="text-align: center;"><span class="header-card">{{currentQuestion.type}}</span></view>
|
||||||
|
</u-col>
|
||||||
|
<u-col span="4">
|
||||||
|
<view style="text-align: right;"><span class="submitButton" @click='handleSubmit()' >交卷</span></view>
|
||||||
|
</u-col>
|
||||||
|
</u-row>
|
||||||
|
</view>
|
||||||
|
<scroll-view class="content" scroll-y="true" v-bind:style="{height:scollHeight+'rpx'}">
|
||||||
|
<view class="name">
|
||||||
|
<view>{{currentIndex}}·{{currentQuestion.name}}</view>
|
||||||
|
<!-- <rich-text :nodes="currentQuestion.name"></rich-text> -->
|
||||||
|
<view v-if="currentQuestion.img">
|
||||||
|
{{currentQuestion.img}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="options">
|
||||||
|
<checkbox-group @change="checkboxGroupChange" v-if="currentQuestion.type=='多选'">
|
||||||
|
<label class="option" v-for="item in currentOptions" :key="item.id" >
|
||||||
|
<view class="option-item1">
|
||||||
|
<checkbox :value="item.value" :checked="item.checked" color="#2979ff"/>
|
||||||
|
</view >
|
||||||
|
<view class="option-item2">{{item.value}}.{{item.text}}</view>
|
||||||
|
</label>
|
||||||
|
</checkbox-group>
|
||||||
|
<radio-group v-else @change="checkboxGroupChange">
|
||||||
|
<label class="option" v-for="item in currentOptions" :key="item.id">
|
||||||
|
<view class="option-item1">
|
||||||
|
<radio :value="item.value" :checked="item.checked" color="#2979ff"></radio>
|
||||||
|
</view>
|
||||||
|
<view class="option-item2">
|
||||||
|
{{item.value}}.{{item.text}}
|
||||||
|
</view>
|
||||||
|
</label>
|
||||||
|
</radio-group>
|
||||||
|
</view>
|
||||||
|
<view style="height:20rpx"></view>
|
||||||
|
</scroll-view>
|
||||||
|
<u-popup v-model="showM" mode="bottom" height="40%">
|
||||||
|
<view class="questionArea" style="display:flex">
|
||||||
|
<block v-for="(item, index) in currentExam.questions_" :key="index">
|
||||||
|
<view class="questionItem questionItem-select" v-if="item.user_answer" @click="jumpQuestion(index)">{{index+1}}</view>
|
||||||
|
<view class="questionItem questionItem-unselect" v-else @click="jumpQuestion(index)">{{index+1}}</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
|
<!-- 底部栏 -->
|
||||||
|
<view class="footer" id="footer">
|
||||||
|
<u-button @click='previousQ()' throttle-time="200" :plain="true" type="primary">上一题</u-button>
|
||||||
|
<u-button @click="showM = !showM" type="primary">答题卡</u-button>
|
||||||
|
<u-button @click='nextQ()' throttle-time="200" :plain="true" type="primary">下一题</u-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -8,15 +72,328 @@
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
currentExam:{questions_:[]},
|
||||||
}
|
currentIndex:0,
|
||||||
|
currentOptions:[],
|
||||||
|
currentQuestion:{type:'单选'},
|
||||||
|
showM:false,
|
||||||
|
keyid:0,
|
||||||
|
start_time:null,
|
||||||
|
scollHeight:0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
//#ifdef MP-WEIXIN
|
||||||
|
uni.hideHomeButton()
|
||||||
|
//#endif
|
||||||
|
this.start_time= (new Date()).getTime()
|
||||||
|
this.currentExam = uni.getStorageSync('currentExam')
|
||||||
|
let res = uni.getSystemInfoSync();
|
||||||
|
let ratio = 750 / res.windowWidth;
|
||||||
|
this.scollHeight = res.windowHeight*ratio - 230
|
||||||
|
this.initQuestion()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
end(){
|
||||||
|
var that = this
|
||||||
|
uni.showModal({
|
||||||
|
title: '警告',
|
||||||
|
content: '时间到,请交卷',
|
||||||
|
showCancel:false,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
that.handIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
change(){
|
||||||
|
|
||||||
|
},
|
||||||
|
handleSubmit(){
|
||||||
|
var that = this
|
||||||
|
let questions = that.currentExam.questions_;
|
||||||
|
for(var i=0;i<questions.length;i++){
|
||||||
|
if(!questions[i].user_answer){
|
||||||
|
uni.showModal({
|
||||||
|
title: '警告',
|
||||||
|
content: '答卷未完成,确认交卷吗?',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
that.handIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确认交卷吗?',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
//直接交卷,不需要判卷了
|
||||||
|
that.handIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handIn(){
|
||||||
|
var that = this
|
||||||
|
uni.showLoading({
|
||||||
|
title:'正在提交...',
|
||||||
|
mask:true
|
||||||
|
})
|
||||||
|
let questions_ = [];
|
||||||
|
for (let i = 0; i < that.currentExam.questions_.length; i++) {
|
||||||
|
let obj = {};
|
||||||
|
obj.id=that.currentExam.questions_[i].id;
|
||||||
|
obj.user_answer=that.currentExam.questions_[i].user_answer;
|
||||||
|
questions_.push(obj);
|
||||||
|
}
|
||||||
|
that.$u.api.submitExam(that.currentExam.examrecord,{questions_:questions_}).then(res=>{
|
||||||
|
uni.setStorageSync('currentExam',res.data)
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.redirectTo({
|
||||||
|
url:'/pages/exam/result'
|
||||||
|
})
|
||||||
|
}).catch(e=>{
|
||||||
|
if(res.msg){
|
||||||
|
uni.showModal({
|
||||||
|
title:'提交失败',
|
||||||
|
content:res.msg,
|
||||||
|
showCancel:false,
|
||||||
|
success(res) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/index/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
// let questions = this.currentExam.questions
|
||||||
|
// let score=0
|
||||||
|
// for(var i=0, lenI =questions.length;i<lenI;i++){
|
||||||
|
// var ret=this.panTi(questions[i])
|
||||||
|
// questions[i].is_right=ret.is_right
|
||||||
|
// questions[i].score=ret.score
|
||||||
|
// score = score+ret.score
|
||||||
|
// }
|
||||||
|
// this.currentExam.score = score
|
||||||
|
// this.currentExam.start_time = this.$u.timeFormat(this.start_time, 'yyyy-mm-dd hh:MM:ss');
|
||||||
|
// this.currentExam.end_time = this.$u.timeFormat((new Date()).getTime(), 'yyyy-mm-dd hh:MM:ss')
|
||||||
|
// this.currentExam.took = Math.floor(((new Date()).getTime() - this.start_time) / 1000)
|
||||||
|
// if(score>=this.currentExam.pass_score){
|
||||||
|
// this.currentExam.is_pass=true
|
||||||
|
// }else{
|
||||||
|
// this.currentExam.is_pass=false
|
||||||
|
// }
|
||||||
|
// if(this.vuex_user.id){
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// uni.setStorageSync('currentExam',this.currentExam)
|
||||||
|
// uni.hideLoading()
|
||||||
|
// uni.redirectTo({
|
||||||
|
// url:'/pages/exam/result'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
panTi(tm_current) {
|
||||||
|
// 返回当前题目是否正确,得分多少
|
||||||
|
let is_right = false, score = 0
|
||||||
|
if (tm_current.type == '多选') {
|
||||||
|
if (tm_current.user_answer) {
|
||||||
|
if (tm_current.user_answer.sort().toString() == tm_current.right.sort().toString()) {
|
||||||
|
is_right = true
|
||||||
|
score = tm_current.total_score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(tm_current.right == tm_current.user_answer){
|
||||||
|
is_right = true
|
||||||
|
score = tm_current.total_score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {'is_right':is_right,'score':score}
|
||||||
|
},
|
||||||
|
initQuestion(){
|
||||||
|
var currentQuestion = this.currentExam.questions_[this.currentIndex];
|
||||||
|
this.currentQuestion = currentQuestion;
|
||||||
|
let options_ = [];
|
||||||
|
let origin = currentQuestion.options;
|
||||||
|
this.currentOptions = [];
|
||||||
|
for (let key in origin) {
|
||||||
|
let option = {
|
||||||
|
value:key,
|
||||||
|
text:origin[key],
|
||||||
|
id: this.keyid++,
|
||||||
|
checked:false
|
||||||
|
}
|
||||||
|
if (currentQuestion.user_answer) {
|
||||||
|
if (key == currentQuestion.user_answer || currentQuestion.user_answer.indexOf(key) != -1) {
|
||||||
|
option.checked = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
option.checked = false
|
||||||
|
}
|
||||||
|
options_.push(option)
|
||||||
|
}
|
||||||
|
this.currentOptions = options_
|
||||||
|
},
|
||||||
|
nextQ(){
|
||||||
|
let index = this.currentIndex + 1
|
||||||
|
if(index<this.currentExam.questions_.length){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
previousQ(){
|
||||||
|
let index = this.currentIndex - 1
|
||||||
|
if(index >= 0){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkboxGroupChange(e){
|
||||||
|
// debugger;
|
||||||
|
console.log(e)
|
||||||
|
this.currentExam.questions_[this.currentIndex].user_answer = e.detail.value
|
||||||
|
},
|
||||||
|
jumpQuestion(index){
|
||||||
|
this.currentIndex = index
|
||||||
|
this.initQuestion()
|
||||||
|
this.showM = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $u-bg-color;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
margin-top:8rpx;
|
||||||
|
.name {
|
||||||
|
font-size:34rpx;
|
||||||
|
padding: 25rpx 30rpx;
|
||||||
|
color:$u-content-color;
|
||||||
|
line-height:130%;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
.options {
|
||||||
|
margin-top:8rpx;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
padding: 6rpx 30rpx;
|
||||||
|
.option {
|
||||||
|
padding: 10rpx 0rpx;
|
||||||
|
display: flex;
|
||||||
|
font-size: 36rpx;
|
||||||
|
.option-item1{
|
||||||
|
justify-content: flex-start
|
||||||
|
}
|
||||||
|
.option-item2{
|
||||||
|
justify-content: flex-start;
|
||||||
|
color:$u-main-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
.header {
|
||||||
|
width: 750rpx;
|
||||||
|
text-align: center;
|
||||||
|
height: 60rpx;
|
||||||
|
line-height: 60rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $theme-color;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
|
&-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 10rpx;
|
||||||
|
font-size:34rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scoreText {
|
||||||
|
color: #00b060;
|
||||||
|
font-size: 35rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sub-header {
|
||||||
|
padding: 4rpx 20rpx;
|
||||||
|
color: #000;
|
||||||
|
font-size: 33rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
.submitButton{
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #ffffff;
|
||||||
|
background-color: $u-type-error;
|
||||||
|
}
|
||||||
|
.header-card {
|
||||||
|
padding: 6rpx 20rpx;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: $u-type-primary-dark;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
width: 750rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
padding: 30rpx 60rpx;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 32rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #4c8af3;
|
||||||
|
box-shadow: 0 0 5px 1px #eee;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
|
||||||
|
&-card {
|
||||||
|
padding: 10rpx 20rpx;
|
||||||
|
border: 1px solid $theme-color;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: $theme-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.questionArea {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
|
.questionItem {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
margin: 10rpx 22rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
font-size: 35rpx;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.questionItem-select {
|
||||||
|
background-color: $theme-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.questionItem-unselect {
|
||||||
|
background-color: #bbbbbb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
|
@ -37,6 +37,10 @@
|
||||||
methods: {
|
methods: {
|
||||||
start(){
|
start(){
|
||||||
this.$u.api.startExam(this.currentExam.id).then(res=>{
|
this.$u.api.startExam(this.currentExam.id).then(res=>{
|
||||||
|
let currentExam =uni.getStorageSync('currentExam');
|
||||||
|
currentExam.examrecord = res.data.examrecord;
|
||||||
|
currentExam.questions_ = res.data.questions_;
|
||||||
|
uni.setStorageSync('currentExam',currentExam)
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url:'/pages/exam/main'
|
url:'/pages/exam/main'
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
<view>
|
<view>
|
||||||
<uni-list>
|
<uni-list>
|
||||||
<uni-list-item v-for="item in list" :key="item.id" @click="goDetail(item.id)" :clickable="true" link>
|
<uni-list-item v-for="item in list" :key="item.id" @click="goDetail(item.id)" :clickable="true" link>
|
||||||
<!-- 自定义 header -->
|
|
||||||
<!-- <view slot="header" class="slot-box">
|
|
||||||
<view>{{item.name}}</view>
|
|
||||||
</view> -->
|
|
||||||
<!-- 自定义 body -->
|
<!-- 自定义 body -->
|
||||||
<template slot="body" style="display: block;">
|
<template slot="body" style="display: block;">
|
||||||
<view>
|
<view>
|
||||||
<text v-if="item.type=='自助模考'">模拟练习</text>
|
<!-- <text v-if="item.type=='自助模考'">模拟练习</text> -->
|
||||||
<text v-else style="font-weight: bold;color:orange">正式竞赛</text>
|
<text style="font-weight: bold;color:orange">{{item.type}}</text>
|
||||||
<text v-if="item.name.indexOf('(补)') != -1">(补)</text>
|
<text v-if="item.name.indexOf('(补)') != -1">(补)</text>
|
||||||
</view>
|
</view>
|
||||||
<view style="color:gray;font-size: 26rpx;">
|
<view style="color:gray;font-size: 26rpx;">
|
||||||
<span>耗时:
|
<span>耗时:
|
||||||
<span style="color:darkblue;font-weight: bold;">{{item.took}}</span>
|
<span style="color:darkblue;font-weight: bold;">{{item.took_format}}</span>
|
||||||
s</span>
|
</span>
|
||||||
-
|
-
|
||||||
<text>提交时间:{{item.create_time}}</text>
|
<text>提交时间:{{item.create_time}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
@ -28,22 +24,8 @@
|
||||||
分</span>
|
分</span>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<!-- 自定义 footer-->
|
|
||||||
<!-- <template slot="footer">
|
|
||||||
<image class="slot-image" src="/static/logo.png" mode="widthFix"></image>
|
|
||||||
</template> -->
|
|
||||||
|
|
||||||
</uni-list-item>
|
</uni-list-item>
|
||||||
</uni-list>
|
</uni-list>
|
||||||
<!-- <uni-card :title="item.name" :isFull="true" isShadow='true' extra="查看详情" @click="clickCard" v-for="item in list" :key="item.id">
|
|
||||||
<view>
|
|
||||||
<text>{{item.type}}</text>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<text>耗时:{{item.took}}</text>
|
|
||||||
<text>开始答题:{{item.start_time}}</text>
|
|
||||||
</view>
|
|
||||||
</uni-card> -->
|
|
||||||
<view style="color:gray;text-align: center;margin-top:20upx">{{loadingText}}</view>
|
<view style="color:gray;text-align: center;margin-top:20upx">{{loadingText}}</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
@ -63,7 +45,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
getList() {
|
getList() {
|
||||||
var that = this
|
var that = this
|
||||||
that.$u.api.getMyExamRecord(that.listQuery).then(res => {
|
that.$u.api.examRecord(that.listQuery).then(res => {
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title: res.data.count + '条答题记录'
|
title: res.data.count + '条答题记录'
|
||||||
|
@ -90,11 +72,11 @@
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title:"正在获取答题详情",
|
title:"正在获取答题详情",
|
||||||
})
|
})
|
||||||
this.$u.api.getExamRecordDetail(id).then(res=>{
|
this.$u.api.examRecordDetail(id).then(res=>{
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.setStorageSync('currentExam', res.data)
|
uni.setStorageSync('currentExam', res.data)
|
||||||
if (res.data.questions.length>0){
|
if (res.data.questions_.length>0){
|
||||||
uni.redirectTo({
|
uni.navigateTo({
|
||||||
url:'/pages/exam/detail?examrecord='+id
|
url:'/pages/exam/detail?examrecord='+id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,15 +28,22 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goDetail(){
|
goDetail(){
|
||||||
uni.showLoading({
|
this.$u.api.examRecordDetail(this.currentExam.id).then(res=>{
|
||||||
title:"正在获取答题详情",
|
|
||||||
})
|
|
||||||
this.$u.api.getExamRecordDetail(this.currentExam.id).then(res=>{
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.setStorageSync('currentExam', res.data)
|
uni.setStorageSync('currentExam', res.data);
|
||||||
uni.redirectTo({
|
debugger;
|
||||||
url:'/pages/exam/detail?examrecord='+this.currentExam.id
|
if (res.data.questions_.length>0){
|
||||||
})
|
uni.redirectTo({
|
||||||
|
url:'/pages/exam/detail?examrecord='+res.data.id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
uni.showToast({
|
||||||
|
title:'获取失败',
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -47,7 +54,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options){
|
onLoad(options){
|
||||||
this.currentExam = uni.getStorageSync('currentExam')
|
this.currentExam = uni.getStorageSync('currentExam');
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,12 +62,13 @@
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.examImage {
|
.examImage {
|
||||||
width: 100%;
|
width: 200rpx;
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
// background-color: #000000;
|
|
||||||
margin-top: 100rpx;
|
margin-top: 100rpx;
|
||||||
height: 300rpx;
|
height: 200rpx;
|
||||||
|
margin: auto;
|
||||||
|
display: block;
|
||||||
|
margin-top: 100rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.finishText {
|
.finishText {
|
||||||
|
|
|
@ -23,25 +23,10 @@
|
||||||
<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
|
<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <view class="u-m-t-20">
|
|
||||||
<u-cell-group>
|
|
||||||
<u-cell-item icon="rmb-circle" title="支付"></u-cell-item>
|
|
||||||
</u-cell-group>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="u-m-t-20">
|
|
||||||
<u-cell-group>
|
|
||||||
<u-cell-item icon="star" title="收藏"></u-cell-item>
|
|
||||||
<u-cell-item icon="photo" title="相册"></u-cell-item>
|
|
||||||
<u-cell-item icon="coupon" title="卡券"></u-cell-item>
|
|
||||||
<u-cell-item icon="heart" title="关注"></u-cell-item>
|
|
||||||
</u-cell-group>
|
|
||||||
</view> -->
|
|
||||||
|
|
||||||
<view class="u-m-t-20">
|
<view class="u-m-t-20">
|
||||||
<u-cell-group>
|
<u-cell-group>
|
||||||
<u-cell-item icon="weixin-fill" title="绑定微信" :arrow="false" @click="bindMP" v-if="!vuex_user.wxmp_openid"></u-cell-item>
|
<u-cell-item icon="weixin-fill" title="绑定微信" :arrow="false" @click="bindMP" v-if="!vuex_user.wxmp_openid"></u-cell-item>
|
||||||
|
<u-cell-item icon="list-dot" title="考试记录" @click="examRecord"></u-cell-item>
|
||||||
<u-cell-item icon="close" title="退出" @click="Logout"></u-cell-item>
|
<u-cell-item icon="close" title="退出" @click="Logout"></u-cell-item>
|
||||||
</u-cell-group>
|
</u-cell-group>
|
||||||
</view>
|
</view>
|
||||||
|
@ -83,7 +68,13 @@
|
||||||
}).catch(e=>{})
|
}).catch(e=>{})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
examRecord(){
|
||||||
|
uni.navigateTo({
|
||||||
|
url:'/pages/exam/record'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue