mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Refactored error url generation
This commit is contained in:
parent
e53ca9d87c
commit
ff25bff70e
2 changed files with 29 additions and 35 deletions
13
CHANGELOG
13
CHANGELOG
|
@ -1,13 +0,0 @@
|
|||
1.6.0.0:
|
||||
Added JSON data format
|
||||
Old one should still work
|
||||
1.6.1.0:
|
||||
Changed server domain name
|
||||
Fixed not found data file "brick"
|
||||
1.6.1.5:
|
||||
Question answering/getting/parsing improvements
|
||||
Passive mode
|
||||
1.6.1.6:
|
||||
Fixed question saving match percent
|
||||
1.6.2.0:
|
||||
Document element getting refactoring
|
51
main.js
51
main.js
|
@ -855,24 +855,8 @@ function Main () {
|
|||
ShowMessage({
|
||||
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
||||
isSimple: true
|
||||
}, undefined, function () {
|
||||
let path = 'lred'
|
||||
try {
|
||||
if (e.message || e.stack) {
|
||||
path += '?'
|
||||
}
|
||||
if (e.message) {
|
||||
path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&'
|
||||
}
|
||||
if (e.stack) {
|
||||
path += 'stack:' + SUtils.SimplifyStack(e.stack)
|
||||
}
|
||||
} catch (e) {
|
||||
Exception(e, 'error at setting error stack/msg link')
|
||||
}
|
||||
openInTab(serverAdress + path, {
|
||||
active: true
|
||||
})
|
||||
}, undefined, () => {
|
||||
OpenErrorPage(e)
|
||||
})
|
||||
|
||||
Exception(e, 'script error at main:')
|
||||
|
@ -1228,7 +1212,7 @@ function HandleQuiz () {
|
|||
if (r !== undefined) { answers.push(r) }
|
||||
HighLightAnswer(result, j) // highlights the answer for the current result
|
||||
}
|
||||
ShowAnswers(answers)
|
||||
ShowAnswers(answers, q.q)
|
||||
}
|
||||
|
||||
function PrepareAnswers (result, j) {
|
||||
|
@ -1254,7 +1238,7 @@ function PrepareAnswers (result, j) {
|
|||
}
|
||||
}
|
||||
|
||||
function ShowAnswers (answers) {
|
||||
function ShowAnswers (answers, question) {
|
||||
assert(answers)
|
||||
|
||||
if (answers.length > 0) { // if there are more than 0 answer
|
||||
|
@ -1264,8 +1248,9 @@ function ShowAnswers (answers) {
|
|||
m: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.',
|
||||
isSimple: true
|
||||
}, undefined, function () {
|
||||
openInTab(serverAdress + 'lred', {
|
||||
active: true
|
||||
OpenErrorPage({
|
||||
message: 'No result found',
|
||||
stack: question // TODO: test this
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -2198,6 +2183,28 @@ var assert = (val) => {
|
|||
if (!val) { throw new Error('Assertion failed') }
|
||||
}
|
||||
|
||||
function OpenErrorPage (e) {
|
||||
let path = 'lred'
|
||||
try {
|
||||
if (e.message || e.stack) {
|
||||
path += '?'
|
||||
}
|
||||
if (e.message) {
|
||||
path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&'
|
||||
}
|
||||
if (e.stack) {
|
||||
path += 'stack:' + SUtils.SimplifyStack(e.stack)
|
||||
}
|
||||
path = SUtils.RemoveSpecialChars(path)
|
||||
} catch (e) {
|
||||
Exception(e, 'error at setting error stack/msg link')
|
||||
}
|
||||
path = path.replace(/ /g, '_')
|
||||
openInTab(serverAdress + path, {
|
||||
active: true
|
||||
})
|
||||
}
|
||||
|
||||
// : }}}
|
||||
|
||||
// : Help {{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue