html in messages, active subject array fixes

This commit is contained in:
MrFry 2020-01-14 13:13:33 +01:00
parent 546e38ccb0
commit 7ba254ef88

View file

@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 1.6.4.9
// @version 1.7.0.0
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@ -58,7 +58,7 @@
var data // all data, which is in the resource txt
var addEventListener // add event listener function
const lastChangeLog = '' // TODO
const lastChangeLog = '- "Húzza a megfelelő helyre ..." kérdés lekezelése\n- Kód refactor\n- Ha valami elszállt: <a href="qmining.frylabs.net">feedback</a> pls'
const serverAdress = 'https://qmining.frylabs.net/'
// const serverAdress = 'http://localhost:8080/'
@ -567,7 +567,6 @@
if (SUtils.EmptyOrWhiteSpace(ddq)) {
var questionData = ''
for (var j = 0; j < allQuestions.length; j++) {
// TODO: test dis
let subAllQuestions = allQuestions[j].childNodes
for (let i = 0; i < subAllQuestions.length; i++) {
if (subAllQuestions[i].data !== undefined && !SUtils.EmptyOrWhiteSpace(subAllQuestions[i].data)) {
@ -1021,8 +1020,6 @@
// throw "asd";
FreshStart()
Version15()
}
// : Version action functions {{{
@ -1037,6 +1034,7 @@
}
delVal('Is' + i + 'Active')
}
delVal('Is-1Active')
setVal('actives', JSON.stringify(res))
}
}
@ -1046,14 +1044,7 @@
if (firstRun === undefined || firstRun === true) {
setVal('firstRun', false)
ShowHelp() // showing help
return true
}
}
function Version15 () {
var version15 = getVal('version15') // if the current run is the frst
if (version15 === undefined || version15 === true) {
setVal('version15', false)
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>'
)
@ -1135,7 +1126,7 @@
isSimple: true
}, undefined, ShowHelp)
}
var r = new QuestionDB(getVal, setVal, delVal)
data = new QuestionDB(getVal, setVal, delVal)
var rt = []
var allCount = -1
LoadMOTD(d)
@ -1171,10 +1162,9 @@
allCount += j
subjCount++
}
r.AddSubject(s)
data.AddSubject(s)
}
data = r
count = allCount + 1 // couse starting with -1 to show errors
} catch (e) {
Exception(e, 'script error at loading:')
@ -1628,7 +1618,7 @@
}
}
if (results[0].match === 100) { // if the result is 100% correct
if (type !== 'radio' || toColor.length === 1) { // TODO why not radio
if (type !== 'radio' || toColor.length === 1) { // FIXME why not radio
for (let i = 0; i < toColor.length; i++) { // going through "toColor"
answers[toColor[i]].style.backgroundColor = '#8cff66'
}
@ -1712,11 +1702,12 @@
if (isSimpleMessage) {
var simpleMessageParagrapg = document.createElement('p') // new paragraph
simpleMessageParagrapg.style.margin = defMargin // fancy margin
var splitText = simpleMessageText.split('\n')
for (var i = 0; i < splitText.length; i++) {
var mesageNode = CreateNodeWithText(simpleMessageParagrapg, splitText[i])
mesageNode.style.margin = defMargin // fancy margin
}
var mesageNode = document.createElement('p') // new paragraph
mesageNode.innerHTML = simpleMessageText.replace(/\n/g, '</br>')
simpleMessageParagrapg.appendChild(mesageNode)
mesageNode.style.margin = defMargin // fancy margin
mainDiv.appendChild(simpleMessageParagrapg) // adding text box to main div
} else { // if its a fucking complicated message
// TABLE SETUP ------------------------------------------------------------------------------------------------------------
@ -2001,8 +1992,7 @@
others: []
})
const ordered = {} // FIXME: this shouldt be ordered here.
// subjects should be sorted in 'data', but the active indexes would be incorrect then
const ordered = {}
Object.keys(grouped).sort().forEach((key) => {
ordered[key] = grouped[key]
})