mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Question image comparing merge
This commit is contained in:
commit
2297c37f10
3 changed files with 73 additions and 42 deletions
2
frame.js
2
frame.js
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 1.6.2.6
|
// @version 1.6.2.7
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author YourFriendlyNeighborhoodDealer
|
// @author YourFriendlyNeighborhoodDealer
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
|
|
4
main.js
4
main.js
|
@ -31,7 +31,7 @@ const forceTestPage = true;
|
||||||
const forceResultPage = false;
|
const forceResultPage = false;
|
||||||
const forceDefaultPage = false;
|
const forceDefaultPage = false;
|
||||||
const logElementGetting = false;
|
const logElementGetting = false;
|
||||||
const log = true;
|
const log = false;
|
||||||
|
|
||||||
const motdShowCount = 3; /* Ammount of times to show motd */
|
const motdShowCount = 3; /* Ammount of times to show motd */
|
||||||
var motd = "";
|
var motd = "";
|
||||||
|
@ -943,7 +943,7 @@ function ParseRawData(data) {
|
||||||
try {
|
try {
|
||||||
currQuestion.I = JSON.parse(currData);
|
currQuestion.I = JSON.parse(currData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
currQuestion.I = [currData];
|
currQuestion.I = currData.split(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExpectedIdentifier = ['?', '+'];
|
ExpectedIdentifier = ['?', '+'];
|
||||||
|
|
59
stable.js
59
stable.js
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 1.6.2.5
|
// @version 1.6.2.7
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author YourFriendlyNeighborhoodDealer
|
// @author YourFriendlyNeighborhoodDealer
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
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 =
|
const lastChangeLog =
|
||||||
'- Passzív mód: ha bepipálod a menü gomb alatt, akkor nem tölti be minden alkalommal a kérdéseket (csak csendben vár).\n - Pár lényeges bugfix\n - Ha találkoztok bugokkal, akkor pls report! thanx';
|
'- Apró, de lényeges fixek\n - Ha találkoztok bugokkal, akkor pls report! thanx';
|
||||||
const serverAdress = "https://qmining.tk/";
|
const serverAdress = "https://qmining.tk/";
|
||||||
|
|
||||||
// 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,7 @@
|
||||||
var lastestVersion = "";
|
var lastestVersion = "";
|
||||||
|
|
||||||
const minMatchAmmount = 55;
|
const minMatchAmmount = 55;
|
||||||
|
const minResultMatchPercent = 99;
|
||||||
const lengthDiffMultiplier = 10;
|
const lengthDiffMultiplier = 10;
|
||||||
|
|
||||||
//: Class descriptions {{{
|
//: Class descriptions {{{
|
||||||
|
@ -249,8 +250,19 @@
|
||||||
//: Main function {{{
|
//: Main function {{{
|
||||||
function Main() {
|
function Main() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
console.time('main');
|
||||||
|
|
||||||
Init(function(count, subjCount) {
|
Init(function(count, subjCount) {
|
||||||
var url = location.href;
|
var url = location.href;
|
||||||
|
|
||||||
|
let skipLoad = GM_getValue("skipLoad");
|
||||||
|
if (count == -2 && subjCount == -2 && skipLoad) {
|
||||||
|
if (url.includes("/quiz/") && url.includes("attempt.php"))
|
||||||
|
ShowMessage({
|
||||||
|
m: "Passzív mód bekapcsolva, válaszok megjelenítéséhez menü gomb alatt kapcsold ki, és frissíts!",
|
||||||
|
isSimple: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
if ((url.includes("/quiz/") && url.includes("attempt.php")) || forceTestPage) { // if the current page is a test
|
if ((url.includes("/quiz/") && url.includes("attempt.php")) || forceTestPage) { // if the current page is a test
|
||||||
HandleQuiz();
|
HandleQuiz();
|
||||||
|
@ -276,7 +288,14 @@
|
||||||
Log(
|
Log(
|
||||||
"Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót! Nagy esélyel a kérdéseket nem lehetett beolvasni."
|
"Itteni hibák 100% a moodle hiba. Kivéve, ha oda van írva hogy script error ;) Ha ilyesmi szerepel itt, akkor olvasd el a segítség szekciót! Nagy esélyel a kérdéseket nem lehetett beolvasni."
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("Moodle Test Script run time:");
|
||||||
|
console.timeEnd('main');
|
||||||
|
|
||||||
|
if (forceTestPage || forceResultPage || forceDefaultPage)
|
||||||
|
alert("TEST MODE");
|
||||||
}
|
}
|
||||||
//: }}}
|
//: }}}
|
||||||
|
|
||||||
|
@ -946,8 +965,10 @@
|
||||||
var useNetDB = GM_getValue("useNetDB");
|
var useNetDB = GM_getValue("useNetDB");
|
||||||
let skipLoad = GM_getValue("skipLoad");
|
let skipLoad = GM_getValue("skipLoad");
|
||||||
|
|
||||||
if (skipLoad)
|
if (skipLoad) {
|
||||||
|
cwith(-2, -2);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (useNetDB != undefined && useNetDB == 1)
|
if (useNetDB != undefined && useNetDB == 1)
|
||||||
return ReadNetDB(cwith, useNetDB);
|
return ReadNetDB(cwith, useNetDB);
|
||||||
|
@ -1051,7 +1072,7 @@
|
||||||
if (!newVersion && !loaded) // --------------------------------------------------------------------------------------------------------------
|
if (!newVersion && !loaded) // --------------------------------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
greetMsg =
|
greetMsg =
|
||||||
"Hiba a @resource tagnál, vagy a fileval van gond! (Lehet át lett helyezve, vagy üres.) Vagy válaszd a netes adatok használatát menüben. Ellenőrizd az elérési utat, vagy hogy a Tampermonkey bővítmény eléri-e a fájlokat. Ha netes forrást használsz, akkor nem elérhető a szerver! Segítségért kattints!";
|
"Hiba a @resource tagnál, vagy a fileval van gond! (Lehet át lett helyezve, vagy üres, vagy nincs tárgy kiválasztva) Vagy válaszd a netes adatok használatát menüben. Ellenőrizd az elérési utat, vagy hogy a Tampermonkey bővítmény eléri-e a fájlokat. Ha netes forrást használsz, akkor nem elérhető a szerver! Segítségért kattints!";
|
||||||
}
|
}
|
||||||
var showSplash = (GM_getValue("showSplash") == undefined) || GM_getValue("showSplash"); // getting value, if splash screen should be shown. Its true, if its undefined, or true
|
var showSplash = (GM_getValue("showSplash") == undefined) || GM_getValue("showSplash"); // getting value, if splash screen should be shown. Its true, if its undefined, or true
|
||||||
// no new version, everything loaded, and show splash is enabled. otherwise something happened, so showing it
|
// no new version, everything loaded, and show splash is enabled. otherwise something happened, so showing it
|
||||||
|
@ -1240,7 +1261,14 @@
|
||||||
|
|
||||||
function SearchSameQuestion(questionData, quiz, i) {
|
function SearchSameQuestion(questionData, quiz, i) {
|
||||||
var r = questionData.Search(quiz[i].Q);
|
var r = questionData.Search(quiz[i].Q);
|
||||||
return r.length == 0 ? -1 : r.length;
|
|
||||||
|
let count = 0;
|
||||||
|
r.forEach((item) => {
|
||||||
|
if (item.match > minResultMatchPercent)
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
|
||||||
|
return count == 0 ? -1 : count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should get the image url from a result page
|
// this should get the image url from a result page
|
||||||
|
@ -1587,7 +1615,7 @@
|
||||||
mainDiv.style.background = "#222d32"; // background color
|
mainDiv.style.background = "#222d32"; // background color
|
||||||
mainDiv.style.color = "#ffffff"; // text color
|
mainDiv.style.color = "#ffffff"; // text color
|
||||||
mainDiv.style.borderColor = "#035a8f"; // border color
|
mainDiv.style.borderColor = "#035a8f"; // border color
|
||||||
mainDiv.style.border = "solid";
|
mainDiv.style.border = "none";
|
||||||
mainDiv.style.top = (startFromTop) + 'px';
|
mainDiv.style.top = (startFromTop) + 'px';
|
||||||
mainDiv.style.left = (window.innerWidth - width) / 2 + 'px';
|
mainDiv.style.left = (window.innerWidth - width) / 2 + 'px';
|
||||||
mainDiv.style.opacity = "0.9"; // setting starting opacity
|
mainDiv.style.opacity = "0.9"; // setting starting opacity
|
||||||
|
@ -1768,7 +1796,6 @@
|
||||||
// mainDiv.style.left = (window.innerWidth - width) / 2 + 'px';
|
// mainDiv.style.left = (window.innerWidth - width) / 2 + 'px';
|
||||||
|
|
||||||
var menuButtonDiv = document.createElement("div");
|
var menuButtonDiv = document.createElement("div");
|
||||||
menuButtonDiv.setAttribute("id", "HelperMenuButton");
|
|
||||||
menuButtonDiv.style.width = buttonWidth + 'px';
|
menuButtonDiv.style.width = buttonWidth + 'px';
|
||||||
menuButtonDiv.style.height = buttonHeight + 'px';
|
menuButtonDiv.style.height = buttonHeight + 'px';
|
||||||
menuButtonDiv.style.top = (window.innerHeight - buttonHeight * 1.5) + 'px';
|
menuButtonDiv.style.top = (window.innerHeight - buttonHeight * 1.5) + 'px';
|
||||||
|
@ -1793,6 +1820,7 @@
|
||||||
menuButton.style.height = buttonHeight - 20 + 'px';
|
menuButton.style.height = buttonHeight - 20 + 'px';
|
||||||
menuButton.style.background = "#222d32"; // background color
|
menuButton.style.background = "#222d32"; // background color
|
||||||
menuButton.style.color = "#ffffff"; // background color
|
menuButton.style.color = "#ffffff"; // background color
|
||||||
|
menuButton.setAttribute("id", "HelperMenuButton");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1817,12 +1845,16 @@
|
||||||
|
|
||||||
questionsTickBox.addEventListener("click", function() {
|
questionsTickBox.addEventListener("click", function() {
|
||||||
GM_setValue("skipLoad", questionsTickBox.checked);
|
GM_setValue("skipLoad", questionsTickBox.checked);
|
||||||
if (GM_getValue("skipLoad")) {
|
var msg = "";
|
||||||
|
if (GM_getValue("skipLoad"))
|
||||||
|
msg = "Passzív mód bekapcsolva, mostantól kérdések nem lesznek betöltve/lekérve.";
|
||||||
|
else
|
||||||
|
msg = "Passzív mód kikapcsolva, frissíts az érvénybe lépéshez!";
|
||||||
|
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
m: "Passzív mód bekapcsolva, mostantól kérdések nem lesznek betöltve/lekérve.",
|
m: msg,
|
||||||
isSimple: true
|
isSimple: true
|
||||||
}, 10);
|
}, 6);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
var loadDataCheckBoxText = CreateNodeWithText(questionsTickBox,
|
var loadDataCheckBoxText = CreateNodeWithText(questionsTickBox,
|
||||||
|
@ -1860,7 +1892,7 @@
|
||||||
menuDiv.style.background = "#222d32"; // background color
|
menuDiv.style.background = "#222d32"; // background color
|
||||||
menuDiv.style.color = "#ffffff"; // text color
|
menuDiv.style.color = "#ffffff"; // text color
|
||||||
menuDiv.style.borderColor = "#035a8f"; // border color
|
menuDiv.style.borderColor = "#035a8f"; // border color
|
||||||
menuDiv.style.border = "solid";
|
menuDiv.style.border = "none";
|
||||||
menuDiv.style.opacity = "1"; // setting starting opacity
|
menuDiv.style.opacity = "1"; // setting starting opacity
|
||||||
|
|
||||||
var fiveMargin = "5px 5px 5px 5px";
|
var fiveMargin = "5px 5px 5px 5px";
|
||||||
|
@ -2121,7 +2153,7 @@
|
||||||
|
|
||||||
// removes some crap from "q"
|
// removes some crap from "q"
|
||||||
function SimplifyQuery(q) {
|
function SimplifyQuery(q) {
|
||||||
var result = q.replace(/\n/g, "").replace(/\s/g, ' '); // WHY TF ARE THERE TWO KINDA SPACES??? (charcode 160 n 32)
|
var result = q.replace(/\n/g, " ").replace(/\s/g, ' '); // WHY TF ARE THERE TWO KINDA SPACES??? (charcode 160 n 32)
|
||||||
return RemoveUnnecesarySpaces(result);
|
return RemoveUnnecesarySpaces(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,5 +2269,4 @@
|
||||||
// O deepest wound of all that he should die
|
// O deepest wound of all that he should die
|
||||||
// On that darkest day.
|
// On that darkest day.
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue