git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
word/multichoice: stop when answers run out
[sheet.git]
/
word
/
multichoice.js
diff --git
a/word/multichoice.js
b/word/multichoice.js
index aa018d015294ec5f031d58c8112542795b031178..5908fdcbec9f3a2a69967bf1d9111bb4e98e193e 100644
(file)
--- a/
word/multichoice.js
+++ b/
word/multichoice.js
@@
-1,16
+1,18
@@
class WordMultiChoice extends WordQuiz {
next() {
class WordMultiChoice extends WordQuiz {
next() {
+ if (this.words.length < 4) return;
let word = this.words.shift();
let word = this.words.shift();
+ if (!word[2]) return this.next();
let form = put(this.form,
let form = put(this.form,
- '+img[src=$]+ul', `/data/word/en/${word[
0
]}.jpg`,
+ '+img[src=$]+ul', `/data/word/en/${word[
2
]}.jpg`,
);
);
- let answers = [word[
2], this.words[1][2], this.words[2][2], this.words[3][2
]]
- .s
ort(() => {return .5 - Math.random()}) // shuffle
+ let answers = [word[
0], this.words[0][0], this.words[1][0], this.words[2][0
]]
+ .s
huffle()
answers.forEach(suggest => {
let label = suggest.replace(/\/.*/, '');
let option = put(form, 'li', label, {onclick: () => {
answers.forEach(suggest => {
let label = suggest.replace(/\/.*/, '');
let option = put(form, 'li', label, {onclick: () => {
- if (suggest != word[
2
]) {
+ if (suggest != word[
0
]) {
// incorrect
put(option, '.wrong');
return;
// incorrect
put(option, '.wrong');
return;