mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Next/prev question button bug fixes
This commit is contained in:
parent
7789c92f93
commit
9c75edfc3c
1 changed files with 5 additions and 7 deletions
12
main.js
12
main.js
|
@ -32,7 +32,7 @@ var serverAdress = "https://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!
|
||||||
// only one of these should be true for testing
|
// only one of these should be true for testing
|
||||||
const forceTestPage = false;
|
const forceTestPage = true;
|
||||||
const forceResultPage = false;
|
const forceResultPage = false;
|
||||||
const forceDefaultPage = false;
|
const forceDefaultPage = false;
|
||||||
const logElementGetting = false;
|
const logElementGetting = false;
|
||||||
|
@ -1189,14 +1189,13 @@ function SaveQuiz(quiz, questionData) {
|
||||||
for (var i = 0; i < quiz.length; i++) // going though quiz
|
for (var i = 0; i < quiz.length; i++) // going though quiz
|
||||||
{
|
{
|
||||||
// searching for same questions in questionData
|
// searching for same questions in questionData
|
||||||
var matchAt = SearchSameQuestion(questionData, quiz, i);
|
|
||||||
var toAdd = ""; // this will be added to some variable depending on if its already in the database
|
var toAdd = ""; // this will be added to some variable depending on if its already in the database
|
||||||
toAdd += "?" + RemoveUnnecesarySpaces(quiz[i].Q) + "\n"; // adding quiz question
|
toAdd += "?" + RemoveUnnecesarySpaces(quiz[i].Q) + "\n"; // adding quiz question
|
||||||
toAdd += "!" + RemoveUnnecesarySpaces(quiz[i].A) + "\n"; // adding quiz answer
|
toAdd += "!" + RemoveUnnecesarySpaces(quiz[i].A) + "\n"; // adding quiz answer
|
||||||
if (quiz[i].HasImage()) {
|
if (quiz[i].HasImage()) {
|
||||||
toAdd += ">" + RemoveUnnecesarySpaces(quiz[i].I) + "\n"; // adding quiz image if there is any
|
toAdd += ">" + RemoveUnnecesarySpaces(quiz[i].I) + "\n"; // adding quiz image if there is any
|
||||||
}
|
}
|
||||||
if (matchAt == -1) // if there is no such item in the database (w/ same q and a)
|
if (SearchSameQuestion(questionData, quiz, i) == -1) // if there is no such item in the database (w/ same q and a)
|
||||||
{
|
{
|
||||||
output += toAdd; // adding to output
|
output += toAdd; // adding to output
|
||||||
newQuestions.push(quiz[i]);
|
newQuestions.push(quiz[i]);
|
||||||
|
@ -1208,17 +1207,16 @@ function SaveQuiz(quiz, questionData) {
|
||||||
var sendSuccess = false;
|
var sendSuccess = false;
|
||||||
var sentData = {};
|
var sentData = {};
|
||||||
try {
|
try {
|
||||||
var subj = "NOSUBJ";
|
|
||||||
try {
|
try {
|
||||||
subj = GetCurrentSubjectName();
|
sentData.subj = GetCurrentSubjectName();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
sentData.subj = "NOSUBJ";
|
||||||
console.log("unable to get subject name :c");
|
console.log("unable to get subject name :c");
|
||||||
}
|
}
|
||||||
var useNetDB = GM_getValue("useNetDB");
|
var useNetDB = GM_getValue("useNetDB");
|
||||||
if (useNetDB != undefined && useNetDB == 1) {
|
if (useNetDB != undefined && useNetDB == 1) {
|
||||||
sentData.allData = quiz;
|
sentData.allData = quiz;
|
||||||
sentData.data = newQuestions;
|
sentData.data = newQuestions;
|
||||||
sentData.subj = subj;
|
|
||||||
sentData.version = GM_info.script.version;
|
sentData.version = GM_info.script.version;
|
||||||
SendXHRMessage("datatoadd=" + JSON.stringify(sentData));
|
SendXHRMessage("datatoadd=" + JSON.stringify(sentData));
|
||||||
sendSuccess = true;
|
sendSuccess = true;
|
||||||
|
@ -1575,7 +1573,7 @@ function ShowMessage(msgItem, timeout, funct) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonMargin = "2px 2px 2px 2px"; // uniform button margin
|
var buttonMargin = "2px 2px 2px 2px"; // uniform button margin
|
||||||
if (msgItem[currItem].length == 0) { // TODO: test this
|
if (msgItem[currItem].length > 1) { // TODO: test this
|
||||||
// PREV SUGG BUTTON ------------------------------------------------------------------------------------------------------------
|
// PREV SUGG BUTTON ------------------------------------------------------------------------------------------------------------
|
||||||
var prevSuggButton = CreateNodeWithText(prevSuggestionCell, "<", "button");
|
var prevSuggButton = CreateNodeWithText(prevSuggestionCell, "<", "button");
|
||||||
prevSuggButton.style.margin = buttonMargin; // fancy margin
|
prevSuggButton.style.margin = buttonMargin; // fancy margin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue