mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
fix(result): Fix simple when no answer
This commit is contained in:
parent
e9c052036f
commit
9855cf80a1
1 changed files with 7 additions and 5 deletions
|
@ -580,12 +580,12 @@
|
||||||
GuessCorrectIn2LengthAnswersByPoints (i, items) {
|
GuessCorrectIn2LengthAnswersByPoints (i, items) {
|
||||||
const first = {
|
const first = {
|
||||||
elem: items[0],
|
elem: items[0],
|
||||||
val: parseInt(items[0].childNodes[0].value),
|
val: items[0].childNodes[0].checked,
|
||||||
text: items[0].innerText
|
text: items[0].innerText
|
||||||
}
|
}
|
||||||
const second = {
|
const second = {
|
||||||
elem: items[1],
|
elem: items[1],
|
||||||
val: parseInt(items[1].childNodes[0].value),
|
val: items[1].childNodes[0].checked,
|
||||||
text: items[1].innerText
|
text: items[1].innerText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,19 +593,21 @@
|
||||||
const grades = grade.split(' ').reduce((acc, text) => {
|
const grades = grade.split(' ').reduce((acc, text) => {
|
||||||
if (text.includes(',')) { // FIXME: fancy regexp
|
if (text.includes(',')) { // FIXME: fancy regexp
|
||||||
acc.push(parseInt(text))
|
acc.push(parseInt(text))
|
||||||
|
} else if (text.includes('.')) { // FIXME: fancy regexp
|
||||||
|
acc.push(parseInt(text))
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (grades[0] === 1) {
|
if (grades[0] === 1) {
|
||||||
if (first.val === 1) {
|
if (first.val) {
|
||||||
return first.text
|
return first.text
|
||||||
} else {
|
} else {
|
||||||
return second.text
|
return second.text
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (first.val === 0) {
|
if (!first.val) {
|
||||||
return first.txt
|
return first.text
|
||||||
} else {
|
} else {
|
||||||
return second.text
|
return second.text
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue