anki-mc icon indicating copy to clipboard operation
anki-mc copied to clipboard

Fixed answer color coding

Open omargoda opened this issue 3 years ago • 6 comments

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.

omargoda avatar Oct 07 '21 14:10 omargoda

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. image

thiagopikcius avatar Oct 09 '21 23:10 thiagopikcius

@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 avatar Oct 10 '21 00:10 omargoda

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

BACKSIDE image

Thank you for your help.

thiagopikcius avatar Oct 10 '21 16:10 thiagopikcius

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

omargoda avatar Oct 14 '21 01:10 omargoda

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.

zjosua avatar Dec 30 '21 11:12 zjosua

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!

jennettadao avatar Feb 04 '22 16:02 jennettadao

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 ).

3ter avatar Oct 27 '22 20:10 3ter

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 .

3ter avatar Oct 30 '22 10:10 3ter