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