{% if results %}
  <ul class="list-unstyled mb-0" id="exam_search_results_list_{{ field }}">
    {% for item in results %}
      <li class="py-1 d-flex justify-content-between align-items-center"
          data-exam-id="{{ item.id }}" data-exam-text="{{ item.text|escapejs }}"
          data-exam-archive="{{ item.archive|yesno:'1,0' }}" data-exam-open-access="{{ item.open_access|yesno:'1,0' }}"
          data-exam-exam-mode="{{ item.exam_mode|yesno:'1,0' }}" data-exam-candidates-only="{{ item.candidates_only|yesno:'1,0' }}">
        <div class="flex-grow-1">
          {{ item.text|escape }}
          {% if item.archive %}<span class="badge bg-secondary ms-2">Archived</span>{% endif %}
          {% if item.open_access %}<span class="badge bg-success ms-2">Open</span>{% endif %}
          {% if item.exam_mode %}<span class="badge bg-info text-dark ms-2">Exam mode</span>{% endif %}
          {% if item.candidates_only %}<span class="badge bg-warning text-dark ms-2">Candidates only</span>{% endif %}
        </div>
        <div>
          <button type="button" class="btn btn-sm btn-primary exam-add-btn" data-exam-id="{{ item.id }}" data-exam-text="{{ item.text|escapejs }}">Add</button>
        </div>
      </li>
    {% endfor %}
  </ul>
  {% if results %}
    <div class="mt-2 text-end">
      <button type="button" class="btn btn-sm btn-outline-success exam-add-all-btn" data-field="{{ field }}">Add all results</button>
    </div>
  {% endif %}
{% else %}
  <div><em>No exams found</em></div>
{% endif %}
