mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Opening error page now passes question as query, and autofills question search field on site
This commit is contained in:
parent
146e352411
commit
37b7d43115
1 changed files with 36 additions and 21 deletions
|
@ -84,6 +84,7 @@
|
|||
|
||||
// forcing pages for testing. unless you test, do not set these to true!
|
||||
// only one of these should be true for testing
|
||||
setVal('ISDEVEL', false)
|
||||
const forceTestPage = false
|
||||
const forceResultPage = false
|
||||
const forceDefaultPage = false
|
||||
|
@ -92,13 +93,13 @@
|
|||
|
||||
const motdShowCount = 3 /* Ammount of times to show motd */
|
||||
let infoExpireTime = 60 // Every n seconds basic info should be loaded from server
|
||||
var uid = 0
|
||||
var cid = 0
|
||||
var motd = ''
|
||||
var userSpecificMotd = ''
|
||||
var lastestVersion = ''
|
||||
var subjInfo
|
||||
|
||||
setVal('ISDEVEL', false)
|
||||
|
||||
if (getVal('ISDEVEL')) {
|
||||
console.log('Moodle script running in developement mode!')
|
||||
infoExpireTime = 1
|
||||
|
@ -111,7 +112,7 @@
|
|||
fatalError:
|
||||
'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
||||
consoleErrorInfo:
|
||||
'Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót!',
|
||||
'Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót! https://qmining.frylabs.net/manual?scriptcmd',
|
||||
freshStartWarning:
|
||||
'<h1>Moodle teszt userscript:<h1><h3>1.5.0 verzió: a script mostantól XMLHTTP kéréseket küld szerver fele! Erre a userscript futtató kiegészítőd is figyelmeztetni fog! Ha ez történik, a script rendes működése érdekében engedélyezd (Always allow domain)! Ha nem akarod, hogy ez történjen, akkor ne engedélyezd, vagy a menüben válaszd ki a "helyi fájl használata" opciót!</h3> <h3>Elküldött adatok: minden teszt után a kérdés-válasz páros. Fogadott adatok: Az összes eddig ismert kérdés. Érdemes help-et elolvasni!!!</h3><h5>Ez az ablak frissités után eltűnik. Ha nem, akkor a visza gombbal próbálkozz.</h5>',
|
||||
noResult:
|
||||
|
@ -574,6 +575,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
getAsd() {
|
||||
const a = document.getElementsByClassName('generalfeedback')
|
||||
if (a.length > 0) {
|
||||
return a[0].innerText
|
||||
}
|
||||
}
|
||||
|
||||
GetCurrentAnswer(i) {
|
||||
if (logElementGetting) {
|
||||
Log('getting curr answer by index: ' + i)
|
||||
|
@ -757,6 +765,14 @@
|
|||
GetRightAnswerFromResult(i) {
|
||||
var fun = []
|
||||
|
||||
// Ugrás... fix: textarea-ban kell válaszolni
|
||||
// TODO
|
||||
// fun.push(i => {
|
||||
// const a = RPM.getAsd()
|
||||
// console.log(a)
|
||||
// return a
|
||||
// })
|
||||
|
||||
// "húzza oda ..." skip
|
||||
fun.push(i => {
|
||||
let temp = RPM.GetAnswersFromGrabBox(i)
|
||||
|
@ -1162,9 +1178,11 @@
|
|||
motd = inf.motd
|
||||
userSpecificMotd = inf.userSpecificMotd
|
||||
subjInfo = inf.subjinfo
|
||||
uid = inf.uid
|
||||
cid = getVal('clientId')
|
||||
overlay.querySelector(
|
||||
'#infoMainDiv'
|
||||
).innerText = `${subjInfo.subjects} tárgy, ${subjInfo.questions} kérdés. Felh #${inf.uid}`
|
||||
).innerText = `${subjInfo.subjects} tárgy, ${subjInfo.questions} kérdés. Felh #${uid}`
|
||||
// FIXME: if cwith() throws an unhandled error it sais server is not avaible
|
||||
cwith()
|
||||
})
|
||||
|
@ -1328,7 +1346,6 @@
|
|||
)
|
||||
})
|
||||
|
||||
// FIXME: promise.all promise resolve order same as original?
|
||||
Promise.all(promises).then(res => {
|
||||
let answers = []
|
||||
|
||||
|
@ -1391,7 +1408,9 @@
|
|||
function() {
|
||||
OpenErrorPage({
|
||||
message: 'No result found',
|
||||
stack: JSON.stringify(question),
|
||||
question: Array.isArray(question)
|
||||
? question[0].replace(/"/g, '').replace(/:/g, '')
|
||||
: question,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
@ -2367,24 +2386,20 @@
|
|||
}
|
||||
|
||||
function OpenErrorPage(e) {
|
||||
let path = 'lred'
|
||||
const queries = []
|
||||
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 += '___version:' + info().script.version
|
||||
path = SUtils.RemoveSpecialChars(path)
|
||||
Object.keys(e).forEach(key => {
|
||||
if (e[key]) {
|
||||
queries.push(`${key}=${encodeURIComponent(e[key])}`)
|
||||
}
|
||||
})
|
||||
queries.push('version=' + encodeURIComponent(info().script.version))
|
||||
queries.push('uid=' + encodeURIComponent(uid))
|
||||
queries.push('cid=' + encodeURIComponent(cid))
|
||||
} catch (e) {
|
||||
Exception(e, 'error at setting error stack/msg link')
|
||||
}
|
||||
path = path.replace(/ /g, '_')
|
||||
openInTab(serverAdress + path, {
|
||||
openInTab(serverAdress + 'lred?' + queries.join('&'), {
|
||||
active: true,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue