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
25
main.js
25
main.js
|
@ -22,7 +22,7 @@
|
|||
|
||||
var data; // all data, which is in the resource txt
|
||||
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/";
|
||||
|
||||
// forcing pages for testing. unless you test, do not set these to true!
|
||||
|
@ -224,7 +224,6 @@ class QuestionDB {
|
|||
//: Main function {{{
|
||||
function Main() {
|
||||
'use strict';
|
||||
console.clear(); // TODO
|
||||
Init(function(count) {
|
||||
var url = location.href;
|
||||
try {
|
||||
|
@ -825,7 +824,11 @@ function ParseRawData(data) {
|
|||
// dont allow overwriting
|
||||
// ?!>>>
|
||||
if (!currQuestion.HasImage()) {
|
||||
try {
|
||||
currQuestion.I = JSON.parse(currData);
|
||||
} catch (e) {
|
||||
currQuestion.I = [currData];
|
||||
}
|
||||
}
|
||||
ExpectedIdentifier = ['?', '+'];
|
||||
continue;
|
||||
|
@ -886,8 +889,6 @@ function NLoad(resource, cwith) {
|
|||
allCount += j;
|
||||
r.AddSubject(s);
|
||||
}
|
||||
console.log(r);
|
||||
console.log(rt);
|
||||
data = r;
|
||||
count = allCount + 1; // couse starting with -1 to show errors
|
||||
} catch (e) {
|
||||
|
@ -1035,7 +1036,6 @@ function HandleUI(url, count) {
|
|||
timeout = null;
|
||||
GM_setValue("motdcount", motdcount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
ShowMessage({
|
||||
|
@ -1098,7 +1098,7 @@ function ShowSaveQuizDialog(addedQ, allQ, allOutput, output, sendSuccess, sentDa
|
|||
|
||||
function SearchSameQuestion(questionData, 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
|
||||
|
@ -1157,11 +1157,8 @@ function SaveQuiz(quiz, questionData) {
|
|||
allOutput += toAdd; // adding to all
|
||||
allQ++;
|
||||
}
|
||||
console.log("QUIZ:");
|
||||
console.log(quiz);
|
||||
console.log(newQuestions); // TODO: test this
|
||||
var sendSuccess = false;
|
||||
var sentData = "undefined";
|
||||
var sentData = {};
|
||||
try {
|
||||
var subj = "NOSUBJ";
|
||||
try {
|
||||
|
@ -1171,10 +1168,10 @@ function SaveQuiz(quiz, questionData) {
|
|||
}
|
||||
var useNetDB = GM_getValue("useNetDB");
|
||||
if (useNetDB != undefined && useNetDB == 1) {
|
||||
sentData = "datatoadd=alldata<=>" + JSON.stringify(quiz) + "<#>data<=>" + JSON.stringify(
|
||||
newQuestions) + "<#>subj<=>" + subj;
|
||||
console.log(sentData); // TODO
|
||||
SendXHRMessage(sentData);
|
||||
sentData.allData = quiz;
|
||||
sentData.data = newQuestions;
|
||||
sentData.subj = subj;
|
||||
SendXHRMessage("datatoadd=" + JSON.stringify(sentData));
|
||||
sendSuccess = true;
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue