From 775e9736812b192c78c6c8e28e2ad9dcc7789971 Mon Sep 17 00:00:00 2001 From: YourFriendlyNeighborhoodDealer Date: Sat, 2 Mar 2019 17:20:18 +0100 Subject: [PATCH] Fixed question highlighting in some cases --- README.md | 2 +- frame.js | 2 +- main.js | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d53a8ca..472a709 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you want to install from here then: Paste main.js between '(function() {' and '})();' Search for 'function Main', and type Main(); right before it -You could also add '// require file:///main.js' to frame.js, and simply call 'Main();' +You could also add '// (AT)require file:///main.js' to frame.js, and simply call 'Main();' there. diff --git a/frame.js b/frame.js index 5a898b1..7c2957c 100644 --- a/frame.js +++ b/frame.js @@ -21,7 +21,7 @@ // ==UserScript== // @name Moodle/Elearning/KMOOC test help -// @version 1.6.2.1 +// @version 1.6.2.3 // @description Online Moodle/Elearning/KMOOC test help // @author YourFriendlyNeighborhoodDealer // @match https://elearning.uni-obuda.hu/main/* diff --git a/main.js b/main.js index c49a040..f944ea8 100644 --- a/main.js +++ b/main.js @@ -1415,7 +1415,16 @@ function SortByPercent(results) { // removes stuff like " a. q1" -> "q1" function RemoveLetterMarking(inp) { - return RemoveUnnecesarySpaces(inp.substr(inp.indexOf(".") + 1, inp.length)); + let dotIndex = inp.indexOf('.'); + let doubledotIndex = inp.indexOf(':'); + let maxInd = 4; // inp.length * 0.2; + + if (dotIndex < maxInd) + return RemoveUnnecesarySpaces(inp.substr(inp.indexOf(".") + 1, inp.length)); + else if (doubledotIndex < maxInd) + return RemoveUnnecesarySpaces(inp.substr(inp.indexOf(":") + 1, inp.length)); + else + return inp; } // highlights the possible solutions to the current question @@ -1436,6 +1445,9 @@ function HighLightAnswer(results, currQuestionNumber) { // removing stuff like "a." answer = RemoveLetterMarking(answer); + if (EmptyOrWhiteSpace(correct) || EmptyOrWhiteSpace(answer)) + continue; + if (NormalizeSpaces(RemoveUnnecesarySpaces(correct)).includes(answer)) // if the correct answer includes the current answer { toColor.push(i); // adding the index