Ugrás... fix

This commit is contained in:
mrfry 2020-11-12 14:31:15 +01:00
parent ad0e355f2d
commit 169e48e389

View file

@ -89,7 +89,8 @@
const forceResultPage = false const forceResultPage = false
const forceDefaultPage = false const forceDefaultPage = false
const logElementGetting = false const logElementGetting = false
const log = true const log = false
const showErrors = false
const motdShowCount = 3 /* Ammount of times to show motd */ const motdShowCount = 3 /* Ammount of times to show motd */
let infoExpireTime = 60 // Every n seconds basic info should be loaded from server let infoExpireTime = 60 // Every n seconds basic info should be loaded from server
@ -549,6 +550,10 @@
} }
} }
getGeneralFeedback(i) {
return document.getElementsByClassName('generalfeedback')[0]
}
GetAnswerNode(i) { GetAnswerNode(i) {
if (logElementGetting) { if (logElementGetting) {
Log('getting answer node') Log('getting answer node')
@ -663,9 +668,11 @@
} }
return res return res
} catch (e) { } catch (e) {
if (showErrors) {
console.info(e) console.info(e)
} }
} }
}
GetRightAnswerIfCorrectShown(i) { GetRightAnswerIfCorrectShown(i) {
if (logElementGetting) { if (logElementGetting) {
@ -760,18 +767,19 @@
return currQuestion return currQuestion
} }
GetRightAnswerFromResult(i) {
let res = this.GetRightAnswerFromResultv2(i)
if (!res) {
res = this.GetRightAnswerFromResultv1(i)
}
return res
}
// tries to get right answer from result page // tries to get right answer from result page
// i is the index of the question // i is the index of the question
GetRightAnswerFromResult(i) { GetRightAnswerFromResultv1(i) {
var fun = [] var fun = []
// Ugrás... fix: textarea-ban kell válaszolni
fun.push(i => {
const a = RPM.getTextAreaAnsweretAsd()
console.log(a)
return a
})
// "húzza oda ..." skip // "húzza oda ..." skip
fun.push(i => { fun.push(i => {
let temp = RPM.GetAnswersFromGrabBox(i) let temp = RPM.GetAnswersFromGrabBox(i)
@ -832,8 +840,10 @@
try { try {
currAnswer = fun[j](i) currAnswer = fun[j](i)
} catch (e) { } catch (e) {
if (showErrors) {
console.info(e) console.info(e)
} }
}
j++ j++
} }
@ -896,9 +906,14 @@
try { try {
var answerNodes = this.GetAnswerNode(i) var answerNodes = this.GetAnswerNode(i)
let items = answerNodes.nodes let items = answerNodes.nodes
const generalfeedback = this.getGeneralFeedback(i)
if (generalfeedback) {
return generalfeedback.innerText
}
if (answerNodes.type === 'checkbox') { if (answerNodes.type === 'checkbox') {
return RPM.GetRightAnswerFromResult(i) return RPM.GetRightAnswerFromResultv1(i)
} }
for (let j = 0; j < items.length; j++) { for (let j = 0; j < items.length; j++) {
@ -922,6 +937,9 @@
} }
} catch (e) { } catch (e) {
Log('error at new nodegetting, trying the oldschool way') Log('error at new nodegetting, trying the oldschool way')
if (showErrors) {
console.info(e)
}
} }
} }
} }
@ -1540,12 +1558,8 @@
var question = {} // the current question var question = {} // the current question
// QUESTION -------------------------------------------------------------------------------------------------------------------- // QUESTION --------------------------------------------------------------------------------------------------------------------
question.Q = RPM.GetQuestionFromResult(i) question.Q = RPM.GetQuestionFromResult(i)
// RIGHTANSWER --------------------------------------------------------------------------------------------------------------------- // RIGHTANSWER ---------------------------------------------------------------------------------------------------------------------
question.A = RPM.GetRightAnswerFromResultv2(i)
if (question.A === undefined) {
question.A = RPM.GetRightAnswerFromResult(i) question.A = RPM.GetRightAnswerFromResult(i)
}
// DATA --------------------------------------------------------------------------------------------------------------------- // DATA ---------------------------------------------------------------------------------------------------------------------
question.data = GetDataFormResult(i) question.data = GetDataFormResult(i)
@ -2283,8 +2297,10 @@
try { try {
lastInfo = JSON.parse(getVal('lastInfo')) lastInfo = JSON.parse(getVal('lastInfo'))
} catch (e) { } catch (e) {
if (showErrors) {
console.info(e) console.info(e)
} }
}
if ( if (
lastInfo.result !== 'success' || lastInfo.result !== 'success' ||
now > lastCheck + infoExpireTime * 1000 now > lastCheck + infoExpireTime * 1000