syntax simplification, getselectanswer index fix

This commit is contained in:
MrFry 2020-01-10 10:41:18 +01:00
parent 077d146614
commit 2b77abc63b

View file

@ -586,11 +586,11 @@
return qtype
}
GetSelectAnswer () {
GetSelectAnswer (i) {
if (logElementGetting) { Log('getting selected answer') }
var t = document.getElementsByTagName('select')
if (t.length > 0) {
return t[0].options[document.getElementsByTagName('select')[0].selectedIndex].innerText
return t[i].options[t[i].selectedIndex].innerText
}
}
@ -746,31 +746,36 @@
GetRightAnswerFromResult (i) {
var fun = []
// "húzza oda ..." skip
fun.push((i) => {
return undefined
})
// the basic type of getting answers
fun.push(function TryGet0 (i) {
fun.push((i) => {
var temp = RPM.GetRightAnswerIfCorrectShown(i) // getting risht answer
if (temp.length > 0) { return temp[0].innerText } // adding the answer to curr question as .a
})
// if there is dropdown list in the current question
fun.push(function TryGet1 (i) {
fun.push((i) => {
if (RPM.GetDropboxes(i).length > 0) { return RPM.GetCurrentAnswer(i) }
})
// if the correct answers are not shown, and the selected answer
// is correct
fun.push(function TryGet2 (i) {
fun.push((i) => {
return RPM.GetRightAnswerIfCorrectNotShown(i)
})
// if there is dropbox in the question
fun.push(function TryGet3 (i) {
return RPM.GetSelectAnswer()
fun.push((i) => {
return RPM.GetSelectAnswer(i)
})
// if the correct answers are not shown, and the selected answer
// is incorrect, and there are only 2 options
fun.push(function TryGet4 (i) {
fun.push((i) => {
var possibleAnswers = RPM.GetPossibleAnswers(i)
if (possibleAnswers.length === 2) {
for (var k = 0; k < possibleAnswers.length; k++) {
@ -779,7 +784,8 @@
}
})
fun.push(function TryGetFinal (i) {
// if everything fails
fun.push((i) => {
return undefined
})