mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Updating stable userscript
This commit is contained in:
parent
68d9673629
commit
304e2d6651
1 changed files with 159 additions and 237 deletions
368
stable.js
368
stable.js
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 1.6.3.3
|
// @version 1.6.4.0
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author MrFry
|
// @author MrFry
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
|
@ -36,7 +36,6 @@
|
||||||
// @license GNU General Public License v3.0 or later
|
// @license GNU General Public License v3.0 or later
|
||||||
// @supportURL qmining.frylabs.net
|
// @supportURL qmining.frylabs.net
|
||||||
// @contributionURL qmining.frylabs.net
|
// @contributionURL qmining.frylabs.net
|
||||||
// @resource data file:///<file path space is %20, and use "/"-s plz not "\" ty (and add .txt)// UTF-8 PLZ>
|
|
||||||
// @namespace https://greasyfork.org/users/153067
|
// @namespace https://greasyfork.org/users/153067
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
@ -47,14 +46,13 @@
|
||||||
function getVal (name) { return GM_getValue(name) }
|
function getVal (name) { return GM_getValue(name) }
|
||||||
function setVal (name, val) { return GM_setValue(name, val) }
|
function setVal (name, val) { return GM_setValue(name, val) }
|
||||||
function openInTab (address, options) { GM_openInTab(address, options) }
|
function openInTab (address, options) { GM_openInTab(address, options) }
|
||||||
function getResourceText (name) { return GM_getResourceText(name) }
|
|
||||||
function xmlhttpRequest (opts) { GM_xmlhttpRequest(opts) }
|
function xmlhttpRequest (opts) { GM_xmlhttpRequest(opts) }
|
||||||
function info () { return GM_info }
|
function info () { return GM_info }
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
var data // all data, which is in the resource txt
|
var data // all data, which is in the resource txt
|
||||||
var addEventListener // add event listener function
|
var addEventListener // add event listener function
|
||||||
const lastChangeLog = 'Félév szerinti csoportosítás menüben'
|
const lastChangeLog = 'Kérdés parsolás bugfixek, old school fálj beolvasás kiszedése, részletesebb hibajelentés és egyéb fixek'
|
||||||
const serverAdress = 'https://qmining.frylabs.net/'
|
const serverAdress = 'https://qmining.frylabs.net/'
|
||||||
|
|
||||||
// forcing pages for testing. unless you test, do not set these to true!
|
// forcing pages for testing. unless you test, do not set these to true!
|
||||||
|
@ -73,9 +71,33 @@
|
||||||
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
|
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
|
||||||
const lengthDiffMultiplier = 10 /* Percent minus for length difference */
|
const lengthDiffMultiplier = 10 /* Percent minus for length difference */
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Other constants
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
const commonUselessAnswerParts = [
|
||||||
|
'A helyes válasz az ',
|
||||||
|
'A helyes válasz a ',
|
||||||
|
'A helyes válaszok: ',
|
||||||
|
'A helyes válaszok:',
|
||||||
|
'A helyes válasz: ',
|
||||||
|
'A helyes válasz:',
|
||||||
|
'The correct answer is:',
|
||||||
|
'\''
|
||||||
|
]
|
||||||
|
const commonUselessStringParts = [',', '\\.', ':', '!']
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
// : Class descriptions {{{
|
// : Class descriptions {{{
|
||||||
|
|
||||||
class StringUtils {
|
class StringUtils {
|
||||||
|
RemoveStuff (value, removableStrings) {
|
||||||
|
removableStrings.forEach((x) => {
|
||||||
|
var regex = new RegExp(x, 'g')
|
||||||
|
value = value.replace(regex, '')
|
||||||
|
})
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
SimplifyQuery (q) {
|
SimplifyQuery (q) {
|
||||||
assert(q)
|
assert(q)
|
||||||
|
|
||||||
|
@ -102,7 +124,7 @@
|
||||||
var toremove = this.NormalizeSpaces(val)
|
var toremove = this.NormalizeSpaces(val)
|
||||||
|
|
||||||
var regex = new RegExp(char, 'g')
|
var regex = new RegExp(char, 'g')
|
||||||
toremove.replace(regex, ' ')
|
toremove = toremove.replace(regex, ' ')
|
||||||
|
|
||||||
return this.RemoveUnnecesarySpaces(toremove)
|
return this.RemoveUnnecesarySpaces(toremove)
|
||||||
}
|
}
|
||||||
|
@ -123,12 +145,13 @@
|
||||||
assert(value)
|
assert(value)
|
||||||
|
|
||||||
value = this.RemoveUnnecesarySpaces(value).toLowerCase()
|
value = this.RemoveUnnecesarySpaces(value).toLowerCase()
|
||||||
var removableChars = [',', '.', ':', '!']
|
return this.RemoveStuff(value, commonUselessStringParts)
|
||||||
for (var i = 0; i < removableChars.length; i++) {
|
|
||||||
var regex = new RegExp(removableChars[i], 'g')
|
|
||||||
value.replace(regex, '')
|
|
||||||
}
|
}
|
||||||
return value
|
|
||||||
|
RemoveSpecialChars (value) {
|
||||||
|
assert(value)
|
||||||
|
|
||||||
|
return this.RemoveStuff(value, ['&'])
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the value is empty, or whitespace
|
// if the value is empty, or whitespace
|
||||||
|
@ -149,6 +172,10 @@
|
||||||
assert(s1)
|
assert(s1)
|
||||||
assert(s2)
|
assert(s2)
|
||||||
|
|
||||||
|
if (s1 === '' || s2 === '') {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
s1 = this.SimplifyStringForComparison(s1).split(' ')
|
s1 = this.SimplifyStringForComparison(s1).split(' ')
|
||||||
s2 = this.SimplifyStringForComparison(s2).split(' ')
|
s2 = this.SimplifyStringForComparison(s2).split(' ')
|
||||||
var match = 0
|
var match = 0
|
||||||
|
@ -161,12 +188,81 @@
|
||||||
if (percent < 0) { percent = 0 }
|
if (percent < 0) { percent = 0 }
|
||||||
return percent
|
return percent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnswerPreProcessor (value) {
|
||||||
|
assert(value)
|
||||||
|
|
||||||
|
return this.RemoveStuff(
|
||||||
|
value, commonUselessAnswerParts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'a. pécsi sör' -> 'pécsi sör'
|
||||||
|
RemoveAnswerLetters (value) {
|
||||||
|
assert(value)
|
||||||
|
|
||||||
|
let s = value.split('. ')
|
||||||
|
if (s[0].length < 2 && s.length > 1) {
|
||||||
|
return s.shift()
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SimplifyQA (value, mods) {
|
||||||
|
if (!value) { return }
|
||||||
|
|
||||||
|
const reducer = (res, fn) => {
|
||||||
|
return fn(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
return mods.reduce(reducer, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
SimplifyAnswer (value) {
|
||||||
|
return this.SimplifyQA(
|
||||||
|
value,
|
||||||
|
[
|
||||||
|
this.RemoveSpecialChars.bind(this),
|
||||||
|
this.RemoveUnnecesarySpaces.bind(this),
|
||||||
|
this.AnswerPreProcessor.bind(this),
|
||||||
|
this.RemoveAnswerLetters.bind(this)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
SimplifyQuestion (value) {
|
||||||
|
return this.SimplifyQA(
|
||||||
|
value,
|
||||||
|
[
|
||||||
|
this.RemoveSpecialChars.bind(this),
|
||||||
|
this.RemoveUnnecesarySpaces.bind(this)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
SimplifyStack (stack) {
|
||||||
|
stack = this.SimplifyQuery(stack)
|
||||||
|
let ns = ''
|
||||||
|
let adding = true
|
||||||
|
stack.split('').forEach((c) => {
|
||||||
|
if (c === '(') {
|
||||||
|
adding = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adding) {
|
||||||
|
ns += c
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === ')') {
|
||||||
|
adding = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return ns
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Question {
|
class Question {
|
||||||
constructor (q, a, i) {
|
constructor (q, a, i) {
|
||||||
this.Q = q
|
this.Q = SUtils.SimplifyQuestion(q)
|
||||||
this.A = a
|
this.A = SUtils.SimplifyAnswer(a)
|
||||||
this.I = i
|
this.I = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,15 +721,6 @@
|
||||||
return this.GetFormCFOfResult(results[i]).getElementsByTagName('img')
|
return this.GetFormCFOfResult(results[i]).getElementsByTagName('img')
|
||||||
}
|
}
|
||||||
|
|
||||||
GetOnlyImageQuestionResult (i) {
|
|
||||||
console.log('############################################################')
|
|
||||||
console.log(i)
|
|
||||||
const results = this.GetFormResult() // getting results element
|
|
||||||
const n = results[i]
|
|
||||||
console.log(n)
|
|
||||||
console.log('############################################################')
|
|
||||||
}
|
|
||||||
|
|
||||||
// gets the question from the result page
|
// gets the question from the result page
|
||||||
// i is the index of the question
|
// i is the index of the question
|
||||||
GetQuestionFromResult (i) {
|
GetQuestionFromResult (i) {
|
||||||
|
@ -682,11 +769,6 @@
|
||||||
if (RPM.GetDropboxes(i).length > 0) { return RPM.GetCurrentAnswer(i) }
|
if (RPM.GetDropboxes(i).length > 0) { return RPM.GetCurrentAnswer(i) }
|
||||||
})
|
})
|
||||||
|
|
||||||
// image and text only question
|
|
||||||
fun.push(function TryGet5 (i) {
|
|
||||||
return RPM.GetOnlyImageQuestionResult(i)
|
|
||||||
})
|
|
||||||
|
|
||||||
// if the correct answers are not shown, and the selected answer
|
// if the correct answers are not shown, and the selected answer
|
||||||
// is correct
|
// is correct
|
||||||
fun.push(function TryGet2 (i) {
|
fun.push(function TryGet2 (i) {
|
||||||
|
@ -810,11 +892,10 @@
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, undefined, function () {
|
}, undefined, () => {
|
||||||
openInTab(serverAdress + 'lred', {
|
OpenErrorPage(e)
|
||||||
active: true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Exception(e, 'script error at main:')
|
Exception(e, 'script error at main:')
|
||||||
}
|
}
|
||||||
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
if (url.includes('eduplayer')) { AddVideoHotkeys(url) } // adding video hotkeys
|
||||||
|
@ -899,13 +980,12 @@
|
||||||
function Version15 () {
|
function Version15 () {
|
||||||
var version15 = getVal('version15') // if the current run is the frst
|
var version15 = getVal('version15') // if the current run is the frst
|
||||||
if (version15 === undefined || version15 === true) {
|
if (version15 === undefined || version15 === true) {
|
||||||
setVal('useNetDB', '1')
|
|
||||||
setVal('version15', false)
|
setVal('version15', false)
|
||||||
document.write(
|
document.write(
|
||||||
'<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észitő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>'
|
'<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észitő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>'
|
||||||
)
|
)
|
||||||
document.close()
|
document.close()
|
||||||
throw 'something, so this stuff stops' // eslint-disable-line
|
throw new Error('something, so this stuff stops')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,31 +1003,7 @@
|
||||||
|
|
||||||
// : }}}
|
// : }}}
|
||||||
|
|
||||||
function GetFileData () {
|
function ReadNetDB (cwith) {
|
||||||
return getResourceText('data')
|
|
||||||
}
|
|
||||||
|
|
||||||
function ReadFile (cwith) {
|
|
||||||
var resource = ''
|
|
||||||
try {
|
|
||||||
resource = GetFileData() // getting data from txt
|
|
||||||
if (resource === undefined) {
|
|
||||||
ShowMessage({
|
|
||||||
m: 'Nem lehetett beolvasni a fájlt :c Ellenőrizd az elérési utat, vagy a fájl jogosultságokat',
|
|
||||||
isSimple: true
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (SUtils.EmptyOrWhiteSpace(resource)) {
|
|
||||||
throw 'data file empty' // eslint-disable-line
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
Exception(e, 'script error at reading file:')
|
|
||||||
}
|
|
||||||
NLoad(resource, cwith)
|
|
||||||
}
|
|
||||||
|
|
||||||
function ReadNetDB (cwith, useNetDB) {
|
|
||||||
function NewXMLHttpRequest () {
|
function NewXMLHttpRequest () {
|
||||||
const url = serverAdress + 'data.json'
|
const url = serverAdress + 'data.json'
|
||||||
xmlhttpRequest({
|
xmlhttpRequest({
|
||||||
|
@ -970,105 +1026,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns a question database from the given data.
|
|
||||||
* Parameter should be raw read file in string with "\n"-s
|
|
||||||
* */
|
|
||||||
function ParseRawData (data) {
|
|
||||||
const d = data.split('\n')
|
|
||||||
const r = new QuestionDB()
|
|
||||||
var logs = []
|
|
||||||
var currSubj = '' // the current subjects name
|
|
||||||
var ExpectedIdentifier = ['+', '?']
|
|
||||||
let currQuestion = new Question()
|
|
||||||
|
|
||||||
var i = -1
|
|
||||||
while (i < d.length) {
|
|
||||||
let currIdentifier
|
|
||||||
let skipped = 0
|
|
||||||
do {
|
|
||||||
if (skipped >= 1) { logs.push(i + ': ' + d[i]) }
|
|
||||||
i++
|
|
||||||
if (i >= d.length) {
|
|
||||||
if (currQuestion.IsComplete()) { r.AddQuestion(currSubj, currQuestion) }
|
|
||||||
return {
|
|
||||||
result: r,
|
|
||||||
logs: logs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currIdentifier = d[i][0]
|
|
||||||
skipped++
|
|
||||||
} while (!ExpectedIdentifier.includes(currIdentifier) && i < d.length)
|
|
||||||
|
|
||||||
let currData = d[i].substring(1).trim()
|
|
||||||
|
|
||||||
if (currIdentifier === '+') {
|
|
||||||
if (currQuestion.IsComplete()) { r.AddQuestion(currSubj, currQuestion) }
|
|
||||||
currQuestion = new Question()
|
|
||||||
currSubj = currData
|
|
||||||
ExpectedIdentifier = ['?']
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currIdentifier === '?') {
|
|
||||||
if (currQuestion.IsComplete()) {
|
|
||||||
r.AddQuestion(currSubj, currQuestion)
|
|
||||||
currQuestion = new Question()
|
|
||||||
}
|
|
||||||
// overwriting is allowed here, bcus:
|
|
||||||
// ?????!>
|
|
||||||
currQuestion.Q = currData
|
|
||||||
ExpectedIdentifier = ['!', '?']
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currIdentifier === '!') {
|
|
||||||
// if dont have question continue
|
|
||||||
if (!currQuestion.HasQuestion()) {
|
|
||||||
throw 'No question! (A)' // eslint-disable-line
|
|
||||||
}
|
|
||||||
// dont allow overwriting
|
|
||||||
// ?!!!!
|
|
||||||
if (!currQuestion.HasAnswer()) {
|
|
||||||
currData = currData.replace('A helyes válaszok: ', '')
|
|
||||||
currData = currData.replace('A helyes válasz: ', '')
|
|
||||||
|
|
||||||
currQuestion.A = currData
|
|
||||||
}
|
|
||||||
ExpectedIdentifier = ['?', '>', '+']
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currIdentifier === '>') {
|
|
||||||
// if dont have question or answer continue
|
|
||||||
if (!currQuestion.HasQuestion()) {
|
|
||||||
throw 'No question! (I)' // eslint-disable-line
|
|
||||||
}
|
|
||||||
if (!currQuestion.HasAnswer()) {
|
|
||||||
throw 'No asnwer! (I)' // eslint-disable-line
|
|
||||||
}
|
|
||||||
// dont allow overwriting
|
|
||||||
// ?!>>>
|
|
||||||
if (!currQuestion.HasImage()) {
|
|
||||||
try {
|
|
||||||
currQuestion.I = JSON.parse(currData)
|
|
||||||
} catch (e) {
|
|
||||||
currQuestion.I = currData.split(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExpectedIdentifier = ['?', '+']
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
result: r,
|
|
||||||
logs: logs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Load (cwith) {
|
function Load (cwith) {
|
||||||
var useNetDB = getVal('useNetDB')
|
|
||||||
let skipLoad = getVal('skipLoad')
|
let skipLoad = getVal('skipLoad')
|
||||||
|
|
||||||
if (skipLoad) {
|
if (skipLoad) {
|
||||||
|
@ -1076,7 +1034,7 @@
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useNetDB !== undefined && useNetDB === 1) { return ReadNetDB(cwith, useNetDB) } else { return ReadFile(cwith) }
|
ReadNetDB(cwith)
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadMOTD (resource) {
|
function LoadMOTD (resource) {
|
||||||
|
@ -1109,16 +1067,12 @@
|
||||||
d = JSON.parse(resource)
|
d = JSON.parse(resource)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log('Old data, trying with old methods....')
|
Log('Old data, trying with old methods....')
|
||||||
try {
|
|
||||||
d = ParseRawData(resource).result
|
|
||||||
} catch (e2) {
|
|
||||||
Log('Couldt parse data!')
|
Log('Couldt parse data!')
|
||||||
|
Log(e)
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: 'Nem sikerült betölteni az adatokat! Ellenőriz a megadott fájlt, vagy az internetelérésed!',
|
m: 'Nem sikerült betölteni az adatokat! Kattints a manualért',
|
||||||
isSimple: true
|
isSimple: true
|
||||||
})
|
}, undefined, ShowHelp)
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var r = new QuestionDB()
|
var r = new QuestionDB()
|
||||||
var rt = []
|
var rt = []
|
||||||
|
@ -1268,7 +1222,7 @@
|
||||||
if (r !== undefined) { answers.push(r) }
|
if (r !== undefined) { answers.push(r) }
|
||||||
HighLightAnswer(result, j) // highlights the answer for the current result
|
HighLightAnswer(result, j) // highlights the answer for the current result
|
||||||
}
|
}
|
||||||
ShowAnswers(answers)
|
ShowAnswers(answers, q.q)
|
||||||
}
|
}
|
||||||
|
|
||||||
function PrepareAnswers (result, j) {
|
function PrepareAnswers (result, j) {
|
||||||
|
@ -1294,7 +1248,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowAnswers (answers) {
|
function ShowAnswers (answers, question) {
|
||||||
assert(answers)
|
assert(answers)
|
||||||
|
|
||||||
if (answers.length > 0) { // if there are more than 0 answer
|
if (answers.length > 0) { // if there are more than 0 answer
|
||||||
|
@ -1304,8 +1258,9 @@
|
||||||
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.',
|
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
|
isSimple: true
|
||||||
}, undefined, function () {
|
}, undefined, function () {
|
||||||
openInTab(serverAdress + 'lred', {
|
OpenErrorPage({
|
||||||
active: true
|
message: 'No result found',
|
||||||
|
stack: JSON.stringify(question)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1326,10 +1281,7 @@
|
||||||
if (addedQ > 0) {
|
if (addedQ > 0) {
|
||||||
msg = 'Klikk ide a nyers adatokhoz. ' + addedQ + ' új kérdés!'
|
msg = 'Klikk ide a nyers adatokhoz. ' + addedQ + ' új kérdés!'
|
||||||
|
|
||||||
var useNetDB = getVal('useNetDB')
|
|
||||||
if (useNetDB !== undefined && useNetDB === 1) {
|
|
||||||
if (!sendSuccess) { msg += ' Nem sikerült kérdéseket elküldeni szervernek. Ha gondolod utánanézhetsz.' } else { msg += 'Az új kérdések elküldve.' }
|
if (!sendSuccess) { msg += ' Nem sikerült kérdéseket elküldeni szervernek. Ha gondolod utánanézhetsz.' } else { msg += 'Az új kérdések elküldve.' }
|
||||||
} else { msg += 'Ne felejtsd el bemásolni a fő txt-be!' }
|
|
||||||
} else {
|
} else {
|
||||||
msg = 'A kérdőívben nincsen új kérdés. Ha mégis le akarod menteni klikk ide.'
|
msg = 'A kérdőívben nincsen új kérdés. Ha mégis le akarod menteni klikk ide.'
|
||||||
if (!data) { msg += ' Lehet azért, mert nincs kérdés betöltve.' }
|
if (!data) { msg += ' Lehet azért, mert nincs kérdés betöltve.' }
|
||||||
|
@ -1342,14 +1294,11 @@
|
||||||
var towrite = '<h3>' + sentData.subj + '<br>TXT-ben nem szereplő kérdések: ' + addedQ + '/' + allQ + '</h3><br>' + output.replace(/\n/g, '<br>') + '<br><h3>Összes kérdés/válasz:</h3>' + allOutput.replace(
|
var towrite = '<h3>' + sentData.subj + '<br>TXT-ben nem szereplő kérdések: ' + addedQ + '/' + allQ + '</h3><br>' + output.replace(/\n/g, '<br>') + '<br><h3>Összes kérdés/válasz:</h3>' + allOutput.replace(
|
||||||
/\n/g, '<br>')
|
/\n/g, '<br>')
|
||||||
|
|
||||||
var useNetDB = getVal('useNetDB')
|
|
||||||
if (useNetDB !== undefined && useNetDB === 1) {
|
|
||||||
try {
|
try {
|
||||||
towrite += '</p>Elküldött adatok:</p> ' + JSON.stringify(sentData)
|
towrite += '</p>Elküldött adatok:</p> ' + JSON.stringify(sentData)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
towrite += '</p>Elküldött adatok:</p> ' + sentData
|
towrite += '</p>Elküldött adatok:</p> ' + sentData
|
||||||
}
|
}
|
||||||
}
|
|
||||||
document.write(towrite)
|
document.write(towrite)
|
||||||
document.close()
|
document.close()
|
||||||
})
|
})
|
||||||
|
@ -1393,10 +1342,7 @@
|
||||||
function SaveQuiz (quiz, questionData) {
|
function SaveQuiz (quiz, questionData) {
|
||||||
try {
|
try {
|
||||||
if (quiz.length === 0) {
|
if (quiz.length === 0) {
|
||||||
throw { // eslint-disable-line
|
throw new Error('quiz length is zero!')
|
||||||
message: 'quiz length is zero!',
|
|
||||||
stack: 'no stack.'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var output = '' // thefinal output
|
var output = '' // thefinal output
|
||||||
var allOutput = '' // thefinal output with all questions
|
var allOutput = '' // thefinal output with all questions
|
||||||
|
@ -1428,14 +1374,11 @@
|
||||||
sentData.subj = 'NOSUBJ'
|
sentData.subj = 'NOSUBJ'
|
||||||
Log('unable to get subject name :c')
|
Log('unable to get subject name :c')
|
||||||
}
|
}
|
||||||
var useNetDB = getVal('useNetDB')
|
|
||||||
if (useNetDB !== undefined && useNetDB === 1) {
|
|
||||||
sentData.allData = quiz
|
sentData.allData = quiz
|
||||||
sentData.data = newQuestions
|
sentData.data = newQuestions
|
||||||
sentData.version = info().script.version
|
sentData.version = info().script.version
|
||||||
SendXHRMessage('datatoadd=' + JSON.stringify(sentData))
|
SendXHRMessage('datatoadd=' + JSON.stringify(sentData))
|
||||||
sendSuccess = true
|
sendSuccess = true
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Exception(e, 'error at sending data to server.')
|
Exception(e, 'error at sending data to server.')
|
||||||
}
|
}
|
||||||
|
@ -1471,9 +1414,6 @@
|
||||||
var img = GetImageFormResult(i)
|
var img = GetImageFormResult(i)
|
||||||
question.i = img
|
question.i = img
|
||||||
|
|
||||||
if (q !== undefined) { q = SUtils.ReplaceCharsWithSpace(q, '\n') }
|
|
||||||
if (a !== undefined) { a = SUtils.ReplaceCharsWithSpace(a, '\n') }
|
|
||||||
|
|
||||||
if (question.a !== undefined) {
|
if (question.a !== undefined) {
|
||||||
quiz.push(new Question(question.q, question.a, question.i)) // adding current question to quiz
|
quiz.push(new Question(question.q, question.a, question.i)) // adding current question to quiz
|
||||||
} else {
|
} else {
|
||||||
|
@ -2107,46 +2047,6 @@
|
||||||
|
|
||||||
CreateNodeWithText(questionTickboxCell, 'Kérdések mutatása válaszhoz', 'span')
|
CreateNodeWithText(questionTickboxCell, 'Kérdések mutatása válaszhoz', 'span')
|
||||||
|
|
||||||
// database mode listbox -----------------------------------------------------------------------------------------------------------------------------
|
|
||||||
var databasemodeListboxRow = tbl.insertRow()
|
|
||||||
var databasemodeListboxCell = databasemodeListboxRow.insertCell()
|
|
||||||
|
|
||||||
var databasemodeListbox = document.createElement('select')
|
|
||||||
databasemodeListbox.type = 'checkbox'
|
|
||||||
// databasemodeListbox.checked = getVal("showSplash") || false;
|
|
||||||
databasemodeListbox.style.position = ''
|
|
||||||
// databasemodeListbox.style.background = "white";
|
|
||||||
databasemodeListbox.style.left = 10 + 'px'
|
|
||||||
databasemodeListbox.style.margin = '5px 5px 5px 5px' // fancy margin
|
|
||||||
databasemodeListbox.style.top = menuDiv.offsetHeight + 'px'
|
|
||||||
|
|
||||||
var databasemodeListboxText = CreateNodeWithText(questionTickboxCell,
|
|
||||||
'Kérdések beszerzése:', 'span')
|
|
||||||
databasemodeListboxCell.appendChild(databasemodeListboxText)
|
|
||||||
|
|
||||||
databasemodeListboxCell.appendChild(databasemodeListbox) // adding to main div
|
|
||||||
|
|
||||||
databasemodeListbox.addEventListener('change', function (e) {
|
|
||||||
// sorry for using selectedindex :c
|
|
||||||
setVal('useNetDB', databasemodeListbox.selectedIndex)
|
|
||||||
})
|
|
||||||
|
|
||||||
var uselocal = document.createElement('option')
|
|
||||||
uselocal.text = 'Helyi fájlból (old school)'
|
|
||||||
uselocal.value = 2
|
|
||||||
databasemodeListbox.add(uselocal, 0)
|
|
||||||
|
|
||||||
var usenetsafe = document.createElement('option')
|
|
||||||
usenetsafe.text = 'Netről'
|
|
||||||
usenetsafe.value = 0
|
|
||||||
databasemodeListbox.add(usenetsafe, 1)
|
|
||||||
|
|
||||||
var selected = getVal('useNetDB')
|
|
||||||
if (selected !== undefined) { databasemodeListbox.selectedIndex = selected }
|
|
||||||
|
|
||||||
var databasemodeListboxElement = document.createElement('span') // new paragraph
|
|
||||||
databasemodeListboxCell.appendChild(databasemodeListboxElement)
|
|
||||||
|
|
||||||
// setting up buttons
|
// setting up buttons
|
||||||
var buttonRow = tbl.insertRow()
|
var buttonRow = tbl.insertRow()
|
||||||
var buttonCell = buttonRow.insertCell()
|
var buttonCell = buttonRow.insertCell()
|
||||||
|
@ -2241,6 +2141,28 @@
|
||||||
if (!val) { throw new Error('Assertion failed') }
|
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 {{{
|
// : Help {{{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue