Commit 914f4a47 by 冷斌

fix bug

parent 7c8f9b39
<include file="__THEME__/public_header_w3g"/> <include file="__THEME__/public_header_w3g" />
<style type="text/css"> <style type="text/css">
/*比较多用到的*/ /*比较多用到的*/
.box { .box {
display: flex; display: flex;
display: -webkit-flex; display: -webkit-flex;
align-items: center; align-items: center;
} }
.boxCn { .boxCn {
display: flex !important; display: flex !important;
display: -webkit-flex; display: -webkit-flex;
align-items: center; align-items: center;
justify-content: center !important; justify-content: center !important;
} }
.flex1 { .flex1 {
flex: 1; flex: 1;
} }
/*遮罩层*/ /*遮罩层*/
.mask { .mask {
position: fixed !important; position: fixed !important;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
transition: all .3s ease-in-out; transition: all .3s ease-in-out;
z-index: 8; z-index: 8;
} }
.popUp { .popUp {
background-color: #FFFFFF; background-color: #FFFFFF;
z-index: 10; z-index: 10;
width: 16.875rem; width: 16.875rem;
border-radius: 0.5rem; border-radius: 0.5rem;
overflow: hidden; overflow: hidden;
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
-webkit-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.popUp_title { .popUp_title {
font-family: PingFangSC-Semibold, PingFang SC; font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600; font-weight: 600;
font-size: 1.125rem; font-size: 1.125rem;
height: 1.5625rem; height: 1.5625rem;
line-height: 1.5625rem; line-height: 1.5625rem;
margin-top: 0.9375rem; margin-top: 0.9375rem;
padding: 0 1rem; padding: 0 1rem;
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
} }
.popUp_content { .popUp_content {
padding: 1rem 1rem; padding: 1rem 1rem;
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
font-size: 0.875rem; font-size: 0.875rem;
color: #333333; color: #333333;
} }
.popUp_btns { .popUp_btns {
border-top: 1px solid #eeeeee; border-top: 1px solid #eeeeee;
} }
.popUp_btn { .popUp_btn {
flex: 1; flex: 1;
text-align: center; text-align: center;
line-height: 3.125rem; line-height: 3.125rem;
height: 3.125rem; height: 3.125rem;
font-family: PingFangSC-Semibold, PingFang SC; font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600; font-weight: 600;
font-size: 1rem; font-size: 1rem;
box-sizing: border-box; box-sizing: border-box;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.popUp_btn0 { .popUp_btn0 {
color: #999999; color: #999999;
border-right: 1px solid #eeeeee; border-right: 1px solid #eeeeee;
} }
.popUp_btn1 { .popUp_btn1 {
color: #65C000; color: #65C000;
} }
/*jixu*/ /*jixu*/
.stopBox { .stopBox {
width: 100%; width: 100%;
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
z-index: 10; z-index: 10;
-webkit-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.stopBtn { .stopBtn {
width: 10rem; width: 10rem;
height: 3rem; height: 3rem;
line-height: 3rem; line-height: 3rem;
display: block; display: block;
margin: 2rem auto; margin: 2rem auto;
color: #FFFFFF; color: #FFFFFF;
font-size: 1rem; font-size: 1rem;
font-family: PingFangSC-Semibold, PingFang SC; font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600; font-weight: 600;
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
border-radius: 1.5rem; border-radius: 1.5rem;
} }
.stopBtn_on { .stopBtn_on {
background-color: #A3E460; background-color: #A3E460;
} }
.stopBtn_out { .stopBtn_out {
border: 1px solid rgba(204, 204, 204, 1); border: 1px solid rgba(204, 204, 204, 1);
} }
body {
background-color: #fff;
}
body {
.testPaperTop { background-color: #fff;
height: 2.25rem; }
padding: 0 0.75rem;
box-sizing: border-box; .testPaperTop {
border-bottom: 1px solid #F5F5F5; height: 2.25rem;
width: 100%; padding: 0 0.75rem;
position: fixed; box-sizing: border-box;
top: 0; border-bottom: 1px solid #F5F5F5;
left: 0; width: 100%;
z-index: 1; position: fixed;
background-color: #FFFFFF; top: 0;
} left: 0;
z-index: 1;
.testPaperTop_time { background-color: #FFFFFF;
font-size: 0.75rem }
}
.testPaperTop_time {
.testPaperTop_da { font-size: 0.75rem
font-size: 0.75rem; }
color: #999999;
} .testPaperTop_da {
font-size: 0.75rem;
.testPaperTop_pau { color: #999999;
margin-left: 1.875rem; }
width: 0.75rem;
height: 0.75rem; .testPaperTop_pau {
} margin-left: 1.875rem;
width: 0.75rem;
.testPaperBotm { height: 0.75rem;
padding: 0.75rem 0.75rem 0.75rem; }
box-sizing: border-box;
margin-top: 2.25rem; .testPaperBotm {
} padding: 0.75rem 0.75rem 0.75rem;
box-sizing: border-box;
.testPaperNum { margin-top: 2.25rem;
margin-right: 0.75rem; }
color: #999999;
font-size: 0.75rem; .testPaperNum {
} margin-right: 0.75rem;
color: #999999;
.testPaperLei { font-size: 0.75rem;
font-size: 0.75rem; }
color: #333333;
} .testPaperLei {
font-size: 0.75rem;
.testPaperColl { color: #333333;
width: 1rem; }
height: 1rem;
} .testPaperColl {
width: 1rem;
.testPaperInfo { height: 1rem;
margin-top: 0.5rem; }
font-size: 1rem;
line-height: 1.875rem; .testPaperInfo {
color: #333333; margin-top: 0.5rem;
} font-size: 1rem;
line-height: 1.875rem;
.testPaperAnswer { color: #333333;
margin-top: 1rem; }
align-items: flex-start;
} .testPaperAnswer {
margin-top: 1rem;
.testPaperAnswer_num { align-items: flex-start;
display: inline-block; }
width: 2.25rem;
height: 2.25rem; .testPaperAnswer_num {
border-radius: 100%; display: inline-block;
border: 1px solid rgba(163, 228, 96, 1); width: 2.25rem;
text-align: center; height: 2.25rem;
line-height: 2.25rem; border-radius: 100%;
color: #65C000; border: 1px solid rgba(163, 228, 96, 1);
font-family: PingFangSC-Semibold, PingFang SC; text-align: center;
font-weight: 600; line-height: 2.25rem;
font-size: 0.875rem; color: #65C000;
margin-right: 0.75rem; font-family: PingFangSC-Semibold, PingFang SC;
} font-weight: 600;
font-size: 0.875rem;
.testPaperAnswer_numAt { margin-right: 0.75rem;
background-color: #A3E460; }
color: #FFFFFF;
} .testPaperAnswer_numAt {
background-color: #A3E460;
.testPaperAnswer_desc { color: #FFFFFF;
line-height: 1.25rem; }
margin: 0;
} .testPaperAnswer_desc {
line-height: 1.25rem;
.testPaperBtns { margin: 0;
justify-content: space-between; }
padding: 3rem 0.75rem 1rem;
box-sizing: border-box; .testPaperBtns {
width: 100%; justify-content: space-between;
padding: 3rem 0.75rem 1rem;
} box-sizing: border-box;
width: 100%;
.testPaperBtn {
width: 10rem; }
height: 3rem;
line-height: 3rem; .testPaperBtn {
text-align: center; width: 10rem;
border: 1px solid rgba(163, 228, 96, 1); height: 3rem;
border-radius: 1.5rem; line-height: 3rem;
box-sizing: border-box; text-align: center;
font-size: 1rem; border: 1px solid rgba(163, 228, 96, 1);
font-family: PingFangSC-Semibold, PingFang SC; border-radius: 1.5rem;
font-weight: 600; box-sizing: border-box;
color: #65C000; font-size: 1rem;
} font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
.testPaperBtn1 { color: #65C000;
color: #FFFFFF; }
background: rgba(163, 228, 96, 1);
} .testPaperBtn1 {
color: #FFFFFF;
background: rgba(163, 228, 96, 1);
.testPaperJiedaPage { }
padding: 0 0.75rem;
box-sizing: border-box;
} .testPaperJiedaPage {
padding: 0 0.75rem;
.testPaperJiedaBox { box-sizing: border-box;
padding: 1rem 0; }
}
.testPaperJiedaBox {
.testPaperJiedaBtn { padding: 1rem 0;
color: #65C000; }
font-size: 0.875rem;
font-family: PingFangSC-Semibold, PingFang SC; .testPaperJiedaBtn {
font-weight: 600; color: #65C000;
} font-size: 0.875rem;
font-family: PingFangSC-Semibold, PingFang SC;
.testPaperJiedaBtn_icon { font-weight: 600;
margin-left: 0.5rem; }
width: 0.75rem;
height: 0.75rem; .testPaperJiedaBtn_icon {
} margin-left: 0.5rem;
width: 0.75rem;
.testPaperAnswers { height: 0.75rem;
padding: 0.5rem 0 0.25rem; }
}
.testPaperAnswers {
.testPaperAnswer { padding: 0.5rem 0 0.25rem;
padding: 0.5rem 0; }
color: #333333;
font-size: 1rem; .testPaperAnswer {
margin: 0; padding: 0.5rem 0;
} color: #333333;
font-size: 1rem;
.testPaperAnswer_n { margin: 0;
color: #65C000; }
}
.testPaperAnswer_n {
.testPaperAnswer_e { color: #65C000;
color: red; }
}
.testPaperAnswer_e {
.testPaperAnswer_infoBox { color: red;
padding: 0.1875rem 0.75rem 0.75rem; }
box-sizing: border-box;
border-top: 1px solid #f5f5f5; .testPaperAnswer_infoBox {
} padding: 0.1875rem 0.75rem 0.75rem;
box-sizing: border-box;
.testPaperAnswer_infoTitle { border-top: 1px solid #f5f5f5;
font-family: PingFangSC-Semibold, PingFang SC; }
font-weight: 600;
color: #333333; .testPaperAnswer_infoTitle {
font-size: 1rem; font-family: PingFangSC-Semibold, PingFang SC;
padding: 0.75rem 0 0.75rem 0.75rem; font-weight: 600;
box-sizing: border-box; color: #333333;
position: relative; font-size: 1rem;
margin: 0; padding: 0.75rem 0 0.75rem 0.75rem;
} box-sizing: border-box;
position: relative;
.testPaperAnswer_infoTitle::before { margin: 0;
content: ""; }
position: absolute;
left: 0; .testPaperAnswer_infoTitle::before {
top: 50%; content: "";
width: 4px; position: absolute;
height: 4px; left: 0;
border-radius: 100%; top: 50%;
background-color: #A3E460; width: 4px;
margin-top: -2px; height: 4px;
} border-radius: 100%;
background-color: #A3E460;
.testPaperAnswer_info { margin-top: -2px;
color: #333333; }
font-size: 1rem;
line-height: 1.875rem; .testPaperAnswer_info {
} color: #333333;
font-size: 1rem;
line-height: 1.875rem;
}
</style> </style>
<div id="app"> <div id="app">
<div class="testPaperTop box"> <div class="testPaperTop box">
<p class="testPaperTop_time flex1">{{countDown}}</p> <p class="testPaperTop_time flex1">{{countDown}}</p>
<span v-show="!review" class="testPaperTop_da">答题卡</span> <span v-show="!review" class="testPaperTop_da">答题卡</span>
<img v-show="!review" @click="onCounting" class="testPaperTop_pau" <img v-show="!review" @click="onCounting" class="testPaperTop_pau" :src="counting ? '__THEME__/img/pau.png' : '__THEME__/img/right_arrow.png'">
:src="counting ? '__THEME__/img/pau.png' : '__THEME__/img/right_arrow.png'"> </div>
</div> <div class="testPaperBotm">
<div class="testPaperBotm"> <div class="box">
<div class="box"> <span class="testPaperNum">{{current}}/{{totalQuestion}}</span>
<span class="testPaperNum">{{current}}/{{totalQuestion}}</span> <p class="testPaperLei flex1">({{currentQuestionTypeName}})</p>
<p class="testPaperLei flex1">({{currentQuestionTypeName}})</p> <img v-if="currentQuestion.is_collect == 0" @click="onCollect(1)" class="testPaperColl" src="__THEME__/img/share_unstar.png">
<img v-if="currentQuestion.is_collect == 0" @click="onCollect(1)" class="testPaperColl" <img v-if="currentQuestion.is_collect == 1" @click="onCollect(0)" class="testPaperColl" src="__THEME__/img/share_star.png">
src="__THEME__/img/share_unstar.png"> </div>
<img v-if="currentQuestion.is_collect == 1" @click="onCollect(0)" class="testPaperColl" <template v-if="showChoiceQuestion">
src="__THEME__/img/share_star.png"> <div v-html="currentQuestion.content" class="testPaperInfo"></div>
</div> <ul>
<template v-if="showChoiceQuestion"> <li v-for="(opt, index) in currentOptions" :key="index" class="testPaperAnswer box">
<div v-html="currentQuestion.content" class="testPaperInfo"></div> <span @click="onChoose(opt)" class="testPaperAnswer_num" :class="opt.selected ? 'testPaperAnswer_numAt' : ''">{{opt.key}}</span>
<ul> <div v-html="opt.value" class="testPaperAnswer_desc flex1" style="margin-top: 0.625rem;"></div>
<li v-for="(opt, index) in currentOptions" :key="index" class="testPaperAnswer box"> </li>
<span @click="onChoose(opt)" class="testPaperAnswer_num" </ul>
:class="opt.selected ? 'testPaperAnswer_numAt' : ''">{{opt.key}}</span> </template>
<div v-html="opt.value" class="testPaperAnswer_desc flex1" style="margin-top: 0.625rem;"></div> </div>
</li> <div v-if="current == 1" class="testPaperBtns boxCn">
</ul> <p @click="onNextQuestion" class="testPaperBtn testPaperBtn1" style="width: 15rem;">下一题</p>
</template> </div>
</div> <div v-if="current > 1" class="testPaperBtns box">
<div v-if="current == 1" class="testPaperBtns boxCn"> <p @click="onPreviousQuestion" class="testPaperBtn">上一题</p>
<p @click="onNextQuestion" class="testPaperBtn testPaperBtn1" style="width: 15rem;">下一题</p> <p @click="onNextQuestion" class="testPaperBtn testPaperBtn1">{{nextButton}}</p>
</div> </div>
<div v-if="current > 1" class="testPaperBtns box"> <!-- 解析 -->
<p @click="onPreviousQuestion" class="testPaperBtn">上一题</p> <div class="testPaperJiedaPage">
<p @click="onNextQuestion" class="testPaperBtn testPaperBtn1">{{nextButton}}</p> <div class="box testPaperJiedaBox">
</div> <span @click="expand = !expand" class="testPaperJiedaBtn box">{{expand ? '收起解析' : '查看解析'}}<img class="testPaperJiedaBtn_icon" src="__THEME__/img/openBtn.png"></span>
<!-- 解析 --> </div>
<div class="testPaperJiedaPage"> <ul v-if="expand" class="testPaperAnswers">
<div class="box testPaperJiedaBox"> <li class="testPaperAnswer">正确答案:<span v-for="(answer, index) in currentRightOptions" :key="index" class="testPaperAnswer_n">{{answer}}</span></li>
<span @click="expand = !expand" class="testPaperJiedaBtn box">{{expand ? '收起解析' : '查看解析'}}<img <li class="testPaperAnswer">我的答案:<span v-for="(answer, index) in currentMyOptions" :key="index" :class="answer.right ? 'testPaperAnswer_n' : 'testPaperAnswer_e'">{{answer.key}}</span></li>
class="testPaperJiedaBtn_icon" src="__THEME__/img/openBtn.png"></span> </ul>
</div> <div v-if="expand" class="testPaperAnswer_infoBox">
<ul v-if="expand" class="testPaperAnswers"> <p class="testPaperAnswer_infoTitle">解析</p>
<li class="testPaperAnswer">正确答案:<span v-for="(answer, index) in currentRightOptions" :key="index" <div v-html="currentAnalyze" class="testPaperAnswer_info">
class="testPaperAnswer_n">{{answer}}</span></li> </div>
<li class="testPaperAnswer">我的答案:<span v-for="(answer, index) in currentMyOptions" :key="index" </div>
:class="answer.right ? 'testPaperAnswer_n' : 'testPaperAnswer_e'">{{answer.key}}</span> </div>
</li> <!-- 交卷 -->
</ul> <div class="mask" v-if="showFinish">
<div v-if="expand" class="testPaperAnswer_infoBox"> <div class="popUp">
<p class="testPaperAnswer_infoTitle">解析</p> <p class="popUp_title">提示</p>
<div v-html="currentAnalyze" class="testPaperAnswer_info"> <div class="popUp_content">是否交卷并退出考试?</div>
</div> <div class="popUp_btns box">
</div> <span @click="onCancel" class="popUp_btn popUp_btn0 flex1">取消</span>
</div> <span @click="onSure" class="popUp_btn popUp_btn1 flex1">确定</span>
<!-- 交卷 --> </div>
<div class="mask" v-if="showFinish"> </div>
<div class="popUp"> </div>
<p class="popUp_title">提示</p> <!-- 暂停 -->
<div class="popUp_content">是否交卷并退出考试?</div> <div class="mask" v-if="showPause">
<div class="popUp_btns box"> <div class="stopBox">
<span @click="onCancel" class="popUp_btn popUp_btn0 flex1">取消</span> <span @click="onContinue" class="stopBtn stopBtn_on">继续</span>
<span @click="onSure" class="popUp_btn popUp_btn1 flex1">确定</span> <span @click="onQuit" class="stopBtn stopBtn_out">退出</span>
</div> </div>
</div> </div>
</div>
<!-- 暂停 -->
<div class="mask" v-if="showPause">
<div class="stopBox">
<span @click="onContinue" class="stopBtn stopBtn_on">继续</span>
<span @click="onQuit" class="stopBtn stopBtn_out">退出</span>
</div>
</div>
</div> </div>
<include file="__THEME__/public_footer_w3g"/> <include file="__THEME__/public_footer_w3g" />
<script type="text/javascript"> <script type="text/javascript">
new Vue({ new Vue({
el: "#app", el: "#app",
data: function () { data: function() {
return { return {
info: {}, info: {},
temp: {}, temp: {},
current: 1, current: 1,
paperOptions: {}, paperOptions: {},
counting: true, counting: true,
review: false, review: false,
countDown: "00:00:00", countDown: "00:00:00",
timeConsumed: 0, timeConsumed: 0,
expand: false, expand: false,
showPause: false, showPause: false,
showFinish: false, showFinish: false,
//选项 //选项
currentOptions: [], currentOptions: [],
finished: [] finished: []
} }
}, },
computed: { computed: {
//computed //computed
nextButton: function () { nextButton: function() {
if (this.review) { if(this.review) {
return this.current == this.totalQuestion ? '返回' : '下一题' return this.current == this.totalQuestion ? '返回' : '下一题'
} else { } else {
return this.current == this.totalQuestion ? '交卷' : '下一题' return this.current == this.totalQuestion ? '交卷' : '下一题'
} }
}, },
totalQuestion: function () { totalQuestion: function() {
let count = 0 let count = 0
let data = this.paperOptions.options_questions_data let data = this.paperOptions.options_questions_data
this.paperOptions.options_type.forEach(r => { this.paperOptions.options_type.forEach( r => {
count += data[r.question_type].length count += data[r.question_type].length
}) })
return count return count
}, },
currentTypeIndex: function () { currentTypeIndex: function() {
let count = 0 let count = 0
let data = this.paperOptions.options_questions_data let data = this.paperOptions.options_questions_data
let current = this.current let current = this.current
for (let i = 0; i < this.paperOptions.options_type.length; i++) { for(let i = 0; i < this.paperOptions.options_type.length; i++) {
let r = this.paperOptions.options_type[i] let r = this.paperOptions.options_type[i]
let next = count + data[r.question_type].length let next = count + data[r.question_type].length
if (current > count && current <= next) { if(current > count && current <= next) {
return i return i
} else { } else {
count = next count = next
} }
} }
}, },
currentQuestions: function () { currentQuestions: function() {
let optionType = this.currentQuestionType let optionType = this.currentQuestionType
let questionType = optionType.question_type let questionType = optionType.question_type
let questionData = this.paperOptions.options_questions_data let questionData = this.paperOptions.options_questions_data
let questions = questionData[questionType] let questions = questionData[questionType]
return questions return questions
}, },
currentQuestionType: function () { currentQuestionType: function() {
return this.paperOptions.options_type[this.currentTypeIndex] return this.paperOptions.options_type[this.currentTypeIndex]
}, },
currentQuestionTypeName: function () { currentQuestionTypeName: function() {
return this.currentQuestionType.type_info.question_type_title return this.currentQuestionType.type_info.question_type_title
}, },
currentQuestionTypeKey: function () { currentQuestionTypeKey: function() {
return this.currentQuestionType.question_type_key return this.currentQuestionType.question_type_key
}, },
currentQuestion: function () { currentQuestion: function() {
let count = 0 let count = 0
let data = this.paperOptions.options_questions_data let data = this.paperOptions.options_questions_data
let current = this.current let current = this.current
for (let i = 0; i < this.paperOptions.options_type.length; i++) { for(let i = 0; i < this.paperOptions.options_type.length; i++) {
let r = this.paperOptions.options_type[i] let r = this.paperOptions.options_type[i]
let next = count + data[r.question_type].length let next = count + data[r.question_type].length
if (current > count && current <= next) { if(current > count && current <= next) {
return data[r.question_type][current - count - 1] return data[r.question_type][current - count - 1]
} else { } else {
count = next count = next
} }
} }
}, },
//选择题答案 //选择题答案
currentRightOptions: function () { currentRightOptions: function() {
return this.currentQuestion.answer_true_option return this.currentQuestion.answer_true_option
}, },
//我的答案 //我的答案
currentMyOptions: function () { currentMyOptions: function() {
let cur = this.currentRightOptions let cur = this.currentRightOptions
return this.currentOptions.filter(r => { return this.currentOptions.filter( r => { return r.selected }).map( r => {
return r.selected return {
}).map(r => { right: cur.hx_indexOf( k => { return k == r.key }) != -1,
return { key: r.key
right: cur.hx_indexOf(k => { }
return k == r.key })
}) != -1, },
key: r.key //解析
} currentAnalyze: function() {
}) return this.currentQuestion.analyze
}, },
//解析 //Helper
currentAnalyze: function () { showChoiceQuestion: function() {
return this.currentQuestion.analyze let key = this.currentQuestionTypeKey
}, return key == 'radio' || key == 'multiselect' || key == 'judge'
//Helper }
showChoiceQuestion: function () { },
let key = this.currentQuestionTypeKey created: function() {
return key == 'radio' || key == 'multiselect' || key == 'judge' this.info = {:json_encode($paper)};
} this.temp = {:json_encode($tempData)};
}, this.paperOptions = {:json_encode($paper_options)};
created: function () { this.review = "{$review}"
this.info = { this.initAnswerMode()
: this.doCountDown()
json_encode($paper) if(this.review) {
} this.countDown = this.computeTime(this.info.reply_time * 60)
; this.expand = true
this.temp = { }
: console.log("Review = " + this.review)
json_encode($tempData) console.log(this.info)
} console.log(this.temp)
; console.log(this.paperOptions)
this.paperOptions = { },
: watch: {
json_encode($paper_options) current: function(o, n) {
} this.initAnswerMode()
; }
this.review = "{$review}" },
this.initAnswerMode() methods: {
this.doCountDown() initAnswerMode: function() {
if (this.review) { let q = this.currentQuestionTypeKey
this.countDown = this.computeTime(this.info.reply_time * 60) switch(q) {
this.expand = true case "radio":
} this.currentOptions = []
console.log("Review = " + this.review) let Q = this.currentQuestion
console.log(this.info) let old = this.finished.hx_firstOf( r => { return r.qId == Q.exams_question_id })
console.log(this.temp) for(let k in Q.answer_options) {
console.log(this.paperOptions) let value = Q.answer_options[k]
}, let select = old ? old.option == k : false
watch: { this.currentOptions.push({
current: function (o, n) { key: k,
this.initAnswerMode() value: value,
} selected: select
}, })
methods: { }
initAnswerMode: function () { break
let q = this.currentQuestionTypeKey }
switch (q) { },
case "radio": recordData: function() {
this.currentOptions = [] return {
let Q = this.currentQuestion paperId: this.info.exams_paper_id,
let old = this.finished.hx_firstOf(r => { timeConsumed: this.timeConsumed,
return r.qId == Q.exams_question_id questionIndex: this.current,
}) finished: this.finished
for (let k in Q.answer_options) { }
let value = Q.answer_options[k] },
let select = old ? old.option == k : false computeTime: function(time) {
this.currentOptions.push({ let hours = Math.floor(time / 3600)
key: k, let minutes = Math.floor((time % 3600) / 60)
value: value, let seconds = Math.round(time % 60)
selected: select return (hours < 10 ? '0' + hours : hours) + ":" + (minutes < 10 ? '0' + minutes : minutes) + ":" + (seconds < 10 ? '0' + seconds : seconds)
}) },
} doCountDown: function() {
break if(!this.counting || this.review) {
} return
}, }
recordData: function () { if(this.info.reply_time) {
return { let time = this.info.reply_time * 60 - this.timeConsumed
paperId: this.info.exams_paper_id, if(time <= 0) {
timeConsumed: this.timeConsumed, this.showFinish = true
questionIndex: this.current, } else {
finished: this.finished this.countDown = this.computeTime(time)
} setTimeout(this.doCountDown, 1000)
}, this.timeConsumed += 1
computeTime: function (time) { }
let hours = Math.floor(time / 3600) } else {
let minutes = Math.floor((time % 3600) / 60) this.countDown = "不限时"
let seconds = Math.round(time % 60) }
return (hours < 10 ? '0' + hours : hours) + ":" + (minutes < 10 ? '0' + minutes : minutes) + ":" + (seconds < 10 ? '0' + seconds : seconds) },
}, onCollect: function(collect) {
doCountDown: function () { let that = this
if (!this.counting || this.review) { $.post(U('exams/Index/collect'), {
return action: collect,
} source_id: that.currentQuestion.exams_question_id
if (this.info.reply_time) { }, function(res) {
let time = this.info.reply_time * 60 - this.timeConsumed let r = JSON.parse(res)
if (time <= 0) { if(r.status == 1) {
this.showFinish = true that.currentQuestion.is_collect = collect
} else { }
this.countDown = this.computeTime(time) })
setTimeout(this.doCountDown, 1000) },
this.timeConsumed += 1 onChoose: function(opt) {
} if(this.currentQuestionTypeKey == 'radio') {
} else { this.currentOptions.forEach( r => {
this.countDown = "不限时" r.selected = opt.key == r.key
} })
}, }
onCollect: function (collect) { },
let that = this onCounting: function() {
$.post(U('exams/Index/collect'), { if(this.counting) {
action: collect, this.counting = false
source_id: that.currentQuestion.exams_question_id this.showPause = true
}, function (res) { } else {
let r = JSON.parse(res) this.counting = true
if (r.status == 1) { this.doCountDown()
that.currentQuestion.is_collect = collect }
} },
}) onContinue: function() {
}, this.showPause = false
onChoose: function (opt) { this.onCounting()
if (this.currentQuestionTypeKey == 'radio') { },
this.currentOptions.forEach(r => { onQuit: function() {
r.selected = opt.key == r.key this.showPause = false
}) this.saveProgress()
} },
}, onCancel: function() {
onCounting: function () { this.showFinish = false
if (this.counting) { window.history.back()
this.counting = false },
this.showPause = true onSure: function() {
} else { this.showFinish = false
this.counting = true this.submitPaper()
this.doCountDown() },
} onNextQuestion: function() {
}, if(this.current < this.totalQuestion) {
onContinue: function () { this.cacheQuestion()
this.showPause = false if(!this.review) {
this.onCounting() this.expand = false
}, }
onQuit: function () { this.current += 1
this.showPause = false } else {
this.saveProgress() if(!this.review) {
}, this.showFinish = true
onCancel: function () { } else {
this.showFinish = false window.history.back()
window.history.back() }
}, }
onSure: function () { },
this.showFinish = false onPreviousQuestion: function() {
this.submitPaper() if(this.current > 1) {
}, this.current -= 1
onNextQuestion: function () { }
if (this.current < this.totalQuestion) { },
this.cacheQuestion() cacheQuestion: function() {
if (!this.review) { if(this.review) {
this.expand = false return
} }
this.current += 1 let q = this.currentQuestion
} else { let mode = this.finished.hx_firstOf( r => { return r.qId == q.exams_question_id })
if (!this.review) { if(mode) {
this.showFinish = true switch(this.currentQuestionTypeKey) {
} else { case "radio":
window.history.back() let my = this.currentMyOptions
} if(my.length > 0) {
} mode.option = my[0].key
}, }
onPreviousQuestion: function () { break
if (this.current > 1) { }
this.current -= 1 } else {
} switch(this.currentQuestionTypeKey) {
}, case "radio":
cacheQuestion: function () { let my = this.currentMyOptions
if (this.review) { if(my.length > 0) {
return this.finished.push({
} qId: q.exams_question_id,
let q = this.currentQuestion option: my[0].key,
let mode = this.finished.hx_firstOf(r => { key: "radio"
return r.qId == q.exams_question_id })
}) }
if (mode) { break
switch (this.currentQuestionTypeKey) { }
case "radio": }
let my = this.currentMyOptions },
if (my.length > 0) { //Request
mode.option = my[0].key //Collect Params
} collectParam: function() {
break let that = this
} let time = that.info.reply_time * 60 - that.timeConsumed
} else { let param = {
switch (this.currentQuestionTypeKey) { anser_time: that.timeConsumed,
case "radio": exams_mode: 1,
let my = this.currentMyOptions paper_id: that.info.exams_paper_id,
if (my.length > 0) { ch_id: "{$_GET['s_id']}",
this.finished.push({ view_url: "{$_GET['view']}",
qId: q.exams_question_id, is_timeout: time <= 0 ? 1 : 0,
option: my[0].key, paper_options_id: that.paperOptions.exams_paper_options_id,
key: "radio" }
}) that.finished.forEach( r => {
} let key = 'user_answer[' + r.qId + ']'
break switch(r.key) {
} case "radio":
} param[key] = r.option
}, break
//Request }
//Collect Params })
collectParam: function () { return param
let that = this },
let time = that.info.reply_time * 60 - that.timeConsumed saveProgress: function() {
let param = { let that = this
anser_time: that.timeConsumed, that.cacheQuestion()
exams_mode: 1, let param = this.collectParam()
paper_id: that.info.exams_paper_id, $.post(
ch_id: "{$_GET['s_id']}", U('exams/Index/doProgressExams'),
view_url: "{$_GET['view']}", param,
is_timeout: time <= 0 ? 1 : 0, function(res) {
paper_options_id: that.paperOptions.exams_paper_options_id, if (typeof(res) != 'object') {
} try {
that.finished.forEach(r => { let res = JSON.parse(res)
let key = 'user_answer[' + r.qId + ']' } catch (e) {
switch (r.key) { ui.error("处理异常,请重新尝试")
case "radio": }
param[key] = r.option }
break if (res.status == 1) {
} ui.success(res.data.info)
}) window.location.href = res.data.jumpurl
return param } else {
}, ui.error(res.message)
saveProgress: function () { }
let that = this })
that.cacheQuestion() },
let param = this.collectParam() submitPaper: function() {
$.post( let that = this
U('exams/Index/doProgressExams'), that.cacheQuestion()
param, let param = this.collectParam()
function (res) { $.post(
if (typeof (res) != 'object') { U('exams/Index/doHaddleExams'),
try { param,
let res = JSON.parse(res) function(r) {
} catch (e) { let res = JSON.parse(r)
ui.error("处理异常,请重新尝试") if (res.status == 1) {
} ui.success(res.data.info)
} window.location.href = res.data.jumpurl
if (res.status == 1) { } else {
ui.success(res.data.info) ui.error(res.message)
window.location.href = res.data.jumpurl }
} else { })
ui.error(res.message) }
} }
}) })
},
submitPaper: function () {
let that = this
that.cacheQuestion()
let param = this.collectParam()
$.post(
U('exams/Index/doHaddleExams'),
param,
function (r) {
let res = JSON.parse(r)
if (res.status == 1) {
ui.success(res.data.info)
window.location.href = res.data.jumpurl
} else {
ui.error(res.message)
}
})
}
}
})
</script> </script>
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