mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Result question getter criteria error handling
This commit is contained in:
parent
1e0d3fe296
commit
a19fe1236c
1 changed files with 8 additions and 2 deletions
|
@ -418,7 +418,7 @@
|
|||
criteria: () => {
|
||||
const firstChild =
|
||||
document.getElementsByTagName('form')[1].childNodes[0].childNodes[0]
|
||||
if (!firstChild || !firstChild.className.includes('informationitem')) {
|
||||
if (!firstChild.className.includes('informationitem')) {
|
||||
return false
|
||||
}
|
||||
const questionNodes = Array.from(
|
||||
|
@ -758,7 +758,13 @@
|
|||
let resultNodes
|
||||
Object.keys(resultNodeVariants).some((key) => {
|
||||
const variant = resultNodeVariants[key]
|
||||
if (variant.criteria()) {
|
||||
let criteriaPassed = false
|
||||
try {
|
||||
criteriaPassed = variant.criteria()
|
||||
} catch (e) {
|
||||
debugLog('Criteria check failed with error', e)
|
||||
}
|
||||
if (criteriaPassed) {
|
||||
resultNodes = variant.getter()
|
||||
if (resultNodes.length === 0) {
|
||||
warn(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue