Add initial Plenario live polling app
CI / Deploy / test (push) Successful in 49s
CI / Deploy / deploy (push) Failing after 5s

CakePHP 5.4 app for live polls: create via email without login, manage
via secret admin link, join via code. Includes slide types (choice,
wordcloud, open, scale, content), presenter mode, CSV export, captcha,
throttling, tests and Gitea CI/deploy workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 13:24:29 +01:00
commit eb319f8c1e
120 files changed
+15572

No files matched your search

+126
View File
@@ -0,0 +1,126 @@
<?php
declare(strict_types=1);
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* A slide of a poll. `type` decides how participants answer and how results
* are aggregated (see \App\Service\ResultsService and \App\Service\VoteService).
*
* @property int $id
* @property int $poll_id
* @property string $type
* @property string $question
* @property string|null $description
* @property int $position
* @property array<string, mixed>|null $settings
* @property bool $is_voting_open
* @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime $modified
* @property \App\Model\Entity\Poll $poll
* @property array<\App\Model\Entity\SlideOption> $slide_options
* @property array<\App\Model\Entity\Response> $responses
*/
class Slide extends Entity
{
public const TYPE_CHOICE = 'choice';
public const TYPE_WORDCLOUD = 'wordcloud';
public const TYPE_OPEN = 'open';
public const TYPE_SCALE = 'scale';
public const TYPE_CONTENT = 'content';
/**
* Default settings per type. Unknown keys are dropped on save.
*
* @var array<string, array<string, mixed>>
*/
public const DEFAULT_SETTINGS = [
self::TYPE_CHOICE => ['multiple' => false],
// max_words: words per participant incl. upvotes (not downvotes), 0 = unlimited;
// allow_downvotes only takes effect together with allow_upvotes
self::TYPE_WORDCLOUD => ['max_words' => 0, 'allow_upvotes' => true, 'allow_downvotes' => true],
self::TYPE_OPEN => [],
self::TYPE_SCALE => ['scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => ''],
self::TYPE_CONTENT => [],
];
/**
* @var array<string, bool>
*/
protected array $_accessible = [
'type' => true,
'question' => true,
'description' => true,
'settings' => true,
'is_voting_open' => true,
];
/**
* @return array<string, string> type => human readable label
*/
public static function typeLabels(): array
{
return [
self::TYPE_CHOICE => __('Multiple Choice'),
self::TYPE_WORDCLOUD => __('Wortwolke'),
self::TYPE_OPEN => __('Offene Frage'),
self::TYPE_SCALE => __('Skala'),
self::TYPE_CONTENT => __('Inhaltsfolie'),
];
}
/**
* @return array<string, string> type => short description
*/
public static function typeDescriptions(): array
{
return [
self::TYPE_CHOICE => __('Antwortoptionen vorgeben, Ergebnis als Balkendiagramm.'),
self::TYPE_WORDCLOUD => __('Teilnehmende geben Begriffe ein oder unterstützen vorhandene, häufige werden größer.'),
self::TYPE_OPEN => __('Freitext-Antworten, live als Liste.'),
self::TYPE_SCALE => __('Bewertung auf einer Skala, z. B. 1 bis 5.'),
self::TYPE_CONTENT => __('Nur Text anzeigen, ohne Abstimmung.'),
];
}
/**
* @return string
*/
public function typeLabel(): string
{
return static::typeLabels()[$this->type] ?? $this->type;
}
/**
* Whether participants can answer this slide at all.
*
* @return bool
*/
public function isInteractive(): bool
{
return $this->type !== self::TYPE_CONTENT;
}
/**
* Settings merged with the type defaults.
*
* @return array<string, mixed>
*/
public function getSettings(): array
{
$defaults = self::DEFAULT_SETTINGS[$this->type] ?? [];
return array_intersect_key(array_merge($defaults, (array)($this->settings ?? [])), $defaults);
}
/**
* @param string $key Setting name
* @return mixed
*/
public function setting(string $key): mixed
{
return $this->getSettings()[$key] ?? null;
}
}