mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
String processing polishing
This commit is contained in:
parent
2d0b496f27
commit
d3c93c5b99
2 changed files with 32 additions and 14 deletions
5
frame.js
5
frame.js
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Online Moodle/Elearning/KMOOC test help
|
Online Moodle/Elearning/KMOOC test help
|
||||||
Greasyfork: <https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help>
|
Greasyfork: <https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help>
|
||||||
GitLab: <https://gitlab.com/YourFriendlyNeighborhoodDealer/moodle-test-userscript>
|
GitLab: <https://gitlab.com/MrFry/moodle-test-userscript>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 1.6.3.1
|
// @version 1.6.4.0
|
||||||
// @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/*
|
||||||
|
@ -36,7 +36,6 @@
|
||||||
// @license GNU General Public License v3.0 or later
|
// @license GNU General Public License v3.0 or later
|
||||||
// @supportURL qmining.frylabs.net
|
// @supportURL qmining.frylabs.net
|
||||||
// @contributionURL qmining.frylabs.net
|
// @contributionURL qmining.frylabs.net
|
||||||
// @resource data file:///<file path space is %20, and use "/"-s plz not "\" ty (and add .txt)// UTF-8 PLZ>
|
|
||||||
// @namespace https://greasyfork.org/users/153067
|
// @namespace https://greasyfork.org/users/153067
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
41
main.js
41
main.js
|
@ -34,7 +34,7 @@ function info () { return GM_info }
|
||||||
|
|
||||||
var data // all data, which is in the resource txt
|
var data // all data, which is in the resource txt
|
||||||
var addEventListener // add event listener function
|
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/'
|
const serverAdress = 'https://qmining.frylabs.net/'
|
||||||
|
|
||||||
// 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!
|
||||||
|
@ -60,6 +60,8 @@ const commonUselessAnswerParts = [
|
||||||
'A helyes válasz az ',
|
'A helyes válasz az ',
|
||||||
'A helyes válasz a ',
|
'A helyes válasz a ',
|
||||||
'A helyes válaszok: ',
|
'A helyes válaszok: ',
|
||||||
|
'A helyes válaszok:',
|
||||||
|
'A helyes válasz: ',
|
||||||
'A helyes válasz:',
|
'A helyes válasz:',
|
||||||
'The correct answer is:',
|
'The correct answer is:',
|
||||||
'\''
|
'\''
|
||||||
|
@ -152,6 +154,10 @@ class StringUtils {
|
||||||
assert(s1)
|
assert(s1)
|
||||||
assert(s2)
|
assert(s2)
|
||||||
|
|
||||||
|
if (s1 === '' || s2 === '') {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
s1 = this.SimplifyStringForComparison(s1).split(' ')
|
s1 = this.SimplifyStringForComparison(s1).split(' ')
|
||||||
s2 = this.SimplifyStringForComparison(s2).split(' ')
|
s2 = this.SimplifyStringForComparison(s2).split(' ')
|
||||||
var match = 0
|
var match = 0
|
||||||
|
@ -165,7 +171,7 @@ class StringUtils {
|
||||||
return percent
|
return percent
|
||||||
}
|
}
|
||||||
|
|
||||||
QuestionPreProcessor (value) {
|
AnswerPreProcessor (value) {
|
||||||
assert(value)
|
assert(value)
|
||||||
|
|
||||||
return this.RemoveStuff(
|
return this.RemoveStuff(
|
||||||
|
@ -184,16 +190,9 @@ class StringUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimplifyQuestion (value) {
|
SimplifyQA (value, mods) {
|
||||||
if (!value) { return }
|
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) => {
|
const reducer = (res, fn) => {
|
||||||
return fn(res)
|
return fn(res)
|
||||||
}
|
}
|
||||||
|
@ -201,6 +200,26 @@ class StringUtils {
|
||||||
return mods.reduce(reducer, value)
|
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) {
|
SimplifyStack (stack) {
|
||||||
stack = this.SimplifyQuery(stack)
|
stack = this.SimplifyQuery(stack)
|
||||||
let ns = ''
|
let ns = ''
|
||||||
|
@ -225,7 +244,7 @@ class StringUtils {
|
||||||
class Question {
|
class Question {
|
||||||
constructor (q, a, i) {
|
constructor (q, a, i) {
|
||||||
this.Q = SUtils.SimplifyQuestion(q)
|
this.Q = SUtils.SimplifyQuestion(q)
|
||||||
this.A = SUtils.SimplifyQuestion(a)
|
this.A = SUtils.SimplifyAnswer(a)
|
||||||
this.I = i
|
this.I = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue