Files
myep-team/templates/questionnaire/_answers.html.twig
T

80 lines
5.1 KiB
Twig
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{#
# Questionnaire answers, read-only. Expects `definition` (the version they were given under) and
# `answers`, keyed by question key; optionally the response's `context`, whose `teamers` name the
# placements the house manager's teamer questions are keyed by. Questions that are hidden or were left open are skipped; an
# answer the definition does not know (an option key since renamed) is shown as stored rather
# than dropped.
#}
{% set context = context|default({}) %}
<div class="flex flex-col gap-y-8">
{% for section in definition.sections %}
{% set shown = section.questions|filter(question => answers[question.key] is defined and definition.isVisible(question, answers)) %}
{% if shown is not empty %}
<section>
{% if section.title %}
<h2 class="text-lg font-bold pb-2">
{{ section.title }}
</h2>
{% endif %}
<dl class="divide-y divide-gray-100">
{% for question in shown %}
{% set answer = answers[question.key] %}
<div class="py-4 sm:grid sm:grid-cols-2 sm:gap-4">
<dt class="text-sm font-bold leading-6 text-gray-900">
{{ question.label|nl2br }}
</dt>
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:mt-0">
{% if question.type.value == 'rating' %}
<span class="inline-flex items-center gap-x-2">
<span class="inline-flex items-center">
{% for grade in range(1, 5) %}
{{ icon('star', html_classes('w-4 h-4', { 'text-gray-200': answer < grade, 'text-primary': answer >= grade })) }}
{% endfor %}
</span>
{{ answer }} von 5
</span>
{% elseif question.type.value == 'choice' %}
{{ (question.option(answer).label ?? answer) }}
{% elseif question.type.value == 'multi' %}
{{ answer|map(key => (question.option(key).label ?? key))|join(', ') }}
{% elseif question.type.value == 'date' %}
{{ answer|date('d.m.Y') }}
{% elseif question.type.value in ['teamer_guidings', 'teamer_courses'] %}
{# one row per teamer and type; a draft's teamer without a type has nothing to show #}
<ul>
{% for row in answer|filter(row => row.type is defined) %}
<li>
<span class="font-bold">{{ context.teamers[row.disposition].name ?? row.disposition }}</span>
{{ question.option(row.type).label ?? row.type }}:
{% if question.type.value == 'teamer_guidings' %}
{{ row.count ?? '-' }} × mit je {{ row.participants ?? '-' }} Teilnehmenden
{% else %}
{{ row.days ?? '-' }} × {{ (row.hours_per_day ?? '-')|replace({'.': ','}) }} Stunden
{%- if row.dates ?? [] is not empty %},
{{ row.dates|map(date => date|format_datetime(pattern='EEEEEE dd.MM.', locale='de'))|join(', ') }}
{%- endif %}
{% endif %}
</li>
{% endfor %}
</ul>
{% elseif question.type.value == 'programme' %}
<ul>
{% for row in answer.items ?? [] %}
<li>{{ question.option(row.item).label ?? row.item }}: {{ row.participants ?? '-' }} Teilnehmende</li>
{% endfor %}
{% if answer.other is defined %}
<li>Sonstiges: {{ answer.other|nl2br }}</li>
{% endif %}
</ul>
{% else %}
{{ answer|nl2br }}
{% endif %}
</dd>
</div>
{% endfor %}
</dl>
</section>
{% endif %}
{% endfor %}
</div>