Removing + from questions

This commit is contained in:
MrFry 2019-11-22 14:06:10 +01:00
parent 6cee318903
commit dc3e8f5391

View file

@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 1.6.4.7
// @version 1.6.4.8
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@ -82,7 +82,8 @@
'The correct answer is:',
'\''
]
const commonUselessStringParts = [',', '\\.', ':', '!']
const commonUselessStringParts = [',', '\\.', ':', '!', '\\+']
const specialChars = [ '&', '\\+' ]
const lengthDiffMultiplier = 10 /* Percent minus for length difference */
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */
@ -91,10 +92,10 @@
}
class StringUtils {
RemoveStuff (value, removableStrings) {
RemoveStuff (value, removableStrings, toReplace) {
removableStrings.forEach((x) => {
var regex = new RegExp(x, 'g')
value = value.replace(regex, '')
value = value.replace(regex, toReplace || '')
})
return value
}
@ -152,7 +153,7 @@
RemoveSpecialChars (value) {
assert(value)
return this.RemoveStuff(value, ['&'])
return this.RemoveStuff(value, specialChars, ' ')
}
// if the value is empty, or whitespace
@ -1296,7 +1297,9 @@
let count = 0
r.forEach((item) => {
if (item.match > minResultMatchPercent) { count++ }
if (item.match > minResultMatchPercent) {
count++
}
})
return count === 0 ? -1 : count
@ -1392,12 +1395,12 @@
var question = {} // the current question
// QUESTION --------------------------------------------------------------------------------------------------------------------
var q = RPM.GetQuestionFromResult(i)
if (q !== undefined) { question.q = SUtils.SimplifyQuery(q) }
if (q !== undefined) { question.q = SUtils.SimplifyQuestion(q) }
// RIGHTANSWER ---------------------------------------------------------------------------------------------------------------------
var a = RPM.GetRightAnswerFromResultv2(i)
if (a === undefined) { a = RPM.GetRightAnswerFromResult(i) }
if (a !== undefined) { question.a = SUtils.SimplifyQuery(a) }
if (a !== undefined) { question.a = SUtils.SimplifyAnswer(a) }
// IMG ---------------------------------------------------------------------------------------------------------------------
var img = GetImageFormResult(i)
question.i = img