Commit e9cfb545 authored by 范雪寒's avatar 范雪寒

feat: 错题最多四次

parent ea501781
<div class="model-content">
<div style="padding: 10px;">
<div style="width: 500px; margin-top: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 15px;">
答对所有题或答题满<input style="width: 50px;" type="number" nz-input [(ngModel)]="item.maxWrongNumber" (blur)="save()">次自动结束游戏
</div>
</div>
<div style="padding: 10px;">
......
......@@ -10,7 +10,7 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "test_001";
saveKey = "op_09";
// 储存对象
item;
......@@ -22,7 +22,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() {
this.item = {};
this.item = {
maxWrongNumber: 4,
question_arr: []
};
// 获取存储的数据
(<any>window).courseware.getData((data) => {
......@@ -51,14 +54,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
if (!this.item.question_arr) {
this.item.question_arr = [];
}
this.questionArr = this.item.question_arr;
this.questionArr = this.item.question_arr;
}
addQuestionBtnClick() {
this.questionArr.push({
question_audio_url: '',
option_arr: [ //选项 (多选)
]
})
this.save();
......@@ -79,7 +82,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
deleteOptionBtnClick(option, index) {
option.splice( index, 1)
option.splice(index, 1)
this.save();
}
......
......@@ -145,7 +145,8 @@ cc.Class({
initData() {
this.status = {
currentQuestionIdx: 0
currentQuestionIdx: 0,
wrongTime: 0
}
},
......@@ -157,7 +158,7 @@ cc.Class({
},
refreshCoolCatPosition() {
},
jumpToQuestion(questionIdx) {
......@@ -279,7 +280,8 @@ cc.Class({
this.onAnswerRight();
} else {
this.coolCatSpeakWrong(() => {
if (!this.status.wrongOnce) {
this.status.wrongTime++;
if (this.status.wrongTime < this.data.maxWrongNumber) {
this.onAnswerWrong();
} else {
this.onAnswerWrongTwice();
......@@ -301,7 +303,6 @@ cc.Class({
},
onAnswerWrong() {
this.status.wrongOnce = true;
const box = cc.find('Canvas/bg/box');
box.children
.filter(child => child.optionData.selected)
......@@ -316,6 +317,7 @@ cc.Class({
},
onAnswerWrongTwice() {
this.status.currentQuestionIdx = this.data.question_arr.length;
this.nextQuestion();
this.playEffect('jumpAll');
},
......@@ -329,7 +331,6 @@ cc.Class({
.start();
});
this.status.currentQuestionIdx++;
this.status.wrongOnce = false;
if (this.status.currentQuestionIdx < this.data.question_arr.length) {
setTimeout(() => {
......
export const defaultData = {
maxWrongNumber: 4,
"question_arr": [{
"question_audio_url": "",
"option_arr": [{
......
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