From 2b77abc63b34e3f4cd53e3809cf8b5a7c56cb345 Mon Sep 17 00:00:00 2001 From: MrFry Date: Fri, 10 Jan 2020 10:41:18 +0100 Subject: [PATCH] syntax simplification, getselectanswer index fix --- stable.user.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/stable.user.js b/stable.user.js index 6f5139c..86af0f5 100644 --- a/stable.user.js +++ b/stable.user.js @@ -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 })