mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Fixed incorrect image data parsing, and other small stuffs
This commit is contained in:
parent
74bf725c93
commit
29e92a1220
1 changed files with 12 additions and 15 deletions
27
main.js
27
main.js
|
@ -22,7 +22,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
|
||||||
var lastChangeLog = '- Csak egy plusz weboldal gomb a menüben.'; // TODO
|
var lastChangeLog = '- Kérdések adatstruktúra változtatás. Ha jól csináltam, akkor semmit se kellene észrevenni. \n Ha nem, akkor weboldalon lehet hibát jelezni!';
|
||||||
var serverAdress = "http://questionmining.tk/";
|
var serverAdress = "http://questionmining.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!
|
||||||
|
@ -224,7 +224,6 @@ class QuestionDB {
|
||||||
//: Main function {{{
|
//: Main function {{{
|
||||||
function Main() {
|
function Main() {
|
||||||
'use strict';
|
'use strict';
|
||||||
console.clear(); // TODO
|
|
||||||
Init(function(count) {
|
Init(function(count) {
|
||||||
var url = location.href;
|
var url = location.href;
|
||||||
try {
|
try {
|
||||||
|
@ -825,7 +824,11 @@ function ParseRawData(data) {
|
||||||
// dont allow overwriting
|
// dont allow overwriting
|
||||||
// ?!>>>
|
// ?!>>>
|
||||||
if (!currQuestion.HasImage()) {
|
if (!currQuestion.HasImage()) {
|
||||||
currQuestion.I = JSON.parse(currData);
|
try {
|
||||||
|
currQuestion.I = JSON.parse(currData);
|
||||||
|
} catch (e) {
|
||||||
|
currQuestion.I = [currData];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ExpectedIdentifier = ['?', '+'];
|
ExpectedIdentifier = ['?', '+'];
|
||||||
continue;
|
continue;
|
||||||
|
@ -886,8 +889,6 @@ function NLoad(resource, cwith) {
|
||||||
allCount += j;
|
allCount += j;
|
||||||
r.AddSubject(s);
|
r.AddSubject(s);
|
||||||
}
|
}
|
||||||
console.log(r);
|
|
||||||
console.log(rt);
|
|
||||||
data = r;
|
data = r;
|
||||||
count = allCount + 1; // couse starting with -1 to show errors
|
count = allCount + 1; // couse starting with -1 to show errors
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1035,7 +1036,6 @@ function HandleUI(url, count) {
|
||||||
timeout = null;
|
timeout = null;
|
||||||
GM_setValue("motdcount", motdcount);
|
GM_setValue("motdcount", motdcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShowMessage({
|
ShowMessage({
|
||||||
|
@ -1098,7 +1098,7 @@ function ShowSaveQuizDialog(addedQ, allQ, allOutput, output, sendSuccess, sentDa
|
||||||
|
|
||||||
function SearchSameQuestion(questionData, quiz, i) {
|
function SearchSameQuestion(questionData, quiz, i) {
|
||||||
var r = questionData.Search(quiz[i]);
|
var r = questionData.Search(quiz[i]);
|
||||||
return r.length;
|
return r.length == 0 ? -1 : r.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should get the image url from a result page
|
// this should get the image url from a result page
|
||||||
|
@ -1157,11 +1157,8 @@ function SaveQuiz(quiz, questionData) {
|
||||||
allOutput += toAdd; // adding to all
|
allOutput += toAdd; // adding to all
|
||||||
allQ++;
|
allQ++;
|
||||||
}
|
}
|
||||||
console.log("QUIZ:");
|
|
||||||
console.log(quiz);
|
|
||||||
console.log(newQuestions); // TODO: test this
|
|
||||||
var sendSuccess = false;
|
var sendSuccess = false;
|
||||||
var sentData = "undefined";
|
var sentData = {};
|
||||||
try {
|
try {
|
||||||
var subj = "NOSUBJ";
|
var subj = "NOSUBJ";
|
||||||
try {
|
try {
|
||||||
|
@ -1171,10 +1168,10 @@ function SaveQuiz(quiz, questionData) {
|
||||||
}
|
}
|
||||||
var useNetDB = GM_getValue("useNetDB");
|
var useNetDB = GM_getValue("useNetDB");
|
||||||
if (useNetDB != undefined && useNetDB == 1) {
|
if (useNetDB != undefined && useNetDB == 1) {
|
||||||
sentData = "datatoadd=alldata<=>" + JSON.stringify(quiz) + "<#>data<=>" + JSON.stringify(
|
sentData.allData = quiz;
|
||||||
newQuestions) + "<#>subj<=>" + subj;
|
sentData.data = newQuestions;
|
||||||
console.log(sentData); // TODO
|
sentData.subj = subj;
|
||||||
SendXHRMessage(sentData);
|
SendXHRMessage("datatoadd=" + JSON.stringify(sentData));
|
||||||
sendSuccess = true;
|
sendSuccess = true;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue