Possible answers fixes

This commit is contained in:
mrfry 2022-03-23 16:09:15 +01:00
parent 50cb6d3237
commit 2f4786987d

View file

@ -46,7 +46,7 @@
// : Script header {{{
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 2.1.3.5
// @version 2.1.3.6
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/*
@ -87,7 +87,6 @@
// eslint-disable-line
// GM functions, only to disable ESLINT errors
/* eslint-disable */
const a = Main
const usf = unsafeWindow
function getVal(name) {
return GM_getValue(name)
@ -118,7 +117,7 @@
// ------------------------------------------------------------------------------
// forcing pages for testing. unless you test, do not set these to true!
const isDevel = false
const forcedMatchString = isDevel ? '' : null
const forcedMatchString = isDevel ? 'default' : null
// only one of these should be true for testing
const forceTestPage = isDevel && false
const forceResultPage = isDevel && false
@ -353,8 +352,13 @@
const questions = readQuestions.map((question) => {
return {
Q: question.question,
data: Object.assign(
{},
{
possibleAnswers: question.possibleAnswers,
data: question.data,
},
question.data
),
}
})
@ -367,8 +371,6 @@
uid: getUid(),
}
log(sentData)
log('Sent data', sentData)
post('ask', sentData).then((results) => {
removeLoadingMessage()
@ -641,9 +643,12 @@
question.reduce(makeTextFromElements, []).join(' ')
)
const possibleAnswers = possibleAnswerArray.map((x) => {
return removeUnnecesarySpaces(
return {
type: 'txt',
val: removeUnnecesarySpaces(
x.reduce(makeTextFromElements, []).join(' ')
)
),
}
})
const images = getImagesFromElements([
...question,
@ -682,7 +687,7 @@
})
}
function getDataFromTest(node, hashedImages, legacyImages) {
function getDataFromTest(_node, hashedImages, legacyImages) {
if (hashedImages.length > 0) {
return {
type: 'image',
@ -1038,9 +1043,9 @@
if (currElem) {
const img = currElem.getElementsByTagName('img')[0]
if (img) {
elems.push(getAVRTextFromImg(img))
elems.push({ type: 'txt', val: getAVRTextFromImg(img) })
} else {
elems.push(currElem.innerText)
elems.push({ type: 'txt', val: currElem.innerText })
}
}
i++
@ -1163,8 +1168,7 @@
{
Q: question,
subj: 'AVR',
data: { type: 'simple' },
possibleAnswers: possibleAnswers,
data: { type: 'simple', possibleAnswers: possibleAnswers },
},
],
testUrl: url,