Cloze one by one Ankidoid issue

Hello, I’m using a note type that allows clozes one by one. It works perfectly on windows, Mac and iOS. But on Ankidroid it only shows the hint of the cloze if you view the card by searching it in the browser. When reviewing the card, everything works fine, but the hint doesn’t show. The problem appears to be that the hint is not being saved from the front to the back template on Ankidroid reviewng only.

Example:

A bird is {{c1::blue::color}}

The hint “color” doesn’t appear when reviewing the card only on Ankidroid, but appears when viewing the card in the browser on Ankidroid.

Can this possibly be an issue with the code of the card or it’s an Ankidroid issue?

Section of code from the front template:

window.clozeHints = [];
  if (clozeOneByOneEnabled) {
    // save cloze hint to use it on the back
    let clozes = document.getElementsByClassName("cloze");
    for(var i = 0; i < clozes.length; i++) {
      if (clozes[i].innerHTML === "[...]") {
        window.clozeHints.push("");
      } else {
        window.clozeHints.push(clozes[i].innerHTML);
      }
    }

Section of code from the back template

if (window.clozeHints && window.clozeHints[count]) {
          clozeReplacer.classList.add("cloze-hint");
          clozeReplacer.innerHTML = window.clozeHints[count] + CLOZE_REPLACER_SEP;
        } else {
          clozeReplacer.innerHTML = clozeHider(cloze) + CLOZE_REPLACER_SEP;
        }
        count += 1;
        if (initial) {
          cloze.addEventListener("touchend", revealClozeClicked);
          cloze.addEventListener("click", revealClozeClicked);
        }
      }

The note type autoflips to the back template, so the user interacts with the cloze one by one and it’s hint on the back of the card

iirc, in contrast to desktop version, which embeds cards into the same html container and reloads only the relevant part, Ankidroid opens each side of each card as entirely different html page. So any variable values you are storing to window won’t persist. If you need to pass information between different sides of a card – use sessionStorage instead. It would work equally well on any platform.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.