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