Changed namespace, and update URL

This commit is contained in:
MrFry 2019-10-12 12:06:33 +02:00
parent 3279d057c2
commit 63977056e8
3 changed files with 38 additions and 48 deletions

View file

@ -21,7 +21,7 @@
// ==UserScript== // ==UserScript==
// @name Moodle/Elearning/KMOOC test help // @name Moodle/Elearning/KMOOC test help
// @version 1.6.4.1 // @version 1.6.4.3
// @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,8 @@
// @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
// @namespace https://greasyfork.org/users/153067 // @namespace https://qmining.frylabs.net
// @updateURL https://qmining.frylabs.net/moodle-test-userscript/stable.user.js
// ==/UserScript== // ==/UserScript==
(function() { (function() {

38
main.js
View file

@ -49,13 +49,9 @@ const motdShowCount = 3 /* Ammount of times to show motd */
var motd = '' var motd = ''
var lastestVersion = '' var lastestVersion = ''
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */ const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
const lengthDiffMultiplier = 10 /* Percent minus for length difference */
// ------------------------------------------------------------------------------ // : question-classes {{{
// Other constants
// ------------------------------------------------------------------------------
const commonUselessAnswerParts = [ const commonUselessAnswerParts = [
'A helyes válasz az ', 'A helyes válasz az ',
'A helyes válasz a ', 'A helyes válasz a ',
@ -67,9 +63,12 @@ const commonUselessAnswerParts = [
'\'' '\''
] ]
const commonUselessStringParts = [',', '\\.', ':', '!'] const commonUselessStringParts = [',', '\\.', ':', '!']
// ------------------------------------------------------------------------------ const lengthDiffMultiplier = 10 /* Percent minus for length difference */
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */
// : Class descriptions {{{ const assert = (val) => {
if (!val) { throw new Error('Assertion failed') }
}
class StringUtils { class StringUtils {
RemoveStuff (value, removableStrings) { RemoveStuff (value, removableStrings) {
@ -151,10 +150,7 @@ class StringUtils {
} }
CompareString (s1, s2) { CompareString (s1, s2) {
assert(s1) if (!s1 || !s2) {
assert(s2)
if (s1 === '' || s2 === '') {
return 0 return 0
} }
@ -226,6 +222,8 @@ class StringUtils {
} }
} }
const SUtils = new StringUtils()
class Question { class Question {
constructor (q, a, i) { constructor (q, a, i) {
this.Q = SUtils.SimplifyQuestion(q) this.Q = SUtils.SimplifyQuestion(q)
@ -373,8 +371,10 @@ class Subject {
} }
class QuestionDB { class QuestionDB {
constructor () { constructor (getVal, setVal) {
this.Subjects = [] this.Subjects = []
this.getVal = getVal
this.setVal = setVal
} }
get length () { get length () {
@ -384,7 +384,7 @@ class QuestionDB {
get activeIndexes () { get activeIndexes () {
var r = [] var r = []
for (var i = 0; i < this.length; i++) { for (var i = 0; i < this.length; i++) {
if (getVal('Is' + i + 'Active')) { if (this.getVal('Is' + i + 'Active')) {
r.push(i) r.push(i)
} }
} }
@ -392,11 +392,11 @@ class QuestionDB {
} }
GetIfActive (ind) { GetIfActive (ind) {
return getVal('Is' + ind + 'Active') return this.getVal('Is' + ind + 'Active')
} }
ChangeActive (i, value) { ChangeActive (i, value) {
setVal('Is' + i + 'Active', !!value) this.setVal('Is' + i + 'Active', !!value)
} }
AddQuestion (subj, q) { AddQuestion (subj, q) {
@ -452,8 +452,6 @@ class QuestionDB {
} }
} }
var SUtils = new StringUtils()
// : }}} // : }}}
// : DOM getting stuff {{{ // : DOM getting stuff {{{
@ -1042,7 +1040,7 @@ function NLoad (resource, cwith) {
isSimple: true isSimple: true
}, undefined, ShowHelp) }, undefined, ShowHelp)
} }
var r = new QuestionDB() var r = new QuestionDB(getVal, setVal)
var rt = [] var rt = []
var allCount = -1 var allCount = -1
LoadMOTD(d) LoadMOTD(d)
@ -2105,10 +2103,6 @@ function SendXHRMessage (message) {
}) })
} }
var assert = (val) => {
if (!val) { throw new Error('Assertion failed') }
}
function OpenErrorPage (e) { function OpenErrorPage (e) {
let path = 'lred' let path = 'lred'
try { try {

View file

@ -21,7 +21,7 @@
// ==UserScript== // ==UserScript==
// @name Moodle/Elearning/KMOOC test help // @name Moodle/Elearning/KMOOC test help
// @version 1.6.4.2 // @version 1.6.4.3
// @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,8 @@
// @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
// @namespace https://greasyfork.org/users/153067 // @namespace https://qmining.frylabs.net
// @updateURL https://qmining.frylabs.net/moodle-test-userscript/stable.user.js
// ==/UserScript== // ==/UserScript==
(function() { (function() {
@ -67,13 +68,9 @@
var motd = '' var motd = ''
var lastestVersion = '' var lastestVersion = ''
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */
const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */ const minResultMatchPercent = 99 /* Minimum ammount to consider that two questions match during saving */
const lengthDiffMultiplier = 10 /* Percent minus for length difference */
// ------------------------------------------------------------------------------ // : question-classes {{{
// Other constants
// ------------------------------------------------------------------------------
const commonUselessAnswerParts = [ const commonUselessAnswerParts = [
'A helyes válasz az ', 'A helyes válasz az ',
'A helyes válasz a ', 'A helyes válasz a ',
@ -85,9 +82,12 @@
'\'' '\''
] ]
const commonUselessStringParts = [',', '\\.', ':', '!'] const commonUselessStringParts = [',', '\\.', ':', '!']
// ------------------------------------------------------------------------------ const lengthDiffMultiplier = 10 /* Percent minus for length difference */
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */
// : Class descriptions {{{ const assert = (val) => {
if (!val) { throw new Error('Assertion failed') }
}
class StringUtils { class StringUtils {
RemoveStuff (value, removableStrings) { RemoveStuff (value, removableStrings) {
@ -169,10 +169,7 @@
} }
CompareString (s1, s2) { CompareString (s1, s2) {
assert(s1) if (!s1 || !s2) {
assert(s2)
if (s1 === '' || s2 === '') {
return 0 return 0
} }
@ -244,6 +241,8 @@
} }
} }
const SUtils = new StringUtils()
class Question { class Question {
constructor (q, a, i) { constructor (q, a, i) {
this.Q = SUtils.SimplifyQuestion(q) this.Q = SUtils.SimplifyQuestion(q)
@ -391,8 +390,10 @@
} }
class QuestionDB { class QuestionDB {
constructor () { constructor (getVal, setVal) {
this.Subjects = [] this.Subjects = []
this.getVal = getVal
this.setVal = setVal
} }
get length () { get length () {
@ -402,7 +403,7 @@
get activeIndexes () { get activeIndexes () {
var r = [] var r = []
for (var i = 0; i < this.length; i++) { for (var i = 0; i < this.length; i++) {
if (getVal('Is' + i + 'Active')) { if (this.getVal('Is' + i + 'Active')) {
r.push(i) r.push(i)
} }
} }
@ -410,11 +411,11 @@
} }
GetIfActive (ind) { GetIfActive (ind) {
return getVal('Is' + ind + 'Active') return this.getVal('Is' + ind + 'Active')
} }
ChangeActive (i, value) { ChangeActive (i, value) {
setVal('Is' + i + 'Active', !!value) this.setVal('Is' + i + 'Active', !!value)
} }
AddQuestion (subj, q) { AddQuestion (subj, q) {
@ -470,8 +471,6 @@
} }
} }
var SUtils = new StringUtils()
// : }}} // : }}}
// : DOM getting stuff {{{ // : DOM getting stuff {{{
@ -1061,7 +1060,7 @@
isSimple: true isSimple: true
}, undefined, ShowHelp) }, undefined, ShowHelp)
} }
var r = new QuestionDB() var r = new QuestionDB(getVal, setVal)
var rt = [] var rt = []
var allCount = -1 var allCount = -1
LoadMOTD(d) LoadMOTD(d)
@ -2124,10 +2123,6 @@
}) })
} }
var assert = (val) => {
if (!val) { throw new Error('Assertion failed') }
}
function OpenErrorPage (e) { function OpenErrorPage (e) {
let path = 'lred' let path = 'lred'
try { try {