From dc3e8f5391ab414f42c83361edec7ea273b236ce Mon Sep 17 00:00:00 2001 From: MrFry Date: Fri, 22 Nov 2019 14:06:10 +0100 Subject: [PATCH] Removing + from questions --- stable.user.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stable.user.js b/stable.user.js index c3ef39b..200c7db 100644 --- a/stable.user.js +++ b/stable.user.js @@ -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