mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
criteria check error handling in question nodes
This commit is contained in:
parent
a19fe1236c
commit
bb241a9041
1 changed files with 27 additions and 20 deletions
|
@ -46,7 +46,7 @@
|
||||||
// : Script header {{{
|
// : Script header {{{
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 2.1.3.9
|
// @version 2.1.3.10
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author MrFry
|
// @author MrFry
|
||||||
// @match https://elearning.uni-obuda.hu/*
|
// @match https://elearning.uni-obuda.hu/*
|
||||||
|
@ -335,7 +335,8 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugLog("Couldn't get images from result (old)")
|
warn(e)
|
||||||
|
warn("Couldn't get images from result (old)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +395,7 @@
|
||||||
uid: getUid(),
|
uid: getUid(),
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog('Sent data', sentData)
|
log('Sent data', sentData)
|
||||||
post('ask', sentData).then((results) => {
|
post('ask', sentData).then((results) => {
|
||||||
removeLoadingMessage()
|
removeLoadingMessage()
|
||||||
ShowAnswers(
|
ShowAnswers(
|
||||||
|
@ -471,7 +472,13 @@
|
||||||
let questionNodes
|
let questionNodes
|
||||||
Object.keys(questionNodeVariants).some((key) => {
|
Object.keys(questionNodeVariants).some((key) => {
|
||||||
const variant = questionNodeVariants[key]
|
const variant = questionNodeVariants[key]
|
||||||
if (variant.criteria()) {
|
let criteriaPassed = false
|
||||||
|
try {
|
||||||
|
criteriaPassed = variant.criteria()
|
||||||
|
} catch (e) {
|
||||||
|
debugLog('Criteria check failed with error (question nodes)', e)
|
||||||
|
}
|
||||||
|
if (criteriaPassed) {
|
||||||
questionNodes = variant.getter()
|
questionNodes = variant.getter()
|
||||||
if (questionNodes.length === 0) {
|
if (questionNodes.length === 0) {
|
||||||
warn(
|
warn(
|
||||||
|
@ -762,7 +769,7 @@
|
||||||
try {
|
try {
|
||||||
criteriaPassed = variant.criteria()
|
criteriaPassed = variant.criteria()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugLog('Criteria check failed with error', e)
|
debugLog('Criteria check failed with error (result nodes)', e)
|
||||||
}
|
}
|
||||||
if (criteriaPassed) {
|
if (criteriaPassed) {
|
||||||
resultNodes = variant.getter()
|
resultNodes = variant.getter()
|
||||||
|
@ -1152,7 +1159,7 @@
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog(sentData)
|
log(sentData)
|
||||||
post('isAdding', sentData).then((res) => {
|
post('isAdding', sentData).then((res) => {
|
||||||
ShowSaveQuizDialog(res.success, sentData, res.totalNewQuestions)
|
ShowSaveQuizDialog(res.success, sentData, res.totalNewQuestions)
|
||||||
})
|
})
|
||||||
|
@ -1226,7 +1233,7 @@
|
||||||
testUrl: url,
|
testUrl: url,
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog('Sent data', sentData)
|
log('Sent data', sentData)
|
||||||
post('ask', sentData).then((results) => {
|
post('ask', sentData).then((results) => {
|
||||||
removeLoadingMessage()
|
removeLoadingMessage()
|
||||||
ShowAnswers(
|
ShowAnswers(
|
||||||
|
@ -1239,8 +1246,8 @@
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugLog('Error in handleAVRQuiz')
|
warn('Error in handleAVRQuiz')
|
||||||
debugLog(e)
|
warn(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1919,7 +1926,7 @@
|
||||||
// }
|
// }
|
||||||
// }>
|
// }>
|
||||||
function ShowAnswers(results) {
|
function ShowAnswers(results) {
|
||||||
debugLog(results)
|
log(results)
|
||||||
try {
|
try {
|
||||||
const answers = results.reduce((acc, res) => {
|
const answers = results.reduce((acc, res) => {
|
||||||
const prepared = PrepareAnswers(res)
|
const prepared = PrepareAnswers(res)
|
||||||
|
@ -1948,8 +1955,8 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugLog('Error showing answers')
|
warn('Error showing answers')
|
||||||
debugLog(e)
|
warn(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2013,9 +2020,9 @@
|
||||||
sentData.subj = getCurrentSubjectName()
|
sentData.subj = getCurrentSubjectName()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sentData.subj = 'NOSUBJ'
|
sentData.subj = 'NOSUBJ'
|
||||||
debugLog('unable to get subject name :c')
|
warn('unable to get subject name :c')
|
||||||
}
|
}
|
||||||
debugLog('SENT DATA', sentData)
|
log('SENT DATA', sentData)
|
||||||
post('isAdding', sentData).then((res) => {
|
post('isAdding', sentData).then((res) => {
|
||||||
ShowSaveQuizDialog(res.success, sentData, res.totalNewQuestions)
|
ShowSaveQuizDialog(res.success, sentData, res.totalNewQuestions)
|
||||||
})
|
})
|
||||||
|
@ -2073,8 +2080,8 @@
|
||||||
installSource: info().script.updateURL,
|
installSource: info().script.updateURL,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugLog('Unexpected error while registering script')
|
warn('Unexpected error while registering script')
|
||||||
debugLog(err)
|
warn(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2107,8 +2114,8 @@
|
||||||
video.currentTime -= seekTime
|
video.currentTime -= seekTime
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugLog('Hotkey error.')
|
warn('Hotkey error.')
|
||||||
debugLog(err.message)
|
warn(err.message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
var toadd = getVideoElement()
|
var toadd = getVideoElement()
|
||||||
|
@ -2453,8 +2460,8 @@
|
||||||
|
|
||||||
result.msgContainer.child.msgDiv.elem.innerText = getCurrMsg().m
|
result.msgContainer.child.msgDiv.elem.innerText = getCurrMsg().m
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugLog('Error in message updating')
|
warn('Error in message updating')
|
||||||
debugLog(e)
|
warn(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateMessageText()
|
updateMessageText()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue