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

feat: 错题最多四次

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