title: AnkiDroid: Multiple choice questions card with randomized answers
body: <p>I have this card that works perfectly in Anki for PC: the correct answer must be in bold, it will make the highlight on the back of the card appear.
  My problem is that the bold highlight is not shown in the Anki app for Android (Ankidroid) and I have no idea why.
  Could someone please help me?</p>
  <p><strong>Front Template</strong></p>
  <pre><code>&lt;section id=&quot;kard&quot;&gt;
      &lt;article&gt;
          &lt;div class=&quot;tags&quot;&gt;#tags: {{Tags}}&lt;/div&gt;
  
          {{#Pergunta}}
          &lt;div id=&quot;choicesContainer&quot; class=&quot;sample&quot;&gt;
              {{Pergunta}}
              &lt;ol class=&quot;answerList&quot;&gt;
                  &lt;li id=&quot;answer1&quot; class=&quot;answer&quot;&gt;{{Resposta}}&lt;/li&gt;
                  &lt;li id=&quot;answer2&quot; class=&quot;answer&quot;&gt;{{Errada-1}}&lt;/li&gt;
                  &lt;li id=&quot;answer3&quot; class=&quot;answer&quot;&gt;{{Errada-2}}&lt;/li&gt;
                  &lt;li id=&quot;answer4&quot; class=&quot;answer&quot;&gt;{{Errada-3}}&lt;/li&gt;
                  &lt;li id=&quot;answer5&quot; class=&quot;answer&quot;&gt;{{Errada-4}}&lt;/li&gt;
              &lt;/ol&gt;
          &lt;/div&gt;
          {{/Pergunta}}
      &lt;/article&gt;
  &lt;/section&gt;
  
  &lt;script&gt;
      var arrayElements = [];
  
      ((function () {
          var hasReview = typeof (review) !== 'undefined' &amp;&amp; review.arrayElements;
          var parent = document.getElementsByClassName('answerList')[0];
          var elements = [...document.getElementsByClassName('answer')];
  
          var elementAnswer = elements.find(c =&gt; [...c.childNodes].find(d =&gt; d.nodeName == 'B') &amp;&amp; (c.innerText = c.innerText));
          if (!elementAnswer) {
              var el = document.getElementById('choicesContainer');
              el.style = &quot;color:#ee8f1a&quot;;
              el.innerHTML = 'É necessário que a resposta correta esteja NEGRITADA.';
          } else {
              elementAnswer.setAttribute('data-correct', true);
          }
  
          elements.forEach(c =&gt; {
              c.id = Math.floor(Math.random() * 1000);
              arrayElements.push(parent.removeChild(c));
          });
  
          arrayElements = hasReview ? review.arrayElements : arrayElements;
  
          arrayElements.sort((a, b) =&gt; a.id - b.id);
          arrayElements.filter(c =&gt; c.innerText.trim().length)
              .forEach(d =&gt; parent.append(d));
  
          if (!hasReview) {
              review = {
                  arrayElements
              };
          } else {
              review = undefined
          }
      }))()
  &lt;/script&gt;
  </code></pre>
  <p><strong>Styling</strong></p>
  <pre><code>html {
      overflow: scroll;
      overflow-x: hidden;
  }
  
  /* CONTENÇÃO PARA OS CARTÕES */
  #kard {
      padding: 0px 0px;
      max-width: 800px;
      margin: 0 auto;
      word-wrap: break-word;
  }
  
  .card {
      font-family: Open Sans;
      font-size: 20px;
      text-align: left;
      color: #D7DEE9;
      background-color: #333B45;
  }
  
  /* AJUSTE PARA AS ALTERNATIVAS SEREM &quot;a)&quot; , &quot;b)&quot;, &quot;c)&quot;, &quot;d)&quot; e &quot;e)&quot; */
  ol {
    counter-reset: list;
  }
  ol li {
    list-style: none;
  }
  ol li:before {
    content: counter(list, lower-alpha) &quot;) &quot;;
    counter-increment: list;
  }
  
  /* ESTILO PARA AS TAGS APARECEREM NO TOPO DO CARTÃO QUANDO PASSAR O MOUSE */
  .tags {
      color: #ee8f1a;
      opacity: 0;
      font-size: 10px;
      width: 100%;
      text-align: center;
      text-transform: ;
      position: fixed;
      padding: 0;
      top: 0;
      right: 0;
  }
  
  .tags:hover {
      opacity: 1;
      position: fixed;
  }
  
  /* ESTILO DE IMAGEM (para alterar a proporção, mexer apenas em max-width (&quot;%&quot; ou &quot;px&quot; (pixies)) */
  img {
      display: block;
      max-width: 100%;
  }
  
  /* ESTILO DE TABELA (apenas para alterar o tamanho da fonte &quot;px&quot; (pixies)) */
  tr {
      font-size: 18px;
  }
  
  /* ESTILO PARA O CONTAINER EXTRA */
  .extraContainer {
      padding-top: 20px;
  }
  
  /* ESTILO PARA O TITULO DO CAMPO EXTRA */
  .extraTitle {
      font-weight: bold;
      color: #ee8f1a;
  }
  
  /* COR E ESTILO PARA O NEGRITO (b), ITÁLICO (i) E SUBLINHADO (u) */
  
  /* ESTILO NEGRITO (b) */
  b {
      font-weight: bold;
      color: #C695C6;
  }
  
  /* ESTILO ITÁLICO (i) */
  i {
      font-weight: normal;
      font-style: normal;
      text-decoration: none;
      color: #64bfbf;
  }
  
  /* ESTILO SUBLINHADO (u) */
  u {
      text-decoration: none;
      color: #F08080;
  }
  
  /* ESTILO PARA LINKS */
  a {
      color: LightGray;
  }
  
  /* AJUSTES PARA CELULARES */
  .mobile .card {
      color: #D7DEE9;
      background-color: #333B45;
  }
  
  .mobile .tags:hover {
      opacity: 1;
      position: relative;
  }
  
  </code></pre>
  <p><strong>Back Template</strong></p>
  <pre><code>&lt;section id=&quot;kard&quot;&gt;
      &lt;div class=&quot;tags&quot;&gt;#tags: {{Tags}}&lt;/div&gt;
  
  &lt;section id=&quot;kard&quot;&gt;
      &lt;article&gt;
          &lt;div class=&quot;tags&quot;&gt;#tags: {{Tags}}&lt;/div&gt;
  
          {{#Pergunta}}
          &lt;div id=&quot;choicesContainer&quot; class=&quot;sample&quot;&gt;
              {{Pergunta}}
              &lt;ol class=&quot;answerList&quot;&gt;
                  &lt;li id=&quot;answer1&quot; class=&quot;answer&quot;&gt;{{Resposta}}&lt;/li&gt;
                  &lt;li id=&quot;answer2&quot; class=&quot;answer&quot;&gt;{{Errada-1}}&lt;/li&gt;
                  &lt;li id=&quot;answer3&quot; class=&quot;answer&quot;&gt;{{Errada-2}}&lt;/li&gt;
                  &lt;li id=&quot;answer4&quot; class=&quot;answer&quot;&gt;{{Errada-3}}&lt;/li&gt;
                  &lt;li id=&quot;answer5&quot; class=&quot;answer&quot;&gt;{{Errada-4}}&lt;/li&gt;
              &lt;/ol&gt;
          &lt;/div&gt;
          {{/Pergunta}}
      &lt;/article&gt;
  &lt;/section&gt;
  
  &lt;script&gt;
      var arrayElements = [];
  
      ((function () {
          var hasReview = typeof (review) !== 'undefined' &amp;&amp; review.arrayElements;
          var parent = document.getElementsByClassName('answerList')[0];
          var elements = [...document.getElementsByClassName('answer')];
  
          var elementAnswer = elements.find(c =&gt; [...c.childNodes].find(d =&gt; d.nodeName == 'B') &amp;&amp; (c.innerText = c.innerText));
          if (!elementAnswer) {
              var el = document.getElementById('choicesContainer');
              el.style = &quot;color:#ee8f1a&quot;;
              el.innerHTML = 'É necessário que a resposta correta esteja NEGRITADA.';
          } else {
              elementAnswer.setAttribute('data-correct', true);
          }
  
          elements.forEach(c =&gt; {
              c.id = Math.floor(Math.random() * 1000);
              arrayElements.push(parent.removeChild(c));
          });
  
          arrayElements = hasReview ? review.arrayElements : arrayElements;
  
          arrayElements.sort((a, b) =&gt; a.id - b.id);
          arrayElements.filter(c =&gt; c.innerText.trim().length)
              .forEach(d =&gt; parent.append(d));
  
          if (!hasReview) {
              review = {
                  arrayElements
              };
          } else {
              review = undefined
          }
      }))()
  &lt;/script&gt;
      &lt;article id=&quot;extraContainer&quot; class=&quot;extraContainer&quot;&gt;
          {{#Extra}}
          &lt;span class=&quot;extraTitle&quot;&gt;Extra&lt;/span&gt;&lt;br&gt;{{Extra}}
          {{/Extra}}
      &lt;/article&gt;
  &lt;/section&gt;
  &lt;script&gt;
      const answer = arrayElements.find(c =&gt; c.getAttribute('data-correct') == 'true');
      if (answer) {
          answer.style.color = &quot;#3fc178&quot;;
          answer.style.fontWeight = 'bold';
  
      }
      review = undefined;
  &lt;/script&gt;
  </code></pre>