diff --git a/frame.js b/frame.js index a979689..647a180 100644 --- a/frame.js +++ b/frame.js @@ -2,7 +2,7 @@ Online Moodle/Elearning/KMOOC test help Greasyfork: - GitLab: + GitLab: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 1.6.3.1 +// @version 1.6.4.0 // @description Online Moodle/Elearning/KMOOC test help // @author MrFry // @match https://elearning.uni-obuda.hu/main/* @@ -36,7 +36,6 @@ // @license GNU General Public License v3.0 or later // @supportURL qmining.frylabs.net // @contributionURL qmining.frylabs.net -// @resource data file:/// // @namespace https://greasyfork.org/users/153067 // ==/UserScript== diff --git a/main.js b/main.js index 61688cd..ba1d439 100644 --- a/main.js +++ b/main.js @@ -34,7 +34,7 @@ function info () { return GM_info } var data // all data, which is in the resource txt var addEventListener // add event listener function -const lastChangeLog = 'Félév szerinti csoportosítás menüben' +const lastChangeLog = 'Kérdés parsolás bugfixek, old school fálj beolvasás kiszedése, részletesebb hibajelentés és egyéb fixek' const serverAdress = 'https://qmining.frylabs.net/' // forcing pages for testing. unless you test, do not set these to true! @@ -60,7 +60,9 @@ const commonUselessAnswerParts = [ 'A helyes válasz az ', 'A helyes válasz a ', 'A helyes válaszok: ', + 'A helyes válaszok:', 'A helyes válasz: ', + 'A helyes válasz:', 'The correct answer is:', '\'' ] @@ -152,6 +154,10 @@ class StringUtils { assert(s1) assert(s2) + if (s1 === '' || s2 === '') { + return 0 + } + s1 = this.SimplifyStringForComparison(s1).split(' ') s2 = this.SimplifyStringForComparison(s2).split(' ') var match = 0 @@ -165,7 +171,7 @@ class StringUtils { return percent } - QuestionPreProcessor (value) { + AnswerPreProcessor (value) { assert(value) return this.RemoveStuff( @@ -184,16 +190,9 @@ class StringUtils { } } - SimplifyQuestion (value) { + SimplifyQA (value, mods) { if (!value) { return } - let mods = [ - this.RemoveSpecialChars.bind(this), - this.RemoveUnnecesarySpaces.bind(this), - this.QuestionPreProcessor.bind(this), - this.RemoveAnswerLetters.bind(this) - ] - const reducer = (res, fn) => { return fn(res) } @@ -201,6 +200,26 @@ class StringUtils { return mods.reduce(reducer, value) } + SimplifyAnswer (value) { + return this.SimplifyQA( + value, + [ + this.RemoveSpecialChars.bind(this), + this.RemoveUnnecesarySpaces.bind(this), + this.AnswerPreProcessor.bind(this), + this.RemoveAnswerLetters.bind(this) + ]) + } + + SimplifyQuestion (value) { + return this.SimplifyQA( + value, + [ + this.RemoveSpecialChars.bind(this), + this.RemoveUnnecesarySpaces.bind(this) + ]) + } + SimplifyStack (stack) { stack = this.SimplifyQuery(stack) let ns = '' @@ -225,7 +244,7 @@ class StringUtils { class Question { constructor (q, a, i) { this.Q = SUtils.SimplifyQuestion(q) - this.A = SUtils.SimplifyQuestion(a) + this.A = SUtils.SimplifyAnswer(a) this.I = i }