avoid repetition for last 3 questions
This commit is contained in:
@@ -129,6 +129,7 @@ let app = {
|
|||||||
},
|
},
|
||||||
kanas: [],
|
kanas: [],
|
||||||
question: 'あ',
|
question: 'あ',
|
||||||
|
lastQuestions: [ '', '', '' ],
|
||||||
answers: [ 'A', 'I', 'U', 'O' ],
|
answers: [ 'A', 'I', 'U', 'O' ],
|
||||||
wrongAnswers: [],
|
wrongAnswers: [],
|
||||||
},
|
},
|
||||||
@@ -198,7 +199,11 @@ let app = {
|
|||||||
|
|
||||||
const mapping = kanas.mappings[utils.randitem(self.options.mappings)];
|
const mapping = kanas.mappings[utils.randitem(self.options.mappings)];
|
||||||
|
|
||||||
const questionIndex = utils.randindex(self.kanas);
|
const questionIndex = utils.randindex(self.kanas, self.lastQuestions);
|
||||||
|
|
||||||
|
self.lastQuestions.pop(0);
|
||||||
|
self.lastQuestions.push(questionIndex);
|
||||||
|
|
||||||
const similarIndexes = self.findSimilars(questionIndex, mapping);
|
const similarIndexes = self.findSimilars(questionIndex, mapping);
|
||||||
const otherIndexes = utils.randindexes(self.kanas, Math.max(0, self.options.answers - similarIndexes.length - 1), questionIndex, ...similarIndexes );
|
const otherIndexes = utils.randindexes(self.kanas, Math.max(0, self.options.answers - similarIndexes.length - 1), questionIndex, ...similarIndexes );
|
||||||
|
|
||||||
@@ -209,6 +214,12 @@ let app = {
|
|||||||
.map((index) => self.kanas[index][mapping[1]]);
|
.map((index) => self.kanas[index][mapping[1]]);
|
||||||
self.answers = self.answers.shuffle();
|
self.answers = self.answers.shuffle();
|
||||||
self.wrongAnswers = [];
|
self.wrongAnswers = [];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* setTimeout(() => {
|
||||||
|
* this.answer(self.question);
|
||||||
|
* });
|
||||||
|
*/
|
||||||
},
|
},
|
||||||
answer: function (v) {
|
answer: function (v) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user