mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
image comparing fix
This commit is contained in:
parent
c67ae2e014
commit
73d465213c
1 changed files with 15 additions and 6 deletions
|
@ -43,6 +43,7 @@
|
||||||
// TODO:
|
// TODO:
|
||||||
// test select boxes on result page
|
// test select boxes on result page
|
||||||
// dragboxes test on quiz page
|
// dragboxes test on quiz page
|
||||||
|
// image in questions sorted !
|
||||||
|
|
||||||
(function() { // eslint-disable-line
|
(function() { // eslint-disable-line
|
||||||
// GM functions, only to disable ESLINT errors
|
// GM functions, only to disable ESLINT errors
|
||||||
|
@ -253,8 +254,14 @@
|
||||||
constructor (q, a, i) {
|
constructor (q, a, i) {
|
||||||
this.Q = SUtils.SimplifyQuestion(q)
|
this.Q = SUtils.SimplifyQuestion(q)
|
||||||
this.A = SUtils.SimplifyAnswer(a)
|
this.A = SUtils.SimplifyAnswer(a)
|
||||||
|
try {
|
||||||
|
this.I = JSON.parse(i).sort((a, b) => {
|
||||||
|
return a > b
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
this.I = i
|
this.I = i
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toString () {
|
toString () {
|
||||||
var r = '?' + this.Q + '\n!' + this.A
|
var r = '?' + this.Q + '\n!' + this.A
|
||||||
|
@ -298,8 +305,7 @@
|
||||||
const qmatchpercent = SUtils.CompareString(this.Q, q2.Q)
|
const qmatchpercent = SUtils.CompareString(this.Q, q2.Q)
|
||||||
const amatchpercent = SUtils.CompareString(this.A, q2.A)
|
const amatchpercent = SUtils.CompareString(this.A, q2.A)
|
||||||
if (this.I !== undefined) {
|
if (this.I !== undefined) {
|
||||||
const imatchpercent = this.I === undefined ? SUtils.CompareString(this.I.join(' '), q2.I.join(
|
const imatchpercent = q2.I === undefined ? 0 : SUtils.CompareString(this.I.join(' '), q2.I.join(' '))
|
||||||
' ')) : 0
|
|
||||||
return (qmatchpercent + amatchpercent + imatchpercent) / 3
|
return (qmatchpercent + amatchpercent + imatchpercent) / 3
|
||||||
} else {
|
} else {
|
||||||
return (qmatchpercent + amatchpercent) / 2
|
return (qmatchpercent + amatchpercent) / 2
|
||||||
|
@ -674,7 +680,7 @@
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
TestIfQuestionIsGrabBox (i) {
|
GetAnswersFromGrabBox (i) {
|
||||||
if (logElementGetting) { Log('testing if question is grab-box') }
|
if (logElementGetting) { Log('testing if question is grab-box') }
|
||||||
let results = this.GetFormResult() // getting results element
|
let results = this.GetFormResult() // getting results element
|
||||||
let t = results[i].getElementsByClassName('dragitems')[0].childNodes
|
let t = results[i].getElementsByClassName('dragitems')[0].childNodes
|
||||||
|
@ -770,7 +776,7 @@
|
||||||
|
|
||||||
// "húzza oda ..." skip
|
// "húzza oda ..." skip
|
||||||
fun.push((i) => {
|
fun.push((i) => {
|
||||||
let temp = RPM.TestIfQuestionIsGrabBox(i)
|
let temp = RPM.GetAnswersFromGrabBox(i)
|
||||||
console.log('GRABBOX TEST')
|
console.log('GRABBOX TEST')
|
||||||
console.log(temp)
|
console.log(temp)
|
||||||
return temp.map((x) => {
|
return temp.map((x) => {
|
||||||
|
@ -1327,6 +1333,8 @@
|
||||||
function SearchSameQuestion (questionData, quiz, i) {
|
function SearchSameQuestion (questionData, quiz, i) {
|
||||||
var r = questionData.Search(quiz[i])
|
var r = questionData.Search(quiz[i])
|
||||||
|
|
||||||
|
console.log(quiz[i], r) // TODO: remove
|
||||||
|
|
||||||
let count = 0
|
let count = 0
|
||||||
r.forEach((item) => {
|
r.forEach((item) => {
|
||||||
if (item.match > minResultMatchPercent) {
|
if (item.match > minResultMatchPercent) {
|
||||||
|
@ -1377,7 +1385,8 @@
|
||||||
toAdd += '?' + SUtils.RemoveUnnecesarySpaces(quiz[i].Q) + '\n' // adding quiz question
|
toAdd += '?' + SUtils.RemoveUnnecesarySpaces(quiz[i].Q) + '\n' // adding quiz question
|
||||||
toAdd += '!' + SUtils.RemoveUnnecesarySpaces(quiz[i].A) + '\n' // adding quiz answer
|
toAdd += '!' + SUtils.RemoveUnnecesarySpaces(quiz[i].A) + '\n' // adding quiz answer
|
||||||
if (quiz[i].HasImage()) {
|
if (quiz[i].HasImage()) {
|
||||||
toAdd += '>' + SUtils.RemoveUnnecesarySpaces(quiz[i].I) + '\n' // adding quiz image if there is any
|
let imgString = typeof quiz[i].I === 'string' ? quiz[i].I : JSON.stringify(quiz[i].I)
|
||||||
|
toAdd += '>' + imgString + '\n' // adding quiz image if there is any
|
||||||
}
|
}
|
||||||
if (SearchSameQuestion(questionData, quiz, i) === -1) {
|
if (SearchSameQuestion(questionData, quiz, i) === -1) {
|
||||||
output += toAdd // adding to output
|
output += toAdd // adding to output
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue