Commit ebdc9884 authored by JinWei's avatar JinWei

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

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