Commit ebdc9884 authored by JinWei's avatar JinWei

fix: 修复自动保存失败的问题

parent f9984207
...@@ -186,13 +186,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -186,13 +186,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
autoFillOption(ques) { autoFillOption(ques) {
if (ques.optionTypeText) { if (ques.optionTypeText || ques.optionTypePic || ques.optionTypeAudio) {
if (ques.optionCount <= 0) { if (ques.optionCount <= 0) {
ques.optionCount = 5; //tempList.length; ques.optionCount = 5; //tempList.length;
for (let i = 0; i < ques.optionCount; i++) { for (let i = 0; i < ques.optionCount; i++) {
if (this.curBookWords.length > 0) { if (this.curBookWords.length > i) {
ques.optionArr.push({ ques.optionArr.push({
text: this.curBookWords[i].word, text: this.curBookWords[i].word,
wordData: this.curBookWords[i], wordData: this.curBookWords[i],
...@@ -209,7 +209,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -209,7 +209,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} else if (ques.optionArr.length < ques.optionCount) { } else if (ques.optionArr.length < ques.optionCount) {
for (let i = ques.optionArr.length; i < ques.optionCount; i++) { for (let i = ques.optionArr.length; i < ques.optionCount; i++) {
ques.optionArr.push({ ques.optionArr.push({
audioAutoPlay: true audioAutoPlay: true,
wordData: this.getUnusedWord(ques)
}); });
} }
} }
...@@ -236,7 +237,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -236,7 +237,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// } // }
// } // }
// this.refreshOptionRes(ques); this.refreshOptionRes(ques);
} }
/** /**
...@@ -414,9 +415,16 @@ getUnusedWord(ques: any): any { ...@@ -414,9 +415,16 @@ getUnusedWord(ques: any): any {
addOneOption(ques) { addOneOption(ques) {
ques.optionArr.push({ ques.optionArr.push({
audioAutoPlay: true audioAutoPlay: true,
// answer: 'isWrong' wordData: {
word: '',
wordTranslation: '',
wordAudioUrl: '',
imageUrl: ''
}
}); });
ques.optionCount = ques.optionArr.length;
this.refreshOptionRes(ques);
this.save(); this.save();
} }
...@@ -442,7 +450,9 @@ getUnusedWord(ques: any): any { ...@@ -442,7 +450,9 @@ getUnusedWord(ques: any): any {
} }
refreshQuesRes(ques) { refreshQuesRes(ques) {
if (!ques.wordData) {
return; return;
}
if (ques.quesTypeText) { if (ques.quesTypeText) {
if (!ques.text) { if (!ques.text) {
ques.text = ques.wordData.exampleSentence; ques.text = ques.wordData.exampleSentence;
...@@ -463,6 +473,9 @@ getUnusedWord(ques: any): any { ...@@ -463,6 +473,9 @@ getUnusedWord(ques: any): any {
refreshOptionRes(ques) { refreshOptionRes(ques) {
ques.optionArr.forEach(option => { ques.optionArr.forEach(option => {
if (!option.wordData) {
return;
}
if (ques.optionTypeText) { if (ques.optionTypeText) {
if (!option.text) { if (!option.text) {
option.text = option.wordData.word; option.text = option.wordData.word;
......
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