anki-mc
anki-mc copied to clipboard
Fixed answer color coding
I saw a lot of people complaining about a color coding issue when they show the answers as it appears to be confusing which is the right answer and which is wrong. I have posted a comment on the plugin page on the official ANKI forum about how to modify the card back template code to show the convenient color-coding used by most Q banks and a lot of people contacted me saying that it worked best for them, so decided to make a pull request here, so changes are applied to the plugin itself.
I have modified the card back template to display green only if the choice is correct (whether I have chosen it or not) and displays red only if the choice is wrong and I have chosen it.
This has fixed the colors in the table on the FrontSide, but not in the table on the BackSide.
What can I do?
I wish the table on the BackSide wouldn't show.
@thiagopikcius I guess you may have modified the code of cards for the AllInOne card type. What I recommend is that you uninstall the plugin, and then manually add the files inside the src directory into the addons folder for ANKI, this may fix your issue. Try it and tell me how did it go.
@omargoda I've found the problem. The following lines were on the BackSide.
//Colorize the atable and count correct answers. if (colorizeatable) { if (solutions[i] && answers[i] === "1") { arows[(type != 0) ? i : i + 1].setAttribute("class", "correct"); canswers = canswers + 1; } else if (!solutions[i] && answers[i] === "0") { if (colorizefalsefalse) { arows[(type != 0) ? i : i + 1].setAttribute("class", "correct"); } canswers = canswers + 1; } else { arows[(type != 0) ? i : i + 1].setAttribute("class", "wrong"); } } }
I changed them to look like this:
//Colorize the atable and count correct answers.
if (solutions[i] && answers[i] === "1") {
arows[(type != 0) ? i : i + 1].setAttribute("class", "correct");
} else if (solutions[i] && answers[i] === "0") {
arows[(type != 0) ? i : i + 1].setAttribute("class", "correct");
} else if (!solutions[i] && answers[i] === "1") {
arows[(type != 0) ? i : i + 1].setAttribute("class", "wrong");
}
}
I also decided to hide the table from the BackSide. To do that, I added "qtable.style.display="none" after "var atable = qtable.cloneNode(true);". Now they look like this:
var qtable = document.getElementById('qtable'); qtable.innerHTML = Persistence.getItem('qtable'); var output = document.getElementById("output"); var atable = qtable.cloneNode(true); qtable.style.display="none"
I added my own styling to it. Now it looks like this:
FRONTSIDE
BACKSIDE
Thank you for your help.
@thiagopikcius Yes, those are the lines that are supposed to be replaced in order to correct the coding. Nice, it worked for you, hope someone responsible here can merge the pull request and nice styling. Good luck!
Hi @omargoda, thanks for the contribution. I'd be happy to add your styling option to the existing ones. However, with the changes in this PR, all previous options would be lost. Also, as @thiagopikcius already pointed out, the new styling option should be available for the atable as well.
I saw a lot of people complaining about a color coding issue when they show the answers as it appears to be confusing which is the right answer and which is wrong. I have posted a comment on the plugin page on the official ANKI forum about how to modify the card back template code to show the convenient color-coding used by most Q banks and a lot of people contacted me saying that it worked best for them, so decided to make a pull request here, so changes are applied to the plugin itself.
I have modified the card back template to display green only if the choice is correct (whether I have chosen it or not) and displays red only if the choice is wrong and I have chosen it.
Just wanted to say, thank you so much for this! I found the orig color-coding to be really confusing so I really appreciate it!
As @zjosua already pointed out the alternate coloring has to be an option and not a replacement for the current coloring for this PR to get accepted.
One clean way that springs to mind is adding a configuration to the addon where you can select the coloring of your choice and the note type then gets changed accordingly. But I suppose even a manual switch constant on both front and back would get accepted.
I'm happy with the current coloring by the way. I'm going to close the PR in the upcoming weeks to not spread any confusion about it (as can be seen e.g. in #88 ).
I've made a PR with making the colors easy to change and - if nobody objects - am going to close this one in favor of #90 .