427 lines
26 KiB
HTML
427 lines
26 KiB
HTML
{# Eingabefelder je Fragetyp. Die Prüfung macht immer der Server. #}
|
||
|
||
{% macro required_mark(q) %}{% if q.required %}<span class="req" aria-hidden="true"> *</span>{% endif %}{% endmacro %}
|
||
|
||
{% macro describedby(name, q, err) -%}
|
||
{%- set ids = [] -%}
|
||
{%- if q.help_text %}{% set _ = ids.append(name ~ '-help') %}{% endif -%}
|
||
{%- if err %}{% set _ = ids.append(name ~ '-error') %}{% endif -%}
|
||
{%- if ids %} aria-describedby="{{ ids | join(' ') }}"{% endif -%}
|
||
{%- endmacro %}
|
||
|
||
{% macro help_and_error(name, q, err, errors_text) %}
|
||
{% if q.help_text %}<p class="hint" id="{{ name }}-help">{{ q.help_text }}</p>{% endif %}
|
||
{% if err %}<p class="field-error" id="{{ name }}-error">{{ _(errors_text[err]) }}</p>{% endif %}
|
||
{% endmacro %}
|
||
|
||
{% macro question_media(q, media_base, embed_policy) %}
|
||
{% set m = q.config.get('media') or {} %}
|
||
{% if m.kind == 'images' and m['items'] %}
|
||
<div class="q-media gallery{% if m['items'] | length == 1 %} single{% endif %}">
|
||
{% for item in m['items'] %}
|
||
<a href="{{ media_base }}/{{ item.id }}" target="_blank" rel="noopener">
|
||
<img src="{{ media_base }}/{{ item.id }}{% if m['items'] | length > 1 %}/thumb{% endif %}" alt="{{ item.alt }}" {% if item.w and m['items'] | length == 1 %}width="{{ item.w }}" height="{{ item.h }}"{% endif %} loading="lazy">
|
||
</a>
|
||
{% endfor %}
|
||
</div>
|
||
{% elif m.kind == 'video' and m.id %}
|
||
<div class="q-media">
|
||
<video controls preload="metadata" src="{{ media_base }}/{{ m.id }}" {% if m.poster %}poster="{{ media_base }}/{{ m.poster }}"{% endif %} {% if m.title %}aria-label="{{ m.title }}"{% endif %}>
|
||
{% if m.captions %}<track kind="captions" src="{{ media_base }}/{{ m.captions }}" srclang="{{ m.captions_lang or 'de' }}" default>{% endif %}
|
||
<a href="{{ media_base }}/{{ m.id }}">{{ _('Download video') }}</a>
|
||
</video>
|
||
</div>
|
||
{% elif m.kind == 'embed' %}
|
||
{% set info = embed_info(m, embed_policy) %}
|
||
{% if info and not info.consent and info.file %}
|
||
<div class="q-media">
|
||
<video controls preload="metadata" src="{{ info.player }}" {% if m.title %}aria-label="{{ m.title }}"{% endif %}></video>
|
||
</div>
|
||
{% elif info and not info.consent %}
|
||
<div class="q-media embed embed-open">
|
||
<iframe class="embed-frame" src="{{ info.player }}" title="{{ m.title or info.provider }}" allow="fullscreen; picture-in-picture; encrypted-media" allowfullscreen sandbox="allow-scripts allow-same-origin allow-presentation allow-popups" referrerpolicy="strict-origin" loading="lazy"></iframe>
|
||
</div>
|
||
{% elif info %}
|
||
<div class="q-media embed" data-player="{{ info.player }}" data-kind="{{ 'file' if info.file else 'frame' }}" data-title="{{ m.title or info.provider }}">
|
||
<p>{{ _('This video is provided by %(provider)s. When you load it, data such as your IP address is sent to %(provider)s.', provider=info.provider) }}</p>
|
||
<p class="actions">
|
||
<button type="button" class="secondary embed-load">{{ _('Load video') }}</button>
|
||
<a href="{{ info.watch }}" target="_blank" rel="noopener noreferrer">{{ _('Watch at %(provider)s', provider=info.provider) }}</a>
|
||
</p>
|
||
</div>
|
||
{% endif %}
|
||
{% endif %}
|
||
{% endmacro %}
|
||
|
||
{% macro option_tiles(q, name, vals, multiple, media_base, required) %}
|
||
<div class="tiles">
|
||
{% for o in q.config.options %}
|
||
<label class="tile">
|
||
<input type="{{ 'checkbox' if multiple else 'radio' }}" name="{{ name }}" value="{{ o.id }}" {% if o.id in vals %}checked{% endif %} {% if required and not multiple %}required{% endif %}>
|
||
{% if o.image %}<img src="{{ media_base }}/{{ o.image }}/thumb" alt="" loading="lazy">{% else %}<span class="tile-blank" aria-hidden="true"></span>{% endif %}
|
||
<span class="tile-label">{{ o.label }}</span>
|
||
</label>
|
||
{% endfor %}
|
||
</div>
|
||
{% endmacro %}
|
||
|
||
{% macro question_block(q, values, errors, errors_text, media_base='', embed_policy=none, files={}, accept_for=none, places={}, own_status={}) %}
|
||
{{ question_media(q, media_base, embed_policy) }}
|
||
{% set name = 'q' ~ q.id %}
|
||
{% set err = errors.get(q.id) %}
|
||
{% set val = (values.get(name) or [''])[0] %}
|
||
{% set vals = values.get(name) or [] %}
|
||
{% set other = (values.get(name ~ '_other') or [''])[0] %}
|
||
{% set cfg = q.config %}
|
||
{% if q.type == 'heading' %}
|
||
<h2 class="q-heading">{{ q.label }}</h2>
|
||
{% elif q.type == 'info' %}
|
||
<div class="q-info">{{ q.label }}</div>
|
||
{% elif q.type == 'page_break' %}
|
||
<hr class="q-break">
|
||
{% if q.label %}<h2 class="q-heading page-title" tabindex="-1">{{ q.label }}</h2>{% endif %}
|
||
{% elif q.type in ('yes_no', 'single_choice', 'multiple_choice', 'ranking', 'rating', 'file_upload', 'slots', 'poll') and not (q.type == 'single_choice' and cfg.display == 'dropdown') %}
|
||
<fieldset class="question{% if err %} has-error{% endif %}" id="{{ name }}"{{ describedby(name, q, err) }}>
|
||
<legend>{{ q.label }}{{ required_mark(q) }}</legend>
|
||
{{ help_and_error(name, q, err, errors_text) }}
|
||
{% if q.type == 'yes_no' %}
|
||
<div class="choices inline">
|
||
<label class="check"><input type="radio" name="{{ name }}" value="yes" {% if val == 'yes' %}checked{% endif %} {% if q.required %}required{% endif %}> {{ cfg.label_yes or _('Yes') }}</label>
|
||
<label class="check"><input type="radio" name="{{ name }}" value="no" {% if val == 'no' %}checked{% endif %}> {{ cfg.label_no or _('No') }}</label>
|
||
</div>
|
||
{% elif q.type == 'single_choice' and cfg.display == 'images' %}
|
||
{{ option_tiles(q, name, [val], false, media_base, q.required) }}
|
||
{% if cfg.allow_other %}
|
||
<div class="choices">
|
||
<label class="check"><input type="radio" name="{{ name }}" value="__other__" {% if val == '__other__' %}checked{% endif %}> {{ _('Other') }}:</label>
|
||
<input type="text" name="{{ name }}_other" maxlength="500" value="{{ other }}" aria-label="{{ _('Other') }}">
|
||
</div>
|
||
{% endif %}
|
||
{% elif q.type == 'single_choice' %}
|
||
<div class="choices">
|
||
{% for o in cfg.options %}
|
||
<label class="check"><input type="radio" name="{{ name }}" value="{{ o.id }}" {% if val == o.id %}checked{% endif %} {% if q.required %}required{% endif %}> {{ o.label }}</label>
|
||
{% endfor %}
|
||
{% if cfg.allow_other %}
|
||
<label class="check"><input type="radio" name="{{ name }}" value="__other__" {% if val == '__other__' %}checked{% endif %}> {{ _('Other') }}:</label>
|
||
<input type="text" name="{{ name }}_other" maxlength="500" value="{{ other }}" aria-label="{{ _('Other') }}">
|
||
{% endif %}
|
||
</div>
|
||
{% elif q.type == 'multiple_choice' and cfg.display == 'images' %}
|
||
{{ option_tiles(q, name, vals, true, media_base, false) }}
|
||
{% if cfg.allow_other %}
|
||
<div class="choices">
|
||
<label class="check"><input type="checkbox" name="{{ name }}" value="__other__" {% if '__other__' in vals %}checked{% endif %}> {{ _('Other') }}:</label>
|
||
<input type="text" name="{{ name }}_other" maxlength="500" value="{{ other }}" aria-label="{{ _('Other') }}">
|
||
</div>
|
||
{% endif %}
|
||
{% if cfg.min_select or cfg.max_select %}
|
||
<p class="hint">
|
||
{% if cfg.min_select and cfg.max_select %}{{ _('Choose between %(a)s and %(b)s options.', a=cfg.min_select, b=cfg.max_select) }}
|
||
{% elif cfg.min_select %}{{ _('Choose at least %(a)s options.', a=cfg.min_select) }}
|
||
{% else %}{{ _('Choose at most %(b)s options.', b=cfg.max_select) }}{% endif %}
|
||
</p>
|
||
{% endif %}
|
||
{% elif q.type == 'multiple_choice' %}
|
||
<div class="choices">
|
||
{% for o in cfg.options %}
|
||
<label class="check"><input type="checkbox" name="{{ name }}" value="{{ o.id }}" {% if o.id in vals %}checked{% endif %}> {{ o.label }}</label>
|
||
{% endfor %}
|
||
{% if cfg.allow_other %}
|
||
<label class="check"><input type="checkbox" name="{{ name }}" value="__other__" {% if '__other__' in vals %}checked{% endif %}> {{ _('Other') }}:</label>
|
||
<input type="text" name="{{ name }}_other" maxlength="500" value="{{ other }}" aria-label="{{ _('Other') }}">
|
||
{% endif %}
|
||
</div>
|
||
{% if cfg.min_select or cfg.max_select %}
|
||
<p class="hint">
|
||
{% if cfg.min_select and cfg.max_select %}{{ _('Choose between %(a)s and %(b)s options.', a=cfg.min_select, b=cfg.max_select) }}
|
||
{% elif cfg.min_select %}{{ _('Choose at least %(a)s options.', a=cfg.min_select) }}
|
||
{% else %}{{ _('Choose at most %(b)s options.', b=cfg.max_select) }}{% endif %}
|
||
</p>
|
||
{% endif %}
|
||
{% elif q.type == 'ranking' %}
|
||
<p class="hint">{{ _('Give each option a place: 1 is your first choice.') }}</p>
|
||
<div class="ranking">
|
||
{% set n = cfg.options | length %}
|
||
{% for o in cfg.options %}
|
||
{% set rank_name = name ~ '_rank_' ~ o.id %}
|
||
{% set rank_val = (values.get(rank_name) or [''])[0] %}
|
||
<label class="rank-row">
|
||
<select name="{{ rank_name }}">
|
||
<option value="">–</option>
|
||
{% for i in range(1, n + 1) %}<option value="{{ i }}" {% if rank_val == i|string %}selected{% endif %}>{{ i }}</option>{% endfor %}
|
||
</select>
|
||
<span>{{ o.label }}</span>
|
||
</label>
|
||
{% endfor %}
|
||
</div>
|
||
{% elif q.type == 'slots' and cfg.single %}
|
||
{% set a = places.get(q.id, {}).get('single') %}
|
||
{% set st = own_status.get((q.id, 'single')) %}
|
||
{% set mine = 'single' in vals %}
|
||
{% set full = a is not none and a.full %}
|
||
<div class="choices slots">
|
||
<label class="check slot{% if full %} full{% endif %}{% if full and cfg.hide_full and not mine and not err %} row-hidden{% endif %}" data-slots="{{ q.id }}" data-option="single" data-waitlist="{{ 'yes' if cfg.waitlist else 'no' }}">
|
||
<input type="checkbox" name="{{ name }}" value="single" {% if mine %}checked{% endif %} {% if full and not mine and not cfg.waitlist %}disabled{% endif %} {% if q.required %}required{% endif %}>
|
||
<span>{{ _('Sign up') }}</span>
|
||
<span class="slot-state">{{ slot_state(a, st, full, cfg.waitlist) }}</span>
|
||
{{ slot_names_line(q, 'single') }}
|
||
</label>
|
||
</div>
|
||
{% elif q.type == 'slots' %}
|
||
{% set avail = places.get(q.id, {}) %}
|
||
<div class="choices slots" data-slots="{{ q.id }}" data-waitlist="{{ 'yes' if cfg.waitlist else 'no' }}">
|
||
{% for o in cfg.options %}
|
||
{% set a = avail.get(o.id) %}
|
||
{% set mine = o.id in vals %}
|
||
{% set st = own_status.get((q.id, o.id)) %}
|
||
{% set full = a is not none and a.full %}
|
||
{% if not (full and cfg.hide_full and not mine) %}
|
||
<label class="check slot{% if full %} full{% endif %}" data-option="{{ o.id }}">
|
||
<input type="{{ 'checkbox' if cfg.multiple else 'radio' }}" name="{{ name }}" value="{{ o.id }}" {% if mine %}checked{% endif %} {% if full and not mine and not cfg.waitlist %}disabled{% endif %} {% if q.required and not cfg.multiple %}required{% endif %}>
|
||
<span>{{ o.label }}</span>
|
||
<span class="slot-state">
|
||
{%- if st == 'waiting' %}{{ _('you are on the waiting list') }}
|
||
{%- elif st == 'confirmed' %}{{ _('booked for you') }}
|
||
{%- elif a is not none and a.capacity %}
|
||
{%- if full %}{% if cfg.waitlist %}{{ _('booked up, waiting list possible') }}{% else %}{{ _('booked up') }}{% endif %}
|
||
{%- else %}{{ ngettext('%(num)d place left', '%(num)d places left', a.free) }}{% endif %}
|
||
{%- endif -%}
|
||
</span>
|
||
{{ slot_names_line(q, o.id) }}
|
||
</label>
|
||
{% endif %}
|
||
{% endfor %}
|
||
</div>
|
||
{% elif q.type == 'poll' %}
|
||
{% set allowed_votes = ['yes', 'maybe', 'no'] if cfg.answers == 'ynm' else ['yes', 'no'] %}
|
||
{% set vote_names = {'yes': _('Yes'), 'maybe': _('Maybe'), 'no': _('No')} %}
|
||
<div class="poll">
|
||
{% for o in cfg.options %}
|
||
{% set vname = name ~ '_' ~ o.id %}
|
||
{% set cur = (values.get(vname) or [''])[0] %}
|
||
<div class="poll-row{% if o.id in (cfg.confirmed or []) %} confirmed{% endif %}" role="radiogroup" aria-label="{{ option_text(o) }}">
|
||
<span class="poll-option">{{ option_text(o) }}{% if o.proposed %} <span class="badge">{{ _('proposed') }}</span>{% endif %}{% if o.id in (cfg.confirmed or []) %} <span class="badge status-open">{{ _('confirmed') }}</span>{% endif %}</span>
|
||
<span class="poll-votes">
|
||
{% for v in allowed_votes %}<label class="poll-vote vote-{{ v }}"><input type="radio" name="{{ vname }}" value="{{ v }}" {% if cur == v %}checked{% endif %} {% if q.required %}required{% endif %}><span>{{ vote_names[v] }}</span></label>{% endfor %}
|
||
</span>
|
||
</div>
|
||
{% endfor %}
|
||
</div>
|
||
{% if cfg.allow_proposals %}
|
||
<div class="poll-propose">
|
||
{% if cfg.mode == 'dates' %}
|
||
<label>{{ _('Propose another date') }} <input type="date" name="{{ name }}_propose_date" value="{{ (values.get(name ~ '_propose_date') or [''])[0] }}"></label>
|
||
<label>{{ _('Time (optional)') }} <input type="time" name="{{ name }}_propose_time" value="{{ (values.get(name ~ '_propose_time') or [''])[0] }}"></label>
|
||
{% else %}
|
||
<label>{{ _('Propose another option') }} <input type="text" name="{{ name }}_propose_text" maxlength="200" value="{{ (values.get(name ~ '_propose_text') or [''])[0] }}"></label>
|
||
{% endif %}
|
||
<p class="hint">{{ _('Your proposal is added for everyone and counts as your “yes”.') }}</p>
|
||
</div>
|
||
{% endif %}
|
||
{% elif q.type == 'file_upload' %}
|
||
{% set kept = values.get(name ~ '_keep') or [] %}
|
||
{% set kept_files = files.get(q.id) or [] %}
|
||
{% if kept %}
|
||
<ul class="file-list">
|
||
{% for token in kept %}
|
||
{% set f = kept_files[loop.index0] if loop.index0 < kept_files | length else none %}
|
||
<li><label class="check"><input type="checkbox" name="{{ name }}_keep" value="{{ token }}" checked> {% if f %}{{ f.name }} <span class="hint">({{ f.size | filesize }})</span>{% else %}{{ _('File') }}{% endif %}</label></li>
|
||
{% endfor %}
|
||
</ul>
|
||
<p class="hint">{{ _('Uncheck a file to remove it.') }}</p>
|
||
{% endif %}
|
||
<input type="file" name="{{ name }}" {% if (cfg.max_files or 1) > 1 %}multiple{% endif %} {% if accept_for %}accept="{{ accept_for(q) }}"{% endif %} {% if q.required and not kept %}required{% endif %} aria-label="{{ q.label }}">
|
||
<p class="hint">
|
||
{{ ngettext('At most %(num)d file', 'At most %(num)d files', cfg.max_files or 1) }}, {{ _('each at most %(mb)s MB.', mb=cfg.max_mb or 10) }}
|
||
</p>
|
||
{% elif q.type == 'rating' %}
|
||
<div class="rating">
|
||
{% if cfg.label_min %}<span class="hint">{{ cfg.label_min }}</span>{% endif %}
|
||
{% for i in range(1, (cfg.scale_max or 5) + 1) %}
|
||
<label class="rating-point"><input type="radio" name="{{ name }}" value="{{ i }}" {% if val == i|string %}checked{% endif %} {% if q.required %}required{% endif %}><span>{{ i }}</span></label>
|
||
{% endfor %}
|
||
{% if cfg.label_max %}<span class="hint">{{ cfg.label_max }}</span>{% endif %}
|
||
</div>
|
||
{% endif %}
|
||
</fieldset>
|
||
{% elif q.type == 'participant_name' %}
|
||
{# Vorbelegung für Angemeldete: Name und Adresse aus dem Konto #}
|
||
{% set acct_parts = (user.display_name.rsplit(' ', 1) if user and user.display_name else []) %}
|
||
{% set first = (values.get(name ~ '_first') or [acct_parts[0] if acct_parts | length == 2 else ''])[0] %}
|
||
{% set last = (values.get(name ~ '_last') or [acct_parts[1] if acct_parts | length == 2 else ''])[0] %}
|
||
{% set email = (values.get(name ~ '_email') or [user.email if user and not values else ''])[0] %}
|
||
{% set email_mode = cfg.email or 'optional' %}
|
||
<fieldset class="question name-fields{% if err %} has-error{% endif %}" id="{{ name }}"{{ describedby(name, q, err) }}>
|
||
<legend>{{ q.label }}{{ required_mark(q) }}</legend>
|
||
{{ help_and_error(name, q, err, errors_text) }}
|
||
<div class="name-grid">
|
||
<label><span>{{ _('First name') }}<span class="req" aria-hidden="true"> *</span></span>
|
||
<input type="text" name="{{ name }}_first" maxlength="100" autocomplete="given-name" value="{{ first }}" required{% if err %} aria-invalid="true"{% endif %}>
|
||
</label>
|
||
<label><span>{{ _('Last name') }}<span class="req" aria-hidden="true"> *</span></span>
|
||
<input type="text" name="{{ name }}_last" maxlength="100" autocomplete="family-name" value="{{ last }}" required{% if err %} aria-invalid="true"{% endif %}>
|
||
</label>
|
||
{% if email_mode != 'off' %}
|
||
<label class="name-email"><span>{{ _('Email address') }}{% if email_mode == 'required' %}<span class="req" aria-hidden="true"> *</span>{% else %} <span class="hint">({{ _('optional') }})</span>{% endif %}</span>
|
||
<input type="email" name="{{ name }}_email" maxlength="254" autocomplete="email" value="{{ email }}"{% if email_mode == 'required' %} required{% endif %}>
|
||
</label>
|
||
{% endif %}
|
||
</div>
|
||
</fieldset>
|
||
{% else %}
|
||
<div class="question{% if err %} has-error{% endif %}" id="{{ name }}">
|
||
<label for="{{ name }}-input">{{ q.label }}{{ required_mark(q) }}</label>
|
||
{{ help_and_error(name, q, err, errors_text) }}
|
||
{% set common %}id="{{ name }}-input" name="{{ name }}"{{ describedby(name, q, err) }}{% if q.required %} required{% endif %}{% if err %} aria-invalid="true"{% endif %}{% endset %}
|
||
{% if q.type == 'short_text' %}
|
||
<input type="text" {{ common }} maxlength="{{ cfg.max_length or 200 }}" value="{{ val }}">
|
||
{% elif q.type == 'long_text' %}
|
||
<textarea {{ common }} rows="5" maxlength="{{ cfg.max_length or 5000 }}">{{ val }}</textarea>
|
||
{% elif q.type == 'email' %}
|
||
<input type="email" {{ common }} maxlength="254" autocomplete="email" value="{{ val }}">
|
||
{% elif q.type == 'phone' %}
|
||
<input type="tel" {{ common }} maxlength="40" autocomplete="tel" value="{{ val }}">
|
||
{% elif q.type == 'number' %}
|
||
<div class="with-unit">
|
||
<input type="text" inputmode="decimal" {{ common }} maxlength="30" value="{{ val }}">
|
||
{% if cfg.unit %}<span>{{ cfg.unit }}</span>{% endif %}
|
||
</div>
|
||
{% elif q.type == 'date' %}
|
||
<input type="date" {{ common }} {% if cfg.min_date %}min="{{ cfg.min_date }}"{% endif %} {% if cfg.max_date %}max="{{ cfg.max_date }}"{% endif %} value="{{ val }}">
|
||
{% elif q.type == 'time' %}
|
||
<input type="time" {{ common }} value="{{ val }}">
|
||
{% elif q.type == 'datetime' %}
|
||
<input type="datetime-local" {{ common }} value="{{ val }}">
|
||
{% elif q.type == 'single_choice' %}
|
||
<select {{ common }}>
|
||
<option value="">{{ _('Please choose') }}</option>
|
||
{% for o in cfg.options %}<option value="{{ o.id }}" {% if val == o.id %}selected{% endif %}>{{ o.label }}</option>{% endfor %}
|
||
{% if cfg.allow_other %}<option value="__other__" {% if val == '__other__' %}selected{% endif %}>{{ _('Other') }}</option>{% endif %}
|
||
</select>
|
||
{% if cfg.allow_other %}
|
||
<input type="text" name="{{ name }}_other" maxlength="500" value="{{ other }}" placeholder="{{ _('Other') }}" aria-label="{{ _('Other') }}">
|
||
{% endif %}
|
||
{% endif %}
|
||
</div>
|
||
{% endif %}
|
||
{% endmacro %}
|
||
|
||
{# Eintrag "Teilnahme mit Plätzen" mit genau einer Option: Zustand als Text #}
|
||
{# Wer sich schon eingetragen hat (nur wenn das Formular Namen zeigt) #}
|
||
{% macro slot_names_line(q, option_id) -%}
|
||
{%- set by_q = (slot_names.get(q.id) if slot_names is defined and slot_names else none) or {} -%}
|
||
{%- set who = by_q.get(option_id) -%}
|
||
{%- if who and (who.confirmed or who.waiting) -%}
|
||
<span class="slot-names">
|
||
{%- if who.confirmed %}{{ _('Signed up:') }} {{ who.confirmed | join(', ') }}{% endif -%}
|
||
{%- if who.waiting %}{% if who.confirmed %} · {% endif %}<span class="waiting">{{ _('Waiting list:') }} {{ who.waiting | join(', ') }}</span>{% endif -%}
|
||
</span>
|
||
{%- endif -%}
|
||
{%- endmacro %}
|
||
|
||
{% macro slot_state(a, st, full, waitlist) -%}
|
||
{%- if st == 'waiting' %}{{ _('you are on the waiting list') }}
|
||
{%- elif st == 'confirmed' %}{{ _('booked for you') }}
|
||
{%- elif a is not none and a.capacity %}
|
||
{%- if full %}{% if waitlist %}{{ _('booked up, waiting list possible') }}{% else %}{{ _('booked up') }}{% endif %}
|
||
{%- else %}{{ ngettext('%(num)d place left', '%(num)d places left', a.free) }}{% endif %}
|
||
{%- endif -%}
|
||
{%- endmacro %}
|
||
|
||
{% macro cond_attr(q) %}{% if q.config.get('condition') %} data-cond='{{ q.config.condition | tojson }}'{% endif %}{% endmacro %}
|
||
|
||
{# Fragengruppe: eine Tabellenzeile je Frage. Die Prüfung macht der Server. #}
|
||
{% macro group_block(g, members, values, errors, errors_text, places={}, own_status={}) %}
|
||
{% set gname = 'q' ~ g.id %}
|
||
{% set gerr = errors.get(g.id) %}
|
||
{% set kind = g.config.get('member_type') or 'slots' %}
|
||
{% set counting = kind in ('slots', 'yes_no') %}
|
||
{% set limit = (g.config.get('max_select') or 0) if counting else 0 %}
|
||
{% set least = (g.config.get('min_select') or 0) if counting else 0 %}
|
||
{% set group_rules = kind == 'slots' %}
|
||
<fieldset class="question q-group{% if gerr %} has-error{% endif %}" id="{{ gname }}"{% if limit or least %} data-max="{{ limit }}" data-min="{{ least }}" data-count-kind="{{ kind }}"{% endif %}{{ describedby(gname, g, gerr) }}>
|
||
<legend>{{ g.label }}{% if least %}<span class="req" aria-hidden="true"> *</span>{% endif %}</legend>
|
||
{{ help_and_error(gname, g, gerr, errors_text) }}
|
||
{% if limit or least %}
|
||
<p class="hint group-limit" data-too-many="{{ _(errors_text['group_too_many']) }}" data-too-few="{{ _(errors_text['group_too_few']) }}">
|
||
{%- if kind == 'yes_no' %}
|
||
{%- if least and limit %}{{ _('Between %(a)s and %(b)s “Yes” in this group.', a=least, b=limit) }}
|
||
{%- elif least %}{{ ngettext('At least %(num)d “Yes” in this group.', 'At least %(num)d “Yes” in this group.', least) }}
|
||
{%- else %}{{ ngettext('At most %(num)d “Yes” in this group.', 'At most %(num)d “Yes” in this group.', limit) }}{% endif %}
|
||
{%- else %}
|
||
{%- if least and limit and least == limit %}{{ ngettext('Please choose exactly %(num)d entry here.', 'Please choose exactly %(num)d entries here.', least) }}
|
||
{%- elif least and limit %}{{ _('Please choose between %(a)s and %(b)s entries here.', a=least, b=limit) }}
|
||
{%- elif least %}{{ ngettext('Please choose at least %(num)d entry here.', 'Please choose at least %(num)d entries here.', least) }}
|
||
{%- else %}{{ ngettext('You can choose at most %(num)d entry here.', 'You can choose at most %(num)d entries here.', limit) }}{% endif %}
|
||
{%- endif -%}
|
||
</p>
|
||
{% endif %}
|
||
{% if members %}
|
||
{% set first = members[0].config %}
|
||
<div class="table-wrap">
|
||
<table class="group-table group-{{ kind }}">
|
||
<thead>
|
||
<tr>
|
||
<th scope="col"><span class="visually-hidden">{{ _('Question') }}</span></th>
|
||
{% if kind == 'slots' %}
|
||
<th scope="col" class="state">{{ _('Places') }}</th>
|
||
<th scope="col" class="pick">{{ _('Sign up') }}</th>
|
||
{% elif kind == 'yes_no' %}
|
||
<th scope="col" class="pick">{{ first.label_yes or _('Yes') }}</th>
|
||
<th scope="col" class="pick">{{ first.label_no or _('No') }}</th>
|
||
{% elif kind == 'rating' %}
|
||
{% set top = first.scale_max or 5 %}
|
||
{% for i in range(1, top + 1) %}
|
||
<th scope="col" class="pick">{{ i }}{% if loop.first and first.label_min %}<span class="scale-label">{{ first.label_min }}</span>{% elif loop.last and first.label_max %}<span class="scale-label">{{ first.label_max }}</span>{% endif %}</th>
|
||
{% endfor %}
|
||
{% else %}
|
||
{% for o in first.options %}<th scope="col" class="pick">{{ o.label }}</th>{% endfor %}
|
||
{% endif %}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for q in members %}
|
||
{% set name = 'q' ~ q.id %}
|
||
{% set err = errors.get(q.id) %}
|
||
{% set val = (values.get(name) or [''])[0] %}
|
||
{% set cfg = q.config %}
|
||
{% set row_id = name ~ '-row' %}
|
||
{% set must = q.required and not group_rules %}
|
||
{% if kind == 'slots' %}
|
||
{% set a = places.get(q.id, {}).get('single') %}
|
||
{% set st = own_status.get((q.id, 'single')) %}
|
||
{% set mine = 'single' in (values.get(name) or []) %}
|
||
{% set full = a is not none and a.full %}
|
||
{% endif %}
|
||
<tr class="q-row{% if err %} has-error{% endif %}{% if kind == 'slots' and full %} full{% if cfg.hide_full and not mine and not err %} row-hidden{% endif %}{% endif %}" id="{{ name }}" data-qid="{{ q.id }}" data-type="{{ q.type }}"{{ cond_attr(q) }}{% if kind == 'slots' %} data-slots="{{ q.id }}" data-option="single" data-waitlist="{{ 'yes' if cfg.waitlist else 'no' }}"{% endif %}>
|
||
<th scope="row" id="{{ row_id }}">
|
||
{{ q.label }}{% if must %}<span class="req" aria-hidden="true"> *</span>{% endif %}
|
||
{% if q.help_text %}<span class="hint row-help">{{ q.help_text }}</span>{% endif %}
|
||
{% if err %}<span class="field-error">{{ _(errors_text[err]) }}</span>{% endif %}
|
||
{% if kind == 'slots' %}{{ slot_names_line(q, 'single') }}{% endif %}
|
||
</th>
|
||
{% if kind == 'slots' %}
|
||
<td class="slot-state">{{ slot_state(a, st, full, cfg.waitlist) }}</td>
|
||
<td class="pick"><input type="checkbox" name="{{ name }}" value="single" aria-labelledby="{{ row_id }}" {% if mine %}checked{% endif %} {% if full and not mine and not cfg.waitlist %}disabled{% endif %}></td>
|
||
{% elif kind == 'yes_no' %}
|
||
<td class="pick"><input type="radio" name="{{ name }}" value="yes" aria-label="{{ q.label }}: {{ first.label_yes or _('Yes') }}" {% if val == 'yes' %}checked{% endif %} {% if q.required %}required{% endif %}></td>
|
||
<td class="pick"><input type="radio" name="{{ name }}" value="no" aria-label="{{ q.label }}: {{ first.label_no or _('No') }}" {% if val == 'no' %}checked{% endif %}></td>
|
||
{% elif kind == 'rating' %}
|
||
{% for i in range(1, (first.scale_max or 5) + 1) %}
|
||
<td class="pick"><input type="radio" name="{{ name }}" value="{{ i }}" aria-label="{{ q.label }}: {{ i }}" {% if val == i|string %}checked{% endif %} {% if q.required %}required{% endif %}></td>
|
||
{% endfor %}
|
||
{% else %}
|
||
{% for o in cfg.options %}
|
||
<td class="pick"><input type="radio" name="{{ name }}" value="{{ o.id }}" aria-label="{{ q.label }}: {{ o.label }}" {% if val == o.id %}checked{% endif %} {% if q.required %}required{% endif %}></td>
|
||
{% endfor %}
|
||
{% endif %}
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% endif %}
|
||
</fieldset>
|
||
{% endmacro %}
|