mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Changed namespace, and update URL
This commit is contained in:
parent
3279d057c2
commit
63977056e8
3 changed files with 38 additions and 48 deletions
38
main.js
38
main.js
|
@ -49,13 +49,9 @@ const motdShowCount = 3 /* Ammount of times to show motd */
|
|||
var motd = ''
|
||||
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 lengthDiffMultiplier = 10 /* Percent minus for length difference */
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Other constants
|
||||
// ------------------------------------------------------------------------------
|
||||
// : question-classes {{{
|
||||
const commonUselessAnswerParts = [
|
||||
'A helyes válasz az ',
|
||||
'A helyes válasz a ',
|
||||
|
@ -67,9 +63,12 @@ const commonUselessAnswerParts = [
|
|||
'\''
|
||||
]
|
||||
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 {
|
||||
RemoveStuff (value, removableStrings) {
|
||||
|
@ -151,10 +150,7 @@ class StringUtils {
|
|||
}
|
||||
|
||||
CompareString (s1, s2) {
|
||||
assert(s1)
|
||||
assert(s2)
|
||||
|
||||
if (s1 === '' || s2 === '') {
|
||||
if (!s1 || !s2) {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -226,6 +222,8 @@ class StringUtils {
|
|||
}
|
||||
}
|
||||
|
||||
const SUtils = new StringUtils()
|
||||
|
||||
class Question {
|
||||
constructor (q, a, i) {
|
||||
this.Q = SUtils.SimplifyQuestion(q)
|
||||
|
@ -373,8 +371,10 @@ class Subject {
|
|||
}
|
||||
|
||||
class QuestionDB {
|
||||
constructor () {
|
||||
constructor (getVal, setVal) {
|
||||
this.Subjects = []
|
||||
this.getVal = getVal
|
||||
this.setVal = setVal
|
||||
}
|
||||
|
||||
get length () {
|
||||
|
@ -384,7 +384,7 @@ class QuestionDB {
|
|||
get activeIndexes () {
|
||||
var r = []
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (getVal('Is' + i + 'Active')) {
|
||||
if (this.getVal('Is' + i + 'Active')) {
|
||||
r.push(i)
|
||||
}
|
||||
}
|
||||
|
@ -392,11 +392,11 @@ class QuestionDB {
|
|||
}
|
||||
|
||||
GetIfActive (ind) {
|
||||
return getVal('Is' + ind + 'Active')
|
||||
return this.getVal('Is' + ind + 'Active')
|
||||
}
|
||||
|
||||
ChangeActive (i, value) {
|
||||
setVal('Is' + i + 'Active', !!value)
|
||||
this.setVal('Is' + i + 'Active', !!value)
|
||||
}
|
||||
|
||||
AddQuestion (subj, q) {
|
||||
|
@ -452,8 +452,6 @@ class QuestionDB {
|
|||
}
|
||||
}
|
||||
|
||||
var SUtils = new StringUtils()
|
||||
|
||||
// : }}}
|
||||
|
||||
// : DOM getting stuff {{{
|
||||
|
@ -1042,7 +1040,7 @@ function NLoad (resource, cwith) {
|
|||
isSimple: true
|
||||
}, undefined, ShowHelp)
|
||||
}
|
||||
var r = new QuestionDB()
|
||||
var r = new QuestionDB(getVal, setVal)
|
||||
var rt = []
|
||||
var allCount = -1
|
||||
LoadMOTD(d)
|
||||
|
@ -2105,10 +2103,6 @@ function SendXHRMessage (message) {
|
|||
})
|
||||
}
|
||||
|
||||
var assert = (val) => {
|
||||
if (!val) { throw new Error('Assertion failed') }
|
||||
}
|
||||
|
||||
function OpenErrorPage (e) {
|
||||
let path = 'lred'
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue