Am trying to create a note template for learning spelling on anki. Am looking forward for the front of the card to show the word and a cover button which when pressed starts an effect that covers the word gradually from left to right in an animation sense and provide a input field for the word to be typed. When the show answer button is pressed, the input text is then compared with the word and I can then rate my answer with Again or Good.
The challenges in the templates below is as following challenges.
The comparison between the input text and {{word}} doesn’t work (both on ankidroid and anki). When the wrong text (or no text) is entered, it still shows as correct.
When the Input field shows after the word has been covered, a keyboard doesn’t pop up for typing in ankidroid.
I’m not sure what was the idea behind the provided code, but the backside tries using document.getElementById('answerInput') when no such element exists in the first place. So, naturally, it doesn’t compare anything because user input remains undefined.
An actual solution for a custom input method would typically involve using sessionStorage to pass what was typed on the front side to the back of a card. However, the original task doesn’t seem to require anything that can’t be done with the stock Anki typing, so can you provide some background on why you decided to go through the trouble of coding a custom <input> instead of simply using {{type:Word}}?
You need to enable Type answer into the card in the AnkiDroid settings ( → Advanced → Type answer into the card → toggle ON). Adding the inputmode="text" attribute to your input element should be useful as well.
Also, is the provided code AI-generated? Disclosing that would help gauge what kind of response you are expecting.
A working button and the animation are the easy part here, while the logic for processing an answer is missing entirely right now. Developing the input itself into a full-fledged solution would take quite a bit of work, so I would recommend reverting it to the different approach I mentioned:
For the front side this would involve using the following code:
(This can be streamlined further quite a bit, but I tried to keep the layout and the styles intact, because I’m not sure which parts of the design are intentional)
Once the idea is appreciated, any fine-tuning is very much welcomed. Am sure a lot of people might find it useful. I was thinking to, somehow, involve a TTS that demand that the said word is spelt and make the showing and covering of the word an alternative. Either way, the adjustment you’ve made works perfectly fine. Thanks
Designwise, I would get rid of the button entirely and make the word itself clickable (or even the whole card instead, to make it easier to reach on mobile, while adding an Enter shortcut for desktop). The input line itself can cover the word when it appears, instead of it being a separate element. The combined animation will also remove the need for manually syncing the durations between the two currently separate ones.
You might also want to try cloze cards as one more alternative, which will omit and require to be entered only the difficult sections of a word, to keep the prompt clear and not spoil the answer at the same time.
My exact thought. If the entire card could be clickable I think that will do.
I realized hitting enter after typing the word goes straight to the answer/back.
By using the word alternative, I meant the card appears with a voice prompt with accompanied Input Field (default). If a hint is needed, then one could click a button “show and cover” or the card (as you suggested). The default input field disappears, the word is shown and after a given number of seconds it covered and turned into an Input Field (as you proposed).
Like you clearly point out, a cloze could be yet another hint-option. If a card could creatively combine all three means, and allow the user to opt for an approach depending on the desired ease, I think it will be great.
It shouldn’t be a problem, since typing itself will be performed only after the typing field is revealed. So Enter can serve two purposes depending on the state. However, it might require meddling with the app settings and even add-ons/scripts to make it work exactly as intended. A different key can be used instead, for, presumably, less convenient but simpler approach.
A note can also generate two separate cards at the same time: one for tts+hint and one with the word being clozed.
You’ll simply need to use a cloze note type as a base and structure the code on the front template as follows:
{{#c1}}
...your code for the tts+hint card...
{{/c1}}
{{#c2}}
...your code for the cloze card...
{{/c2}}
Use {{type:cloze:Text}} for the input element. The backside template and the rest can be treated the same way as in regular cards. Mark the full contents of the text field as the first cloze (to get the tts card), then use the second cloze to indicate the parts for the second card (just like a usual cloze). If either of the two clozes is skipped, the note won’t generate the respective type of card, so that can be used to control which one of the two types (or both) you want for each note individually.
Alternatively, a regular (non-cloze) note type can be used with two separate predefined card types. Then the tts+hint card type can be created normally. To emulate the cloze card, the difficult parts of the word in the Word field can be marked with bold during note creation. To hide them from the view on the front side of the card, you’ll need to put the Word field into a container:
<div class="clozed">
{{Word}}
</div>
and add a respective rule that would style the omitted parts in a desired way. For example:
.clozed b {
color: transparent;
}
In contrast to the cloze card, in this case, the card will expect you to type the full word instead of just the selected parts during the review.