Let participants edit their open answer while voting is open
CI / Deploy / test (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped

Generalises the comment edit to /p/{code}/edit: open answers can be
corrected (not emptied), scale comments as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 11:59:54 +01:00
1 parent e6f52a0449
commit 51d1be8695
7 files changed
+135 -48

No files matched your search

+22 -12
View File
@@ -8,9 +8,11 @@
* @var \App\Model\Entity\Slide|null $slide
* @var array<string, mixed> $state
* @var string $participantHash Seed for the shuffled items of ordering slides
* @var string|null $ownComment Own comment on a scale slide (editable while voting is open)
* @var string|null $ownText Own open answer or scale comment (editable while voting is open)
* @var int $pollIntervalMs
*/
use App\Service\VoteService;
$this->assign('title', $poll->title);
$this->assign('bodyClass', 'participant');
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
@@ -218,20 +220,28 @@ $countdown = function (?int $remaining): string {
<?= $this->Form->end() ?>
<?php elseif ($state['hasResponded']) : ?>
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
<?php if ($slide->type === 'scale' && $slide->hasComments() && $slide->isVotingOpen()) : ?>
<?php if ($ownComment !== null) : ?>
<p class="own-comment__label"><?= __('Dein Kommentar:') ?></p>
<blockquote class="own-comment"><?= nl2br(h($ownComment)) ?></blockquote>
<?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen()) :
$isOpen = $slide->type === 'open'; ?>
<?php if ($ownText !== null) : ?>
<p class="own-comment__label"><?= $isOpen ? __('Deine Antwort:') : __('Dein Kommentar:') ?></p>
<blockquote class="own-comment"><?= nl2br(h($ownText)) ?></blockquote>
<?php endif; ?>
<details class="own-comment__edit">
<summary><?= $ownComment !== null ? __('Kommentar bearbeiten') : __('Kommentar hinzufügen') ?></summary>
<?= $this->Form->create(null, ['url' => ['_name' => 'participate:comment', 'code' => $poll->join_code], 'class' => 'vote-form']) ?>
<summary><?= match (true) {
$isOpen => __('Antwort bearbeiten'),
$ownText !== null => __('Kommentar bearbeiten'),
default => __('Kommentar hinzufügen'),
} ?></summary>
<?= $this->Form->create(null, ['url' => ['_name' => 'participate:edit', 'code' => $poll->join_code], 'class' => 'vote-form']) ?>
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
<label class="scale-comment" for="scale-comment"><?= __('Kommentar') ?></label>
<textarea id="scale-comment" name="comment" rows="3" maxlength="500"
aria-describedby="comment-edit-hint"><?= h((string)$ownComment) ?></textarea>
<p class="hint" id="comment-edit-hint"><?= __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Bewertung bleibt.') ?></p>
<?= $this->Form->button(__('Kommentar speichern'), ['class' => 'button button--primary button--block']) ?>
<label class="scale-comment" for="edit-text"><?= $isOpen ? __('Antwort') : __('Kommentar') ?></label>
<textarea id="edit-text" name="<?= $isOpen ? 'text' : 'comment' ?>" rows="3" maxlength="500"
<?= $isOpen ? 'required' : '' ?>
aria-describedby="edit-text-hint"><?= h((string)$ownText) ?></textarea>
<p class="hint" id="edit-text-hint"><?= $isOpen
? __('Möglich, solange die Abstimmung läuft.')
: __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Bewertung bleibt.') ?></p>
<?= $this->Form->button($isOpen ? __('Antwort speichern') : __('Kommentar speichern'), ['class' => 'button button--primary button--block']) ?>
<?= $this->Form->end() ?>
</details>
<?php endif; ?>