mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Fixed question results, where there are 2 questions, and none of them are marked incorrect
This commit is contained in:
parent
cc8de2e15f
commit
aec830c265
1 changed files with 67 additions and 7 deletions
|
@ -21,13 +21,14 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 2.0.0.6
|
// @version 2.0.0.10
|
||||||
// @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/*
|
||||||
// @match https://elearning.uni-obuda.hu/kmooc/*
|
// @match https://elearning.uni-obuda.hu/kmooc/*
|
||||||
// @match https://mooc.unideb.hu/*
|
// @match https://mooc.unideb.hu/*
|
||||||
// @match https://qmining.frylabs.net/*
|
// @match https://qmining.frylabs.net/*
|
||||||
|
// @noframes
|
||||||
// @match http://qmining.frylabs.net/*
|
// @match http://qmining.frylabs.net/*
|
||||||
// @grant GM_getResourceText
|
// @grant GM_getResourceText
|
||||||
// @grant GM_info
|
// @grant GM_info
|
||||||
|
@ -61,14 +62,14 @@
|
||||||
var addEventListener // add event listener function
|
var addEventListener // add event listener function
|
||||||
const serverAdress = 'https://qmining.frylabs.net/'
|
const serverAdress = 'https://qmining.frylabs.net/'
|
||||||
// const serverAdress = 'http://localhost:8080/'
|
// const serverAdress = 'http://localhost:8080/'
|
||||||
const apiAdress = 'https://api.frylabs.net/'
|
// const apiAdress = 'https://api.frylabs.net/'
|
||||||
// const apiAdress = 'http://localhost:8080/'
|
const apiAdress = 'http://localhost:8080/'
|
||||||
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
||||||
|
|
||||||
// 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!
|
||||||
// only one of these should be true for testing
|
// only one of these should be true for testing
|
||||||
const forceTestPage = false
|
const forceTestPage = false
|
||||||
const forceResultPage = false
|
const forceResultPage = true
|
||||||
const forceDefaultPage = false
|
const forceDefaultPage = false
|
||||||
const logElementGetting = false
|
const logElementGetting = false
|
||||||
const log = true
|
const log = true
|
||||||
|
@ -288,6 +289,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResultsPageModell {
|
class ResultsPageModell {
|
||||||
|
GetFormulationClearfix () {
|
||||||
|
if (logElementGetting) { Log('getting formulation clearfix lol') }
|
||||||
|
return document.getElementsByClassName('formulation clearfix')
|
||||||
|
}
|
||||||
|
|
||||||
|
GetGrade (i) {
|
||||||
|
if (logElementGetting) { Log('getting grade') }
|
||||||
|
const fcf = QPM.GetFormulationClearfix()[i]
|
||||||
|
return fcf.parentNode.parentNode.childNodes[0].childNodes[2].innerText
|
||||||
|
}
|
||||||
|
|
||||||
DetermineQuestionType (nodes) {
|
DetermineQuestionType (nodes) {
|
||||||
let qtype = ''
|
let qtype = ''
|
||||||
let i = 0
|
let i = 0
|
||||||
|
@ -546,6 +558,52 @@
|
||||||
return currAnswer
|
return currAnswer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuessCorrectIn2LengthAnswersByIncorrect (items) {
|
||||||
|
const first = items[0]
|
||||||
|
const second = items[1]
|
||||||
|
if (first.className.includes('incorrect')) {
|
||||||
|
return second.innerText
|
||||||
|
}
|
||||||
|
if (second.className.includes('incorrect')) {
|
||||||
|
return first.innerText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuessCorrectIn2LengthAnswersByPoints (i, items) {
|
||||||
|
const first = {
|
||||||
|
elem: items[0],
|
||||||
|
val: parseInt(items[0].childNodes[0].value),
|
||||||
|
text: items[0].innerText
|
||||||
|
}
|
||||||
|
const second = {
|
||||||
|
elem: items[1],
|
||||||
|
val: parseInt(items[1].childNodes[0].value),
|
||||||
|
text: items[1].innerText
|
||||||
|
}
|
||||||
|
|
||||||
|
const grade = RPM.GetGrade(i) // 1,00 közül 1,00 leosztályozva
|
||||||
|
const grades = grade.split(' ').reduce((acc, text) => {
|
||||||
|
if (text.includes(',')) { // FIXME: fancy regexp
|
||||||
|
acc.push(parseInt(text))
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (grades[0] === 1) {
|
||||||
|
if (first.val === 1) {
|
||||||
|
return first.text
|
||||||
|
} else {
|
||||||
|
return second.text
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (first.val === 0) {
|
||||||
|
return first.txt
|
||||||
|
} else {
|
||||||
|
return second.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// version 2 of getting right answer from result page
|
// version 2 of getting right answer from result page
|
||||||
// i is the index of the question
|
// i is the index of the question
|
||||||
GetRightAnswerFromResultv2 (i) {
|
GetRightAnswerFromResultv2 (i) {
|
||||||
|
@ -562,10 +620,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.length === 2) {
|
if (items.length === 2) {
|
||||||
for (let j = 0; j < items.length; j++) {
|
const resByIncorrect = this.GuessCorrectIn2LengthAnswersByIncorrect(items)
|
||||||
let cn = items[j].className
|
if (!resByIncorrect) {
|
||||||
if (!cn.includes('correct')) { return items[j].innerText }
|
const resPoints = this.GuessCorrectIn2LengthAnswersByPoints(i, items)
|
||||||
|
return resPoints
|
||||||
}
|
}
|
||||||
|
return resByIncorrect
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log('error at new nodegetting, trying the oldschool way')
|
Log('error at new nodegetting, trying the oldschool way')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue