Fixed question highlighting in some cases

This commit is contained in:
YourFriendlyNeighborhoodDealer 2019-03-02 17:20:18 +01:00
parent 52d6bd9be9
commit 775e973681
3 changed files with 15 additions and 3 deletions

14
main.js
View file

@ -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