Solving Problem with Re: Cloze and Non-Cloze in One Card?

I am having trouble with a specific use case that I have not been able to solve. Essentially, for language learning, I want to be able to make a “Cloze Conjugation Card” and a “Listening Card” using the same four fields. However, at the moment I am stuck since the listening card won’t have a Cloze. Is there anyway around this? Either a setting to adjust or a clever way to use a cloze of the audio to solve this problem since there can not be different card templates with he Cloze card type?

For more details of the desired behavior is four fields:

  1. Question: “Fill in the blank”
  2. Cloze: Estoy {{c1::hablando}} (hablar)
  3. Audio: [File containing audio]
  4. Listen: “Listen, what is it saying”

I want two cards, each with a front and a back:

Card #1: (typical cloze)
[Front]
“Answer the question
Estoy […] (hablar)”
[Back]
"Answer the question
Estoy hablando (hablar)
[Audio File]

Card #2: (A listening card without a cloze)
[Font]
“Listen to the following
[Audio File]”

[Back]
“Listen
Estoy hablando (hablar) ← Ideally this would be without the {{c1::hablar}}
[Audio File]”

Is there a way to accomplish this? I expect to make on the order of a 1000 cards like this. A work around as using a “basic type” and having a “SentenceBlank” and “SentenceComplete” field to have cards like:
Front:
Estoy _____ (hablar)
Back:
Estoy hablando (hablar)

But this would require an (1) extra copy/paste step into a different field (2) Typing “_____” over the verb (3) Coloring the verb in the answer stem. I would need to repeat these steps 1000+ times for the expected cards. There are also features of the Cloze type that are convenient, like having the cloze highlighted in a different color. To do this manually in the basic type would be another task to repeat a 1000+ times.

It might help you to think about the logic of how cloze cards are created.

  • Anki looks at the front template to know what fields are cloze-filtered (i.e. can have cloze markers).
  • To make card 1, Anki looks at those fields and finds every c1-marker. Then Anki shows the contents of each c1-marked field with the c1 text covered.
  • To make card 2, Anki looks at those fields and finds every c2-marker. Then Anki shows the contents of each c2-marked field with the c2 text covered.
  • etc.

So, you can use an empty cloze marker to force a card to be created. Add it to the Audio field:

[File containing audio]{{c2::}}

Your front/back templates will need to have a cloze field replacement for each field you want Anki to look in:

{{cloze:Cloze}}
{{cloze:Audio}}

The type of instructions you’re putting on the card (“Fill in the blank,” “Answer the question,” “Listen to the following,” “Listen, what is it saying”) usually aren’t necessary. It doesn’t seem likely that you won’t know what to do when you see these cards, and extra text is just a distraction.

But if it is important to you to have them, at the very least, you should put them in your template and not in a field of every card. Try using conditional replacement so the static text only shows up on the correct card – Card Generation - Anki Manual .

{{#c1}}
Answer the question:<br>
{{cloze:Cloze}}
{{/c1}}

If you mean for that “(hablar)” to be a hint – why not use cloze hints for that? Adding/Editing - Anki Manual

Are you saying you want it without the “hablando” or without the “(hablar)”? I believe the “(hablar)” will go away if you use cloze hints. I can’t think of any way to hide the “hablando” – but I’m also not sure why you wouldn’t want to show the answer on the back of he card. How else do you check if you got it right?

3 Likes

This still has the original problem after putting empty cloze in the audio field.

For example in this case:

Front

{{cloze::ClozeSpanish}}
{{cloze::Audio}}

Back

{{cloze::ClozeSpanish}}
{{cloze::Audio}}

I also get the same behavior with this setup as the front and back.

{{#c1}}
Answer the question:<br><br>
{{cloze:ClozeSpanish}}
{{/c1}}

{{#c2}}
Answer the question:<br><br>
{{cloze:Audio}}
{{/c2}}

The audio does not play on the card’s backside when the ClozeSpanish cloze is presented. And similarly, when the Audio cloze is presented, the backside does not have the sentence in Spanish.

I have a use case with a text->MP3 program such that the Cloze hints would disrupt the text->audio conversion.

This may have been a miscommunication since I was likely doing a bad behavior. In the back template, if I use a field (e.g. Question) with a cloze but use {{Question}} instead of {{cloze:Question}}, it directly outputs text including the {{c1:…}}. This happens if I try to brute force the audio to play in the back template (i.e. it prints {{c2:}}; see photo attached).

You’ll definitely need another {{Field Replacement}} for those additional fields if you want them to show up not on their card.

Something outside of Anki, I presume? Does it have text processing, like the HyperTTS add-on? I’ve never tried that part, but it seems like it would be able to handle excluding the hints.

Well, something’s gotta give, right? :sweat_smile: You’re trying to use a cloze note type to make 2 cards, neither of which really needs to be cloze at all. [I skipped past the usual caution I give – In many languages, it’s not worth studying every conjugation separately from the others, or separately for every verb – especially if the conjugations are regular. Is this the right approach to take for Spanish?]

If you want those additional fields on the back, you could –

  • Accept that you’ll have a little cloze-marker chaff along with them.
  • Hide the field, for the audio one anyway. So no play button, but no cloze-marker.
  • Do the extra work to make un-marked versions of these fields on your notes – something like add the extra fields to your note type, Change Note Type to the same type, map each field to 2 fields, Find and Replace to remove the markers from the 2nd one.
  • Devise/discover some masterful solution with JS to strip out the cloze markers when displaying the field. [I’m not the right person to ask about that, but it seems like it could exist.]

Hi @Danika_Dakika . I think the short answer is you do not know how to solve the problem. I will keep looking for a solution.

I’m not sure I completely understand the desired setup from the description, but it sounds like you can achieve it easier if you put all the clozes (including the dummy one) into the same cloze field:

Estoy {{c1::hablando}} por teléfono con mi madre (hablar){{c2::}}

and use this for the front side template:

{{#c1}}
Answer the question
<br><br>
{{cloze:ClozeSpanish}}
{{/c1}}

{{#c2}}
Listen to the following
<br><br>
{{Audio}}
{{/c2}}

and this for the back:

{{#c1}}
Answer the question
<br><br>
{{cloze:ClozeSpanish}}
<br><br>
{{Audio}}
{{/c1}}

{{#c2}}
Listen to the following
<br><br>
{{cloze:ClozeSpanish}}
<br><br>
{{Audio}}
{{/c2}}

Alternatively, if you are aiming to make only a single cloze card out of each note, I think you’d be better off using regular note type instead of a cloze one. Cloze types’ main advantage is the ability to make an unspecified number of similar cards from a single note – anything else can be replicated in a regular note type with a bit of CSS. This will also remove the need to add the empty cloze to each note.

1 Like

I’m having trouble visualizing exactly what you want, but my understanding is that you don’t want a cloze card. You want to fill in a blank in a basic card.

I only know basic programming stuff, but this can be ‘easily’ done. I use spoilers on my cards. I tried finding my original source, but it was years ago and I can’t find it again. Someone set up some autohotkey shortcuts, and now I can’t find them again.

In any case, the simplest version I think would be to use a spoiler tag and hover over the text when you are ready to see the answer. You could either split your blank sentence into two or 3 fields (if you want to automate the blank text and save some keystrokes in the long run), or you can flank the part to hide with some html.

To hide the text, this is what I use in the
Styling:

/*  SPOILERS  */

.spoiler { 
	font-style: normal;
	color: #252525; 
	text-shadow: none;
	background-color:#252525;
	padding: 0px 5px 0px;
}

.spoiler:hover {
	background-color: white; 
	text-shadow: 1px 1px 2px #DDDDDD;
}

Front template:
<span class="spoiler">{{Inglês}}</span>

You can either wrap the whole field or you can wrap a part of the field.

When I want to hide just a part of the field, the individual text needs to be wrapped in the span. I customized an addon to wrap the text for me:

Custom Styles (font color, background colour, classes)

If you want to make the card more like what you requested, then you can add some javascript to the back:

<!-- Spoiler reveal -->
<script>
    document.querySelectorAll('.spoiler').forEach(item => {
        item.style.setProperty('--spoiler-bg', 'transparent'); /* Make it transparent */
        item.style.setProperty('--hide-hint', 'none'); /* Hide hint */
        item.style.color = 'white'; /* Make answer text white */
    });
</script>

If you don’t want the answer when hovering, just delete the spoiler:hover CSS.

Finally, I decided to share my language learning template. It’s not posted yet as there is a 24 hour delay. But here is the link:

Language Template

Description

I am sharing my language learning template.
The field names can be edited to your liking. Mine is in Portuguese, but change it as desired. Each note has for fields:

  1. native text
  2. An image
  3. English text
  4. Audio (for native audio)
  5. Notes just in case desired (not sure I use that field, but it can be added to cards)
  6. Extra image fields to be used if there is a noun with multiple meanings. A few other fields unrelated to the language learning that I use.

If all the main fields are filled, then 5 cards will be generated. As an example, if you are studying Portuguese, you will get Audio → native Text Audio → Image(and/or English text) Image/English → Audio Image/Englsih → native text Native text → English.

This will enable you to learn the vocabulary forwards and backwards. It provides the flexibility to Immerse yourself in the language by leaving the English field empty. Or you can have both the English field and the picture, in which case it will have the English as a spoiler. Hovering will show the English. If you don’t want your card to show a picture, then you can leave the picture blank.

1 Like

Perhaps an even simpler approach would be to repurpose one of the stock text formatting tools. This will make it easier to edit in general and a valid option for non-desktop apps. For example, adding this style:

.b-cloze b {
	color: transparent;
	border-bottom: solid var(--fg, black) .1em;
	display: inline-block;
	vertical-align: bottom;
	height: 0;
	width: 1.5em;
}

will make the parts of the text, marked in the editor as bold:
image
look like this on the Card:
image

when it is placed inside the respective class. Any other styling, like revealing the word when hovered, can be attached to this just as well.

1 Like

Yes, there are lots of options. I didn’t know about that trick. Thanks!!!

2 Likes

This does not make a card with just the audio. My desired output is at least two cards:

  1. Spanish sentence with a cloze containing the conjugated verb
  2. A card only showing the audio that then shows the full sentence

However I would also like the ability to make a card that also has:
3. A cloze with the English as a hint (i.e. {{c1::hablar::to speak}}), then plays the audio and shows the complete setence above from #1 and #2.
4. A card with an English sentence that then plays the audio and shows the complete sentence in spanish.

I think you understand what I am trying to do, so I am interested to look at your language template. But I am worried this won’t work for me. I typically do a large amount of my reviews while on the treadmill with a controller, so hovering won’t be an option.

I do indeed want a cloze card (unless there is some clean macro for making the blank (i.e. “____”)). I have made a few alreay and its pretty ungainly, but I do think finding a way to solve the problem with the existing cloze functionality would be the best.

What I have now is here. But I expect there is a more efficient way, prompting the original post.

Font Templates

Back Template

I think Eltaurus’s idea is the best option. Not sure there is an easy way to simplify things for you. at least not with my limited knowledge.

1 Like

Thanks for giving it a go! And for your detailed reply. I really appreciate it. I will also give your template a go to see what I can learn from what you have implemented. Thanks again!

I think I am understanding a little better. Every “cloze” card is a fill in the blank. You want a fill in the blank card generated from a regular note.

there is an old note type called “cloze anything” that allows you to do this.
It still works:

Cloze Anything

1 Like

I’m not sure what you mean. The setup I suggested produces these two cards:

I don’t see anything about them that doesn’t fit the description


In general, you can add any number of Card Types this way. Just put the respective code for each type inside {{#c…}} / {{/c…}} conditions with respective numbers inside Card Template, and make sure you have the required number of clozes anywhere inside the Cards’ Fields.

If you want the same part being clozed in multiple Cards, in particular, you can use nested clozes:

{{c3::{{c1::hablar}}::to speak}}

Why though? For everything you described so far, regular Cards Types seem like a much better fit than Cloze Cards.

What’s wrong with the repurposed bold formatting I suggested previously? From the editing standpoint, it will work exactly the same as adding clozes: you will only press the b button instead of the […] one. And it will also remove the need for dummy clozes you will otherwise have to make each time in order to get your non-Cloze Cards with a Cloze Note Type.

1 Like