151 Commits
Author SHA1 Message Date
gnilebein 33708d45df Pull Request „Update renovatebot/github-action action to v47“ mergen (#133)
CI / Deploy / PHP 8.4 (push) Successful in 1m20s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m43s
2026-11-26 20:10:01 +01:00
Renovate Bot 8852b987fe Update renovatebot/github-action action to v47
CI / Deploy / PHP 8.4 (push) Successful in 2m11s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m10s
2026-11-26 18:01:02 +00:00
gnilebein 210b0ef227 Merge pull request 'Lock file maintenance' (#132) from renovate/lock-file-maintenance into main
CI / Deploy / PHP 8.4 (push) Successful in 2m29s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 2m31s
Reviewed-on: #132
2026-11-25 12:37:17 +01:00
Renovate Bot e4cb6f38f7 Lock file maintenance
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m25s
CI / Deploy / test (push) Successful in 5s
2026-11-25 11:34:47 +00:00
gnilebein 08868ac4e0 Merge pull request 'Run Renovate every two hours' (#131) from chore/renovate-every-2h into main
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / deploy (push) Successful in 17s
CI / Deploy / test (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 2m15s
Reviewed-on: #131
2026-11-25 12:32:40 +01:00
gnilebein aecf7a4246 Merge pull request 'Start every slide on a new page in the PDF export' (#130) from fix/pdf-page-per-slide into main
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Failing after 5s
CI / Deploy / PHP 8.5 (push) Successful in 2m6s
Reviewed-on: #130
2026-11-25 12:30:58 +01:00
gnilebeinandClaude Sonnet 5.5 71485f42f4 Run Renovate every two hours
CI / Deploy / PHP 8.4 (push) Successful in 3m19s
CI / Deploy / test (push) Successful in 3s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 3m21s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 12:27:40 +01:00
gnilebeinandClaude Sonnet 5.5 3536970107 Start every slide on a new page in the PDF export
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 10s
CI / Deploy / PHP 8.5 (push) Successful in 3m15s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 12:26:59 +01:00
gnilebein cb911114c6 Merge pull request 'Update renovatebot/github-action action to v46.3.15' (#129) from renovate/renovatebot-github-action-46.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m20s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 2m26s
CI / Deploy / test (push) Successful in 2s
Reviewed-on: #129
2026-11-25 12:24:15 +01:00
Renovate Bot c8aeb54a87 Update renovatebot/github-action action to v46.3.15
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m58s
2026-11-25 04:01:03 +00:00
gnilebein e90d9c38eb Merge pull request 'Lock file maintenance' (#128) from renovate/lock-file-maintenance into main
CI / Deploy / PHP 8.4 (push) Successful in 1m21s
CI / Deploy / deploy (push) Successful in 11s
CI / Deploy / PHP 8.5 (push) Successful in 1m41s
CI / Deploy / test (push) Successful in 2s
Reviewed-on: #128
2026-11-24 15:44:15 +01:00
Renovate Bot e4019276a0 Lock file maintenance
CI / Deploy / PHP 8.4 (push) Successful in 1m22s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m18s
CI / Deploy / test (push) Successful in 2s
2026-11-23 04:01:32 +00:00
gnilebein b1da8eabd4 Merge pull request 'Walk through Q&A stages with "next" before leaving the slide' (#127) from fix/qa-next-stages into main
CI / Deploy / PHP 8.4 (push) Skipped
CI / Deploy / test (push) Successful in 0s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Skipped
Release / test (push) Successful in 1m18s
Release / package (push) Successful in 42s
Release / image (push) Successful in 4m57s
Reviewed-on: #127
2026-11-21 13:51:36 +01:00
gnilebeinandClaude Sonnet 5.5 d1d748f760 Walk through Q&A stages with "next" before leaving the slide
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m14s
CI / Deploy / test (push) Successful in 2s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:47:27 +01:00
gnilebein 7475f096ea Merge pull request 'Feature/choice comment only' (#126) from feature/choice-comment-only into main
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / PHP 8.5 (push) Successful in 1m28s
Reviewed-on: #126
2026-11-21 13:42:21 +01:00
gnilebeinandClaude Sonnet 5.5 6c77470824 Show the word cloud to participants as a compact list
CI / Deploy / PHP 8.4 (push) Successful in 1m21s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m36s
Participants get a list with fixed text size, a weight bar and big +/- buttons (like Q&A voting) instead of the cloud. On stage the cloud shrinks as the number of words grows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:39:56 +01:00
gnilebeinandClaude Sonnet 5.5 7a80794ded Drop the image description field
CI / Deploy / PHP 8.4 (push) Successful in 1m36s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m36s
Slide images are shown on the presenter's screen, so a description for
screen readers is not asked for any more. The column stays (always empty).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:35:48 +01:00
gnilebein ebaf6fbe53 Merge pull request 'Make "comment without rating" a choice in a comment dropdown' (#125) from feature/scale-no-answer into main
CI / Deploy / PHP 8.4 (push) Successful in 1m21s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / PHP 8.5 (push) Successful in 1m21s
CI / Deploy / test (push) Successful in 2s
Reviewed-on: #125
2026-11-21 13:09:44 +01:00
gnilebeinandClaude Sonnet 5.5 b496032604 Make "comment without rating" a choice in a comment dropdown
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
The scale form replaces the comment checkbox with a dropdown: no
comment field, comment with mandatory rating, or comment alone is
enough. Existing slides keep their behaviour (rating mandatory).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:07:20 +01:00
gnilebein 9e869ef979 Merge pull request 'Allow a comment without a rating on scales instead of "Keine Angabe"' (#124) from feature/scale-no-answer into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m17s
Reviewed-on: #124
2026-11-21 12:59:40 +01:00
gnilebeinandClaude Sonnet 5.5 dbac9e93c7 Allow a comment without a rating on scales instead of "Keine Angabe"
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 1s
With the comment field enabled, scales and star ratings accept a
comment alone. It counts as taking part but not in the average or the
distribution; the number is shown separately. The explicit skip button
and its setting are removed again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 12:58:01 +01:00
gnilebein 6cdab11898 Merge pull request 'Add "Keine Angabe" to scales and an "Enthaltung" shortcut for choice slides' (#123) from feature/scale-no-answer into main
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / PHP 8.5 (push) Successful in 1m20s
Reviewed-on: #123
2026-11-21 12:41:57 +01:00
gnilebeinandClaude Sonnet 5.5 d6432911ed Add "Keine Angabe" to scales and an "Enthaltung" shortcut for choice slides
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m38s
CI / Deploy / test (push) Successful in 2s
Scales and star ratings get an optional "Keine Angabe" answer (setting
allow_skip). It counts as taking part but stays out of the average and
the distribution; the number is shown separately on stage, in the
evaluation and in the PDF. The choice form gets a button that appends an
"Enthaltung" option.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 12:39:44 +01:00
gnilebein 1b48ce7852 Merge pull request 'Add an optional countdown to every slide that collects answers' (#122) from feature/countdown-all-types into main
CI / Deploy / PHP 8.4 (push) Successful in 1m44s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m47s
Reviewed-on: #122
2026-11-21 12:22:12 +01:00
gnilebein 3916678b1f Merge pull request 'Show "Gerade ist keine Frage aktiv" on the presenter stage while paused' (#121) from fix/pause-stage-text into main
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m48s
Reviewed-on: #121
2026-11-21 12:21:40 +01:00
gnilebeinandClaude Sonnet 5.5 27771e7470 Add an optional countdown to every slide that collects answers
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m29s
Choice, word cloud, open question, scale and ordering slides get a time
limit like the quiz. With a limit the slide waits ("ready") showing only
the question; next starts the countdown, the next one ends it, the third
moves on. Stage results and the ordering solution are withheld until the
countdown has started. The countdown music plays during any countdown.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 12:18:33 +01:00
gnilebeinandClaude Sonnet 5.5 1ad1063772 Show "Gerade ist keine Frage aktiv" on the presenter stage while paused
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m18s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 12:06:32 +01:00
gnilebein 722e845cff Merge pull request 'Use a compact image-style dropzone for the countdown audio upload' (#120) from feature/quiz-audio into main
CI / Deploy / PHP 8.4 (push) Successful in 1m37s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m37s
Reviewed-on: #120
2026-11-21 11:52:22 +01:00
gnilebeinandClaude Sonnet 5.5 0dfbf1d04a Use a compact image-style dropzone for the countdown audio upload
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m24s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 11:50:10 +01:00
gnilebein 918270540f Merge pull request 'Add countdown audio per presentation' (#117) from feature/quiz-audio into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m34s
Reviewed-on: #117
2026-11-21 11:46:28 +01:00
gnilebein 3b2bff6116 Merge pull request 'Use B (break) as pause key in the presenter view' (#119) from feature/pause-key-b into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m35s
Reviewed-on: #119
2026-11-21 11:45:05 +01:00
gnilebeinandClaude Sonnet 5.5 12ab64312b Sort use statements in AdminController
CI / Deploy / PHP 8.4 (push) Successful in 1m52s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m53s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 11:43:46 +01:00
gnilebeinandClaude Sonnet 5.5 a16aff6b88 Use B (break) as pause key in the presenter view
CI / Deploy / PHP 8.4 (push) Successful in 1m58s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
P keeps working as an alias.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 11:42:35 +01:00
gnilebein ab033d5216 Merge pull request 'Accept arrow up/down for slide navigation in the presenter view' (#118) from fix/presenter-arrow-up-down into main
CI / Deploy / PHP 8.4 (push) Successful in 2m6s
CI / Deploy / test (push) Successful in 3s
CI / Deploy / deploy (push) Successful in 10s
CI / Deploy / PHP 8.5 (push) Successful in 2m6s
Reviewed-on: #118
2026-11-21 11:41:18 +01:00
gnilebeinandClaude Sonnet 5.5 bf9f86d24a Accept arrow up/down for slide navigation in the presenter view
CI / Deploy / PHP 8.4 (push) Successful in 1m37s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m36s
Presenter remotes often send ArrowUp/ArrowDown instead of left/right.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 11:37:37 +01:00
gnilebeinandClaude Sonnet 5.5 2f7a401522 Add countdown audio per presentation
CI / Deploy / PHP 8.4 (push) Failing after 1m18s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Failing after 1s
CI / Deploy / PHP 8.5 (push) Failing after 2m4s
One audio file per poll (MP3, M4A, OGG, WAV) is uploaded in the admin
settings and looped in the presenter view while a quiz runs. Format is
detected by magic bytes, files are served with a fixed content type,
copied with the poll and swept by images_cleanup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 11:36:01 +01:00
gnilebein cad09163d9 Merge pull request 'Close an open ordering slide on "next" before moving on' (#116) from fix/order-next-reveals into main
CI / Deploy / PHP 8.4 (push) Successful in 1m14s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m22s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #116
2026-11-21 09:24:32 +01:00
gnilebeinandClaude Sonnet 5.5 7fd4a0da8c Close an open ordering slide on "next" before moving on
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m28s
Forward in the presenter view now reveals the solution first (like the
quiz build steps) instead of skipping straight to the next slide.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 09:21:54 +01:00
gnilebein 4d9ce7e5f5 Merge pull request 'Lock file maintenance' (#113) from renovate/lock-file-maintenance into main
CI / Deploy / PHP 8.4 (push) Successful in 2m31s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 2m33s
Reviewed-on: #113
2026-11-20 11:15:09 +01:00
gnilebein e4790fcc27 Merge pull request 'Move embed and clone sections into the settings card' (#115) from feature/menu-clone-poll into main
CI / Deploy / PHP 8.4 (push) Successful in 2m29s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 2m30s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #115
2026-11-20 11:14:31 +01:00
gnilebeinandClaude Sonnet 5.5 76d8311e50 Move embed and clone sections into the settings card
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m26s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 11:10:43 +01:00
gnilebein 4aaabb85ed Merge pull request 'Add admin menu drawer and poll cloning, drop participant screen tools' (#114) from feature/menu-clone-poll into main
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / deploy (push) Successful in 11s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m39s
Reviewed-on: #114
2026-11-20 11:00:15 +01:00
gnilebeinandClaude Sonnet 5.5 bd57f23be6 Add admin menu drawer and poll cloning, drop participant screen tools
CI / Deploy / PHP 8.4 (push) Successful in 1m51s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m51s
- Remove fullscreen and wake lock buttons from the participant view.
- Turn the admin sidebar into a drawer below 900px, opened from a header
  menu button next to the theme switch (progressive enhancement).
- Add "Umfrage kopieren": clone a poll with all slides, options and images
  but without responses, with its own join code and admin link.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 10:57:33 +01:00
gnilebein 0f91377de3 Merge pull request 'Update docker/metadata-action action to v6' (#111) from renovate/docker-metadata-action-6.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m58s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m57s
Reviewed-on: #111
2026-11-20 07:46:53 +01:00
gnilebein a2ffb8085b Merge pull request 'Update docker/setup-buildx-action action to v4' (#112) from renovate/docker-setup-buildx-action-4.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m56s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m58s
Reviewed-on: #112
2026-11-20 07:46:50 +01:00
gnilebein 8e9313bd10 Merge pull request 'Update docker/login-action action to v4' (#110) from renovate/docker-login-action-4.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 1m15s
Reviewed-on: #110
2026-11-20 07:45:02 +01:00
gnilebein e1e521cb83 Merge pull request 'Update docker/build-push-action action to v7' (#109) from renovate/docker-build-push-action-7.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m53s
CI / Deploy / deploy (push) Canceled after 0s
CI / Deploy / PHP 8.5 (push) Successful in 1m48s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #109
2026-11-20 07:44:36 +01:00
gnilebein be9ebe7c3c Merge pull request 'Update actions/checkout action to v7' (#108) from renovate/actions-checkout-7.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m54s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 10s
CI / Deploy / PHP 8.5 (push) Successful in 1m52s
Reviewed-on: #108
2026-11-20 07:44:34 +01:00
Renovate Bot 8471e5bef8 Lock file maintenance
CI / Deploy / PHP 8.4 (push) Successful in 2m9s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m15s
2026-11-20 06:42:52 +00:00
Renovate Bot 56c9177eae Update docker/setup-buildx-action action to v4
CI / Deploy / PHP 8.4 (push) Successful in 2m14s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m14s
2026-11-20 06:42:26 +00:00
Renovate Bot f48cccbf48 Update docker/metadata-action action to v6
CI / Deploy / PHP 8.4 (push) Successful in 2m17s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m17s
CI / Deploy / test (push) Successful in 3s
2026-11-20 06:42:22 +00:00
Renovate Bot 30a5c10635 Update docker/login-action action to v4
CI / Deploy / PHP 8.4 (push) Successful in 1m58s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m14s
2026-11-20 06:42:20 +00:00
Renovate Bot 592c2d8f5f Update docker/build-push-action action to v7
CI / Deploy / PHP 8.4 (push) Successful in 2m14s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 4s
CI / Deploy / PHP 8.5 (push) Successful in 2m17s
2026-11-20 06:42:17 +00:00
Renovate Bot c8a5464a98 Update actions/checkout action to v7
CI / Deploy / PHP 8.4 (push) Successful in 1m22s
CI / Deploy / test (push) Successful in 5s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m15s
2026-11-20 06:42:13 +00:00
gnilebein ea8115957e Merge pull request 'Feature/load test' (#107) from feature/load-test into main
CI / Deploy / PHP 8.4 (push) Successful in 3m13s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / PHP 8.5 (push) Successful in 1m49s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #107
2026-11-19 09:20:15 +01:00
gnilebeinandClaude Sonnet 5.5 29b565facc Add JMeter load test simulating participants across slides
CI / Deploy / PHP 8.4 (push) Successful in 2m30s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 2m16s
Participants poll the state like the browser, reload the page when the
version changes and vote according to the form of the current slide.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-19 09:17:07 +01:00
gnilebeinandClaude Sonnet 5.5 ebfab0ef20 Add polls seed command for demo and load test polls
Every run creates a new poll with one slide per interactive type and
shows the first (choice) slide live with voting open.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-19 09:16:54 +01:00
gnilebein 09ed675e08 Merge pull request 'Update renovatebot/github-action action to v46.3.14' (#105) from renovate/renovatebot-github-action-46.x into main
CI / Deploy / PHP 8.4 (push) Successful in 1m51s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m25s
Reviewed-on: #105
2026-11-18 09:05:57 +01:00
gnilebein d3fdb63b8e Merge pull request 'Update appleboy/ssh-action action to v1.2.5' (#106) from renovate/appleboy-ssh-action-1.x into main
CI / Deploy / PHP 8.4 (push) Successful in 2m7s
CI / Deploy / deploy (push) Successful in 4s
CI / Deploy / PHP 8.5 (push) Successful in 1m24s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #106
2026-11-18 09:05:44 +01:00
Renovate Bot 749e4c8242 Update appleboy/ssh-action action to v1.2.5
CI / Deploy / PHP 8.4 (push) Successful in 1m54s
CI / Deploy / test (push) Successful in 4s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
2026-11-18 08:03:12 +00:00
Renovate Bot 27a45e12e0 Update renovatebot/github-action action to v46.3.14
CI / Deploy / PHP 8.4 (push) Successful in 1m52s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 3s
CI / Deploy / PHP 8.5 (push) Successful in 1m45s
2026-11-18 08:03:08 +00:00
gnilebein a1348cc40e Merge pull request 'Add Github Tocket' (#104) from feature/qr-download into main
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / test (push) Successful in 3s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 2m26s
Reviewed-on: #104
2026-11-18 09:02:07 +01:00
gnilebein 7085eb17f8 Add Github Tocket
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m17s
2026-11-18 08:42:06 +01:00
gnilebein b933d2065d Merge pull request 'Add PNG download for the participant QR code in the admin' (#103) from feature/qr-download into main
CI / Deploy / PHP 8.4 (push) Successful in 1m31s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m32s
Reviewed-on: #103
2026-11-18 08:24:56 +01:00
gnilebeinandClaude Sonnet 5.5 945fc94e77 Add PNG download for the participant QR code in the admin
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m33s
A button appears on hover/focus over the QR code (always visible on
touch devices) and saves it as a 1024px PNG, rendered client-side from
the SVG via canvas. No new dependency or server image library needed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 08:19:58 +01:00
gnilebein 26648adca8 Merge pull request 'Migrate Renovate config' (#101) from renovate/migrate-config into main
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m8s
Reviewed-on: #101
2026-11-17 21:23:42 +01:00
Renovate Bot f3871269de Migrate config renovate.json
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
2026-11-17 20:22:13 +00:00
gnilebein a9b14af8bf Merge pull request 'Add Renovate for dependency updates' (#99) from chore/renovate into main
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 1m11s
Reviewed-on: #99
2026-11-17 19:26:20 +01:00
gnilebeinandClaude Sonnet 5.5 9fed0a046d Add Renovate for dependency updates
CI / Deploy / PHP 8.4 (push) Successful in 1m7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 19:21:15 +01:00
gnilebein 30b13ead50 Merge pull request 'Show the answers page in the modal dialog' (#98) from fix/answers-in-modal into main
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.4 (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Skipped
Release / test (push) Successful in 1m12s
Release / package (push) Successful in 48s
Release / image (push) Successful in 1m51s
Reviewed-on: #98
2026-11-17 14:31:48 +01:00
gnilebeinandClaude Sonnet 5.5 1c294d7dc7 Show the answers page in the modal dialog
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m18s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 14:29:15 +01:00
gnilebein 64abb56a63 Merge pull request 'Feature/image upload ux' (#97) from feature/image-upload-ux into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m18s
Reviewed-on: #97
2026-11-17 14:23:44 +01:00
gnilebeinandClaude Sonnet 5.5 bb2d1443cf Remove the "voting open" checkbox from the slide form
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
is_voting_open is presenter state (SlideControlService), so the form
never takes it over anymore, for all slide types instead of only quiz
and Q&A. New slides start open (quiz closed), as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 14:21:29 +01:00
gnilebeinandClaude Sonnet 5.5 83c76d72ec Rename "personal ranking" to "own assessment" in the UI
The label now says what participants do (sort by their own assessment,
e.g. by importance) instead of using the vague term "Rangfolge".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 14:21:28 +01:00
gnilebeinandClaude Sonnet 5.5 c6a92e347f Redesign the image section of the slide form
Show a dropzone (with drag and drop) while a slide has no image and a
row with preview, replace and remove buttons otherwise. A newly chosen
file is previewed right away. Placement is picked from tiles with a
small sketch instead of long radio labels, technical details move into
a collapsible help. The section gets full-width dividers, and the modal
a slim scrollbar.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 14:21:27 +01:00
gnilebein 0ad29aa484 Merge pull request 'Add personal ranking mode to order slides and show image placement only with an image' (#96) from feature/personal-ranking into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m15s
Reviewed-on: #96
2026-11-17 09:22:51 +01:00
gnilebeinandClaude Sonnet 5.5 4dcddd15e7 Fix coding standard in SlidesTable::sanitizeSettings
CI / Deploy / PHP 8.4 (push) Failing after 7s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Failing after 0s
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 09:18:47 +01:00
gnilebeinandClaude Sonnet 5.5 0aac113f30 Add personal ranking mode to order slides and show image placement only with an image
CI / Deploy / PHP 8.4 (push) Failing after 1m28s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Failing after 2s
CI / Deploy / PHP 8.5 (push) Failing after 1m31s
Order slides get a "ranking" setting without a correct solution: the stage shows
the live average ranking, participants only get a confirmation. The image
placement question in the slide form is only shown for an existing image or a
chosen file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 09:15:49 +01:00
gnilebein 85627b364d Merge pull request 'Make the admin sidebar cards collapsible' (#95) from feature/presenter-notes into main
CI / Deploy / PHP 8.4 (push) Successful in 2m0s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 9s
CI / Deploy / PHP 8.5 (push) Successful in 1m29s
Release / test (push) Successful in 1m40s
Release / package (push) Successful in 59s
Release / image (push) Successful in 2m54s
Reviewed-on: #95
2026-11-16 19:50:54 +01:00
gnilebeinandClaude Sonnet 5.5 2c0b8d2216 Make the admin sidebar cards collapsible
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m9s
Participation and settings are open by default, the rest is closed.
Anchor links like #export open their card.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:45:03 +01:00
gnilebein 59ce3e3e10 Merge pull request 'Feature/presenter notes' (#94) from feature/presenter-notes into main
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / PHP 8.5 (push) Successful in 1m20s
Reviewed-on: #94
2026-11-16 19:40:59 +01:00
gnilebeinandClaude Sonnet 5.5 74b69f3c9a Never load the YouTube player in the speaker view
CI / Deploy / PHP 8.4 (push) Successful in 1m17s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m18s
Avoids hearing the video twice next to the presentation window.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:32:05 +01:00
gnilebeinandClaude Sonnet 5.5 99fcfec165 Separate current and next slide visibly in the speaker view
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:32:04 +01:00
gnilebeinandClaude Sonnet 5.5 446617de6f Always label the reset button "Umfrage zurücksetzen"
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:31:52 +01:00
gnilebeinandClaude Sonnet 5.5 fc28d158cb Keep the present menu button at normal height
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m21s
CI / Deploy / test (push) Successful in 1s
Enlarge only the arrow glyph, not the button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:20:42 +01:00
gnilebeinandClaude Sonnet 5.5 9d682fa0a3 Make the arrow of the present menu larger
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:19:39 +01:00
gnilebeinandClaude Sonnet 5.5 b61bf34a1b Open the speaker view from a menu next to the present button
Replace the separate button by a split button: "Präsentieren" with a
dropdown that holds the speaker view entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 19:19:06 +01:00
gnilebein 0c97f61763 Merge pull request 'Add a speaker view with a next-slide preview and keep the live slide in view' (#93) from feature/presenter-notes into main
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
Reviewed-on: #93
2026-11-16 15:45:15 +01:00
gnilebeinandClaude Sonnet 5.5 66ed198f87 Add a speaker view with a next-slide preview and keep the live slide in view
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
- New /admin/{token}/speaker page for a second window: current slide, preview of
  the next slide and the usual controls. It does not start the presentation.
- The presenter state gets `next` (labels only, no solutions).
- The dashboard scrolls the live slide into view when the presenter moves on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:43:49 +01:00
gnilebein a07a9a1a34 Merge pull request 'Add the logo and the web wordmark colors to e-mails' (#92) from feature/mail-branding into main
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
Reviewed-on: #92
2026-11-16 15:15:57 +01:00
gnilebeinandClaude Sonnet 5.5 72b688186f Add the logo and the web wordmark colors to e-mails
CI / Deploy / PHP 8.4 (push) Successful in 1m10s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m6s
The HTML layout now shows the logo (inline CID attachment, generated with
the favicon script) before "Plenar" in the text color and "IO" in the primary
color, like the site header. Muted gray and background match the web tokens.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:08:13 +01:00
gnilebein 8262411225 Merge pull request 'Drop app_local.php from production and show the mail transport in polls remind' (#91) from fix/no-app-local-in-production into main
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / PHP 8.5 (push) Successful in 1m8s
Reviewed-on: #91
2026-11-16 14:54:44 +01:00
gnilebeinandClaude Sonnet 5.5 7fa33bbbdd Drop app_local.php from production and show the mail transport in polls remind
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
app_local.php takes precedence over config/.env, so a copy made from an older
template forced the file transport and reminders never left the server.
Release package and Docker image now ship without it; app.php reads the
database from DATABASE_URL (SQLite default). app_local.example.php keeps
development defaults only. polls remind prints the transport and warns when
SMTP_HOST is set but SMTP is not used.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 14:52:58 +01:00
gnilebein 6f20ddf5f7 Merge pull request 'Let polls remind target one poll for testing' (#90) from feature/remind-force into main
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Reviewed-on: #90
2026-11-16 14:12:33 +01:00
gnilebeinandClaude Sonnet 5.5 f21aead039 Let polls remind target one poll for testing
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m6s
CI / Deploy / test (push) Successful in 1s
`polls remind <id|code>` sends the reminder to that poll right away,
ignoring the reminder window, an earlier reminder and POLL_REMINDER_DAYS.
A forced reminder does not set the reminded marker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 14:10:08 +01:00
gnilebein 4f03414d7a Merge pull request 'Add --json to polls list and polls show' (#87) from feature/polls-json into main
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m17s
Reviewed-on: #87
2026-11-16 14:05:55 +01:00
gnilebein 872a211afa Merge pull request 'Use the logo as favicon' (#88) from feature/favicon into main
CI / Deploy / PHP 8.4 (push) Successful in 1m41s
CI / Deploy / test (push) Successful in 3s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m42s
Reviewed-on: #88
2026-11-16 14:03:43 +01:00
gnilebein 1ceac5ee68 Merge remote-tracking branch 'origin/main' into feature/polls-json
CI / Deploy / PHP 8.4 (push) Successful in 1m43s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m45s
# Conflicts:
#	docs/deployment.md
#	docs/operations.md
2026-11-16 14:03:11 +01:00
gnilebeinandClaude Sonnet 5.5 82b352c053 Use the logo as favicon
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m5s
favicon.svg, favicon.ico (16/32/48) and apple-touch-icon.png, generated
from the same geometry as .brand__mark (resources/favicon/generate.php).
Linked from all layouts via one element.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 14:02:21 +01:00
gnilebein 514ab050a7 Merge pull request 'Remove the polls menu, keep the single commands' (#86) from fix/remove-polls-menu into main
CI / Deploy / PHP 8.4 (push) Successful in 1m30s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m27s
Reviewed-on: #86
2026-11-16 14:00:06 +01:00
gnilebeinandClaude Sonnet 5.5 3d6ade668f Add --json to polls list and polls show
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m37s
Machine-readable output for scripts; never contains the admin token
unless --link is given.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:59:38 +01:00
gnilebeinandClaude Sonnet 5.5 349359dad3 Remove the polls menu, keep the single commands
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 3s
CI / Deploy / PHP 8.5 (push) Successful in 1m2s
bin/cake polls list|show|delete|remind|cleanup stay as they are.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:58:26 +01:00
gnilebein 664088e139 Merge pull request 'Revert "Browse and delete polls from a numbered list in the polls menu"' (#85) from fix/polls-menu-simple-list into main
CI / Deploy / PHP 8.4 (push) Successful in 1m10s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m11s
Reviewed-on: #85
2026-11-16 13:54:39 +01:00
gnilebein e3f74e375f Revert "Browse and delete polls from a numbered list in the polls menu"
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
CI / Deploy / test (push) Successful in 1s
This reverts commit 7b83cf2f2c.
2026-11-16 13:52:02 +01:00
gnilebein bd401ed94a Merge pull request 'Feature/polls menu' (#84) from feature/polls-menu into main
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
Reviewed-on: #84
2026-11-16 13:40:21 +01:00
gnilebeinandClaude Sonnet 5.5 7b83cf2f2c Browse and delete polls from a numbered list in the polls menu
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Paged list with pick by number (open) and "d 1,3" to delete several at
once after one confirmation. List query and table moved into the shared
base command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:35:38 +01:00
gnilebeinandClaude Sonnet 5.5 6e8fef022b Add a menu-driven entry to the polls CLI
CI / Deploy / PHP 8.4 (push) Successful in 1m15s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m14s
`bin/cake polls` without a sub command offers list, search, open a poll
(details, admin link, delete), remind and cleanup. It only wraps the existing
commands, previews before destructive actions and asks first; every prompt
has a safe default so closed stdin ends it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:31:33 +01:00
gnilebein f0b5f7b2bb Merge pull request 'Docs/split agents md' (#83) from docs/split-agents-md into main
CI / Deploy / PHP 8.4 (push) Successful in 1m14s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m27s
CI / Deploy / test (push) Successful in 2s
Reviewed-on: #83
2026-11-16 13:14:05 +01:00
gnilebein af15cee1a2 Merge pull request 'Feature/poll expiry' (#82) from feature/poll-expiry into main
CI / Deploy / PHP 8.4 (push) Successful in 1m27s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m58s
Reviewed-on: #82
2026-11-16 13:13:53 +01:00
gnilebein 87ecdff54e Merge remote-tracking branch 'origin/feature/poll-expiry' into docs/split-agents-md
CI / Deploy / PHP 8.4 (push) Successful in 1m24s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m21s
# Conflicts:
#	README.md
2026-11-16 13:11:28 +01:00
gnilebein cbb24111ff Merge remote-tracking branch 'origin/main' into docs/split-agents-md
CI / Deploy / PHP 8.4 (push) Successful in 1m29s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m47s
CI / Deploy / test (push) Successful in 0s
# Conflicts:
#	README.md
2026-11-16 13:11:15 +01:00
gnilebein 37f02fa1dc Merge remote-tracking branch 'origin/main' into feature/poll-expiry
CI / Deploy / PHP 8.4 (push) Successful in 1m20s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 3m5s
# Conflicts:
#	README.md
2026-11-16 13:10:01 +01:00
gnilebeinandClaude Sonnet 5.5 f7fe4a47aa Move local setup and test docs out of the README
CI / Deploy / PHP 8.4 (push) Successful in 1m19s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m28s
CI / Deploy / test (push) Successful in 2s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:03:18 +01:00
gnilebeinandClaude Sonnet 5.5 ae57bf1352 Move deployment and configuration docs out of the README
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
README keeps overview, features, local setup, privacy and links;
operator instructions live in docs/deployment.md and
docs/configuration.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:00:27 +01:00
gnilebeinandClaude Sonnet 5.5 d690f16673 Split AGENTS.md into core rules and detailed docs
CI / Deploy / PHP 8.4 (push) Successful in 1m23s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
CI / Deploy / test (push) Successful in 0s
Keep AGENTS.md as a short entry point (role, commands, conventions,
invariants) and move per-area details to docs/.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 12:52:35 +01:00
gnilebeinandClaude Sonnet 5.5 b811294065 Document the cleanup cron job
CI / Deploy / PHP 8.4 (push) Successful in 3m22s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m29s
Server and Docker setup, requirements, first-run check with --dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 12:46:58 +01:00
gnilebeinandClaude Sonnet 5.5 a19cd8339e Add poll expiry, reminder mail and polls admin CLI
CI / Deploy / PHP 8.4 (push) Successful in 1m57s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 2m9s
Polls are deleted POLL_RETENTION_DAYS (default 90) after creation by the
cron job `bin/cake polls cleanup`. POLL_REMINDER_DAYS (default 14) before
that the owner gets a one-time reminder mail (expiry_reminded_at).

New commands: polls list, show (admin link only with --link), delete,
remind, cleanup. The expiry date is shown in the creation mail and the
dashboard. Docs: README, AGENTS.md, .env.example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 12:46:12 +01:00
gnilebein 3c07eba7db Merge pull request 'Feature/slide images' (#81) from feature/slide-images into main
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m9s
Reviewed-on: #81
2026-11-15 14:02:41 +01:00
gnilebeinandClaude Sonnet 5.5 4caff47a09 Drop the image description field
CI / Deploy / PHP 8.4 (push) Successful in 1m27s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m24s
Slide images are shown on the presenter's screen, so a description for
screen readers is not asked for any more. The column stays (always empty).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 13:59:33 +01:00
gnilebeinandClaude Sonnet 5.5 33c75e504f Make the slide image description optional
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
A missing description rejected the whole save and dropped the selected
file, which cannot be refilled in the form. The description is now an
optional hint for screen readers; empty means alt="". The "decorative"
checkbox is gone, it meant the same.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 13:56:27 +01:00
gnilebeinandClaude Sonnet 5.5 8522918c75 Use a trash button to remove a slide image
CI / Deploy / PHP 8.4 (push) Successful in 1m35s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m35s
With JavaScript the "remove image" checkbox is replaced by a button with a
trash icon that toggles the same checkbox, dims the preview and announces
the pending removal. Without JavaScript the checkbox still works.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 13:54:13 +01:00
gnilebein 492872750c Merge pull request 'Add optional images to slides' (#80) from feature/slide-images into main
CI / Deploy / PHP 8.4 (push) Successful in 1m13s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m12s
Reviewed-on: #80
2026-11-14 23:22:00 +01:00
gnilebeinandClaude Sonnet 5.5 a395b50894 Add optional images to slides
CI / Deploy / PHP 8.4 (push) Successful in 1m10s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
Slides (except YouTube) can carry one image. Uploads are validated, rotated
by EXIF orientation, scaled to 1600 px and stored as WebP outside webroot,
which also strips camera metadata. Images have an alt text (or are marked
decorative) and a layout: top, side or full screen (content slides).

Files are removed after the commit when a slide is deleted or its image is
replaced, with the poll, and `bin/cake images_cleanup` sweeps leftovers.
Duplicated slides get their own file. Docker image gains gd with WebP.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 23:17:37 +01:00
gnilebein f887b99a1e Merge pull request 'Let the dashboard follow the presenter' (#79) from feature/clicker-quiz-and-reset into main
CI / Deploy / PHP 8.4 (push) Successful in 1m0s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m2s
CI / Deploy / test (push) Successful in 2s
Reviewed-on: #79
2026-11-13 12:22:43 +01:00
gnilebeinandClaude Sonnet 5.5 8c7818ee40 Let the dashboard follow the presenter
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
The live marker in the slide list stayed on the last known slide when the
presenter moved on in another window or with a clicker. The dashboard now
polls a cheap version fingerprint (admin:live) and reloads the lists when it
changes, but never under an open dialog, a pending request or a drag.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 12:19:12 +01:00
gnilebein a633ac6f23 Merge pull request 'Offer reset when slides were touched, not only when answers exist' (#78) from feature/clicker-quiz-and-reset into main
CI / Deploy / PHP 8.4 (push) Successful in 1m10s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / PHP 8.5 (push) Successful in 1m11s
Reviewed-on: #78
2026-11-13 10:55:35 +01:00
gnilebein 06a1171bf5 Merge pull request 'Document required and default values for environment variables' (#77) from docs/readme-env-table into main
CI / Deploy / PHP 8.4 (push) Successful in 1m3s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 59s
Reviewed-on: #77
2026-11-13 10:30:21 +01:00
gnilebeinandClaude Sonnet 5.5 3ba6e3e7ad Document required and default values for environment variables
CI / Deploy / PHP 8.4 (push) Successful in 1m7s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m8s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 10:28:22 +01:00
gnilebeinandClaude Sonnet 5.5 9c6a19f0de Offer reset when slides were touched, not only when answers exist
CI / Deploy / PHP 8.4 (push) Successful in 1m7s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m6s
The dashboard and per-slide reset buttons only checked for responses, so a
started quiz without votes, a closed slide or a running presentation could
not be reset. Check Slide::isFresh() and Poll::isStarted() as well.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 10:26:44 +01:00
gnilebein 355a22384b Merge pull request 'Feature/clicker quiz and reset' (#76) from feature/clicker-quiz-and-reset into main
CI / Deploy / PHP 8.4 (push) Successful in 59s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m3s
Reviewed-on: #76
2026-11-13 10:22:50 +01:00
gnilebeinandClaude Sonnet 5.5 0eb054ed29 Reset every slide to the state of a new slide
CI / Deploy / PHP 8.4 (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Resetting answers now reopens closed slides (and hides the solution of
ordering slides) instead of only restarting quiz and Q&A slides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 10:19:17 +01:00
gnilebeinandClaude Sonnet 5.5 e4622b439e Step through quizzes with next on a clicker
Next on a quiz starts it, then ends it, and only then moves to the next
slide. Prev always goes to the previous slide and never touches the quiz.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 10:18:43 +01:00
gnilebein 3c66597696 Merge pull request 'Reset poll to "not started" and keep prepared Q&A questions' (#75) from feature/reset-not-started into main
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / deploy (push) Successful in 11s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m4s
Reviewed-on: #75
2026-11-13 10:03:49 +01:00
gnilebeinandClaude Sonnet 5.5 97a60290b4 Reset poll to "not started" and keep prepared Q&A questions
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Resetting a poll now also clears the live/paused slide so the presentation
starts over. Questions entered beforehand on Q&A slides are kept by default
(only their upvotes are removed); the dashboard offers a checkbox to delete
them too. Resetting a single slide always keeps them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 09:52:26 +01:00
gnilebein 7be66fa5e4 Merge pull request 'Add optional comment field to multiple choice slides' (#74) from feature/choice-comments into main
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Release / test (push) Successful in 58s
Release / package (push) Successful in 38s
Release / image (push) Successful in 1m40s
Reviewed-on: #74
2026-11-13 09:31:37 +01:00
gnilebeinandClaude Sonnet 5.5 61718ed7c6 Add optional comment field to multiple choice slides
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m11s
Participants can justify their choice; the comment is stored once in the
first response row, rotates on the stage like scale comments and is listed
in the admin area and the PDF export.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 09:29:25 +01:00
gnilebein 303431c02b Merge pull request 'Hide quiz answer options on stage until the quiz starts' (#73) from fix/quiz-hide-options-until-start into main
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Successful in 8s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / PHP 8.5 (push) Successful in 1m10s
Reviewed-on: #73
2026-11-13 08:35:50 +01:00
gnilebeinandClaude Sonnet 5.5 28bfd535f4 Hide quiz answer options on stage until the quiz starts
CI / Deploy / PHP 8.4 (push) Successful in 1m16s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m17s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 08:33:56 +01:00
gnilebein 19320f01c4 Merge pull request 'Document Docker image as test-only' (#72) from docs/docker-test-only into main
CI / Deploy / PHP 8.4 (push) Successful in 1m8s
CI / Deploy / deploy (push) Successful in 5s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m9s
Release / test (push) Successful in 57s
Release / package (push) Successful in 37s
Release / image (push) Successful in 1m37s
Reviewed-on: #72
2026-11-12 23:04:27 +01:00
gnilebeinandClaude Sonnet 5.5 996173edeb Document Docker image as test-only
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / test (push) Successful in 3s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m10s
The image uses the built-in PHP server and SQLite, so it is not meant for
production. Say so in README, docker-compose.yml and AGENTS.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 23:03:14 +01:00
gnilebein 1d87281855 Merge pull request 'Stop FormHelper from emitting inline validity handlers' (#71) from fix/csp-inline-validity-handlers into main
CI / Deploy / PHP 8.4 (push) Successful in 1m4s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m3s
Reviewed-on: #71
2026-11-12 22:58:26 +01:00
gnilebeinandClaude Sonnet 5.5 220227fa86 Stop FormHelper from emitting inline validity handlers
CI / Deploy / PHP 8.4 (push) Successful in 1m7s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
Required fields got generated oninvalid/oninput attributes, which the CSP
blocks and logs on every page and when parsing dashboard fragments.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 22:54:08 +01:00
gnilebein a0f3f9885b Merge pull request 'Fix dashboard buttons posting to the wrong URL' (#70) from fix/dashboard-action-field into main
CI / Deploy / PHP 8.4 (push) Successful in 1m7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / PHP 8.5 (push) Successful in 1m6s
Reviewed-on: #70
2026-11-12 22:44:08 +01:00
gnilebeinandClaude Sonnet 5.5 77d0bfb547 Fix dashboard buttons posting to the wrong URL
CI / Deploy / PHP 8.4 (push) Successful in 1m4s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m5s
Forms with a field named "action" (play, pause) shadow the form.action
property, so the fragment request went to /admin/[object HTMLInputElement].
Read the attribute instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 22:42:03 +01:00
gnilebein ce2627d03a Merge pull request 'Feature/qa prepared questions' (#69) from feature/qa-prepared-questions into main
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / deploy (push) Successful in 7s
CI / Deploy / PHP 8.5 (push) Successful in 1m5s
CI / Deploy / test (push) Successful in 1s
Reviewed-on: #69
2026-11-12 22:37:00 +01:00
gnilebeinandClaude Sonnet 5.5 34d7e20567 Show two answer rows by default for quiz and order slides
CI / Deploy / PHP 8.4 (push) Successful in 1m0s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Successful in 2s
CI / Deploy / PHP 8.5 (push) Successful in 1m5s
Only two entries are required, so the form no longer offers four empty rows
up front; further rows come via the add button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 22:34:21 +01:00
gnilebeinandClaude Sonnet 5.5 4b5f9d92a1 Add prepared questions to Q&A slides
The slide form takes questions entered beforehand (e.g. received by mail),
one per line, while collecting. They are stored as regular questions with a
reserved participant hash, synced idempotently, and not counted as participants.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 22:34:12 +01:00
gnilebeinandClaude Sonnet 5.5 76d8bb3170 Require PHP 8.4 in README
PHP 8.3 is no longer listed as supported.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 22:33:49 +01:00
gnilebein 4c33d9fa15 Merge pull request 'Ci/php matrix' (#68) from ci/php-matrix into main
CI / Deploy / PHP 8.4 (push) Successful in 1m4s
CI / Deploy / deploy (push) Successful in 6s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m4s
Reviewed-on: #68
2026-11-12 10:56:06 +01:00
gnilebeinandClaude Sonnet 5.5 b4d7a48001 Test against PHP 8.4 and 8.5 and require PHP 8.4
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / test (push) Successful in 0s
CI / Deploy / deploy (push) Skipped
CI / Deploy / PHP 8.5 (push) Successful in 1m5s
The lock file pins PHPUnit 13 and Symfony 8, which need PHP 8.4. PHP 8.3
is in its last support year, so drop it from the matrix instead of
downgrading the dependencies.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 10:53:48 +01:00
gnilebeinandClaude Sonnet 5.5 5a3880c6e9 Run CI tests against PHP 8.3, 8.4 and 8.5
CI / Deploy / PHP 8.3 (push) Failing after 49s
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / deploy (push) Skipped
CI / Deploy / test (push) Failing after 1s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
Move the test steps into a matrix job and keep a aggregating `test` job so the
branch protection check name stays stable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 10:46:40 +01:00
107 changed files with 8536 additions and 1118 deletions

No files matched your search

+23 -4
View File
@@ -32,15 +32,21 @@ on:
branches: ['**']
jobs:
test:
# Matrix over the supported PHP versions.
phpunit:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
php-version: ${{ matrix.php }}
extensions: mbstring, intl, pdo_sqlite, sqlite3
coverage: none
@@ -53,6 +59,19 @@ jobs:
- name: Coding standard
run: vendor/bin/phpcs --warning-severity=0
# Stable check name required by the branch protection of main: green only if all PHP versions are green.
test:
needs: phpunit
if: always()
runs-on: ubuntu-latest
steps:
- name: All PHP versions passed
run: |
if [ "${{ needs.phpunit.result }}" != "success" ]; then
echo "Matrix result: ${{ needs.phpunit.result }}" >&2
exit 1
fi
deploy:
needs: test
# Deactivated until the repository variable DEPLOY_ENABLED is "true".
@@ -63,7 +82,7 @@ jobs:
cancel-in-progress: false
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ vars.SSH_HOST }}
port: ${{ vars.SSH_PORT || 22 }}
+9 -9
View File
@@ -29,7 +29,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Check tag is a semantic version
env:
@@ -60,7 +60,7 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
@@ -85,9 +85,9 @@ jobs:
index.php .htaccess composer.json composer.lock | tar -x -C build
cd "build/$NAME"
rm -f bin/cake.bat bin/bash_completion.sh
# --no-scripts: the installer must not bake a random salt into app_local.php (SECURITY_SALT comes from config/.env)
# --no-scripts: no app_local.php in the package; everything comes from config/.env (see app_local.example.php)
composer install --no-dev --no-scripts --no-interaction --no-progress --prefer-dist --optimize-autoloader
cp config/app_local.example.php config/app_local.php
rm -f config/app_local.example.php
mkdir -p tmp/cache/models tmp/cache/persistent tmp/cache/views tmp/sessions logs data
printf '%s\n' "$VERSION" > VERSION
cd ../..
@@ -138,13 +138,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Login to registry
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
registry: ${{ vars.DOCKER_REPO }}
username: ${{ gitea.actor }}
@@ -152,7 +152,7 @@ jobs:
- name: Image tags
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6
with:
images: ${{ vars.DOCKER_REPO }}/${{ gitea.repository_owner }}/${{ vars.IMAGE_NAME }}
tags: |
@@ -161,7 +161,7 @@ jobs:
type=semver,pattern={{major}},enable=${{ !contains(gitea.ref_name, '-') && !startsWith(gitea.ref_name, 'v0.') }}
- name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
file: ./Dockerfile
platforms: linux/amd64
+33
View File
@@ -0,0 +1,33 @@
# Dependency updates with Renovate (Composer packages, Docker base images, workflow actions).
#
# Runs every two hours (UTC) and on demand. Renovate opens pull requests on `renovate/*` branches; the normal CI
# (ci.yml, job `test`) runs on them, and they are merged by hand like every other PR.
# Rules live in renovate.json. Renovate is restricted to this repository (no autodiscovery).
#
# Repository secret (Settings → Actions → Secrets):
# RENOVATE_TOKEN Gitea access token with scopes repository (read/write), issue (read/write),
# user (read); plus organization (read) if the repo belongs to an organization.
name: Renovate
on:
schedule:
- cron: '0 */2 * * *'
workflow_dispatch:
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Run Renovate
uses: renovatebot/github-action@v47.0.0
with:
token: ${{ secrets.RENOVATE_TOKEN }}
env:
RENOVATE_PLATFORM: gitea
RENOVATE_ENDPOINT: ${{ gitea.server_url }}/api/v1
RENOVATE_REPOSITORIES: ${{ gitea.repository }}
RENOVATE_GIT_AUTHOR: Renovate Bot <renovate@noreply.invalid>
GITHUB_COM_TOKEN: ${{ secrets._GITHUB_COM_TOKEN }}
LOG_LEVEL: info
+2
View File
@@ -12,6 +12,8 @@
/webroot/bake
# SQLite-Backups aus der Deploy-Pipeline
/data/backups/
# Folienbilder (UPLOADS_PATH)
/data/uploads/
# Composer
/composer.phar
# Test-/Analyse-Artefakte
+56 -271
View File
@@ -1,7 +1,7 @@
# AGENTS.md – Infos für KI-Agents
Diese Datei ist die zentrale Arbeitsgrundlage für KI-Agents (Claude Code, Codex, Cursor, …).
**Halte sie aktuell**, wenn du Architektur, Konventionen, Routen, Konfiguration oder Befehle änderst.
**Halte sie und `docs/` aktuell**, wenn du Architektur, Konventionen, Routen, Konfiguration oder Befehle änderst.
Lokale, maschinenspezifische Infos gehören in `CLAUDE.local.md` (nicht versioniert).
## Rolle & Arbeitsweise
@@ -33,6 +33,8 @@ E-Mail anlegen, kein Login, Verwaltung über einen geheimen Admin-Link, Teilnahm
| Tests | `vendor/bin/phpunit` |
| Coding Standard | `vendor/bin/phpcs` / Autofix `vendor/bin/phpcbf` |
| Neue Migration | `bin/cake bake migration NameDerMigration` |
| Verwaiste Folienbilder löschen | `bin/cake images_cleanup [--dry-run]` |
| Umfragen verwalten (Admin-CLI) | `bin/cake polls list\|show\|delete\|remind\|cleanup\|seed` (siehe [docs/operations.md](docs/operations.md)) |
**Vor jedem Commit:** `vendor/bin/phpunit` und `vendor/bin/phpcs` müssen grün sein
(Warnungen zur Zeilenlänge bei langen deutschen Texten sind ok).
@@ -40,74 +42,46 @@ E-Mail anlegen, kein Login, Verwaltung über einen geheimen Admin-Link, Teilnahm
Zum manuellen Testen im Browser bzw. per HTTP den Cake-Dev-Server nutzen (`bin/cake server`).
Mails landen lokal als `.eml` in `tmp/mails/`; im Debug-Modus zeigt `/created` den Admin-Link direkt an.
## Architektur
## Weitere Dokumentation (`docs/`)
Hier stehen nur Überblick und Regeln, die nie gebrochen werden dürfen. **Wer einen Bereich ändert, liest vorher das
passende Dokument und pflegt es danach** (Details zu Verhalten, Settings, Tests und Fallstricken):
| Bereich | Dokument |
|---|---|
| Lokal starten, Tests, Mitarbeit | [docs/development.md](docs/development.md) |
| Verzeichnisstruktur, Klassen, Tabellen | [docs/architecture.md](docs/architecture.md) |
| Folientypen (Wortwolke, Quiz, Q&A, Reihenfolge, YouTube, Skala/Sterne, Kommentare), Checkliste „Neuen Folientyp hinzufügen“ | [docs/slide-types.md](docs/slide-types.md) |
| Folienbilder (Upload, Ablage, Löschen) | [docs/images.md](docs/images.md) |
| Live-Schaltung, Referentenansicht, Pause, Ausblenden, Zurücksetzen, Duplizieren, Umfrage kopieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) |
| Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild | [docs/frontend.md](docs/frontend.md) |
| PDF-Export | [docs/pdf-export.md](docs/pdf-export.md) |
| Ablauf/Cleanup von Umfragen, CI/Deploy, Releases, Docker, Renovate | [docs/operations.md](docs/operations.md) |
| Betreiber-Anleitung (Docker, Cronjob, Releases) und Umgebungsvariablen | [docs/deployment.md](docs/deployment.md), [docs/configuration.md](docs/configuration.md) |
## Architektur in Kürze
```
config/
app.php Defaults inkl. Block 'Plenario' (Captcha, Throttle, Polling) und Cache 'throttle'
app_local.example.php Vorlage für app_local.php (SQLite, FileTransport) – app_local.php ist gitignored
.env.example Alle Umgebungsvariablen (config/.env wird optional geladen)
routes.php Alle Routen benannt, KEINE Fallback-Routen
Migrations/ Schema (einzige Quelle der Wahrheit, auch für Tests)
config/ app.php (Block 'Plenario'), app_local.php (nur lokal, gitignored; Produktion nur .env), .env.example,
routes.php (alle Routen benannt, KEINE Fallbacks), Migrations/ (Schema = einzige Quelle der Wahrheit)
src/
Captcha/ CaptchaInterface + NoCaptcha / MathCaptcha / RecaptchaCaptcha, CaptchaFactory
Error/RedactingErrorLogger maskiert Admin-Token und Embed-Key in allen Log-Einträgen (`Error.logger` in app.php)
Controller/
AppController Basis aller Controller: `joinUrl()`, `adminUrlFor()`, `setPollInterval()`, `throttle()`, `json()`,
`protect()` (no-referrer/noindex/no-store für Seiten mit Geheimnis in der URL: Admin, Embed)
HomeController Startseite, Anlegen (/create), Bestätigung, Join, Recover
AdminAppController Basis für /admin/{token}: löst Poll über Token-Hash auf (404 sonst), setzt Privacy-Header (no-referrer, no-store)
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Löschen
SlidesController Folien-CRUD, Ein-/Ausblenden (`visibility`), Duplizieren (`duplicate` → `SlidesTable::duplicate()`, Kopie direkt dahinter, öffnet das Formular der Kopie), Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
YouTube-Link prüfen (`youtubeCheck`, JSON)
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigene Antwort/Kommentar bearbeiten; anonymes Cookie plenario_pid
EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control
ErrorController Fehlerseiten (Templates unter templates/Error, Layout `error`)
Mailer/ PollMailer (adminLink, recovery; `sendSafely()` loggt Transportfehler statt zu werfen), Transport/FileTransport (lokal)
Middleware/ HostHeaderMiddleware: prüft in Produktion den Host gegen APP_FULL_BASE_URL;
SecurityHeadersMiddleware (äußerste Schicht): CSP mit Nonce, Framing, nosniff, Referrer-/Permissions-Policy
für alle Antworten inkl. JSON und Fehlerseiten; vom Controller gesetzte Header gewinnen
Model/ Polls → Slides → SlideOptions, Slides → Responses
Service/
VoteService Validiert + speichert Antworten (alle Abstimmungsregeln hier)
ResultsService Aggregiert Ergebnisse je Folientyp (JSON-Struktur im Docblock)
PollStateService State-JSON für Presenter und Teilnehmende
ThrottleService Rate-Limit pro IP (Cache 'throttle'), in Controllern über `AppController::throttle()`:
Anlegen/Recover pro Stunde, Antworten (`vote`) pro Minute (`THROTTLE_VOTES_PER_MINUTE`, 429)
YouTubeService YouTube-Links/Timecodes parsen, Watch-/Embed-URLs, Prüfung per oEmbed (Http\Client)
QaService Q&A: Phasen wechseln, Fragen nach Upvotes ranken, Fokus beim Besprechen
SlideControlService Folien-Aktionen open/close/toggle/stage/question (Presenter und Einbettung gemeinsam)
ResetService Antworten löschen: einzelne Folie (`slide`) bzw. alle Folien der Umfrage (`poll`)
ReportService Daten für den PDF-Export: Ergebnisse aller interaktiven Folien, mit/ohne interne Inhalte
View/PdfView.php Rendert Template als HTML (Layout `pdf`) und wandelt es mit Dompdf in ein PDF
templates/ Deutsche UI, Layouts: default, present (Vollbild, dunkel), error, email
webroot/css/plenario.css Eigenes CSS, kein Framework; Farben nur als Tokens (Hell/Dunkel, siehe Theme unten)
webroot/js/plenario.js Vanilla JS: Polling, Ergebnis-Rendering, Presenter-Steuerung, Sortieren (`makeSortable`: Pointer Events + Pfeiltasten,
genutzt für Folienliste, Reihenfolge-Editor und Teilnehmer-Antwort)
tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures sind leer
Controller/ AppController (Basis), Home, Admin (+ AdminAppController), Slides, Participate, Embed, Error
Service/ VoteService, ResultsService, PollStateService, ThrottleService, ImageService, YouTubeService,
QaService, SlideControlService, ResetService, ReportService
Model/ Polls → Slides → SlideOptions, Slides → Responses
Middleware/ HostHeader, SecurityHeaders (CSP mit Nonce, Framing, Referrer-Policy)
Command/ images_cleanup, polls list|show|delete|remind|cleanup|seed
Mailer/ PollMailer
templates/ Deutsche UI; Layouts: default, present, error, email, fragment, pdf
webroot/ css/plenario.css (eigenes CSS, Tokens), js/plenario.js (Vanilla JS)
tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures sind leer
```
### Datenmodell
Folientypen: `choice|wordcloud|open|scale|content|quiz|youtube|qa|order`. Live-Updates: kein WebSocket, Presenter und
Teilnehmende pollen per `fetch` (`Plenario.pollIntervalMs`), die Teilnehmerseite lädt bei geänderter `version` neu.
Vollständige Struktur und Datenmodell: [docs/architecture.md](docs/architecture.md).
- `polls`: `title`, `email`, `admin_token_hash` (sha256), `admin_token_encrypted` (Security::encrypt),
`join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`,
`last_admin_access` (höchstens alle 10 min aktualisiert, Grundlage für ein künftiges Aufräumen alter Umfragen),
`embed_key` (Einbett-Schlüssel), `embed_seen_at` (letztes Lebenszeichen der eingebetteten Live-Folie),
`paused_slide_id` (Folie vor der Pause), `comment_speed` (Tempo der Skala-Kommentare in Prozent, Standard 100)
- `slides`: `type` (`choice|wordcloud|open|scale|content|quiz|youtube|qa|order`), `question`, `description`, `position`,
`is_hidden` (ausgeblendet: vorbereitet, aber nicht Teil der Präsentation),
`settings` (JSON, je Typ siehe `Slide::DEFAULT_SETTINGS`), `is_voting_open`,
`voting_started_at` / `voting_ends_at` (nur Quiz: Start und Deadline, `null` = manuell beenden),
`stage` / `focus_response_id` (nur Q&A: Phase und gerade besprochene Frage)
- `slide_options`: Antwortoptionen für `choice`, `quiz` und `order`; `is_correct` markiert richtige Quiz-Antworten,
bei `order` ist `position` die richtige Reihenfolge
- `responses`: `participant_hash`, `slide_option_id` | `text_value` | `numeric_value` | `parent_id`.
Mehrfachauswahl/mehrere Wörter = mehrere Zeilen mit gleichem `participant_hash`.
Q&A: Frage = Zeile mit `text_value`, Upvote = Zeile mit `parent_id` (= id der Frage, FK mit CASCADE).
Reihenfolge: eine Zeile pro Person, `text_value` = Options-ids kommagetrennt (`VoteService::parseOrder()`).
Skala: `numeric_value`, optional Kommentar in `text_value`.
### Zentrale Regeln (nicht versehentlich brechen)
## Zentrale Regeln (nicht versehentlich brechen)
- **Kein Login.** Zugriff auf die Verwaltung = Besitz des Tokens in der URL `/admin/{token}`.
Token nie loggen (Fehler-Logs maskiert `RedactingErrorLogger` automatisch; eigene `Log::…`-Aufrufe nie mit URL/Token),
@@ -128,187 +102,27 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
Reihenfolge nach dem Schließen) – dann nur die Lösung **ohne** Zählungen/Verteilung (`PollStateService::participantResults()`
entfernt `count`, `percent`, `placed`, `correctCount`; die JS-Renderer erkennen daran die Teilnehmeransicht).
Q&A nutzt eigenes `qa`. Es gibt keinen Schalter dafür pro Umfrage.
- Ausnahme Wortwolke: Begriffe werden einzeln abgegeben (AJAX, `vote` liefert dann JSON `{ok, message, state}`),
jeder Begriff einmal pro Person, beliebig viele Begriffe. Einen vorhandenen Begriff erneut nennen
bzw. in der Wolke anklicken = Upvote (gleiche Zeile in `responses`). Mit `allow_upvotes` sehen Teilnehmende
die Wolke live; Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`).
Downvotes (`vote=down`, Setting `allow_downvotes`, nur zusammen mit Upvotes): Zeile mit `numeric_value = VoteService::DOWNVOTE` (-1),
nur auf fremde, vorhandene Begriffe, ein Rating pro Begriff und Person.
Wortgröße richtet sich nur nach den Upvotes (`count`), Downvotes stehen separat in `down`.
`vote=remove` nimmt den eigenen Eintrag zu einem Begriff zurück (genannt/Upvote oder Downvote, `VoteService::removeWord()`,
löscht nur Zeilen mit dem eigenen `participant_hash`); Tippfehler = entfernen und neu eingeben, kein Bearbeiten (die Zeile
ist zugleich die Stimme). Teilnehmende bekommen dafür `words.own` (eigene Begriffe wie eingegeben) und sehen sie als Chips mit „ד.
- Quiz: Phasen `ready` → `running` → `finished` (`Slide::quizPhase()`). Neue Quiz-Folien starten geschlossen;
erst der Presenter startet (`control` open/toggle → `Slide::setVotingOpen()` setzt Start + Deadline aus
`time_limit`, erneutes Öffnen eines laufenden Quiz startet den Timer nicht neu). „Offen“ heißt immer
`Slide::isVotingOpen()` (inkl. Deadline), nicht nur `is_voting_open`. Abgelaufene Quizze schließt
`SlidesTable::closeIfExpired()` beim State-Abruf. **Zählungen und `is_correct` dürfen vor `finished` nie im
JSON/HTML landen** (weder Presenter noch Teilnehmende); danach sehen Teilnehmende die Lösung und ob sie
richtig lagen (ohne Verteilung). Zurücksetzen setzt das Quiz wieder auf `ready`.
- **Quiz:** Zählungen und `is_correct` dürfen vor `finished` nie im JSON/HTML landen (weder Presenter noch Teilnehmende);
„offen“ heißt immer `Slide::isVotingOpen()`, nicht nur `is_voting_open`. Details: [docs/slide-types.md](docs/slide-types.md).
- **Reihenfolge:** richtige Reihenfolge und Zählungen erst nach dem Schließen der Abstimmung im JSON, nie vor dem Start eines Countdowns
(`Slide::isOrderRevealed()` ist in der Phase `ready` falsch).
- **Countdown:** jede Folie mit Antworten außer Q&A kann ein Zeitlimit haben (`time_limit`, 0 = keins). Mit Countdown startet sie geschlossen
(`ready`), zeigt nur die Frage, „Weiter“ startet/beendet ihn wie beim Quiz. Auf die Bühne gehen Ergebnisse dafür nur über
`ResultsService::forStage()`. Details: [docs/slide-types.md](docs/slide-types.md).
- **Pause/Live-Folie:** `current_slide_id`/`paused_slide_id` nur über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` /
`forgetSlide()` setzen, nie direkt. Details: [docs/presenter.md](docs/presenter.md).
- `Poll`/`Response` haben `_hidden` für sensible Felder; mass assignment über `_accessible` restriktiv halten.
- Alle POST-Formulare laufen über CSRF (`CsrfProtectionMiddleware`). JS sendet `X-CSRF-Token` aus `<meta name="csrf-token">`.
Ausnahme: Embed-Routen (siehe [docs/presenter.md](docs/presenter.md)).
- Ausgaben in Templates immer mit `h()` escapen. JS baut DOM mit `textContent`, nie `innerHTML` mit Nutzerdaten.
- **CSP:** keine Inline-Event-Handler (`onclick=` …) und kein `eval`; Verhalten per `data-*`-Attribut in `plenario.js`.
Skripte über `$this->Html->script()` (bekommt die Nonce automatisch); ein unvermeidbares Inline-`<script>` braucht
`nonce` aus dem Request-Attribut `cspScriptNonce` (Beispiel: `element/theme_init`). Neue externe Quellen (Skripte,
Iframes) in `SecurityHeadersMiddleware::policy()` freigeben. Inline-`style`-Attribute sind erlaubt.
Bestätigungs-Buttons: `Form->postButton()` + `data-confirm`, nie `postLink` mit `confirm`.
- Routen nur benannt verwenden (`['_name' => 'admin', 'token' => $adminToken]`), keine Fallbacks einführen.
- Q&A-Folie (`qa`, „Fragen & Antworten“): Phasen `collect` → `vote` → `discuss` (`Slide::qaStage()`, `QaService`),
der Presenter schaltet manuell weiter (V bzw. Stepper, auch zurück). `collect`: Fragen einreichen (max.
`VoteService::MAX_QA_QUESTIONS` pro Person, gleiche Frage nur einmal pro Folie), Teilnehmende sehen alle bisherigen Fragen
(gegen Dubletten, eigene markiert), aber noch keine Upvotes.
`vote`: Upvotes auf fremde Fragen, Budget pro Person = Anteil der Fragen (Setting `upvote_share` in Prozent, `Slide::QA_UPVOTE_SHARES`, aufgerundet, mindestens 1:
`Slide::qaBudget(Anzahl Fragen)`; im State/JSON `maxUpvotes`), wächst also mit der Fragenzahl, frei verteilbar (auch mehrere auf eine Frage,
je Upvote eine Zeile), `vote=remove` nimmt eine Stimme der Frage zurück; im State `qa.upvoted` = {Frage-id: eigene Stimmen}.
Setting `max_upvotes_per_question` begrenzt die eigenen Stimmen je Frage (0 = nur durch das Budget begrenzt,
effektiv `Slide::qaUpvotesPerQuestion($budget)`, State `maxPerQuestion`). `upvote_share = 0` = ohne Upvotes: es gibt keine Phase `vote`
(`Slide::qaStages()` = collect → discuss, im Presenter-JSON `results.stages`), besprochen wird in Eingangsreihenfolge;
wird es während `vote` auf 0 gesetzt, springt `SlidesController::saveSlide()` nach `discuss`.
Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget
(State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt;
Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung; die Bühne (Presenter/Embed) zeigt in `vote` keine Fragen,
sondern nur den Hinweis „Schau auf dein Gerät und stimme ab“ mit Fragenzahl, Budget und vergebener Gesamtsumme (`Results.qa`); auch sonst gibt es dort
keine Zählungen je Frage und keine Rangfolge (`ResultsService::qa()`, nur die Summe `upvotes`), damit niemand beeinflusst wird. `discuss`: Abstimmung zu, Fragen nach Upvotes
sortiert (Gleichstand: älteste zuerst), `focus_response_id` = aktuelle Frage. In `discuss` blättern next/prev
(→/←, Klicker) zuerst durch die Fragen, erst danach durch die Folien. Fokuswechsel per `updateAll` ohne `modified`,
damit Teilnehmerseiten nicht neu laden. Teilnehmende bekommen nie `results`, sondern `qa` aus `PollStateService::qaState()`.
Zurücksetzen startet wieder bei `collect`.
Eigene Fragen bearbeiten/löschen (`vote=edit|delete` + `question_id`, `VoteService::editQuestion()`) nur in `collect`:
danach könnten Upvotes bzw. die Besprechung an einem anderen Text hängen. Bearbeiten prüft Dubletten ohne die eigene Frage,
Löschen entfernt auch übrig gebliebene Upvotes (Presenter von `vote` zurück nach `collect`). Im JS hält `qaEditing` das
Neu-Rendern beim Polling an, solange eine Frage bearbeitet wird.
- YouTube-Folie (`youtube`): nicht interaktiv (wie `content`). Settings `url` (wie eingegeben), `video_id`, `start` (Sekunden),
`autoplay`. Startzeit-Feld leer = Timecode aus dem Link (`t`/`start`), sonst gewinnt das Feld (`1:30`, `2` = Minuten).
Beim Speichern prüft `SlidesController::prepareYouTube()` per oEmbed: nicht gefunden/nicht einbettbar = Fehler,
YouTube nicht erreichbar = speichern mit Warnung; leerer Titel wird mit dem Videotitel gefüllt. Eingebettet wird nur
im Presenter (`youtube-nocookie.com`), Teilnehmende sehen Link + Teilen-Button (Web Share API, sonst Kopieren).
Iframes brauchen `referrerpolicy="strict-origin"`, weil Admin-Seiten `no-referrer` senden und YouTube ohne Referrer
nicht abspielt (nur Origin, nie der Pfad mit Token). Tests mocken YouTube über `HttpClientTrait` (`mockClientGet`).
- Reihenfolge-Folie (`order`): Admin legt die Einträge in der richtigen Reihenfolge an (Formular `order_options[]`, Zeilen
per Drag & Drop/Pfeiltasten sortierbar, ids bleiben beim Umsortieren erhalten). Teilnehmende bekommen sie per
`Slide::shuffledOptions(participantHash)` gemischt (stabil, nie schon richtig), sortieren und senden `order[]` (alle ids genau einmal),
einmal pro Person. Startet offen wie normale Folien; **aufgelöst wird beim Schließen der Abstimmung** (`Slide::isOrderRevealed()`).
Vorher landen weder richtige Reihenfolge noch Zählungen im JSON (Presenter sieht die Einträge gemischt mit Seed `slide:{id}`);
danach sieht der Presenter die Lösung inkl. „X von N komplett richtig“ und je Eintrag, wie oft er an der richtigen Stelle lag;
Teilnehmende nur die Lösung mit eigenen Platzierungen und `order.isCorrect`. Tests: `OrderTest.php`, `OrderSlideTest.php`.
- **Zurücksetzen** (`ResetService`) löscht **nur Antworten**: Folie (`slides:reset`) bzw. alle Folien der Umfrage
(`admin:reset`, Dashboard → „Sicherheit“). Nur Quiz (`ready`) und Q&A (`collect`) springen zurück, weil ihre Phasen
ohne Antworten keinen Sinn ergeben; offen/geschlossen anderer Folien, aktuelle Folie/Pause, Einstellungen bleiben.
Idempotent, in einer Transaktion. Tests: `PollResetTest.php`.
- **Duplizieren** (`slides:duplicate`, POST): kopiert Fragetext (+ „(Kopie)“), Beschreibung, Einstellungen und Optionen
inkl. `is_correct`, **nie Antworten**. Die Kopie landet direkt hinter dem Original und startet wie eine neue Folie
(`Slide::startFresh()`: Quiz `ready`, Q&A `collect`, sonst offen) – auch `add()` nutzt `startFresh()`.
Tests: `DuplicateSlideTest.php`.
- **Ausgeblendete Folien** (`is_hidden`, `slides:visibility` mit `hidden=1|0`, explizit statt Toggle → idempotent):
bleiben in der Verwaltung (gestrichelt, Badge „ausgeblendet“), gehören aber nicht zur Präsentation. Präsentation =
`SlidesTable::listForPoll($pollId, true)`: Start, →/←, `goto` (400 für ausgeblendete), Zähler im Presenter-State
(`count` ohne, `hiddenCount` = ausgeblendete), PDF-Export (Nummerierung wie in der Präsentation). Einbettung einer
ausgeblendeten Folie geht nicht live (`isHidden` im Embed-State). Eine ausgeblendete Folie darf nie live/pausiert sein:
Ausblenden der Live- oder pausierten Folie pausiert wie Löschen (`forgetSlide()` + `SlidesTable::replacementFor()` =
nächste sichtbare Folie, sonst die vorige). `is_hidden` ist nicht mass-assignable. Tests: `HiddenSlideTest.php`.
- **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne
`paused_slide_id` = noch nicht gestartet. Immer über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` /
`forgetSlide()` setzen, nie `current_slide_id` direkt. Presenter: P bzw. der Pause-Button schaltet um (Aktionen `stop`/`resume`, beide idempotent, kein Server-Toggle),
←/→ setzt ebenfalls bei der pausierten Folie fort.
Wird die Live- oder pausierte Folie gelöscht, pausiert die Umfrage und setzt mit der nachrückenden Folie fort
(`forgetSlide()`, keine FKs auf `current_slide_id`/`paused_slide_id`, sie dürfen nie auf gelöschte Folien zeigen).
- **Einbettung** (`/e/{key}/{id}`, `EmbedController`): eigener `embed_key` statt Admin-Token (darf nur diese Folie zeigen,
live schalten, pausieren und `SlideControlService`-Aktionen), wird beim ersten Dashboard-Aufruf erzeugt
(`ensureEmbedKey`, idempotent) und lässt sich neu erzeugen. Die Seite schaltet sich live, solange sie sichtbar ist
(IntersectionObserver + `visibilitychange`), sendet Heartbeats und beim Verschwinden `pause` (sendBeacon).
`pause` wirkt nur, wenn die eigene Folie noch live ist; `heartbeat` holt keine Folie zurück, die im Presenter
gewechselt wurde. Bleiben Heartbeats aus (`Plenario.embed.timeoutSeconds`), pausiert `PollsTable::pauseIfEmbedStale()`
beim nächsten State-Abruf. Embed-Routen haben **keinen CSRF-Check** (Third-Party-Iframe ohne Cookies, der Schlüssel
ist die Berechtigung, siehe `Application::middleware()`) und erlauben Framing per CSP `frame-ancestors`
(`EMBED_FRAME_ANCESTORS`); alle anderen Seiten bleiben `X-Frame-Options: SAMEORIGIN`. Beides entscheidet
`SecurityHeadersMiddleware::isEmbed()` anhand des Pfads (auch für Fehlerseiten).
- **Anonymes / internes Feedback** (offene Frage bzw. Skala mit Setting `private`, `Slide::isPrivate()`): steuert den
Schalter „Ergebnisse verbergen“ (H) im Presenter/Embed. Das JSON enthält die vollständigen Ergebnisse plus
`results.private = true`; `initPresenter` verbirgt sie beim Wechsel auf eine solche Folie und zeigt stattdessen nur die
Anzahl (`Results.privateSummary`). Einblenden gilt nur für diese Folie, die globale Wahl für normale Folien (`hideAll`)
bleibt unberührt. Teilnehmende bekommen (wie bei allen Abstimmungsfolien) keine `results`. Die Fassung des PDF-Exports ohne interne Inhalte entfernt sie per
`ResultsService::withoutContents()`. Volle Ansicht in der Verwaltung (`slides:answers` → „Auswertung“).
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value`
in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State
`results.comments` (Teilnehmende bekommen sie nie: Skalen liefern ihnen grundsätzlich keine `results`, siehe `PollStateService::forParticipant()`)
(älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch (Anzeigedauer nach Textlänge, kein Setting pro Folie:
`Comments.delay()` = 2,5 s + 15 Zeichen/s, 5–30 s, geteilt durch das Tempo der Umfrage `polls.comment_speed` (Prozent aus
`Poll::COMMENT_SPEEDS`, im State `poll.commentSpeed` als Faktor, Dashboard → „Einstellungen“); Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „Kommentar X von N“,
vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem
`animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling; die Box ist so hoch wie der längste Kommentar – alle liegen unsichtbar in derselben Grid-Zelle –, damit die zentrierte Bühne beim Wechsel nicht springt; höchstens `--comment-max` ≈ 5 Zeilen, längere Kommentare setzt `Comments.fit()` kleiner statt sie abzuschneiden; die Bewertung steht über dem Text, damit sie an fester Stelle bleibt; der Fortschritt läuft als Rahmen der Box: `Comments.progressBorder()`, SVG-Rechteck mit `pathLength` 100, zwei Linien ab gegenüberliegenden Ecken). Bei internem Feedback erscheinen sie erst,
wenn der Presenter die Ergebnisse einblendet.
- **Sterne-Bewertung** (Skala mit Setting `style = stars`, `Slide::isStarRating()`, Standard `numbers`): immer 1 bis `scale_max`
Sterne (`SlidesTable::sanitizeSettings()` erzwingt `scale_min = 1`), gespeichert wie jede Skala als `numeric_value`.
Teilnehmende wählen Sterne (Radios in DOM-Reihenfolge 1..n, Füllung per CSS `:has()`), der State enthält `results.stars`;
`Results.stars` in `plenario.js` zeigt den Durchschnitt als teilweise gefüllte Sterne und die Verteilung als Donut 5 → 1.
Text-Ausgabe (Auswertung, PDF) über `Slide::ratingText()` (`★★★★☆`), barrierearm über `element/rating`.
- **Skala-Darstellung auf der Bühne:** Durchschnitt (große Zahl + Skala bzw. Sterne) und Verteilung (Donut per CSS
`conic-gradient`, je Wert eine eigene Farbe aus `--c0…--c5` in fester Reihenfolge, bei mehr Werten gemischt; Legende mit „% (Anzahl)“ und den Beschriftungen der Enden) nebeneinander
(`Results.scaleLayout()` / `Results.donut()`). Setting `scale_view` (`Slide::SCALE_VIEWS`: `both` | `average` | `chart`,
Dropdown im Formular) zeigt nur einen Teil, dann zentriert; im JSON `results.view`, die Daten bleiben vollständig.
Gilt nur für Presenter/Embed, Auswertung und PDF zeigen immer beides.
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
`submit()`, in der Folien-Sperre, legt nie eine neue Antwort an.
- **Formatierung von Folientexten** (nur `description`, nie Eingaben von Teilnehmenden) im WhatsApp-Stil: `*fett*`,
`_kursiv_`, `~durchgestrichen~`, Aufzählung mit `- `/`* ` am Zeilenanfang, Zeilenumbrüche. Zwei gleiche Implementierungen:
`FormatHelper::text()` (PHP: Teilnehmerseite, PDF; escapt alles und erzeugt nur diese Tags) und `Format` in `plenario.js`
(Presenter/Embed; baut DOM-Knoten, kein `innerHTML`). Regeln in beiden gleich halten (Regex `INLINE`/`LIST_ITEM`),
Tests: `FormatHelperTest.php`.
- **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller
interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien
(`Slide::isPrivate()`) erscheinen nur mit Teilnehmerzahl. `?internal=1` = vollständige Fassung inkl.
anonymer Antworten, interner Skalen und Kommentar-Bewertungen (Dateiname `…-intern.pdf`, Hinweis „Vertraulich“ auf jeder
Seite); ohne private Folien wird der Parameter ignoriert. Quiz/Reihenfolge folgen auch hier den Auflöse-Regeln
(vor `finished` bzw. Schließen keine Zählungen/Lösung). Layout `templates/layout/pdf.php` ist eigenständig: keine
externen Ressourcen, keine CSS-Variablen, Schrift DejaVu Sans; Seitenzahlen setzt `PdfView::addPageNumbers()`.
Tests prüfen das HTML über `PlenarioTestTrait::exportHtml()` (das PDF selbst ist nicht durchsuchbar).
- **Vollbild & Display anlassen** (Teilnehmeransicht, `initScreenTools` in `plenario.js`): zwei optionale Icon-Buttons im Header neben dem Farbschema-Schalter (Layout-Block `headerTools`)
(`data-fullscreen-toggle`, `data-wakelock-toggle`), bleiben ohne Browser-Unterstützung versteckt (iPhone-Safari kennt kein Vollbild).
Der Wake Lock ist standardmäßig an (braucht keine Nutzergeste); nur ein bewusstes Ausschalten wird gemerkt.
Die Seite lädt bei Folienwechsel neu: der Wake Lock wird per `sessionStorage` (`plenario-wakelock`) wieder angefordert,
Vollbild braucht eine Nutzergeste und muss nach dem Wechsel ggf. neu gewählt werden.
- **Dashboard ohne Neuladen** (`initAdminDashboard()`, `Fragments` in `plenario.js`): Formulare in `[data-live]` (Folienliste, Kopf)
und das Folienformular im `<dialog>` laufen per `fetch` mit Header `X-Fragment`; `AdminAppController::beforeRender()` nimmt dann
das Layout `fragment` (nur Inhalt + Flash). Die Server-Aktionen bleiben normale POST + Redirect, das JS tauscht die Bereiche
`[data-refresh="head|slides|flash"]` (als DOM-Knoten, nie `innerHTML`) und stellt den Fokus wieder her. Bearbeiten/Anlegen:
Links mit `data-modal` laden das Formular (`[data-modal-content]`) in den Dialog; Validierungsfehler kommen als Formular
zurück (Dialog bleibt offen), Erfolg als Dashboard-Fragment (Dialog schließt). Ohne JS funktioniert alles als normale Seite.
**Buttons mit Bestätigung** nutzen `Form->postButton()` + `data-confirm` (CakePHPs `postLink`/`confirm` erzeugt ein Inline-`onclick`,
das die CSP blockiert); das JS fragt per `window.confirm()` vor dem Absenden. Tests: `AdminFragmentTest.php`.
### Neuen Folientyp hinzufügen (Checkliste)
1. Konstante + Label + Beschreibung + `DEFAULT_SETTINGS` in `src/Model/Entity/Slide.php`
2. Settings-Sanitizing in `SlidesTable::sanitizeSettings()`
3. Validierung/Speicherung in `VoteService::submit()` (eigene `…Rows()`-Methode)
4. Aggregation in `ResultsService::forSlide()` + Docblock der JSON-Struktur
5. Formularfelder in `templates/Slides/form.php`, Eingabe in `templates/Participate/view.php`
6. Renderer in `webroot/js/plenario.js` (`Results.<type>`), Styles in `plenario.css`, Badge-Farbe;
Ausgabe im PDF-Export (`templates/Admin/export.php`)
7. Tests in `tests/TestCase/Service/VoteServiceTest.php` (Quiz: `QuizTest.php`, Q&A: `QaTest.php`)
8. Nach neuen Spalten lokal `bin/cake cache clear_all`, sonst nutzt das ORM das alte Schema aus dem Cache
### Farbschema (Tag/Nacht)
`data-theme="light|dark"` auf `<html>`, ohne Attribut gilt die Systemeinstellung. `element/theme_init` setzt die
Wahl aus `localStorage` vor dem ersten Rendern (Inline-Skript im `<head>`), `element/theme_switch` ist der Schalter
(`Theme` in `plenario.js`). Presenter: eigener Schlüssel `plenario-theme-present`, Standard dunkel, Taste T.
Neue Farben als Token in beiden Dark-Blöcken von `plenario.css` pflegen; auf der Bühne Overlays mit `rgba(var(--tint), …)`.
### Live-Updates
Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/state`) pollen per `fetch`
(`Plenario.pollIntervalMs`). Die Teilnehmerseite lädt neu, wenn sich `version` im State ändert.
- Bilder: Datei erst nach dem Commit löschen, nie davor; keine Pflichtfelder zum Bild. Details: [docs/images.md](docs/images.md).
- Neuer Folientyp: Checkliste in [docs/slide-types.md](docs/slide-types.md).
## Konventionen
@@ -329,43 +143,14 @@ Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/
eigenen Branch (z. B. `feature/…`, `fix/…`, `docs/…`), pushen und per Pull Request in Gitea mergen.
Merge erst, wenn der Status-Check `test` grün ist. Kein Force-Push auf `main`.
## Deployment
Deploy erfolgt über Git (Remote: Gitea) mit `.gitea/workflows/ci.yml`:
## Deployment in Kürze
- Job `test` (PHPUnit + phpcs) läuft bei jedem Push auf jeden Branch. `main` ist per Branch-Schutz
in Gitea gesperrt: kein direkter Push, Merge nur per PR und nur mit grünem Status-Check des Jobs `test`.
- Job `deploy` läuft nur bei Push auf `main`, nur bei grünen Tests und **nur wenn die Repo-Variable
`DEPLOY_ENABLED=true` gesetzt ist** (standardmäßig deaktiviert). Er verbindet sich per SSH
(DirectAdmin, `plenario.gnilebein.de`, Checkout direkt in `public_html`), holt den Code per HTTPS mit
dem kurzlebigen Job-Token (kein Deploy-Key auf dem Server), macht `git reset --hard origin/main`,
bricht ab, wenn `config/.env` fehlt, dann `composer install --no-dev`, `migrations migrate`, `cache clear_all`. PHP und Composer werden
automatisch erkannt (überschreibbar über `PHP_BIN`/`COMPOSER_BIN`).
- Benötigte Variablen/Secrets sind im Kopf der Workflow-Datei dokumentiert. Zugangsdaten nur als
Gitea-Secret, nie ins Repo.
**Container (Docker):** `Dockerfile` (`php:8.5-cli-alpine`, Multi-Stage mit Composer) startet über
`docker/entrypoint.sh` den eingebauten Server (`bin/cake server -H 0.0.0.0 -p 8765`, `PHP_CLI_SERVER_WORKERS=8`,
sonst bedient er nur einen Request gleichzeitig). Code in `/app`, SQLite in Volume `/data`
(`DATABASE_URL=sqlite:////data/plenario.sqlite`), Konfiguration nur per Umgebungsvariablen (`config/.env.example`).
`SECURITY_SALT` ist Pflicht (Entrypoint bricht sonst ab; `composer install --no-scripts`, damit kein Salt eingebrannt wird).
Der Start ist idempotent (Migrationen + `cache clear_all`). Der Healthcheck prüft eine statische Datei, weil die Host-Prüfung
(`APP_FULL_BASE_URL`) `127.0.0.1` auf echten Seiten mit 400 ablehnt. Betrieb hinter einem TLS-Proxy mit `X-Forwarded-Proto`.
Beispiel: `docker-compose.yml`. Image und App-Paket entstehen nur bei Releases (siehe nächster Absatz).
**Releases (SemVer):** `.gitea/workflows/release.yml` läuft nur bei Tags `vMAJOR.MINOR.PATCH[-suffix]` (kein Build bei normalen
Pushes). Job `test` (PHPUnit + phpcs) gatet `package` und `image`. `package` baut `plenario-<version>.tar.gz` (git archive des Tags,
`composer install --no-dev --no-scripts`, `app_local.php` aus dem Example, leere `tmp/`/`logs/`/`data/`, Datei `VERSION`; nur per Whitelist: bin, config, plugins, resources, src, templates, webroot, index.php, .htaccess, composer-Dateien;
kein tests/CI/Docker/README) + `SHA256SUMS` und hängt sie an das Gitea-Release (wird angelegt bzw. aktualisiert, Changelog = Commit-Betreffs
seit dem letzten Tag, Suffix = Pre-Release). `image` pusht `:<version>`, `:<major>.<minor>`, `:<major>` und `:latest` (die
beiden letzten nicht bei Pre-Releases bzw. `v0.`) in die Gitea-Registry (Variablen `DOCKER_REPO`, `IMAGE_NAME`, Secret `PAT`).
Wer das Paket ändert (z. B. weitere Dateien ausschließen), pflegt den Schritt „Build package“ in dieser Datei.
Produktiv auf dem Server in `config/.env`: `DEBUG=false`, `APP_FULL_BASE_URL`, `SECURITY_SALT`, SMTP
(`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD`, `SMTP_TLS` – einzelne Variablen statt URL; `EMAIL_TRANSPORT_DEFAULT_URL` geht weiter als Altlast).
Ohne `DEBUG=false` steht die per Composer erzeugte `app_local.php` auf debug=true und zeigt Admin-Links direkt an.
Document-Root zeigt idealerweise auf `webroot/`; liegt die App direkt im Document-Root (z. B. `public_html`),
leiten `.htaccess` + `index.php` im Projektroot alles nach `webroot/` weiter.
CI (`.gitea/workflows/ci.yml`): Job `phpunit` (PHPUnit + phpcs, PHP 8.4/8.5) auf jedem Push, der Sammel-Job `test` ist der
Check des Branch-Schutzes. Job `deploy` läuft nur bei Push auf `main`, grünen Tests und `DEPLOY_ENABLED=true`. Releases
entstehen nur bei Tags `vMAJOR.MINOR.PATCH` (`release.yml`). Docker ist nur für Tests gedacht, nie als
produktionstauglich darstellen. Alles Weitere (Server-Konfiguration, Paket, Container, Ablauf/Cron von Umfragen):
[docs/operations.md](docs/operations.md).
## Bekannte Grenzen / Ideen
+1 -1
View File
@@ -1,6 +1,6 @@
# CLAUDE.md
Alle Projektinfos für Agents stehen in **AGENTS.md** – bitte dort lesen und dort pflegen:
Alle Projektinfos für Agents stehen in **AGENTS.md** (Details je Bereich unter **docs/**) – bitte dort lesen und dort pflegen:
@AGENTS.md
+10 -6
View File
@@ -2,20 +2,23 @@
# Configuration only through environment variables (see config/.env.example).
FROM php:8.5-cli-alpine AS base
RUN apk add --no-cache icu-libs \
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
&& docker-php-ext-install -j"$(nproc)" intl \
# gd with JPEG/WebP: slide images are scaled and stored as WebP
RUN apk add --no-cache icu-libs libjpeg-turbo libpng libwebp \
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev libjpeg-turbo-dev libpng-dev libwebp-dev \
&& docker-php-ext-configure gd --with-jpeg --with-webp \
&& docker-php-ext-install -j"$(nproc)" intl gd \
&& apk del .build-deps
# Image uploads of up to 10 MB (IMAGE_MAX_UPLOAD_MB) must pass PHP's limits
RUN printf 'upload_max_filesize=10M\npost_max_size=12M\n' > /usr/local/etc/php/conf.d/plenario-uploads.ini
FROM base AS build
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY composer.json composer.lock ./
# --no-scripts: the installer must not bake a random salt into app_local.php (SECURITY_SALT comes at runtime)
# --no-scripts: no app_local.php in the image; everything comes from the environment at runtime
RUN composer install --no-dev --no-scripts --no-progress --prefer-dist --optimize-autoloader
COPY . .
RUN composer dump-autoload --no-dev --optimize \
&& cp config/app_local.example.php config/app_local.php
RUN composer dump-autoload --no-dev --optimize
FROM base
WORKDIR /app
@@ -25,6 +28,7 @@ COPY docker/entrypoint.sh /usr/local/bin/plenario-entrypoint
ENV DEBUG=false \
SHOW_ADMIN_LINK_AFTER_CREATE=false \
DATABASE_URL=sqlite:////data/plenario.sqlite \
UPLOADS_PATH=/data/uploads \
PHP_CLI_SERVER_WORKERS=8
RUN chmod +x /usr/local/bin/plenario-entrypoint \
+17 -207
View File
@@ -15,23 +15,17 @@ Der Name ist ein Wortspiel aus zwei Teilen:
Dazu passt auch der Gedanke dahinter: Ergebnisse gehören auf die Bühne und nicht auf die Geräte der Teilnehmenden.
Basiert auf **CakePHP 5.4** (PHP 8.3 oder neuer, das automatische Deployment verlangt 8.4),
Basiert auf **CakePHP 5.4** (PHP 8.4 oder neuer),
läuft lokal mit **SQLite**, ohne Build-Schritt fürs Frontend.
## Inhalt
- [So funktioniert es](#so-funktioniert-es)
- [Funktionen](#funktionen)
- [Lokal starten (Entwicklung)](#lokal-starten-entwicklung)
- [Tests](#tests)
- [Konfiguration](#konfiguration)
- [Deployment mit Docker](#deployment-mit-docker)
- [Deployment ohne Docker](#deployment-ohne-docker)
- [Releases und Versionierung](#releases-und-versionierung)
- [Automatisches Deployment (Gitea Actions)](#automatisches-deployment-gitea-actions)
- [Konfiguration und Deployment](#konfiguration-und-deployment)
- [Betrieb & Skalierung](#betrieb--skalierung)
- [Datenschutz](#datenschutz)
- [Mitentwickeln](#mitentwickeln)
- [Entwicklung und Mitarbeit](#entwicklung-und-mitarbeit)
## So funktioniert es
@@ -61,6 +55,9 @@ Wichtige Tasten im Präsentationsmodus: `←` / `→` Folie wechseln, `P` Pause,
- **Reihenfolge** – Einträge sortieren, aufgelöst wird beim Schließen der Abstimmung
- **Fragen & Antworten** – Fragen sammeln, per Upvote priorisieren, nacheinander besprechen
- **Inhaltsfolie** und **YouTube-Video** (ohne Abstimmung)
- **Bilder** auf Folien (außer YouTube): werden beim Hochladen auf höchstens 1600 Pixel verkleinert und als WebP
gespeichert (Kameradaten wie der Aufnahmeort fallen dabei weg), mit Bildbeschreibung und Platzierung oben, daneben
oder bildschirmfüllend
- Präsentationsmodus: Vollbild, Tastatursteuerung, QR-Code, Pause, Tag-/Nachtmodus, Live-Ergebnisse
- Ergebnisse erscheinen auf der Bühne, nicht auf den Geräten der Teilnehmenden – dort nur, wo sie damit
arbeiten (Wortwolke) oder ihre eigene Antwort aufgelöst wird (Quiz, Reihenfolge)
@@ -74,201 +71,15 @@ Wichtige Tasten im Präsentationsmodus: `←` / `→` Folie wechseln, `P` Pause,
- Admin-Link bzw. Einbett-Links neu erzeugen (alte werden ungültig), Umfrage löschen
- Rate-Limits pro IP für Anlegen, Wiederherstellen und Abstimmen
## Lokal starten (Entwicklung)
## Konfiguration und Deployment
Voraussetzungen: PHP 8.3+ mit den Erweiterungen `intl`, `mbstring`, `openssl`, `pdo_sqlite`, `curl`
sowie [Composer](https://getcomposer.org/).
Alle Einstellungen gehen über Umgebungsvariablen oder `config/.env` (Vorlage: [config/.env.example](config/.env.example)).
Für die Produktion zählen mindestens `DEBUG=false`, `APP_FULL_BASE_URL`, `SECURITY_SALT` (nach dem ersten Einsatz
**nie mehr ändern**) und ein Mail-Transport (`SMTP_*`).
```bash
git clone https://gitea.gnilebein.de/gnilebein/Plenario.git
cd Plenario
composer install # legt config/app_local.php an (SQLite, Mails als Datei)
bin/cake migrations migrate # erstellt data/plenario.sqlite
bin/cake server -p 8765 # http://localhost:8765
```
Unter Windows ggf. `php bin/cake.php …` statt `bin/cake …`.
Lokal werden keine Mails verschickt: Sie landen als `.eml` in `tmp/mails/`. Zusätzlich wird der
Admin-Link im Debug-Modus direkt nach dem Anlegen angezeigt.
Nach neuen Migrationen `bin/cake cache clear_all` ausführen, sonst nutzt das ORM das alte Schema aus dem Cache.
Zurücksetzen der lokalen Daten: `data/plenario.sqlite` löschen und die Migrationen erneut laufen lassen.
## Tests
```bash
vendor/bin/phpunit # nutzt tmp/tests.sqlite, Schema kommt aus den Migrationen
vendor/bin/phpcs # CakePHP Coding Standard (Autofix: vendor/bin/phpcbf)
```
## Konfiguration
Alle Einstellungen gehen über Umgebungsvariablen oder `config/.env`
(Vorlage mit allen Variablen: [config/.env.example](config/.env.example)). Echte Umgebungsvariablen
haben Vorrang vor der Datei.
| Variable | Bedeutung |
|---|---|
| `DEBUG` | `false` in Produktion |
| `APP_FULL_BASE_URL` | Absolute URL, wird für Links in E-Mails gebraucht (Pflicht in Produktion). In Produktion wird außerdem der Host-Header dagegen geprüft |
| `SECURITY_SALT` | Langer Zufallswert. **Nicht nachträglich ändern** – damit werden Admin-Tokens verschlüsselt und Teilnehmer-IDs gehasht |
| `DATABASE_URL` | Leer = SQLite in `data/`. Sonst z. B. `mysql://user:pw@host/plenario?encoding=utf8mb4` oder `postgres://user:pw@host/plenario` |
| `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD` | Mailserver (Port Standard 587). Ohne `SMTP_HOST` werden Mails nur als Datei abgelegt |
| `SMTP_TLS` | `true` (Standard) = STARTTLS; Port 465 nutzt automatisch SSL; `false` = unverschlüsselt |
| `MAIL_FROM`, `MAIL_FROM_NAME` | Absender |
| `CAPTCHA_TYPE` | `none`, `math` (Standard) oder `recaptcha` |
| `RECAPTCHA_SITE_KEY`, `RECAPTCHA_SECRET_KEY` | Für reCAPTCHA v2 („Ich bin kein Roboter“) |
| `SHOW_ADMIN_LINK_AFTER_CREATE` | Nur für Entwicklung |
| `THROTTLE_CREATE_PER_HOUR`, `THROTTLE_RECOVER_PER_HOUR` | Umfragen bzw. Wiederherstellungs-Mails pro IP und Stunde (0 = aus) |
| `THROTTLE_VOTES_PER_MINUTE` | Antworten pro IP und Minute (0 = aus). Hoch lassen: Oft teilt sich ein ganzer Saal eine IP |
| `POLL_INTERVAL_MS` | Aktualisierungsintervall der Live-Ansichten |
| `EMBED_HEARTBEAT_SECONDS`, `EMBED_TIMEOUT_SECONDS` | Eingebettete Folien: Lebenszeichen-Intervall und Zeit bis zur automatischen Pause |
| `EMBED_FRAME_ANCESTORS` | Welche Seiten Folien einbetten dürfen (CSP `frame-ancestors`), z. B. `https://*.canva.com`; `*` = alle |
Einen `SECURITY_SALT` erzeugen:
```bash
php -r "echo bin2hex(random_bytes(32));"
# oder ohne PHP:
openssl rand -hex 32
```
## Deployment mit Docker
Das [Dockerfile](Dockerfile) baut ein schlankes Image (`php:8.5-cli-alpine`, Multi-Stage mit Composer).
Der eingebaute PHP-Server läuft mit 8 Workern auf Port **8765**, die SQLite-Datenbank liegt im Volume `/data`.
Beim Start laufen die Migrationen automatisch (idempotent, mehrfaches Starten ist unproblematisch).
Das fertige Image liegt in der Gitea-Registry:
`gitea.gnilebein.de/gnilebein/plenario:latest` (letzter stabiler Release). Für feste Versionen gibt es die
SemVer-Tags `:1.4.0`, `:1.4` und `:1` (Pre-Releases wie `v1.5.0-rc.1` nur als `:1.5.0-rc.1`).
Gebaut wird das Image nur bei einem neuen Release-Tag, siehe [Releases](#releases-und-versionierung).
### Schnellstart mit `docker run`
```bash
docker run -d --name plenario -p 8765:8765 -v plenario-data:/data \
-e SECURITY_SALT="$(openssl rand -hex 32)" \
-e APP_FULL_BASE_URL=https://plenario.example.org \
-e MAIL_FROM=noreply@example.org \
-e SMTP_HOST=mail.example.org -e SMTP_PORT=587 \
-e SMTP_USER=noreply@example.org -e SMTP_PASSWORD='geheim' \
--restart unless-stopped \
gitea.gnilebein.de/gnilebein/plenario:latest
```
### Empfohlen: Docker Compose
1. Eine `.env` neben der [docker-compose.yml](docker-compose.yml) anlegen (Vorlage: [config/.env.example](config/.env.example)):
```dotenv
SECURITY_SALT=<64 Zeichen Zufall, siehe oben>
APP_FULL_BASE_URL=https://plenario.example.org
MAIL_FROM=noreply@example.org
MAIL_FROM_NAME=PlenarIO
SMTP_HOST=mail.example.org
SMTP_PORT=587
SMTP_USER=noreply@example.org
SMTP_PASSWORD=geheim
SMTP_TLS=true
CAPTCHA_TYPE=math
```
2. Starten:
```bash
docker compose up -d
docker compose logs -f plenario # Start und Migrationen beobachten
```
3. Aktualisieren auf die neueste Version:
```bash
docker compose pull && docker compose up -d
```
Die Datenbank bleibt im Volume `plenario-data` erhalten; neue Migrationen laufen beim Start automatisch.
Statt das Image zu ziehen, lässt sich auch lokal bauen: in der `docker-compose.yml` die Zeile `# build: .`
aktivieren oder `docker build -t plenario .` ausführen.
### Wichtig im Container
- **`SECURITY_SALT` ist Pflicht.** Fehlt er, bricht der Start mit einer Fehlermeldung ab. Er wird nicht ins Image
eingebrannt, sondern zur Laufzeit gesetzt. Nach dem ersten Einsatz **nie mehr ändern** (sonst werden
Admin-Tokens unlesbar und Teilnehmer-IDs ungültig).
- **`APP_FULL_BASE_URL` muss die öffentliche URL sein**, inklusive `https://`. Sie wird für die Links in
E-Mails verwendet, und in Produktion wird der Host-Header dagegen geprüft.
- **Mail-Versand einrichten.** Ohne `SMTP_HOST` schreibt PlenarIO Mails nur als Datei ins
Container-Dateisystem – der Admin-Link kommt dann **nie** bei den Nutzenden an.
- **TLS-Proxy davorschalten** (Caddy, nginx, Traefik, …), der `X-Forwarded-Proto` setzt. Der eingebaute
PHP-Server spricht nur HTTP. Beispiel für Caddy:
```
plenario.example.org {
reverse_proxy localhost:8765
}
```
- **Daten sichern:** Alles Wichtige liegt in `/data` (SQLite-Datei `plenario.sqlite`). Backup z. B. mit
`docker run --rm -v plenario-data:/data -v "$PWD":/backup alpine tar czf /backup/plenario-data.tgz -C /data .`
- **Bind-Mount statt Volume:** Der Container läuft als Benutzer `www-data` (UID 82). Das Host-Verzeichnis
muss für ihn beschreibbar sein (`chown 82:82 ./data`).
- **Andere Datenbank:** Für viele gleichzeitige Teilnehmende `DATABASE_URL` auf MySQL/PostgreSQL setzen
(siehe [Betrieb & Skalierung](#betrieb--skalierung)).
- **Healthcheck:** Das Image prüft eine statische Datei (`/css/plenario.css`), weil die Host-Prüfung echte Seiten
bei Aufrufen über `127.0.0.1` ablehnen würde.
- **Weitere Einstellungen** (Captcha, Rate-Limits, Polling, Einbettung) gehen ebenfalls per Umgebungsvariable,
siehe [Konfiguration](#konfiguration).
## Deployment ohne Docker
1. Code auschecken, `composer install --no-dev --optimize-autoloader`
2. `config/.env` (oder echte Umgebungsvariablen) setzen, mindestens `DEBUG=false`,
`APP_FULL_BASE_URL`, `SECURITY_SALT`, Mail-Transport
3. `bin/cake migrations migrate` und `bin/cake cache clear_all`
4. Document-Root auf `webroot/` zeigen lassen; `tmp/`, `logs/` und `data/` beschreibbar machen.
Liegt die App direkt im Document-Root (z. B. `public_html`), leiten `.htaccess` und `index.php`
im Projektroot alles nach `webroot/` weiter.
Bei Updates: Code aktualisieren, `composer install --no-dev`, Migrationen und `cache clear_all` wiederholen.
## Automatisches Deployment (Gitea Actions)
[.gitea/workflows/ci.yml](.gitea/workflows/ci.yml) testet jeden Push (PHPUnit + phpcs).
`main` ist geschützt, gemergt wird nur per Pull Request mit grünem Test. Nach dem Merge deployt der Job
`deploy` per SSH – aber nur, wenn die Repo-Variable `DEPLOY_ENABLED=true` gesetzt ist. Er holt den Code,
führt `composer install --no-dev`, die Migrationen und `cache clear_all` aus. Benötigte Variablen und Secrets
stehen im Kopf der Workflow-Datei. Einmalig auf dem Server: `config/.env` anlegen, ohne sie bricht der Deploy ab.
Der Workflow bedient vor allem die Instanz unter <https://plenario.gnilebein.de/>, ist aber nicht fest darauf
verdrahtet: Ziel und Werkzeuge kommen ausschließlich aus Repository-Variablen (`SSH_HOST`, `SSH_PORT`, `SSH_USER`,
`DEPLOY_PATH`, optional `PHP_BIN`/`COMPOSER_BIN`) und Secrets (`SSH_KEY` oder `SSH_PASSWORD`). Wer PlenarIO auf einem
eigenen Server betreibt, setzt dort seine Werte und `DEPLOY_ENABLED=true` – die Workflow-Datei bleibt unverändert.
Voraussetzungen: SSH-Zugang mit Shell, `git` und PHP ≥ 8.4 auf dem Server, der Server erreicht die Gitea-Instanz per
HTTPS. Ohne `DEPLOY_ENABLED` passiert nichts (Standard).
## Releases und Versionierung
PlenarIO nutzt [Semantic Versioning](https://semver.org/lang/de/) (`MAJOR.MINOR.PATCH`): Major bei inkompatiblen
Änderungen (z. B. Schema-/Konfigurationsumbrüche), Minor für neue Funktionen, Patch für Fehlerbehebungen.
Eine Version entsteht durch einen Tag auf `main`:
```bash
git tag v1.4.0 && git push origin v1.4.0 # Pre-Release: v1.5.0-rc.1
```
Der Workflow [.gitea/workflows/release.yml](.gitea/workflows/release.yml) läuft nur bei solchen Tags (`vX.Y.Z[-suffix]`),
führt zuerst die Tests aus und erzeugt dann
- ein **App-Paket** `plenario-<version>.tar.gz` samt `SHA256SUMS` als Anhang des Gitea-Releases (fertig mit
Produktions-`vendor/`, nur die Anwendung (Whitelist), ohne Tests, CI, Docker und Entwicklerdateien, `VERSION`-Datei enthalten; Einrichtung wie unter
[Deployment ohne Docker](#deployment-ohne-docker), nur ohne Composer-Schritt) und
- das **Docker-Image** mit den Tags `:<version>`, `:<major>.<minor>`, `:<major>` und `:latest`.
Tags mit Suffix (`-rc.1`, `-beta.2`) werden als Pre-Release markiert und bekommen weder `:latest` noch `:<major>`.
Der Workflow ist wiederholbar: ein erneuter Lauf aktualisiert das vorhandene Release.
- [Konfiguration](docs/configuration.md): alle Umgebungsvariablen, `SECURITY_SALT` erzeugen
- [Deployment](docs/deployment.md): ohne Docker (Produktivbetrieb), Docker (nur Testbetrieb), Cronjob und Admin-CLI
für Ablauf und Aufräumen von Umfragen, automatisches Deployment per Gitea Actions, Releases und Versionierung
## Betrieb & Skalierung
@@ -288,10 +99,9 @@ Für Einzelveranstaltungen und typische Meetings reicht SQLite problemlos.
IP-Adresse). YouTube-Folien werden im Präsentationsmodus über `youtube-nocookie.com` eingebettet;
Teilnehmende bekommen nur einen Link. Beides gehört in die Datenschutzerklärung des Betreibers.
## Mitentwickeln
## Entwicklung und Mitarbeit
- Quellcode, Issues und Pull Requests: <https://gitea.gnilebein.de/gnilebein/Plenario>
- `main` ist geschützt: Änderungen auf einem eigenen Branch pushen und per Pull Request mergen.
Vor jedem Commit müssen `vendor/bin/phpunit` und `vendor/bin/phpcs` grün sein.
- Architektur, Konventionen und Regeln, die man nicht versehentlich brechen darf, stehen in
[AGENTS.md](AGENTS.md) (zentrale Arbeitsgrundlage, auch für KI-Agents).
- Lokales Setup, Tests und Ablauf: [docs/development.md](docs/development.md)
- Architektur, Konventionen und Regeln, die man nicht versehentlich brechen darf: [AGENTS.md](AGENTS.md)
(zentrale Arbeitsgrundlage, auch für KI-Agents), Details in [docs/](docs/README.md)
+1 -1
View File
@@ -5,7 +5,7 @@
"type": "project",
"homepage": "https://cakephp.org",
"require": {
"php": ">=8.2",
"php": ">=8.4",
"cakephp/cakephp": "5.4.*",
"cakephp/migrations": "^5.0",
"cakephp/plugin-installer": "^2.0",
Generated
+112 -175
View File
@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ddccb2d95917b222589d74cc89a09235",
"content-hash": "d1039a47e3b46af459f914d1ea67c437",
"packages": [
{
"name": "cakephp/cakephp",
"version": "5.4.4",
"version": "5.4.5",
"source": {
"type": "git",
"url": "https://github.com/cakephp/cakephp.git",
"reference": "47f15a350fff9ac374172a5c675bca6b4146716f"
"reference": "87a19de8ef83a8f343072b16d89c3bdb3972b367"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/cakephp/zipball/47f15a350fff9ac374172a5c675bca6b4146716f",
"reference": "47f15a350fff9ac374172a5c675bca6b4146716f",
"url": "https://api.github.com/repos/cakephp/cakephp/zipball/87a19de8ef83a8f343072b16d89c3bdb3972b367",
"reference": "87a19de8ef83a8f343072b16d89c3bdb3972b367",
"shasum": ""
},
"require": {
@@ -27,7 +27,6 @@
"ext-json": "*",
"ext-mbstring": "*",
"laminas/laminas-diactoros": "^3.8",
"laminas/laminas-httphandlerrunner": "^2.6",
"league/container": "^5.1",
"php": ">=8.2",
"psr/container": "^1.1 || ^2.0",
@@ -68,7 +67,7 @@
"cakephp/validation": "self.version"
},
"require-dev": {
"boundwize/structarmed": "^0.19",
"boundwize/structarmed": "^0.19 || ^0.20",
"cakephp/cakephp-codesniffer": "^5.3",
"http-interop/http-factory-tests": "^2.0",
"mockery/mockery": "^1.6",
@@ -128,8 +127,8 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/cakephp"
},
"time": "2026-11-01T00:47:56+00:00",
"published-time": "2026-11-01T00:48:07+00:00"
"time": "2026-11-22T18:48:53+00:00",
"published-time": "2026-11-22T18:49:23+00:00"
},
{
"name": "cakephp/chronos",
@@ -856,74 +855,6 @@
"time": "2026-11-04T10:34:30+00:00",
"published-time": "2026-11-04T10:56:11+00:00"
},
{
"name": "laminas/laminas-httphandlerrunner",
"version": "2.14.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-httphandlerrunner.git",
"reference": "14d5182a4ba180c998dfbba9d19f9a70337c02b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-httphandlerrunner/zipball/14d5182a4ba180c998dfbba9d19f9a70337c02b4",
"reference": "14d5182a4ba180c998dfbba9d19f9a70337c02b4",
"shasum": ""
},
"require": {
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/http-message-implementation": "^1.0 || ^2.0",
"psr/http-server-handler": "^1.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "~3.1.0",
"laminas/laminas-diactoros": "^3.6.0",
"phpunit/phpunit": "^10.5.46",
"psalm/plugin-phpunit": "^0.19.5",
"vimeo/psalm": "^6.10.3"
},
"type": "library",
"extra": {
"laminas": {
"config-provider": "Laminas\\HttpHandlerRunner\\ConfigProvider"
}
},
"autoload": {
"psr-4": {
"Laminas\\HttpHandlerRunner\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Execute PSR-15 RequestHandlerInterface instances and emit responses they generate.",
"homepage": "https://laminas.dev",
"keywords": [
"components",
"laminas",
"mezzio",
"psr-15",
"psr-7"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-httphandlerrunner/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-httphandlerrunner/issues",
"rss": "https://github.com/laminas/laminas-httphandlerrunner/releases.atom",
"source": "https://github.com/laminas/laminas-httphandlerrunner"
},
"funding": [
{
"url": "https://crowdfunding.linuxfoundation.org/initiatives/laminas-project",
"type": "custom"
}
],
"time": "2026-09-21T10:14:52+00:00",
"published-time": "2026-09-21T10:15:58+00:00"
},
{
"name": "league/container",
"version": "5.2.0",
@@ -2243,16 +2174,16 @@
},
{
"name": "composer/composer",
"version": "2.11.1",
"version": "2.11.3",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
"reference": "472b418967419c6124edd91dc6310a3bec091dae"
"reference": "e4a580d4d41edb0eb5a470f441c9780ba49df75f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/472b418967419c6124edd91dc6310a3bec091dae",
"reference": "472b418967419c6124edd91dc6310a3bec091dae",
"url": "https://api.github.com/repos/composer/composer/zipball/e4a580d4d41edb0eb5a470f441c9780ba49df75f",
"reference": "e4a580d4d41edb0eb5a470f441c9780ba49df75f",
"shasum": ""
},
"require": {
@@ -2342,7 +2273,7 @@
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/composer/issues",
"security": "https://github.com/composer/composer/security/policy",
"source": "https://github.com/composer/composer/tree/2.11.1"
"source": "https://github.com/composer/composer/tree/2.11.3"
},
"funding": [
{
@@ -2354,8 +2285,8 @@
"type": "github"
}
],
"time": "2026-10-30T13:52:10+00:00",
"published-time": "2026-10-30T14:03:09+00:00"
"time": "2026-11-24T09:14:18+00:00",
"published-time": "2026-11-24T09:17:33+00:00"
},
{
"name": "composer/metadata-minifier",
@@ -2944,16 +2875,16 @@
},
{
"name": "justinrainbow/json-schema",
"version": "6.14.0",
"version": "6.15.1",
"source": {
"type": "git",
"url": "https://github.com/jsonrainbow/json-schema.git",
"reference": "bae415e135dd68260c2d020ba392850231e9b1ab"
"reference": "24021a898c17193ed7c2111b5fbf1c6486ae85ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/bae415e135dd68260c2d020ba392850231e9b1ab",
"reference": "bae415e135dd68260c2d020ba392850231e9b1ab",
"url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/24021a898c17193ed7c2111b5fbf1c6486ae85ff",
"reference": "24021a898c17193ed7c2111b5fbf1c6486ae85ff",
"shasum": ""
},
"require": {
@@ -3003,10 +2934,16 @@
],
"support": {
"issues": "https://github.com/jsonrainbow/json-schema/issues",
"source": "https://github.com/jsonrainbow/json-schema/tree/6.14.0"
"source": "https://github.com/jsonrainbow/json-schema/tree/6.15.1"
},
"time": "2026-10-24T08:53:34+00:00",
"published-time": "2026-10-24T08:53:38+00:00"
"funding": [
{
"url": "https://github.com/DannyvdSluijs",
"type": "github"
}
],
"time": "2026-11-24T20:35:12+00:00",
"published-time": "2026-11-24T20:35:18+00:00"
},
{
"name": "marc-mabe/php-enum",
@@ -3371,16 +3308,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "14.5.1",
"version": "14.5.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "4063552c678ce3beb4b7f131a5b7354a19ff3e2a"
"reference": "2f122b9b48af71ad9b4448368febc26af86534c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4063552c678ce3beb4b7f131a5b7354a19ff3e2a",
"reference": "4063552c678ce3beb4b7f131a5b7354a19ff3e2a",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2f122b9b48af71ad9b4448368febc26af86534c9",
"reference": "2f122b9b48af71ad9b4448368febc26af86534c9",
"shasum": ""
},
"require": {
@@ -3398,7 +3335,7 @@
"sebastian/version": "^7.0.1"
},
"require-dev": {
"phpunit/phpunit": "^13.4.5"
"phpunit/phpunit": "^13.4.6"
},
"suggest": {
"ext-pcov": "PHP extension that provides line coverage",
@@ -3436,7 +3373,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.5.1"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/14.5.2"
},
"funding": [
{
@@ -3456,8 +3393,8 @@
"type": "tidelift"
}
],
"time": "2026-11-02T11:47:37+00:00",
"published-time": "2026-11-02T11:49:08+00:00"
"time": "2026-11-09T05:24:08+00:00",
"published-time": "2026-11-09T05:25:09+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -3758,16 +3695,16 @@
},
{
"name": "phpunit/phpunit",
"version": "13.4.6",
"version": "13.4.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "4821376960d0e1e5a7b7b700955ebcab33ecd71b"
"reference": "291e66a76eb39f2fb8f880d38edc30dbd7acd9a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4821376960d0e1e5a7b7b700955ebcab33ecd71b",
"reference": "4821376960d0e1e5a7b7b700955ebcab33ecd71b",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/291e66a76eb39f2fb8f880d38edc30dbd7acd9a2",
"reference": "291e66a76eb39f2fb8f880d38edc30dbd7acd9a2",
"shasum": ""
},
"require": {
@@ -3781,7 +3718,7 @@
"phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1",
"php": ">=8.4.1",
"phpunit/php-code-coverage": "^14.5.0",
"phpunit/php-code-coverage": "^14.5.2",
"phpunit/php-file-iterator": "^7.0.2",
"phpunit/php-invoker": "^7.0.0",
"phpunit/php-text-template": "^6.0.1",
@@ -3797,7 +3734,7 @@
"sebastian/object-enumerator": "^8.1.0",
"sebastian/recursion-context": "^8.0.1",
"sebastian/type": "^7.0.2",
"sebastian/version": "^7.0.1",
"sebastian/version": "^7.1.0",
"staabm/side-effects-detector": "^1.0.5"
},
"bin": [
@@ -3838,7 +3775,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/13.4.6"
"source": "https://github.com/sebastianbergmann/phpunit/tree/13.4.8"
},
"funding": [
{
@@ -3846,8 +3783,8 @@
"type": "other"
}
],
"time": "2026-11-02T07:12:28+00:00",
"published-time": "2026-11-02T07:13:08+00:00"
"time": "2026-11-19T12:17:15+00:00",
"published-time": "2026-11-19T12:18:28+00:00"
},
{
"name": "react/promise",
@@ -4979,16 +4916,16 @@
},
{
"name": "sebastian/version",
"version": "7.0.1",
"version": "7.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "f1598cf1d8d1ca4c0f194a52f2fe72a559a7b0b1"
"reference": "08e41d0c7e146bfc8cef7e63989b1294453a6d6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/f1598cf1d8d1ca4c0f194a52f2fe72a559a7b0b1",
"reference": "f1598cf1d8d1ca4c0f194a52f2fe72a559a7b0b1",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/08e41d0c7e146bfc8cef7e63989b1294453a6d6a",
"reference": "08e41d0c7e146bfc8cef7e63989b1294453a6d6a",
"shasum": ""
},
"require": {
@@ -4997,7 +4934,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "7.0-dev"
"dev-main": "7.1-dev"
}
},
"autoload": {
@@ -5021,7 +4958,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"security": "https://github.com/sebastianbergmann/version/security/policy",
"source": "https://github.com/sebastianbergmann/version/tree/7.0.1"
"source": "https://github.com/sebastianbergmann/version/tree/7.1.0"
},
"funding": [
{
@@ -5041,8 +4978,8 @@
"type": "tidelift"
}
],
"time": "2026-10-04T05:51:14+00:00",
"published-time": "2026-10-04T05:52:22+00:00"
"time": "2026-11-09T06:31:27+00:00",
"published-time": "2026-11-09T06:31:50+00:00"
},
{
"name": "seld/jsonlint",
@@ -5426,23 +5363,23 @@
},
{
"name": "symfony/console",
"version": "v8.1.11",
"version": "v8.1.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "5a315b092b81f3e920e9daea1a2ae4c66ed298b9"
"reference": "20d14376137e111569de1f62ba4274731a9c9345"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/5a315b092b81f3e920e9daea1a2ae4c66ed298b9",
"reference": "5a315b092b81f3e920e9daea1a2ae4c66ed298b9",
"url": "https://api.github.com/repos/symfony/console/zipball/20d14376137e111569de1f62ba4274731a9c9345",
"reference": "20d14376137e111569de1f62ba4274731a9c9345",
"shasum": ""
},
"require": {
"php": ">=8.4.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php85": "^1.32",
"symfony/polyfill-php85": "^1.33",
"symfony/service-contracts": "^2.5|^3",
"symfony/string": "^7.4.6|^8.0.6"
},
@@ -5502,7 +5439,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v8.1.11"
"source": "https://github.com/symfony/console/tree/v8.1.12"
},
"funding": [
{
@@ -5522,8 +5459,8 @@
"type": "tidelift"
}
],
"time": "2026-11-04T07:07:11+00:00",
"published-time": "2026-11-04T11:31:39+00:00"
"time": "2026-11-24T15:59:55+00:00",
"published-time": "2026-11-25T09:31:15+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -5599,16 +5536,16 @@
},
{
"name": "symfony/filesystem",
"version": "v8.1.11",
"version": "v8.1.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "58f57b6a33e3495f7f41e01258f1ae5ef76cccd2"
"reference": "a8f7a3cf9d3140902eaee85baf1f8e98666d336a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/58f57b6a33e3495f7f41e01258f1ae5ef76cccd2",
"reference": "58f57b6a33e3495f7f41e01258f1ae5ef76cccd2",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/a8f7a3cf9d3140902eaee85baf1f8e98666d336a",
"reference": "a8f7a3cf9d3140902eaee85baf1f8e98666d336a",
"shasum": ""
},
"require": {
@@ -5646,7 +5583,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v8.1.11"
"source": "https://github.com/symfony/filesystem/tree/v8.1.12"
},
"funding": [
{
@@ -5666,21 +5603,21 @@
"type": "tidelift"
}
],
"time": "2026-11-04T08:39:20+00:00",
"published-time": "2026-11-04T11:32:01+00:00"
"time": "2026-11-24T15:59:55+00:00",
"published-time": "2026-11-25T09:29:32+00:00"
},
{
"name": "symfony/finder",
"version": "v8.1.11",
"version": "v8.1.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "a2902e479ba5691d20d51d100a715ea19ad2c837"
"reference": "7022913b72c56ac5123922726aa94f2f98b726ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/a2902e479ba5691d20d51d100a715ea19ad2c837",
"reference": "a2902e479ba5691d20d51d100a715ea19ad2c837",
"url": "https://api.github.com/repos/symfony/finder/zipball/7022913b72c56ac5123922726aa94f2f98b726ad",
"reference": "7022913b72c56ac5123922726aa94f2f98b726ad",
"shasum": ""
},
"require": {
@@ -5715,7 +5652,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v8.1.11"
"source": "https://github.com/symfony/finder/tree/v8.1.12"
},
"funding": [
{
@@ -5735,8 +5672,8 @@
"type": "tidelift"
}
],
"time": "2026-11-02T10:58:30+00:00",
"published-time": "2026-11-04T11:31:20+00:00"
"time": "2026-11-24T15:06:41+00:00",
"published-time": "2026-11-25T09:29:36+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -6407,16 +6344,16 @@
},
{
"name": "symfony/polyfill-php85",
"version": "v1.43.0",
"version": "v1.44.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php85.git",
"reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6"
"reference": "94c794cb5ba51784bc259f11e9f128593297d8dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/86a42cbcc07adc331481a5ab310a4024bfc227f6",
"reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6",
"url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/94c794cb5ba51784bc259f11e9f128593297d8dc",
"reference": "94c794cb5ba51784bc259f11e9f128593297d8dc",
"shasum": ""
},
"require": {
@@ -6463,7 +6400,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php85/tree/v1.43.0"
"source": "https://github.com/symfony/polyfill-php85/tree/v1.44.0"
},
"funding": [
{
@@ -6483,21 +6420,21 @@
"type": "tidelift"
}
],
"time": "2026-09-25T15:46:47+00:00",
"published-time": "2026-09-30T10:23:32+00:00"
"time": "2026-10-30T15:20:09+00:00",
"published-time": "2026-11-15T14:20:22+00:00"
},
{
"name": "symfony/process",
"version": "v8.1.10",
"version": "v8.1.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "08aa69fa0998bb65a089f9e148a2c0f8b391398e"
"reference": "4969fe2cf92f0075b070ab2bc0faef2734114bae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/08aa69fa0998bb65a089f9e148a2c0f8b391398e",
"reference": "08aa69fa0998bb65a089f9e148a2c0f8b391398e",
"url": "https://api.github.com/repos/symfony/process/zipball/4969fe2cf92f0075b070ab2bc0faef2734114bae",
"reference": "4969fe2cf92f0075b070ab2bc0faef2734114bae",
"shasum": ""
},
"require": {
@@ -6529,7 +6466,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v8.1.10"
"source": "https://github.com/symfony/process/tree/v8.1.12"
},
"funding": [
{
@@ -6549,8 +6486,8 @@
"type": "tidelift"
}
],
"time": "2026-10-25T14:40:25+00:00",
"published-time": "2026-10-28T18:25:20+00:00"
"time": "2026-11-23T09:20:57+00:00",
"published-time": "2026-11-25T09:29:08+00:00"
},
{
"name": "symfony/service-contracts",
@@ -6642,16 +6579,16 @@
},
{
"name": "symfony/string",
"version": "v8.1.10",
"version": "v8.1.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "6c6110979c0150393bbb336170e286d51ab4d76c"
"reference": "b3f937ce8203f33efea3cce084ad4a9f0cce97c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/6c6110979c0150393bbb336170e286d51ab4d76c",
"reference": "6c6110979c0150393bbb336170e286d51ab4d76c",
"url": "https://api.github.com/repos/symfony/string/zipball/b3f937ce8203f33efea3cce084ad4a9f0cce97c5",
"reference": "b3f937ce8203f33efea3cce084ad4a9f0cce97c5",
"shasum": ""
},
"require": {
@@ -6708,7 +6645,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v8.1.10"
"source": "https://github.com/symfony/string/tree/v8.1.12"
},
"funding": [
{
@@ -6728,21 +6665,21 @@
"type": "tidelift"
}
],
"time": "2026-10-23T17:06:53+00:00",
"published-time": "2026-10-28T18:24:27+00:00"
"time": "2026-11-24T15:59:55+00:00",
"published-time": "2026-11-25T09:30:00+00:00"
},
{
"name": "twig/markdown-extra",
"version": "v3.29.0",
"version": "v3.31.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/markdown-extra.git",
"reference": "8a8e3c28ed17b03ed4965b2e265a018d61f00ba5"
"reference": "fec48a4e62b644d176c64f2a703373f48c3b92dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/8a8e3c28ed17b03ed4965b2e265a018d61f00ba5",
"reference": "8a8e3c28ed17b03ed4965b2e265a018d61f00ba5",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/fec48a4e62b644d176c64f2a703373f48c3b92dd",
"reference": "fec48a4e62b644d176c64f2a703373f48c3b92dd",
"shasum": ""
},
"require": {
@@ -6755,7 +6692,7 @@
"league/commonmark": "^2.7",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8|^2.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/phpunit-bridge": "^7.4|^8.0",
"tempest/markdown": "^1.2"
},
"type": "library",
@@ -6790,7 +6727,7 @@
"twig"
],
"support": {
"source": "https://github.com/twigphp/markdown-extra/tree/v3.29.0"
"source": "https://github.com/twigphp/markdown-extra/tree/v3.31.1"
},
"funding": [
{
@@ -6802,21 +6739,21 @@
"type": "tidelift"
}
],
"time": "2026-09-06T20:35:36+00:00",
"published-time": "2026-09-18T09:10:33+00:00"
"time": "2026-11-24T11:49:00+00:00",
"published-time": "2026-11-24T12:48:58+00:00"
},
{
"name": "twig/twig",
"version": "v3.30.0",
"version": "v3.31.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "8c737079b726af72ff8ef3c595be9f6a810ea1ef"
"reference": "6f6ec372231b53d1d564567a78beb8844cafa132"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/8c737079b726af72ff8ef3c595be9f6a810ea1ef",
"reference": "8c737079b726af72ff8ef3c595be9f6a810ea1ef",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/6f6ec372231b53d1d564567a78beb8844cafa132",
"reference": "6f6ec372231b53d1d564567a78beb8844cafa132",
"shasum": ""
},
"require": {
@@ -6871,7 +6808,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.30.0"
"source": "https://github.com/twigphp/Twig/tree/v3.31.1"
},
"funding": [
{
@@ -6883,8 +6820,8 @@
"type": "tidelift"
}
],
"time": "2026-09-25T13:20:01+00:00",
"published-time": "2026-09-25T13:20:14+00:00"
"time": "2026-11-24T12:48:40+00:00",
"published-time": "2026-11-24T12:48:53+00:00"
}
],
"aliases": [],
@@ -6893,7 +6830,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=8.2"
"php": ">=8.4"
},
"platform-dev": {},
"plugin-api-version": "2.11.0"
+11
View File
@@ -41,8 +41,19 @@ THROTTLE_CREATE_PER_HOUR=10
THROTTLE_RECOVER_PER_HOUR=5
# Max. answers per IP and minute (0 = unlimited). Keep it high: a whole audience may share one Wi-Fi/IP.
THROTTLE_VOTES_PER_MINUTE=600
# Polls are deleted this many days after their creation by the cron job `bin/cake polls cleanup`
# (0 = never expire). The owner gets a reminder mail POLL_REMINDER_DAYS before (0 = no reminder).
POLL_RETENTION_DAYS=90
POLL_REMINDER_DAYS=14
# How often presenter and participant pages poll for updates (ms)
POLL_INTERVAL_MS=2000
# Slide images: directory (default data/uploads; in containers e.g. /data/uploads), largest upload in MB
# (PHP's upload_max_filesize and post_max_size must allow it) and slides with an image per poll
# UPLOADS_PATH=/var/www/plenario-uploads
IMAGE_MAX_UPLOAD_MB=10
IMAGE_MAX_PER_POLL=20
# Countdown music of a presentation: largest upload in MB (PHP's upload_max_filesize and post_max_size must allow it)
AUDIO_MAX_UPLOAD_MB=10
# Embedded slides (/e/{key}/{slide}, e.g. Canva): heartbeat interval and timeout until pause (s)
EMBED_HEARTBEAT_SECONDS=5
EMBED_TIMEOUT_SECONDS=20
@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* One optional image per slide. The (scaled) file lives in the upload directory, see
* \App\Service\ImageService; the table only holds its random file name and how to show it.
*/
class AddImageToSlides extends BaseMigration
{
/**
* @return void
*/
public function up(): void
{
$table = $this->table('slides');
$columns = [
// file name inside the poll's upload directory (null = no image)
'image' => ['string', ['null' => true, 'default' => null, 'limit' => 40]],
// alternative text, '' = purely decorative image
'image_alt' => ['string', ['null' => true, 'default' => null, 'limit' => 255]],
// top | side | full (null = default of the slide type)
'image_layout' => ['string', ['null' => true, 'default' => null, 'limit' => 8]],
'image_width' => ['integer', ['null' => true, 'default' => null]],
'image_height' => ['integer', ['null' => true, 'default' => null]],
];
$changed = false;
foreach ($columns as $name => [$type, $options]) {
if (!$table->hasColumn($name)) {
$table->addColumn($name, $type, $options);
$changed = true;
}
}
if ($changed) {
$table->update();
}
}
/**
* @return void
*/
public function down(): void
{
$table = $this->table('slides');
foreach (['image', 'image_alt', 'image_layout', 'image_width', 'image_height'] as $name) {
if ($table->hasColumn($name)) {
$table->removeColumn($name);
}
}
$table->update();
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* When the reminder mail before a poll expires was sent (null = not yet), so it goes out only once.
*/
class AddExpiryRemindedAtToPolls extends BaseMigration
{
/**
* @return void
*/
public function up(): void
{
$table = $this->table('polls');
if (!$table->hasColumn('expiry_reminded_at')) {
$table->addColumn('expiry_reminded_at', 'datetime', [
'null' => true,
'default' => null,
'after' => 'last_admin_access',
])->update();
}
}
/**
* @return void
*/
public function down(): void
{
$table = $this->table('polls');
if ($table->hasColumn('expiry_reminded_at')) {
$table->removeColumn('expiry_reminded_at')->update();
}
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* Optional audio file per presentation, played in the presenter view while a quiz countdown runs.
* The file lives in the upload directory, see \App\Service\AudioService; the table only holds its
* random file name.
*/
class AddAudioToPolls extends BaseMigration
{
/**
* @return void
*/
public function up(): void
{
$table = $this->table('polls');
if (!$table->hasColumn('audio')) {
$table->addColumn('audio', 'string', ['null' => true, 'default' => null, 'limit' => 40])->update();
}
}
/**
* @return void
*/
public function down(): void
{
$table = $this->table('polls');
if ($table->hasColumn('audio')) {
$table->removeColumn('audio')->update();
}
}
}
+30
View File
@@ -49,7 +49,31 @@ return [
// Answers (incl. word cloud entries and upvotes) per IP and minute; a whole audience may share one IP.
'votesPerMinute' => (int)env('THROTTLE_VOTES_PER_MINUTE', 600),
],
// Polls are deleted this many days after their creation by `bin/cake polls cleanup` (cron).
// 0 = never expire.
'retention' => [
'days' => (int)env('POLL_RETENTION_DAYS', 90),
// The owner gets a reminder mail this many days before (0 = no reminder, must be < days).
'reminderDays' => (int)env('POLL_REMINDER_DAYS', 14),
],
'pollIntervalMs' => (int)env('POLL_INTERVAL_MS', 2000),
// Slide images (see \App\Service\ImageService): scaled and re-encoded as WebP, stored outside webroot.
'images' => [
// One sub directory per poll. In containers keep it on the volume, e.g. /data/uploads.
'path' => (string)env('UPLOADS_PATH', ROOT . DS . 'data' . DS . 'uploads'),
// Largest accepted upload (the original, before scaling). PHP's upload_max_filesize/post_max_size must allow it.
'maxUploadBytes' => (int)env('IMAGE_MAX_UPLOAD_MB', 10) * 1024 * 1024,
// Longest edge after scaling, in pixels.
'maxEdge' => 1600,
'quality' => 82,
// Slides with an image per poll.
'maxPerPoll' => (int)env('IMAGE_MAX_PER_POLL', 20),
],
// Countdown audio of a presentation (see \App\Service\AudioService): stored as uploaded next to the images.
'audio' => [
// Largest accepted upload. PHP's upload_max_filesize/post_max_size must allow it.
'maxUploadBytes' => (int)env('AUDIO_MAX_UPLOAD_MB', 10) * 1024 * 1024,
],
// Slides embedded in other presentation software (/e/{key}/{slide}, e.g. Canva).
'embed' => [
// A visible embedded slide reports every N seconds that it is still on screen ...
@@ -353,6 +377,10 @@ return [
'default' => [
'className' => Connection::class,
'driver' => Sqlite::class,
// Default: SQLite file in data/. For MySQL/MariaDB/PostgreSQL set DATABASE_URL, e.g.
// mysql://user:pass@localhost/plenario?encoding=utf8mb4
'database' => ROOT . DS . 'data' . DS . 'plenario.sqlite',
'url' => env('DATABASE_URL', null),
'persistent' => false,
'timezone' => 'UTC',
@@ -396,6 +424,8 @@ return [
'test' => [
'className' => Connection::class,
'driver' => Sqlite::class,
'database' => ROOT . DS . 'tmp' . DS . 'tests.sqlite',
'url' => env('DATABASE_TEST_URL', null),
'persistent' => false,
'timezone' => 'UTC',
'encoding' => 'utf8',
+8 -38
View File
@@ -1,65 +1,35 @@
<?php
/*
* Local configuration overrides for Plenario.
* Development defaults for PlenarIO. Only for local work: `composer install` copies this file to
* config/app_local.php (gitignored, never overwritten afterwards).
*
* Copy this file to config/app_local.php (done automatically by
* `composer install`) and adjust it. app_local.php is NOT committed.
*
* Every value can alternatively be provided via environment variables.
* Production does NOT use app_local.php. Everything is configured in config/.env or real environment
* variables (see config/.env.example); config/app.php reads them. The release package and the Docker image
* ship without app_local.php on purpose: it takes precedence over the environment, so a stale copy would
* silently override settings (e.g. force the file mail transport).
*/
use Cake\Database\Driver\Sqlite;
use function Cake\Core\env;
return [
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
'App' => [
// Absolute base URL used for links in e-mails, e.g. https://plenario.example.org
'fullBaseUrl' => env('APP_FULL_BASE_URL', 'http://localhost:8765'),
],
'Security' => [
// Replaced by a random value during `composer install`
'salt' => env('SECURITY_SALT', '__SALT__'),
],
'Plenario' => [
'captcha' => [
// 'none' | 'math' | 'recaptcha'
'type' => env('CAPTCHA_TYPE', 'math'),
'recaptcha' => [
'siteKey' => env('RECAPTCHA_SITE_KEY', ''),
'secretKey' => env('RECAPTCHA_SECRET_KEY', ''),
],
],
// Shows the admin link on the confirmation page. Development only!
'showAdminLinkAfterCreate' => filter_var(env('SHOW_ADMIN_LINK_AFTER_CREATE', env('DEBUG', true)), FILTER_VALIDATE_BOOLEAN),
],
'Datasources' => [
/*
* Default: SQLite file in data/. For MySQL/MariaDB/PostgreSQL set
* DATABASE_URL, e.g.
* mysql://user:pass@localhost/plenario?encoding=utf8mb4
*/
'default' => [
'driver' => Sqlite::class,
'database' => ROOT . DS . 'data' . DS . 'plenario.sqlite',
'url' => env('DATABASE_URL', null),
],
'test' => [
'driver' => Sqlite::class,
'database' => ROOT . DS . 'tmp' . DS . 'tests.sqlite',
'url' => env('DATABASE_TEST_URL', null),
],
],
'EmailTransport' => [
/*
* Local default: mails are written as .eml files to tmp/mails/.
* For real delivery set SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD and SMTP_TLS
* (see config/.env.example); then this override is skipped.
*/
// Mails are written as .eml files to tmp/mails/ unless an SMTP server is configured
'default' => env('SMTP_HOST') || env('EMAIL_TRANSPORT_DEFAULT_URL') ? [] : [
'className' => \App\Mailer\Transport\FileTransport::class,
],
+15 -1
View File
@@ -33,7 +33,15 @@ return function (RouteBuilder $routes): void {
$builder->connect('/p/{code}/state', 'Participate::state', ['_name' => 'participate:state'])
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
->setPass(['code']);
$builder->connect('/p/{code}/vote', 'Participate::vote', ['_name' => 'participate:vote'])
// Slide images (also used by presenter and embed): random file name, only images of this poll.
$builder->connect('/p/{code}/img/{file}', 'Participate::image', ['_name' => 'participate:image'])
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}', 'file' => '[a-f0-9]{24}\.webp'])
->setPass(['code', 'file']);
// Countdown audio of a poll (played by the presenter view): random file name, only files of this poll.
$builder->connect('/p/{code}/audio/{file}', 'Participate::audio', ['_name' => 'participate:audio'])
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}', 'file' => '[a-f0-9]{24}\.(mp3|ogg|wav|m4a)'])
->setPass(['code', 'file']);
$builder->connect('/p/{code}/vote','Participate::vote', ['_name' => 'participate:vote'])
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
->setPass(['code'])
->setMethods(['POST']);
@@ -63,16 +71,22 @@ return function (RouteBuilder $routes): void {
$admin->connect('/', 'Admin::index', ['_name' => 'admin'])->setPatterns($token);
$admin->connect('/settings', 'Admin::settings', ['_name' => 'admin:settings'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/audio', 'Admin::audio', ['_name' => 'admin:audio'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/rotate-token', 'Admin::rotateToken', ['_name' => 'admin:rotate'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/rotate-embed-key', 'Admin::rotateEmbedKey', ['_name' => 'admin:rotate-embed'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/reset', 'Admin::reset', ['_name' => 'admin:reset'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/clone', 'Admin::cloneAll', ['_name' => 'admin:clone'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token);
$admin->connect('/speaker', 'Admin::speaker', ['_name' => 'admin:speaker'])->setPatterns($token);
$admin->connect('/state', 'Admin::state', ['_name' => 'admin:state'])->setPatterns($token);
$admin->connect('/live', 'Admin::live', ['_name' => 'admin:live'])->setPatterns($token);
$admin->connect('/control', 'Admin::control', ['_name' => 'admin:control'])
->setPatterns($token)->setMethods(['POST']);
$admin->connect('/qr.svg', 'Admin::qr', ['_name' => 'admin:qr'])->setPatterns($token);
+1
View File
@@ -1,3 +1,4 @@
# FOR TESTING ONLY - not suitable for production (built-in PHP server, SQLite).
# Example: docker compose up -d
# Put it behind a TLS reverse proxy that sets X-Forwarded-Proto; APP_FULL_BASE_URL = public URL.
services:
+19
View File
@@ -0,0 +1,19 @@
# Entwicklerdokumentation
Details zu PlenarIO. Die zentrale Einstiegsdatei mit Rolle, Befehlen, Konventionen und den Regeln, die nie gebrochen
werden dürfen, ist [AGENTS.md](../AGENTS.md). Die [README](../README.md) gibt den Überblick für Anwender.
| Dokument | Inhalt |
|---|---|
| [development.md](development.md) | Lokal starten, Tests, Mitarbeit |
| [architecture.md](architecture.md) | Verzeichnisstruktur, Klassen, Datenmodell |
| [slide-types.md](slide-types.md) | Folientypen im Detail, Checkliste für neue Typen |
| [images.md](images.md) | Folienbilder |
| [presenter.md](presenter.md) | Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback |
| [frontend.md](frontend.md) | Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild |
| [pdf-export.md](pdf-export.md) | PDF-Export |
| [operations.md](operations.md) | Ablauf von Umfragen, Deployment, Releases, Docker |
| [deployment.md](deployment.md) | Anleitung für Betreiber: Docker, ohne Docker, Cronjob, Admin-CLI, Gitea Actions, Releases |
| [configuration.md](configuration.md) | Alle Umgebungsvariablen |
Wer Verhalten ändert, pflegt das passende Dokument mit (und AGENTS.md nur, wenn sich eine zentrale Regel ändert).
+73
View File
@@ -0,0 +1,73 @@
# Architektur und Datenmodell
Verzeichnisstruktur, Klassen und Tabellen im Detail.
```
config/
app.php Defaults inkl. Block 'Plenario' (Captcha, Throttle, Polling) und Cache 'throttle'
app_local.example.php Dev-Defaults (debug, FileTransport), von `composer install` nach app_local.php kopiert (gitignored, nur lokal, nie in Produktion)
.env.example Alle Umgebungsvariablen (config/.env wird optional geladen)
routes.php Alle Routen benannt, KEINE Fallback-Routen
Migrations/ Schema (einzige Quelle der Wahrheit, auch für Tests)
src/
Captcha/ CaptchaInterface + NoCaptcha / MathCaptcha / RecaptchaCaptcha, CaptchaFactory
Error/RedactingErrorLogger maskiert Admin-Token und Embed-Key in allen Log-Einträgen (`Error.logger` in app.php)
Controller/
AppController Basis aller Controller: `joinUrl()`, `adminUrlFor()`, `setPollInterval()`, `throttle()`, `json()`,
`protect()` (no-referrer/noindex/no-store für Seiten mit Geheimnis in der URL: Admin, Embed)
HomeController Startseite, Anlegen (/create), Bestätigung, Join, Recover
AdminAppController Basis für /admin/{token}: löst Poll über Token-Hash auf (404 sonst), setzt Privacy-Header (no-referrer, no-store)
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Kopieren (`cloneAll`), Löschen
SlidesController Folien-CRUD, Ein-/Ausblenden (`visibility`), Duplizieren (`duplicate` → `SlidesTable::duplicate()`, Kopie direkt dahinter, öffnet das Formular der Kopie), Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
YouTube-Link prüfen (`youtubeCheck`, JSON)
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigene Antwort/Kommentar bearbeiten; anonymes Cookie plenario_pid
EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control
ErrorController Fehlerseiten (Templates unter templates/Error, Layout `error`)
Command/ImagesCleanupCommand `images_cleanup`: Bilddateien ohne Folie entfernen (idempotent)
Command/Polls*Command `polls list|show|delete|remind|cleanup` (Basis `PollsCommand`: Suche per id/Code, Links, Löschen)
Mailer/ PollMailer (adminLink, recovery; `sendSafely()` loggt Transportfehler statt zu werfen), Transport/FileTransport (lokal)
Middleware/ HostHeaderMiddleware: prüft in Produktion den Host gegen APP_FULL_BASE_URL;
SecurityHeadersMiddleware (äußerste Schicht): CSP mit Nonce, Framing, nosniff, Referrer-/Permissions-Policy
für alle Antworten inkl. JSON und Fehlerseiten; vom Controller gesetzte Header gewinnen
Model/ Polls → Slides → SlideOptions, Slides → Responses
Service/
VoteService Validiert + speichert Antworten (alle Abstimmungsregeln hier)
ResultsService Aggregiert Ergebnisse je Folientyp (JSON-Struktur im Docblock)
PollStateService State-JSON für Presenter und Teilnehmende
ThrottleService Rate-Limit pro IP (Cache 'throttle'), in Controllern über `AppController::throttle()`:
Anlegen/Recover pro Stunde, Antworten (`vote`) pro Minute (`THROTTLE_VOTES_PER_MINUTE`, 429)
ImageService Folienbilder: prüfen, drehen (EXIF), auf `maxEdge` verkleinern, als WebP speichern, löschen, aufräumen
YouTubeService YouTube-Links/Timecodes parsen, Watch-/Embed-URLs, Prüfung per oEmbed (Http\Client)
QaService Q&A: Phasen wechseln, Fragen nach Upvotes ranken, Fokus beim Besprechen
SlideControlService Folien-Aktionen open/close/toggle/stage/question (Presenter und Einbettung gemeinsam)
ResetService Antworten löschen: einzelne Folie (`slide`) bzw. alle Folien der Umfrage (`poll`)
ReportService Daten für den PDF-Export: Ergebnisse aller interaktiven Folien, mit/ohne interne Inhalte
View/PdfView.php Rendert Template als HTML (Layout `pdf`) und wandelt es mit Dompdf in ein PDF
templates/ Deutsche UI, Layouts: default, present (Vollbild, dunkel), error, email
webroot/css/plenario.css Eigenes CSS, kein Framework; Farben nur als Tokens (Hell/Dunkel, siehe Theme unten)
webroot/js/plenario.js Vanilla JS: Polling, Ergebnis-Rendering, Presenter-Steuerung, Sortieren (`makeSortable`: Pointer Events + Pfeiltasten,
genutzt für Folienliste, Reihenfolge-Editor und Teilnehmer-Antwort)
tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures sind leer
```
## Datenmodell
- `polls`: `title`, `email`, `admin_token_hash` (sha256), `admin_token_encrypted` (Security::encrypt),
`join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`,
`last_admin_access` (höchstens alle 10 min aktualisiert, nur Anzeige in `polls list|show`),
`expiry_reminded_at` (Erinnerungsmail vor dem Ablauf verschickt, siehe [operations.md](operations.md)),
`embed_key` (Einbett-Schlüssel), `embed_seen_at` (letztes Lebenszeichen der eingebetteten Live-Folie),
`paused_slide_id` (Folie vor der Pause), `comment_speed` (Tempo der Skala-Kommentare in Prozent, Standard 100)
- `slides`: `type` (`choice|wordcloud|open|scale|content|quiz|youtube|qa|order`), `question`, `description`, `position`,
`is_hidden` (ausgeblendet: vorbereitet, aber nicht Teil der Präsentation),
`settings` (JSON, je Typ siehe `Slide::DEFAULT_SETTINGS`), `is_voting_open`,
`voting_started_at` / `voting_ends_at` (nur Quiz: Start und Deadline, `null` = manuell beenden),
`stage` / `focus_response_id` (nur Q&A: Phase und gerade besprochene Frage)
- `slides.image` / `image_alt` / `image_layout` / `image_width` / `image_height`: optionales Bild (siehe [images.md](images.md))
- `slide_options`: Antwortoptionen für `choice`, `quiz` und `order`; `is_correct` markiert richtige Quiz-Antworten,
bei `order` ist `position` die richtige Reihenfolge
- `responses`: `participant_hash`, `slide_option_id` | `text_value` | `numeric_value` | `parent_id`.
Mehrfachauswahl/mehrere Wörter = mehrere Zeilen mit gleichem `participant_hash`.
Q&A: Frage = Zeile mit `text_value`, Upvote = Zeile mit `parent_id` (= id der Frage, FK mit CASCADE).
Reihenfolge: eine Zeile pro Person, `text_value` = Options-ids kommagetrennt (`VoteService::parseOrder()`).
Skala: `numeric_value`, optional Kommentar in `text_value`.
+43
View File
@@ -0,0 +1,43 @@
# Konfiguration
Alle Einstellungen über Umgebungsvariablen oder `config/.env`. Anleitung zum Betrieb: [deployment.md](deployment.md).
Alle Einstellungen gehen über Umgebungsvariablen oder `config/.env`
(Vorlage mit allen Variablen: [config/.env.example](../config/.env.example)). Echte Umgebungsvariablen
haben Vorrang vor der Datei.
**Pflicht in Produktion:** `DEBUG=false`, `APP_FULL_BASE_URL`, `SECURITY_SALT` und ein Mail-Transport (`SMTP_HOST`).
Alles andere ist optional und hat einen Standardwert. In der Spalte „Standard“ bedeutet „–“: kein Standard, der Wert muss gesetzt werden.
| Variable | Pflicht? | Standard | Bedeutung |
|---|---|---|---|
| `DEBUG` | Produktion: ja | `false` (lokal: die von Composer erzeugte `app_local.php` setzt `true`) | In Produktion `false` lassen, sonst werden Admin-Links direkt angezeigt |
| `APP_FULL_BASE_URL` | Produktion: ja | – (lokal `http://localhost:8765`) | Öffentliche URL inkl. `https://`, wird für Links in E-Mails gebraucht. In Produktion wird außerdem der Host-Header dagegen geprüft |
| `SECURITY_SALT` | ja | – (lokal wird er von Composer erzeugt) | Langer Zufallswert. **Nicht nachträglich ändern** – damit werden Admin-Tokens verschlüsselt und Teilnehmer-IDs gehasht |
| `DATABASE_URL` | optional | leer = SQLite in `data/` | Sonst z. B. `mysql://user:pw@host/plenario?encoding=utf8mb4` oder `postgres://user:pw@host/plenario` |
| `SMTP_HOST` | Produktion: ja | leer = Mails nur als Datei in `tmp/mails/` (per `app_local.php`), sonst PHP `mail()` | Mailserver. Ohne ihn kommt der Admin-Link nie bei den Nutzenden an. **Achtung:** Eine `config/app_local.php` hat Vorrang vor `.env`; ein `FileTransport` darin (ältere Vorlage) überschreibt SMTP, die Mails landen dann nur in `tmp/mails/`. Auf Servern gehört keine `app_local.php` hin, sie ist nur für die lokale Entwicklung. `bin/cake polls remind` zeigt den verwendeten Transport an und warnt davor |
| `SMTP_PORT` | optional | `587` | Port 465 nutzt automatisch SSL |
| `SMTP_USER`, `SMTP_PASSWORD` | optional | leer | Zugangsdaten, falls der Mailserver sie verlangt |
| `SMTP_TLS` | optional | `true` | `true` = STARTTLS, `false` = unverschlüsselt |
| `MAIL_FROM` | empfohlen | `noreply@localhost` | Absenderadresse, sollte zum Mailserver passen |
| `MAIL_FROM_NAME` | optional | `PlenarIO` | Absendername |
| `CAPTCHA_TYPE` | optional | `math` | `none`, `math` (Rechenaufgabe) oder `recaptcha` |
| `RECAPTCHA_SITE_KEY`, `RECAPTCHA_SECRET_KEY` | nur bei `recaptcha` | leer | Für reCAPTCHA v2 („Ich bin kein Roboter“) |
| `SHOW_ADMIN_LINK_AFTER_CREATE` | optional | Wert von `DEBUG` | Nur für Entwicklung, in Produktion nie aktivieren |
| `THROTTLE_CREATE_PER_HOUR` | optional | `10` | Umfragen pro IP und Stunde (0 = aus) |
| `THROTTLE_RECOVER_PER_HOUR` | optional | `5` | Wiederherstellungs-Mails pro IP und Stunde (0 = aus) |
| `THROTTLE_VOTES_PER_MINUTE` | optional | `600` | Antworten pro IP und Minute (0 = aus). Hoch lassen: Oft teilt sich ein ganzer Saal eine IP |
| `POLL_RETENTION_DAYS` | optional | `90` | Umfragen werden so viele Tage nach dem Anlegen vom Cronjob gelöscht (0 = nie) |
| `POLL_REMINDER_DAYS` | optional | `14` | So viele Tage vorher bekommt der Besitzer eine Erinnerungsmail (0 = keine, muss kleiner als die Laufzeit sein) |
| `POLL_INTERVAL_MS` | optional | `2000` | Aktualisierungsintervall der Live-Ansichten in Millisekunden |
| `EMBED_HEARTBEAT_SECONDS` | optional | `5` | Eingebettete Folien: Intervall des Lebenszeichens |
| `EMBED_TIMEOUT_SECONDS` | optional | `20` | Eingebettete Folien: Zeit ohne Lebenszeichen bis zur automatischen Pause |
| `EMBED_FRAME_ANCESTORS` | optional | `*` (alle) | Welche Seiten Folien einbetten dürfen (CSP `frame-ancestors`), z. B. `https://*.canva.com` |
Einen `SECURITY_SALT` erzeugen:
```bash
php -r "echo bin2hex(random_bytes(32));"
# oder ohne PHP:
openssl rand -hex 32
```
+213
View File
@@ -0,0 +1,213 @@
# Deployment
Betrieb von PlenarIO: Docker (nur Testbetrieb), Installation ohne Docker, Cronjob, Admin-CLI, Gitea Actions und Releases.
Alle Variablen: [configuration.md](configuration.md).
## Deployment mit Docker
> **Nur für Testzwecke.** Das Docker-Image ist zum Ausprobieren und für Tests gedacht und **nicht für den
> Produktionsbetrieb geeignet**: Es nutzt den eingebauten PHP-Server (kein Webserver wie Apache oder nginx mit PHP-FPM)
> und SQLite in einem Volume. Für den echten Betrieb siehe [Deployment ohne Docker](#deployment-ohne-docker).
Das [Dockerfile](../Dockerfile) baut ein schlankes Image (`php:8.5-cli-alpine`, Multi-Stage mit Composer).
Der eingebaute PHP-Server läuft mit 8 Workern auf Port **8765**, die SQLite-Datenbank und die Folienbilder (`/data/uploads`)
liegen im Volume `/data`.
Beim Start laufen die Migrationen automatisch (idempotent, mehrfaches Starten ist unproblematisch).
Das fertige Image liegt in der Gitea-Registry:
`gitea.gnilebein.de/gnilebein/plenario:latest` (letzter stabiler Release). Für feste Versionen gibt es die
SemVer-Tags `:1.4.0`, `:1.4` und `:1` (Pre-Releases wie `v1.5.0-rc.1` nur als `:1.5.0-rc.1`).
Gebaut wird das Image nur bei einem neuen Release-Tag, siehe [Releases](#releases-und-versionierung).
### Schnellstart mit `docker run`
```bash
docker run -d --name plenario -p 8765:8765 -v plenario-data:/data \
-e SECURITY_SALT="$(openssl rand -hex 32)" \
-e APP_FULL_BASE_URL=https://plenario.example.org \
-e MAIL_FROM=noreply@example.org \
-e SMTP_HOST=mail.example.org -e SMTP_PORT=587 \
-e SMTP_USER=noreply@example.org -e SMTP_PASSWORD='geheim' \
--restart unless-stopped \
gitea.gnilebein.de/gnilebein/plenario:latest
```
### Docker Compose
1. Eine `.env` neben der [docker-compose.yml](../docker-compose.yml) anlegen (Vorlage: [config/.env.example](../config/.env.example)):
```dotenv
SECURITY_SALT=<64 Zeichen Zufall, siehe oben>
APP_FULL_BASE_URL=https://plenario.example.org
MAIL_FROM=noreply@example.org
MAIL_FROM_NAME=PlenarIO
SMTP_HOST=mail.example.org
SMTP_PORT=587
SMTP_USER=noreply@example.org
SMTP_PASSWORD=geheim
SMTP_TLS=true
CAPTCHA_TYPE=math
```
2. Starten:
```bash
docker compose up -d
docker compose logs -f plenario # Start und Migrationen beobachten
```
3. Aktualisieren auf die neueste Version:
```bash
docker compose pull && docker compose up -d
```
Die Datenbank bleibt im Volume `plenario-data` erhalten; neue Migrationen laufen beim Start automatisch.
Statt das Image zu ziehen, lässt sich auch lokal bauen: in der `docker-compose.yml` die Zeile `# build: .`
aktivieren oder `docker build -t plenario .` ausführen.
### Wichtig im Container
- **Cronjob:** Der Container führt kein cron aus. Das Ablaufen und Erinnern von Umfragen braucht einen Aufruf vom Host,
siehe [Cronjob einrichten](#cronjob-einrichten).
- **`SECURITY_SALT` ist Pflicht.** Fehlt er, bricht der Start mit einer Fehlermeldung ab. Er wird nicht ins Image
eingebrannt, sondern zur Laufzeit gesetzt. Nach dem ersten Einsatz **nie mehr ändern** (sonst werden
Admin-Tokens unlesbar und Teilnehmer-IDs ungültig).
- **`APP_FULL_BASE_URL` muss die öffentliche URL sein**, inklusive `https://`. Sie wird für die Links in
E-Mails verwendet, und in Produktion wird der Host-Header dagegen geprüft.
- **Mail-Versand einrichten.** Ohne `SMTP_HOST` schreibt PlenarIO Mails nur als Datei ins
Container-Dateisystem – der Admin-Link kommt dann **nie** bei den Nutzenden an.
- **TLS-Proxy davorschalten** (Caddy, nginx, Traefik, …), der `X-Forwarded-Proto` setzt. Der eingebaute
PHP-Server spricht nur HTTP. Beispiel für Caddy:
```
plenario.example.org {
reverse_proxy localhost:8765
}
```
- **Daten sichern:** Alles Wichtige liegt in `/data` (SQLite-Datei `plenario.sqlite`). Backup z. B. mit
`docker run --rm -v plenario-data:/data -v "$PWD":/backup alpine tar czf /backup/plenario-data.tgz -C /data .`
- **Bind-Mount statt Volume:** Der Container läuft als Benutzer `www-data` (UID 82). Das Host-Verzeichnis
muss für ihn beschreibbar sein (`chown 82:82 ./data`).
- **Andere Datenbank:** Für viele gleichzeitige Teilnehmende `DATABASE_URL` auf MySQL/PostgreSQL setzen
(siehe [Betrieb & Skalierung](../README.md#betrieb--skalierung)).
- **Healthcheck:** Das Image prüft eine statische Datei (`/css/plenario.css`), weil die Host-Prüfung echte Seiten
bei Aufrufen über `127.0.0.1` ablehnen würde.
- **Weitere Einstellungen** (Captcha, Rate-Limits, Polling, Einbettung) gehen ebenfalls per Umgebungsvariable,
siehe [Konfiguration](configuration.md).
## Deployment ohne Docker
1. Code auschecken, `composer install --no-dev --optimize-autoloader`
2. `config/.env` (oder echte Umgebungsvariablen) setzen, mindestens `DEBUG=false`,
`APP_FULL_BASE_URL`, `SECURITY_SALT`, Mail-Transport
3. `bin/cake migrations migrate` und `bin/cake cache clear_all`
4. Document-Root auf `webroot/` zeigen lassen; `tmp/`, `logs/` und `data/` beschreibbar machen.
Liegt die App direkt im Document-Root (z. B. `public_html`), leiten `.htaccess` und `index.php`
im Projektroot alles nach `webroot/` weiter.
Folienbilder landen in `data/uploads` (anderer Ort: `UPLOADS_PATH`), nie unter `webroot/`; das Verzeichnis gehört in die
Datensicherung. Voraussetzungen: PHP-Erweiterung `gd` mit WebP sowie `upload_max_filesize` und `post_max_size` passend zu
`IMAGE_MAX_UPLOAD_MB` (Standard 10 MB, PHP-Standard sind nur 2 MB bzw. 8 MB). Dateien ohne Folie (z. B. nach einem Absturz)
entfernt `bin/cake images_cleanup` (`--dry-run` zeigt sie nur an).
Die Quiz-Musik (eine Audiodatei je Präsentation) liegt im selben Verzeichnis; ihre Obergrenze steht in `AUDIO_MAX_UPLOAD_MB`
(Standard 10 MB), auch dafür müssen `upload_max_filesize` und `post_max_size` reichen.
Bei Updates: Code aktualisieren, `composer install --no-dev`, Migrationen und `cache clear_all` wiederholen.
### Umfragen verwalten und aufräumen (CLI)
Zum Verwalten per Hand und für Skripte/Cron:
| Befehl | Zweck |
|---|---|
| `bin/cake polls list [--expired] [--email=text] [--sort=created\|activity\|title] [--json]` | Umfragen mit E-Mail, Ablaufdatum und Erinnerung |
| `bin/cake polls show <id\|code> [--link] [--json]` | Details; mit `--link` auch der geheime Admin-Link (nur auf Wunsch) |
| `bin/cake polls delete <id\|code> [--yes]` | Eine Umfrage samt Folien, Antworten und Bildern löschen (fragt nach) |
| `bin/cake polls remind [<id\|code>] [--dry-run]` | Erinnerungsmails für bald ablaufende Umfragen (je Umfrage einmal). Mit ID oder Code geht die Mail sofort und erzwungen nur an diese Umfrage, zum Testen: unabhängig vom Erinnerungsfenster und von `POLL_REMINDER_DAYS`, beliebig oft, ohne die Umfrage als erinnert zu markieren (die reguläre Erinnerung kommt trotzdem noch) |
| `bin/cake polls cleanup [--dry-run]` | Der Cronjob: erst erinnern, dann abgelaufene Umfragen löschen, danach verwaiste Bilddateien |
Eine Umfrage läuft `POLL_RETENTION_DAYS` Tage (Standard 90) nach dem Anlegen ab und wird dann gelöscht, unabhängig davon,
wie oft sie genutzt wurde. `POLL_REMINDER_DAYS` Tage vorher (Standard 14, 0 = keine Erinnerung) bekommt der Besitzer
einmalig eine Mail mit Ablaufdatum und Admin-Link, um die Ergebnisse als PDF zu sichern. Das Ablaufdatum steht außerdem in
der Anlege-Mail und im Dashboard (Karte „Sicherheit“). Es wird berechnet, eine Änderung der Einstellung gilt also sofort
für alle Umfragen.
Mit `--json` geben `polls list` und `polls show` statt der Tabelle bzw. des Texts reines JSON aus (Datumswerte als
ISO 8601, ohne weitere Ausgabe), z. B. für `jq`: `bin/cake polls list --json --expired | jq '.[].email'`. Der Admin-Link
steht auch dort nur mit `--link` (`adminUrl`, sonst `null`).
### Cronjob einrichten
Ein einziger täglicher Cronjob erledigt Erinnern, Löschen und Bild-Aufräumen (`polls cleanup`). Ohne ihn läuft keine
Umfrage ab und niemand wird erinnert.
**Server mit Shell/DirectAdmin** (Menü „Cronjobs“ bzw. `crontab -e`), täglich um 3:17 Uhr:
```
17 3 * * * cd /pfad/zu/plenario && /pfad/zu/php bin/cake.php polls cleanup --quiet
```
- Das Verzeichnis muss das Projektstammverzeichnis sein (dort liegt `config/.env`, sie wird automatisch gelesen).
Den PHP-Pfad zeigt `which php` bzw. in DirectAdmin die PHP-Auswahl, z. B. `/usr/local/php84/bin/php`; es muss PHP ≥ 8.4 sein.
- `--quiet` unterdrückt die Ausgabe bei Erfolg. Fehler (z. B. ein fehlgeschlagener Mailversand) erscheinen trotzdem,
Exit-Code 1; mit gesetzter `MAILTO` schickt cron sie per Mail. Ein Protokoll geht mit `>> logs/cleanup.log 2>&1`.
- Der Benutzer des Cronjobs braucht Schreibrechte auf `tmp/`, `logs/`, `data/` (Datenbank, Bilder), derselbe Benutzer wie der Webserver.
- Die Erinnerungsmails brauchen den produktiven Mail-Transport (`SMTP_*`) und `APP_FULL_BASE_URL` in der `config/.env`,
sonst stimmen die Links nicht.
**Docker** (nur Testbetrieb): Im Container läuft kein cron, der Aufruf kommt vom Host:
```
17 3 * * * cd /pfad/zu/compose && docker compose exec -T plenario bin/cake polls cleanup --quiet
```
**Erster Einsatz:** Umfragen, die zu dem Zeitpunkt schon älter als `POLL_RETENTION_DAYS` sind, werden ohne Erinnerung
gelöscht (die Mail geht nur im Fenster vor dem Ablauf raus). Deshalb erst prüfen und dann den Cronjob anlegen:
```
bin/cake polls list --expired # was wäre sofort weg?
bin/cake polls cleanup --dry-run # Erinnerungen und Löschungen nur anzeigen
```
Der Befehl ist idempotent: mehrfaches Ausführen (auch zweimal am Tag) verschickt keine Erinnerung doppelt und
löscht nichts Zusätzliches.
## Automatisches Deployment (Gitea Actions)
[.gitea/workflows/ci.yml](../.gitea/workflows/ci.yml) testet jeden Push (PHPUnit + phpcs).
`main` ist geschützt, gemergt wird nur per Pull Request mit grünem Test. Nach dem Merge deployt der Job
`deploy` per SSH – aber nur, wenn die Repo-Variable `DEPLOY_ENABLED=true` gesetzt ist. Er holt den Code,
führt `composer install --no-dev`, die Migrationen und `cache clear_all` aus. Benötigte Variablen und Secrets
stehen im Kopf der Workflow-Datei. Einmalig auf dem Server: `config/.env` anlegen, ohne sie bricht der Deploy ab.
Der Workflow bedient vor allem die Instanz unter <https://plenario.gnilebein.de/>, ist aber nicht fest darauf
verdrahtet: Ziel und Werkzeuge kommen ausschließlich aus Repository-Variablen (`SSH_HOST`, `SSH_PORT`, `SSH_USER`,
`DEPLOY_PATH`, optional `PHP_BIN`/`COMPOSER_BIN`) und Secrets (`SSH_KEY` oder `SSH_PASSWORD`). Wer PlenarIO auf einem
eigenen Server betreibt, setzt dort seine Werte und `DEPLOY_ENABLED=true` – die Workflow-Datei bleibt unverändert.
Voraussetzungen: SSH-Zugang mit Shell, `git` und PHP ≥ 8.4 auf dem Server, der Server erreicht die Gitea-Instanz per
HTTPS. Ohne `DEPLOY_ENABLED` passiert nichts (Standard).
## Releases und Versionierung
PlenarIO nutzt [Semantic Versioning](https://semver.org/lang/de/) (`MAJOR.MINOR.PATCH`): Major bei inkompatiblen
Änderungen (z. B. Schema-/Konfigurationsumbrüche), Minor für neue Funktionen, Patch für Fehlerbehebungen.
Eine Version entsteht durch einen Tag auf `main`:
```bash
git tag v1.4.0 && git push origin v1.4.0 # Pre-Release: v1.5.0-rc.1
```
Der Workflow [.gitea/workflows/release.yml](../.gitea/workflows/release.yml) läuft nur bei solchen Tags (`vX.Y.Z[-suffix]`),
führt zuerst die Tests aus und erzeugt dann
- ein **App-Paket** `plenario-<version>.tar.gz` samt `SHA256SUMS` als Anhang des Gitea-Releases (fertig mit
Produktions-`vendor/`, nur die Anwendung (Whitelist), ohne Tests, CI, Docker und Entwicklerdateien, `VERSION`-Datei enthalten; Einrichtung wie unter
[Deployment ohne Docker](#deployment-ohne-docker), nur ohne Composer-Schritt) und
- das **Docker-Image** mit den Tags `:<version>`, `:<major>.<minor>`, `:<major>` und `:latest`.
Tags mit Suffix (`-rc.1`, `-beta.2`) werden als Pre-Release markiert und bekommen weder `:latest` noch `:<major>`.
Der Workflow ist wiederholbar: ein erneuter Lauf aktualisiert das vorhandene Release.
+50
View File
@@ -0,0 +1,50 @@
# Entwicklung
Lokales Setup, Tests und Mitarbeit. Regeln und Konventionen: [AGENTS.md](../AGENTS.md).
## Lokal starten
Voraussetzungen: PHP 8.4+ mit den Erweiterungen `intl`, `mbstring`, `openssl`, `pdo_sqlite`, `curl`, `gd` (mit WebP)
sowie [Composer](https://getcomposer.org/).
```bash
git clone https://gitea.gnilebein.de/gnilebein/Plenario.git
cd Plenario
composer install # legt config/app_local.php an (nur Dev-Defaults: debug, Mails als Datei)
bin/cake migrations migrate # erstellt data/plenario.sqlite
bin/cake server -p 8765 # http://localhost:8765
```
Unter Windows ggf. `php bin/cake.php …` statt `bin/cake …`.
Lokal werden keine Mails verschickt: Sie landen als `.eml` in `tmp/mails/`. Zusätzlich wird der
Admin-Link im Debug-Modus direkt nach dem Anlegen angezeigt.
Nach neuen Migrationen `bin/cake cache clear_all` ausführen, sonst nutzt das ORM das alte Schema aus dem Cache.
Zurücksetzen der lokalen Daten: `data/plenario.sqlite` löschen und die Migrationen erneut laufen lassen.
## Tests
```bash
vendor/bin/phpunit # nutzt tmp/tests.sqlite, Schema kommt aus den Migrationen
vendor/bin/phpcs # CakePHP Coding Standard (Autofix: vendor/bin/phpcbf)
```
Vor jedem Commit müssen beide grün sein. `main` ist geschützt: Änderungen auf einem eigenen Branch pushen und per Pull Request mergen.
## Lasttest (JMeter)
`tests/load/plenario.jmx` simuliert Teilnehmende: Seite `/p/{code}` laden, kurz lesen, einmal auf der aktuellen
Auswahlfrage abstimmen (CSRF-Token, Folien- und Options-ID werden aus der Seite gelesen) und danach im
`Plenario.pollIntervalMs`-Takt `/p/{code}/state` abfragen. Jeder Thread hat eigene Cookies, ist also ein eigener Teilnehmer.
```bash
jmeter -n -t tests/load/plenario.jmx -Jhost=localhost -Jport=8765 -Jcode=ABCD \
-Jusers=200 -Jrampup=60 -Jduration=300 -l tmp/load.jtl -e -o tmp/load-report
```
Parameter: `protocol` (http), `host`, `port`, `code` (Join-Code), `users`, `rampup` (s), `duration` (s), `pollms` (2000).
Passende Testdaten legt `bin/cake polls seed` an: jeder Aufruf erzeugt eine **neue** Umfrage (neue ID und neuer Code)
mit je einer Folie pro interaktivem Typ; die erste Folie (Auswahlfrage) ist live und offen. `--json` liefert Code und
Admin-Link für Skripte, `--title`/`--email` passen die Daten an. Aufräumen: `bin/cake polls delete <id> -y`. Alle Last kommt von einer IP: bei
`THROTTLE_VOTES_PER_MINUTE` (Standard 600) antwortet die Abstimmung sonst mit 429. Nur gegen eigene Instanzen testen.
+63
View File
@@ -0,0 +1,63 @@
# Frontend und Oberfläche
Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild. CSP-Regeln stehen in [AGENTS.md](../AGENTS.md).
## Dashboard ohne Neuladen
- **Einklappbare Seitenleiste** der Verwaltung: `<details class="card collapsible">` mit `<summary><h2>`. Standard: Teilnahme,
Einstellungen (direkt unter dem QR-Code; beim Hover/Fokus erscheint „Als PNG speichern“, `data-qr-download` rendert das SVG per Canvas als 1024-px-PNG, nur im Admin) offen; „Ergebnisse als PDF“, „In Präsentation einbetten“ und „Sicherheit“ zu.
Offene Karten trennt eine Linie zwischen Überschrift und Inhalt.
Anker-Links wie `#export` öffnen ihre Karte (`openCollapsible()` in `plenario.js`).
- **Dashboard ohne Neuladen** (`initAdminDashboard()`, `Fragments` in `plenario.js`): Formulare in `[data-live]` (Folienliste, Kopf)
und das Folienformular im `<dialog>` laufen per `fetch` mit Header `X-Fragment`; `AdminAppController::beforeRender()` nimmt dann
das Layout `fragment` (nur Inhalt + Flash). Die Server-Aktionen bleiben normale POST + Redirect, das JS tauscht die Bereiche
`[data-refresh="head|slides|flash"]` (als DOM-Knoten, nie `innerHTML`) und stellt den Fokus wieder her. Bearbeiten/Anlegen:
Links mit `data-modal` laden das Formular (`[data-modal-content]`) in den Dialog (ebenso die Antworten-/Auswertungsseite `slides:answers`); Validierungsfehler kommen als Formular
zurück (Dialog bleibt offen), Erfolg als Dashboard-Fragment (Dialog schließt). Ohne JS funktioniert alles als normale Seite.
Die Liste folgt auch dem Presenter (Live-Markierung, Status): `initAdminDashboard()` pollt `admin:live` (`AdminController::live()`,
nur `{version}` aus `PollStateService::dashboardVersion()`, billiger als der Presenter-State) und lädt `head`/`slides` nur bei geänderter Version
neu – nie bei offenem Dialog, laufender Anfrage oder Drag & Drop; der Fokus wird wiederhergestellt. Wechselt dabei die Live-Folie, scrollt `revealCurrent()` sie per `scrollIntoView({block: 'nearest'})` in den
sichtbaren Bereich (bei langen Listen; bewegt nichts, wenn sie schon sichtbar ist; ohne Animation bei `prefers-reduced-motion`). Test: `PollResetTest::testDashboardLiveVersionFollowsThePresenter`.
**Buttons mit Bestätigung** nutzen `Form->postButton()` + `data-confirm` (CakePHPs `postLink`/`confirm` erzeugt ein Inline-`onclick`,
das die CSP blockiert); das JS fragt per `window.confirm()` vor dem Absenden. Tests: `AdminFragmentTest.php`.
## Farbschema (Tag/Nacht)
`data-theme="light|dark"` auf `<html>`, ohne Attribut gilt die Systemeinstellung. `element/theme_init` setzt die
Wahl aus `localStorage` vor dem ersten Rendern (Inline-Skript im `<head>`), `element/theme_switch` ist der Schalter
(`Theme` in `plenario.js`). Presenter: eigener Schlüssel `plenario-theme-present`, Standard dunkel, Taste T.
Neue Farben als Token in beiden Dark-Blöcken von `plenario.css` pflegen; auf der Bühne Overlays mit `rgba(var(--tint), …)`.
## Formatierung von Folientexten
- **Formatierung von Folientexten** (nur `description`, nie Eingaben von Teilnehmenden) im WhatsApp-Stil: `*fett*`,
`_kursiv_`, `~durchgestrichen~`, Aufzählung mit `- `/`* ` am Zeilenanfang, Zeilenumbrüche. Zwei gleiche Implementierungen:
`FormatHelper::text()` (PHP: Teilnehmerseite, PDF; escapt alles und erzeugt nur diese Tags) und `Format` in `plenario.js`
(Presenter/Embed; baut DOM-Knoten, kein `innerHTML`). Regeln in beiden gleich halten (Regex `INLINE`/`LIST_ITEM`),
Tests: `FormatHelperTest.php`.
## Verwaltung: Menü-Drawer
- Die Seitenleiste der Verwaltung (Teilnahme, Einstellungen inkl. Einbetten und Kopieren, PDF, Sicherheit) wird unter 900 px zu einem Drawer von rechts.
Der Menü-Button (`data-drawer-toggle`, Layout-Block `headerMenu`) sitzt im Header rechts neben dem Farbschema-Schalter.
`initDrawer` in `plenario.js` fügt dem `<aside>` die Klasse `sidebar--drawer` hinzu und zeigt den Button; ohne JS bleibt die
Leiste ein normaler Block unter den Folien. Schließen: ✕, Klick auf den Hintergrund, Esc oder Anker-Link in der Leiste (`#export`, `#embed`).
- Teilnehmeransicht: kein Vollbild- und kein Display-anlassen-Schalter (bewusst entfernt).
## Favicon
Das Logo (`.brand__mark` in `plenario.css`) ist auch das Favicon: `webroot/favicon.svg` (moderne Browser), `favicon.ico`
(16/32/48 px, Fallback) und `apple-touch-icon.png` (180 px, iOS, deckend ohne Rundung, die macht iOS selbst). Eingebunden über
`templates/element/favicon.php` in allen drei Layouts (default, present, error). Die Dateien sind statisch und werden aus
einer Geometrie erzeugt (auch das Mail-Logo, siehe unten): Ändert sich das Logo, `php resources/favicon/generate.php webroot` ausführen (braucht `ext-gd`)
und Farben/Anteile im Skript an `.brand__mark` angleichen. Test: `FaviconTest.php`.
## E-Mail-Layout
`templates/layout/email/html/default.php` übernimmt Logo und Farben der Webseite (Light-Theme): Hintergrund `--bg`, Text `--text`,
Grau `--muted`, Buttons/Links und „IO“ in `--primary`. Mails kennen weder Stylesheets noch SVG, deshalb stehen die Werte als
Inline-Styles (Tabelle für die Markenzeile) im Layout und in den Mail-Templates. **Ändert sich ein Token in `plenario.css`,
die Hex-Werte in `templates/layout/email/` und `templates/email/html/` nachziehen.** Das Logo ist `resources/mail/logo.png`
(wird vom Favicon-Generator mit erzeugt) und hängt als Inline-Anhang (`cid:`) an jeder Mail: `PollMailer` fügt es im Konstruktor
hinzu, so erscheint es auch ohne „Bilder laden“ und ohne öffentliche Basis-URL. Test: `PollMailerTest.php`.
+25
View File
@@ -0,0 +1,25 @@
# Folienbilder
Ein Bild pro Folie: Upload, Verarbeitung, Auslieferung und Löschregeln.
- **Folienbilder** (ein Bild pro Folie, alle Typen außer `youtube`, `Slide::supportsImage()`): Upload im Folienformular (multipart,
`SlidesController::prepareImage()`), verarbeitet von `ImageService::store()`: Format per `getimagesizefromstring` (JPEG/PNG/GIF/WebP,
**kein SVG, keine animierten GIFs**), EXIF-Drehung (eigener Parser, die `exif`-Erweiterung fehlt oft), längste Kante höchstens
`Plenario.images.maxEdge` (1600), Ausgabe immer WebP (entfernt alle Metadaten inkl. GPS). Das Original wird nie gespeichert.
Ablage `{Plenario.images.path}/{poll_id}/{24 Hex}.webp` (Standard `data/uploads`, Docker `/data/uploads`) **außerhalb von `webroot/`**,
ausgeliefert über `participate:image` (`/p/{code}/img/{file}`, auch für Presenter und Einbettung; nur Dateien dieser Umfrage, `immutable`
gecacht, kein Cookie). Jedes neue Bild bekommt einen neuen Namen → neue URL, ersetzte Bilder sind sofort 404.
Eine Bildbeschreibung wird bewusst nicht abgefragt (`image_alt` bleibt `""`, die Spalte ist ungenutzt): Bilder sind Beamer-Dekoration. Nie Pflichtfelder zum Bild einführen, die den Upload verwerfen: das Dateifeld lässt sich nach einem Fehler nicht neu füllen. Der Formularbereich (`element/slide_image_fields`) ist ein eigener Abschnitt: ohne Bild eine Dropzone (Label auf dem versteckten
Dateifeld `#image-file`, Drag & Drop), mit Bild eine Zeile aus Vorschau, „Ersetzen“ und „Entfernen“; eine gewählte Datei wird sofort als
Vorschau gezeigt (`initImageFields()`, ersetzt `remove_image` per Button, die Checkbox bleibt für den Betrieb ohne JavaScript). Die Platzierung
(`data-image-layout`, Kacheln mit Mini-Skizze, echte Radios) blendet `initImageFields()` nur ein, wenn ein Bild vorhanden (und nicht zum Entfernen markiert) oder eine Datei gewählt ist; ohne JavaScript bleibt sie sichtbar. Layout `image_layout` (`top`|`side`|`full`, `full` nur
Inhaltsfolien, `null` = Standard je Typ: Inhaltsfolie `side`, sonst `top`; `Slide::imageLayout()`); `side` gilt nur für die Bühne
(CSS `stage--img-*`), Teilnehmende sehen das Bild immer oben (`element/slide_image`). Kontingent `Plenario.images.maxPerPoll` Folien mit Bild.
Im State steht `slide.image` = `{url, alt, layout, width, height}` (`PollStateService::slidePayload()`).
**Löschen:** die Datei geht nach dem Commit weg, nie davor. Bild ersetzen/entfernen: alte Datei nach erfolgreichem Speichern; Fehler beim
Speichern: die neue Datei wird verworfen (`discardImage()`). Folie löschen: explizit im Controller nach der Transaktion
(`Model.afterDeleteCommit` feuert **nicht** innerhalb einer äußeren Transaktion). Umfrage löschen: `PollsTable::afterDeleteCommit` räumt das
Verzeichnis. Duplizieren kopiert die Datei (kein geteiltes Bild, keine Referenzzählung). Zurücksetzen lässt Bilder unberührt.
Reste (Absturz) entfernt `bin/cake images_cleanup`. Beim Patchen von Entity-Feldern ist `patch([...], ['guard' => false])` nötig, und
`patch()` setzt Fehler des Feldes zurück: Fehlermeldungen erst danach setzen. Das Upload-Objekt gehört nicht in `patchEntity()` (Marshaller
scheitert an `UploadedFile`). Tests: `SlideImageTest.php`, `ImageServiceTest.php` (`ImageTestTrait`).
+80
View File
@@ -0,0 +1,80 @@
# Betrieb: Ablauf, Deployment, Releases, Docker
Aufräumen und Erinnerungen, CI/CD, Release-Pakete, Container.
## Ablauf von Umfragen
- **Ablauf von Umfragen** (`Plenario.retention.days` = `POLL_RETENTION_DAYS`, Standard 90, 0 = nie): berechnet, nicht gespeichert:
`Poll::expiresAt()` = `created` + Tage (feste Laufzeit, Nutzung verlängert nichts); Finder `PollsTable::findExpired()`.
**Erinnerung** (`Plenario.retention.reminderDays` = `POLL_REMINDER_DAYS`, Standard 14, 0 = aus, effektiv höchstens Laufzeit − 1:
`Poll::reminderLeadDays()`): `polls remind` mailt einmal pro Umfrage (`PollMailer::expiryReminder()`, mit Admin-Link; Finder
`findReminderDue()` = Erinnerungsfenster, noch nicht abgelaufen, `expiry_reminded_at` leer; Marker erst nach erfolgreichem Versand,
sonst nächster Lauf erneut). Ablaufdatum steht auch in der Anlege-Mail und im Dashboard (Karte „Sicherheit“).
Aufräumen per Cron: `bin/cake polls cleanup` (erst `remind`, dann idempotent löschen über `PollsTable::delete()` samt
Folien/Bildern, danach `images_cleanup`; `--dry-run`; Cron-Einrichtung für Server und Docker steht in [deployment.md](deployment.md) unter
„Cronjob einrichten“, im Container läuft kein cron). `last_admin_access` fließt nicht mehr ein. `polls show --link`
ist die einzige Stelle, die den Admin-Link ausgibt (nie in `list`).
`polls list|show --json` gibt nur JSON aus (`PollsCommand::pollData()`/`printJson()`, Ausgabemodus RAW, sonst würden `<…>` in Titeln als
Markup verschluckt; nie das Token, `adminUrl` nur mit `--link`).
`polls remind <id|code>` erzwingt die Erinnerung für genau eine Umfrage (Testzweck): ignoriert Fenster, Marker und `POLL_REMINDER_DAYS`,
setzt `expiry_reminded_at` nicht, braucht aber ein Ablaufdatum (`POLL_RETENTION_DAYS` > 0).
Tests: `PollsCommandsTest.php` (leert vorher alle Umfragen).
## Deployment
Deploy erfolgt über Git (Remote: Gitea) mit `.gitea/workflows/ci.yml`:
- Job `phpunit` (PHPUnit + phpcs) läuft bei jedem Push auf jeden Branch, als Matrix gegen PHP 8.4 und 8.5.
Der Sammel-Job `test` ist nur grün, wenn alle Matrix-Läufe grün sind, und bleibt der Check, den der Branch-Schutz
verlangt (so muss dort bei neuen PHP-Versionen nichts angepasst werden). `main` ist per Branch-Schutz
in Gitea gesperrt: kein direkter Push, Merge nur per PR und nur mit grünem Status-Check des Jobs `test`.
- Job `deploy` läuft nur bei Push auf `main`, nur bei grünen Tests und **nur wenn die Repo-Variable
`DEPLOY_ENABLED=true` gesetzt ist** (standardmäßig deaktiviert). Er verbindet sich per SSH
(DirectAdmin, `plenario.gnilebein.de`, Checkout direkt in `public_html`), holt den Code per HTTPS mit
dem kurzlebigen Job-Token (kein Deploy-Key auf dem Server), macht `git reset --hard origin/main`,
bricht ab, wenn `config/.env` fehlt, dann `composer install --no-dev`, `migrations migrate`, `cache clear_all`. PHP und Composer werden
automatisch erkannt (überschreibbar über `PHP_BIN`/`COMPOSER_BIN`).
- Benötigte Variablen/Secrets sind im Kopf der Workflow-Datei dokumentiert. Zugangsdaten nur als
Gitea-Secret, nie ins Repo.
## Abhängigkeiten (Renovate)
`.gitea/workflows/renovate.yml` startet alle zwei Stunden (cron `0 */2 * * *`, UTC) und manuell ([Actions → Renovate → Run workflow]) Renovate.
Es prüft Composer-Pakete (CakePHP-Version und Plugins), Docker-Basisimages und Actions in den Workflows und legt
PRs auf `renovate/*`-Branches an; dort läuft die normale CI, gemergt wird von Hand. Regeln in `renovate.json`:
CakePHP-Pakete in einem PR (auch das nächste Minor, da `5.4.*` gepinnt ist), Dev-Tools gebündelt, `composer.lock`-Pflege
montags, die PHP-Constraint wird nie automatisch angehoben. Außerdem pflegt Renovate das Issue „Dependency Dashboard“
mit allen offenen Updates. Das Secret `RENOVATE_TOKEN` (Gitea-Token mit `repository`, `issue`, `user`) liegt nur in den
Repo-Secrets, nie im Repo. Renovate ist per `RENOVATE_REPOSITORIES` auf dieses Repo beschränkt. Läuft unter dem Token-Besitzer
(PRs erscheinen unter dessen Namen, ohne Benachrichtigung für ihn); ein eigener Bot-Account lässt sich später durch Austausch
des Secrets einsetzen.
## Container (Docker)
**Container (Docker) – nur für Testzwecke, nicht für den Produktivbetrieb geeignet** (eingebauter PHP-Server, SQLite; das steht
auch in der README und in [deployment.md](deployment.md) und darf dort nicht als „empfohlen“ oder produktionstauglich erscheinen): `Dockerfile` (`php:8.5-cli-alpine`, Multi-Stage mit Composer) startet über
`docker/entrypoint.sh` den eingebauten Server (`bin/cake server -H 0.0.0.0 -p 8765`, `PHP_CLI_SERVER_WORKERS=8`,
sonst bedient er nur einen Request gleichzeitig). Code in `/app`, SQLite in Volume `/data`
(`DATABASE_URL=sqlite:////data/plenario.sqlite`), Konfiguration nur per Umgebungsvariablen (`config/.env.example`).
`SECURITY_SALT` ist Pflicht (Entrypoint bricht sonst ab; `composer install --no-scripts`, damit kein Salt eingebrannt wird).
Der Start ist idempotent (Migrationen + `cache clear_all`). Der Healthcheck prüft eine statische Datei, weil die Host-Prüfung
(`APP_FULL_BASE_URL`) `127.0.0.1` auf echten Seiten mit 400 ablehnt. Betrieb hinter einem TLS-Proxy mit `X-Forwarded-Proto`.
Beispiel: `docker-compose.yml`. Image und App-Paket entstehen nur bei Releases (siehe „Releases“).
## Releases (SemVer)
**Releases (SemVer):** `.gitea/workflows/release.yml` läuft nur bei Tags `vMAJOR.MINOR.PATCH[-suffix]` (kein Build bei normalen
Pushes). Job `test` (PHPUnit + phpcs) gatet `package` und `image`. `package` baut `plenario-<version>.tar.gz` (git archive des Tags,
`composer install --no-dev --no-scripts`, **ohne** `app_local.php` (nur `.env`), leere `tmp/`/`logs/`/`data/`, Datei `VERSION`; nur per Whitelist: bin, config, plugins, resources, src, templates, webroot, index.php, .htaccess, composer-Dateien;
kein tests/CI/Docker/README) + `SHA256SUMS` und hängt sie an das Gitea-Release (wird angelegt bzw. aktualisiert, Changelog = Commit-Betreffs
seit dem letzten Tag, Suffix = Pre-Release). `image` pusht `:<version>`, `:<major>.<minor>`, `:<major>` und `:latest` (die
beiden letzten nicht bei Pre-Releases bzw. `v0.`) in die Gitea-Registry (Variablen `DOCKER_REPO`, `IMAGE_NAME`, Secret `PAT`).
Wer das Paket ändert (z. B. weitere Dateien ausschließen), pflegt den Schritt „Build package“ in `release.yml`.
## Produktiv-Konfiguration
Produktiv auf dem Server in `config/.env`: `DEBUG=false`, `APP_FULL_BASE_URL`, `SECURITY_SALT`, SMTP
(`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD`, `SMTP_TLS` – einzelne Variablen statt URL; `EMAIL_TRANSPORT_DEFAULT_URL` geht weiter als Altlast).
Produktion kennt keine `app_local.php`: Paket und Docker-Image liefern sie nicht mit, `app.php` liest alles aus der Umgebung (Standard `DEBUG=false`). Eine `app_local.php` hätte Vorrang vor `.env` und überschreibt still einzelne Werte (z. B. den Mail-Transport); auf bestehenden Servern aus der Zeit vor diesem Stand löschen.
Document-Root zeigt idealerweise auf `webroot/`; liegt die App direkt im Document-Root (z. B. `public_html`),
leiten `.htaccess` + `index.php` im Projektroot alles nach `webroot/` weiter.
+13
View File
@@ -0,0 +1,13 @@
# PDF-Export
Ergebnisbericht der Umfrage als PDF.
- **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller
interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien
(`Slide::isPrivate()`) erscheinen nur mit Teilnehmerzahl. `?internal=1` = vollständige Fassung inkl.
anonymer Antworten, interner Skalen und Kommentar-Bewertungen (Dateiname `…-intern.pdf`, Hinweis „Vertraulich“ auf jeder
Seite); ohne private Folien wird der Parameter ignoriert. Quiz/Reihenfolge folgen auch hier den Auflöse-Regeln
(vor `finished` bzw. Schließen keine Zählungen/Lösung). Jede Folie beginnt auf einer neuen Seite (`.slide + .slide { page-break-before: always }`; die erste folgt dem Titelblock).
Layout `templates/layout/pdf.php` ist eigenständig: keine
externen Ressourcen, keine CSS-Variablen, Schrift DejaVu Sans; Seitenzahlen setzt `PdfView::addPageNumbers()`.
Tests prüfen das HTML über `PlenarioTestTrait::exportHtml()` (das PDF selbst ist nicht durchsuchbar).
+87
View File
@@ -0,0 +1,87 @@
# Präsentation, Steuerung und Einbettung
Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung und anonymes Feedback.
## Live-Updates
Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/state`) pollen per `fetch`
(`Plenario.pollIntervalMs`). Die Teilnehmerseite lädt neu, wenn sich `version` im State ändert.
## Referentenansicht
- Die Referentenansicht lädt **nie** den YouTube-Player (`renderMedia()` in `plenario.js` zeigt dort nur einen Hinweis),
damit das Video nicht doppelt zu hören ist.
- `/admin/{token}/speaker` (`admin:speaker`, Button ⧉ im Präsentationsmodus und Eintrag „Referentenansicht“ im Aufklappmenü (▾) von „Präsentieren“ in der Verwaltung, jeweils neues Fenster) ist für den eigenen Bildschirm des
Präsentierenden: gleiche Seite und gleiches JS wie `present` (`initPresenter`, Steuerung per Tasten/Buttons), plus
`data-next`-Kasten „Als Nächstes“ links neben der aktuellen Folie (`stage--speaker`). Anders als `present` startet sie die Präsentation nicht.
- Datenquelle ist `next` im Presenter-State (`PollStateService::nextPreview()`): Folie hinter der Live-Folie (ausgeblendete werden übersprungen),
bei Pause die pausierte, vor dem Start die erste, `null` nach der letzten. Nur Beschriftungen – nie `is_correct`, bei Reihenfolge keine Optionen
(die gespeicherte Reihenfolge ist die Lösung). Tests: `SpeakerViewTest.php`.
## Pause
- **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne
`paused_slide_id` = noch nicht gestartet. Immer über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` /
`forgetSlide()` setzen, nie `current_slide_id` direkt. Presenter: B (Break; P funktioniert weiterhin) bzw. der Pause-Button schaltet um (Aktionen `stop`/`resume`, beide idempotent, kein Server-Toggle),
←/→ setzt ebenfalls bei der pausierten Folie fort. Tasten zum Weiterschalten: →, ↓, Bild ab, Leertaste (vor) und ←, ↑, Bild auf (zurück); Presenter-Fernbedienungen senden oft ↑/↓.
Wird die Live- oder pausierte Folie gelöscht, pausiert die Umfrage und setzt mit der nachrückenden Folie fort
(`forgetSlide()`, keine FKs auf `current_slide_id`/`paused_slide_id`, sie dürfen nie auf gelöschte Folien zeigen).
## Ausgeblendete Folien
- **Ausgeblendete Folien** (`is_hidden`, `slides:visibility` mit `hidden=1|0`, explizit statt Toggle → idempotent):
bleiben in der Verwaltung (gestrichelt, Badge „ausgeblendet“), gehören aber nicht zur Präsentation. Präsentation =
`SlidesTable::listForPoll($pollId, true)`: Start, →/←, `goto` (400 für ausgeblendete), Zähler im Presenter-State
(`count` ohne, `hiddenCount` = ausgeblendete), PDF-Export (Nummerierung wie in der Präsentation). Einbettung einer
ausgeblendeten Folie geht nicht live (`isHidden` im Embed-State). Eine ausgeblendete Folie darf nie live/pausiert sein:
Ausblenden der Live- oder pausierten Folie pausiert wie Löschen (`forgetSlide()` + `SlidesTable::replacementFor()` =
nächste sichtbare Folie, sonst die vorige). `is_hidden` ist nicht mass-assignable. Tests: `HiddenSlideTest.php`.
## Zurücksetzen
- **Zurücksetzen** (`ResetService`) löscht **nur Antworten**: Folie (`slides:reset`) bzw. alle Folien der Umfrage
(`admin:reset`, Dashboard → „Sicherheit“). Jede Folie geht danach in den Zustand einer neuen Folie (`Slide::startFresh()`:
Quiz `ready`, Q&A `collect`, alle anderen offen – bei Reihenfolge bleibt die Lösung so verdeckt); Einstellungen bleiben. Das Zurücksetzen der
Umfrage setzt außerdem die Präsentation auf „nicht gestartet“ (`Poll::notStarted()`: weder live noch pausiert). Vorab eingetragene Q&A-Fragen bleiben standardmäßig erhalten (nur ihre Upvotes gehen weg):
Folien-Reset behält sie immer, der Umfrage-Reset hat die Checkbox `keep_prepared` (nur sichtbar, wenn es welche gibt).
Die Reset-Buttons (Dashboard, ↺ je Folie) erscheinen nicht nur bei Antworten, sondern auch, wenn eine Folie vom Ausgangszustand abweicht
(`Slide::isFresh()`: Quiz gestartet, Folie geschlossen, Q&A-Phase) oder die Präsentation läuft/pausiert (`Poll::isStarted()`).
Idempotent, in einer Transaktion. Tests: `PollResetTest.php`.
## Duplizieren
- **Duplizieren** (`slides:duplicate`, POST): kopiert Fragetext (+ „(Kopie)“), Beschreibung, Einstellungen und Optionen
inkl. `is_correct`, **nie Antworten**. Die Kopie landet direkt hinter dem Original und startet wie eine neue Folie
(`Slide::startFresh()`: Quiz `ready`, Q&A `collect`, sonst offen) – auch `add()` nutzt `startFresh()`.
Tests: `DuplicateSlideTest.php`.
## Ganze Umfrage kopieren
- **Umfrage kopieren** (`admin:clone`, POST, Abschnitt unter „Einstellungen“ in der Verwaltung; `PollsTable::clonePoll()` + `SlidesTable::copyAllToPoll()`):
neue Umfrage „… (Kopie)“ mit gleicher E-Mail, `comment_speed`, allen Folien (Einstellungen, Optionen inkl. richtiger Antworten,
Ausblenden-Flag, Bilder als eigene Dateien) – **ohne Antworten**, nicht gestartet, mit neuem Code und neuem Admin-Link.
Der Link geht wie beim Anlegen per Mail an den Besitzer, danach Weiterleitung zur Verwaltung der Kopie. Alles in einer Transaktion,
bei Fehlern werden kopierte Bilddateien wieder gelöscht. Nutzt das Throttle-Bucket `create`.
## Einbettung
- **Einbettung** (`/e/{key}/{id}`, `EmbedController`): eigener `embed_key` statt Admin-Token (darf nur diese Folie zeigen,
live schalten, pausieren und `SlideControlService`-Aktionen), wird beim ersten Dashboard-Aufruf erzeugt
(`ensureEmbedKey`, idempotent) und lässt sich neu erzeugen. Die Seite schaltet sich live, solange sie sichtbar ist
(IntersectionObserver + `visibilitychange`), sendet Heartbeats und beim Verschwinden `pause` (sendBeacon).
`pause` wirkt nur, wenn die eigene Folie noch live ist; `heartbeat` holt keine Folie zurück, die im Presenter
gewechselt wurde. Bleiben Heartbeats aus (`Plenario.embed.timeoutSeconds`), pausiert `PollsTable::pauseIfEmbedStale()`
beim nächsten State-Abruf. Embed-Routen haben **keinen CSRF-Check** (Third-Party-Iframe ohne Cookies, der Schlüssel
ist die Berechtigung, siehe `Application::middleware()`) und erlauben Framing per CSP `frame-ancestors`
(`EMBED_FRAME_ANCESTORS`); alle anderen Seiten bleiben `X-Frame-Options: SAMEORIGIN`. Beides entscheidet
`SecurityHeadersMiddleware::isEmbed()` anhand des Pfads (auch für Fehlerseiten).
## Anonymes / internes Feedback
- **Anonymes / internes Feedback** (offene Frage bzw. Skala mit Setting `private`, `Slide::isPrivate()`): steuert den
Schalter „Ergebnisse verbergen“ (H) im Presenter/Embed. Das JSON enthält die vollständigen Ergebnisse plus
`results.private = true`; `initPresenter` verbirgt sie beim Wechsel auf eine solche Folie und zeigt stattdessen nur die
Anzahl (`Results.privateSummary`). Einblenden gilt nur für diese Folie, die globale Wahl für normale Folien (`hideAll`)
bleibt unberührt. Teilnehmende bekommen (wie bei allen Abstimmungsfolien) keine `results`. Die Fassung des PDF-Exports ohne interne Inhalte entfernt sie per
`ResultsService::withoutContents()`. Volle Ansicht in der Verwaltung (`slides:answers` → „Auswertung“).
+182
View File
@@ -0,0 +1,182 @@
# Folientypen
Details zu den einzelnen Folientypen. Übersicht und zentrale Regeln stehen in [AGENTS.md](../AGENTS.md).
**Abstimmung offen/geschlossen:** `slides.is_voting_open` ist Laufzeitzustand der Präsentation und im Folienformular
nicht editierbar (`SlidesController::saveSlide()` übernimmt das Feld nie). Neue Folien starten offen (Quiz geschlossen),
geändert wird es nur über die Presenter-Steuerung (`SlideControlService`) bzw. `QaService`; der Reset stellt es zurück.
## Wortwolke
- Ausnahme Wortwolke: Begriffe werden einzeln abgegeben (AJAX, `vote` liefert dann JSON `{ok, message, state}`),
jeder Begriff einmal pro Person, beliebig viele Begriffe. Einen vorhandenen Begriff erneut nennen
bzw. in der Wolke anklicken = Upvote (gleiche Zeile in `responses`). Mit `allow_upvotes` sehen Teilnehmende
die Wolke live; Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`).
Teilnehmende sehen sie als kompakte Liste (`Results.wordList()`: feste Schriftgröße, Gewichtsbalken, große „+“/„−“-Buttons, wie beim Q&A-Voting),
die Bühne als Wolke, deren Schrift mit der Wortzahl kleiner wird (`--cloud-scale`).
Downvotes (`vote=down`, Setting `allow_downvotes`, nur zusammen mit Upvotes): Zeile mit `numeric_value = VoteService::DOWNVOTE` (-1),
nur auf fremde, vorhandene Begriffe, ein Rating pro Begriff und Person.
Wortgröße richtet sich nur nach den Upvotes (`count`), Downvotes stehen separat in `down`.
Darstellung: Die Bühne zeigt die Wolke (`Results.wordcloud`); die Schriftgröße wird über `--cloud-scale` mit der Wortanzahl
kleiner, damit viele Begriffe nicht überlaufen. Teilnehmende sehen mit Upvotes stattdessen eine Liste
(`Results.wordList`, Klassen `wc-*`) mit „+“/„−“-Buttons und Gewichtsbalken, ähnlich dem Q&A-Voting.
`vote=remove` nimmt den eigenen Eintrag zu einem Begriff zurück (genannt/Upvote oder Downvote, `VoteService::removeWord()`,
löscht nur Zeilen mit dem eigenen `participant_hash`); Tippfehler = entfernen und neu eingeben, kein Bearbeiten (die Zeile
ist zugleich die Stimme). Teilnehmende bekommen dafür `words.own` (eigene Begriffe wie eingegeben) und sehen sie als Chips mit „ד.
## Quiz
- Quiz: Phasen `ready` → `running` → `finished` (`Slide::quizPhase()`). Neue Quiz-Folien starten geschlossen;
erst der Presenter startet (`control` open/toggle → `Slide::setVotingOpen()` setzt Start + Deadline aus
`time_limit`, erneutes Öffnen eines laufenden Quiz startet den Timer nicht neu). „Offen“ heißt immer
`Slide::isVotingOpen()` (inkl. Deadline), nicht nur `is_voting_open`. Abgelaufene Quizze schließt
`SlidesTable::closeIfExpired()` beim State-Abruf. **Zählungen und `is_correct` dürfen vor `finished` nie im
JSON/HTML landen** (weder Presenter noch Teilnehmende); danach sehen Teilnehmende die Lösung und ob sie
richtig lagen (ohne Verteilung). Zurücksetzen setzt das Quiz wieder auf `ready`.
- **Quiz-Musik:** je **Präsentation** (nicht je Folie) eine Audiodatei (`polls.audio`), hochgeladen im Menü unter „Einstellungen →
Musik zum Quiz-Countdown“ (gilt für alle Countdowns) (`Admin::audio`, Route `admin:audio`; Entfernen = Feld `remove`; Dropzone wie bei Folienbildern, nur kompakter: `initAudioForm()` sendet die Datei sofort nach Auswahl/Drop, ohne JavaScript der Button „Hochladen“). Gespeichert wird die Datei unverändert
(`AudioService`: Format nur an den ersten Bytes erkannt – MP3, M4A, OGG, WAV –, Zufallsname mit fester Endung, Obergrenze
`Plenario.audio.maxUploadBytes`) im Upload-Verzeichnis der Umfrage, ausgeliefert über `participate:audio` (`/p/{code}/audio/{file}`,
nur die Datei dieser Umfrage, feste Content-Type, Range-Anfragen). Im State steht `poll.audioUrl`. Abgespielt wird nur in der
Referentenansicht/Einbettung (`StageAudio` in `plenario.js`): als Schleife, solange irgendeine Folie mit Countdown (Quiz oder Zeitlimit) `running` ist, Stopp bei
Ende/Folienwechsel/Pause. Teilnehmende hören nichts. Blockiert der Browser den Start (keine Nutzeraktion), wird er beim
nächsten Klick/Tastendruck wiederholt. „Umfrage kopieren“ kopiert die Datei, Löschen der Umfrage und `images_cleanup` räumen sie mit auf.
**Klicker/Presenter-Stick** (sendet nur →/← bzw. Bild↑/↓): `AdminController::control` behandelt `next` auf einem Quiz als
Schritt – `ready` → starten, `running` → beenden (Lösung), erst `finished` → nächste Folie. `prev` geht immer zur vorigen Folie
und startet nie ein Quiz. Tests: `QuizClickerTest.php`.
## Countdown für alle Folien mit Antworten
- Jede Folie, auf der geantwortet wird, außer Q&A (`Slide::supportsTimer()`: Auswahl, Wortwolke, offene Frage, Skala, Reihenfolge, Quiz),
hat die Einstellung `time_limit` (Sekunden, `Slide::TIME_LIMITS`, **0 = kein Countdown**, Standard bei allen außer dem Quiz).
Formularfeld: `element/slide_time_limit`; das Quiz behält sein eigenes Feld (dort heißt 0 „ich beende selbst“).
- Mit Countdown (`Slide::usesPhases()`, beim Quiz immer) durchläuft die Folie dieselben **Phasen wie das Quiz**: `ready` → `running` →
`finished` (`Slide::phase()`, `null` ohne Countdown). `startFresh()` lässt sie geschlossen starten (`ready`), `setVotingOpen(true)`
startet das Zeitfenster (Start + Deadline), `SlidesTable::closeIfExpired()` schließt nach Ablauf. Nach dem Speichern im Formular wird eine
noch nicht gezeigte Folie neu initialisiert (`startFresh()`), damit eine geänderte Zeit sofort wirkt.
- Ablauf im Presenter (`AdminController::control()`): „Weiter“ startet den Countdown (`ready` → `running`), das nächste „Weiter“ beendet
ihn vorzeitig, erst das dritte geht zur nächsten Folie (wie beim Quiz; „Zurück“ rührt ihn nie an). **V** schaltet ebenso (erneutes
Öffnen startet den Countdown neu). Ohne Countdown wechselt das erste „Weiter“ direkt zur nächsten Folie.
- **`ready` zeigt nur die Frage:** `ResultsService::forStage()` (Presenter/Einbettung) liefert dann nur `{ready: true, timer}`, nie
Antworten, Zählungen oder Lösung; die Auswertung/PDF nutzt weiter `forSlide()` (ungegatet). `Slide::isOrderRevealed()` ist in `ready`
falsch, sonst würde die Reihenfolge-Lösung vor dem Start verraten. Teilnehmende sehen „Die Abstimmung startet gleich“ und können nicht
abstimmen (`VoteService`: „… noch nicht begonnen“). Private Folien zeigen wie sonst nur die Anzahl.
- State: `results.timer` = `{phase, timeLimit, remaining}` (Presenter/Einbettung, auch beim Quiz), `timer` im Teilnehmer-State (nicht beim
Quiz, der hat `quiz`). Die Bühne zeigt den Countdown unter der Frage (`[data-stage-timer]`, beim Quiz im Ergebnis); die Musik
(`poll.audioUrl`) läuft bei jeder laufenden Phase. Tests: `TimedSlideTest.php`, `QuizClickerTest.php`.
## Fragen & Antworten (Q&A)
- Q&A-Folie (`qa`, „Fragen & Antworten“): Phasen `collect` → `vote` → `discuss` (`Slide::qaStage()`, `QaService`),
der Presenter schaltet manuell weiter (V bzw. Stepper, auch zurück). `collect`: Fragen einreichen (max.
`VoteService::MAX_QA_QUESTIONS` pro Person, gleiche Frage nur einmal pro Folie), Teilnehmende sehen alle bisherigen Fragen
(gegen Dubletten, eigene markiert), aber noch keine Upvotes.
`vote`: Upvotes auf fremde Fragen, Budget pro Person = Anteil der Fragen (Setting `upvote_share` in Prozent, `Slide::QA_UPVOTE_SHARES`, aufgerundet, mindestens 1:
`Slide::qaBudget(Anzahl Fragen)`; im State/JSON `maxUpvotes`), wächst also mit der Fragenzahl, frei verteilbar (auch mehrere auf eine Frage,
je Upvote eine Zeile), `vote=remove` nimmt eine Stimme der Frage zurück; im State `qa.upvoted` = {Frage-id: eigene Stimmen}.
Setting `max_upvotes_per_question` begrenzt die eigenen Stimmen je Frage (0 = nur durch das Budget begrenzt,
effektiv `Slide::qaUpvotesPerQuestion($budget)`, State `maxPerQuestion`). `upvote_share = 0` = ohne Upvotes: es gibt keine Phase `vote`
(`Slide::qaStages()` = collect → discuss, im Presenter-JSON `results.stages`), besprochen wird in Eingangsreihenfolge;
wird es während `vote` auf 0 gesetzt, springt `SlidesController::saveSlide()` nach `discuss`.
Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget
(State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt;
Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung; die Bühne (Presenter/Embed) zeigt in `vote` keine Fragen,
sondern nur den Hinweis „Schau auf dein Gerät und stimme ab“ mit Fragenzahl, Budget und vergebener Gesamtsumme (`Results.qa`); auch sonst gibt es dort
keine Zählungen je Frage und keine Rangfolge (`ResultsService::qa()`, nur die Summe `upvotes`), damit niemand beeinflusst wird. `discuss`: Abstimmung zu, Fragen nach Upvotes
sortiert (Gleichstand: älteste zuerst), `focus_response_id` = aktuelle Frage. „Weiter“ (next, →/Klicker) geht
zuerst durch die Phasen (`collect` → `vote` → `discuss`, `QaService::advance()`), dann durch die Fragen, erst danach zur nächsten Folie;
„Zurück“ blättert nur in `discuss` durch die Fragen. Fokuswechsel per `updateAll` ohne `modified`,
damit Teilnehmerseiten nicht neu laden. Teilnehmende bekommen nie `results`, sondern `qa` aus `PollStateService::qaState()`.
Zurücksetzen startet wieder bei `collect`.
**Vorab eingereichte Fragen** (z. B. per Mail): Textarea `prepared_text` im Folienformular (eine Frage pro Zeile, höchstens
`QaService::MAX_PREPARED`), nur in `collect` sichtbar/änderbar. `QaService::syncPrepared()` gleicht sie idempotent ab (gleiche Texte
behalten ihre id, entfernte verschwinden samt Upvotes, von Teilnehmenden schon gestellte werden nicht doppelt angelegt). Gespeichert
als normale Fragen mit `participant_hash = VoteService::PREPARED_HASH` (kein gültiger HMAC → niemand kann sie bearbeiten/löschen,
jeder darf sie unterstützen); sie zählen nicht als Teilnehmende. Zurücksetzen behält sie (außer die Checkbox beim Umfrage-Reset ist abgewählt), Duplizieren kopiert sie nicht.
Tests: `QaPreparedTest.php`.
Eigene Fragen bearbeiten/löschen (`vote=edit|delete` + `question_id`, `VoteService::editQuestion()`) nur in `collect`:
danach könnten Upvotes bzw. die Besprechung an einem anderen Text hängen. Bearbeiten prüft Dubletten ohne die eigene Frage,
Löschen entfernt auch übrig gebliebene Upvotes (Presenter von `vote` zurück nach `collect`). Im JS hält `qaEditing` das
Neu-Rendern beim Polling an, solange eine Frage bearbeitet wird.
## YouTube
- YouTube-Folie (`youtube`): nicht interaktiv (wie `content`). Settings `url` (wie eingegeben), `video_id`, `start` (Sekunden),
`autoplay`. Startzeit-Feld leer = Timecode aus dem Link (`t`/`start`), sonst gewinnt das Feld (`1:30`, `2` = Minuten).
Beim Speichern prüft `SlidesController::prepareYouTube()` per oEmbed: nicht gefunden/nicht einbettbar = Fehler,
YouTube nicht erreichbar = speichern mit Warnung; leerer Titel wird mit dem Videotitel gefüllt. Eingebettet wird nur
im Presenter (`youtube-nocookie.com`), Teilnehmende sehen Link + Teilen-Button (Web Share API, sonst Kopieren).
Iframes brauchen `referrerpolicy="strict-origin"`, weil Admin-Seiten `no-referrer` senden und YouTube ohne Referrer
nicht abspielt (nur Origin, nie der Pfad mit Token). Tests mocken YouTube über `HttpClientTrait` (`mockClientGet`).
## Reihenfolge
- Reihenfolge-Folie (`order`): Admin legt die Einträge in der richtigen Reihenfolge an (Formular `order_options[]`, Zeilen
per Drag & Drop/Pfeiltasten sortierbar, ids bleiben beim Umsortieren erhalten). Teilnehmende bekommen sie per
`Slide::shuffledOptions(participantHash)` gemischt (stabil, nie schon richtig), sortieren und senden `order[]` (alle ids genau einmal),
einmal pro Person. Startet offen wie normale Folien; **aufgelöst wird beim Schließen der Abstimmung** (`Slide::isOrderRevealed()`).
„Weiter“ (→/Leertaste) schließt eine noch offene Reihenfolge-Folie zuerst (Auflösung) und wechselt erst beim nächsten Druck.
Vorher landen weder richtige Reihenfolge noch Zählungen im JSON (Presenter sieht die Einträge gemischt mit Seed `slide:{id}`);
danach sieht der Presenter die Lösung inkl. „X von N komplett richtig“ und je Eintrag, wie oft er an der richtigen Stelle lag;
Teilnehmende nur die Lösung mit eigenen Platzierungen und `order.isCorrect`. Tests: `OrderTest.php`, `OrderSlideTest.php`.
- **Eigene Einschätzung** (Setting `ranking`, `Slide::isRanking()`): keine richtige Lösung (Checkbox „Keine richtige Reihenfolge …“, z. B. nach Wichtigkeit).
Gespeichert wird wie sonst (`order[]`), die Reihenfolge der Einträge im Editor zählt nicht. `isOrderRevealed()` ist dann nie wahr:
Teilnehmende bekommen weder `results` noch Urteil (`order.ranking` steuert die Texte), nur die Bestätigung. Der Presenter sieht live
(auch bei offener Abstimmung, es gibt nichts zu verbergen) `ResultsService::ranking()`: Einträge nach durchschnittlichem Platz
(`average`, `score` 0–100 für den Balken, `position`); ohne Antworten gemischt. Export/Admin-Liste haben eigene Zweige.
## Skala, Sterne und Kommentare
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value`
in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State
`results.comments` (Teilnehmende bekommen sie nie: Skalen liefern ihnen grundsätzlich keine `results`, siehe `PollStateService::forParticipant()`)
(älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch (Anzeigedauer nach Textlänge, kein Setting pro Folie:
`Comments.delay()` = 2,5 s + 15 Zeichen/s, 5–30 s, geteilt durch das Tempo der Umfrage `polls.comment_speed` (Prozent aus
`Poll::COMMENT_SPEEDS`, im State `poll.commentSpeed` als Faktor, Dashboard → „Einstellungen“); Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „Kommentar X von N“,
vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem
`animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling; die Box ist so hoch wie der längste Kommentar – alle liegen unsichtbar in derselben Grid-Zelle –, damit die zentrierte Bühne beim Wechsel nicht springt; höchstens `--comment-max` ≈ 5 Zeilen, längere Kommentare setzt `Comments.fit()` kleiner statt sie abzuschneiden; die Bewertung steht über dem Text, damit sie an fester Stelle bleibt; der Fortschritt läuft als Rahmen der Box: `Comments.progressBorder()`, SVG-Rechteck mit `pathLength` 100, zwei Linien ab gegenüberliegenden Ecken). Bei internem Feedback erscheinen sie erst,
wenn der Presenter die Ergebnisse einblendet.
- **Kommentare bei Multiple Choice** (Setting `comments`, gleiches `Slide::hasComments()` wie bei Skalen): optionales Feld `comment`,
gespeichert als `text_value` **nur in der ersten Zeile** der Person (bei Mehrfachauswahl gibt es mehrere Zeilen; Zählungen
gruppieren nach `slide_option_id` und ignorieren `text_value`). Bearbeiten/Anlegen/Leeren wie bei Skalen über `participate:edit`
(`editText()` und `ownText()` lesen die Zeile mit der kleinsten id). Presenter/Embed bekommen `results.comments` (`value` immer
`null`, keine Zuordnung zur Option), `Results.choice` zeigt sie mit `Comments` unter den Balken; Teilnehmende nie.
Volle Liste: `slides:answers` („Kommentare“), PDF-Export unter der Tabelle. Tests: `ChoiceCommentsTest.php`.
- **Sterne-Bewertung** (Skala mit Setting `style = stars`, `Slide::isStarRating()`, Standard `numbers`): immer 1 bis `scale_max`
Sterne (`SlidesTable::sanitizeSettings()` erzwingt `scale_min = 1`), gespeichert wie jede Skala als `numeric_value`.
Teilnehmende wählen Sterne (Radios in DOM-Reihenfolge 1..n, Füllung per CSS `:has()`), der State enthält `results.stars`;
`Results.stars` in `plenario.js` zeigt den Durchschnitt als teilweise gefüllte Sterne und die Verteilung als Donut 5 → 1.
Text-Ausgabe (Auswertung, PDF) über `Slide::ratingText()` (`★★★★☆`), barrierearm über `element/rating`.
- **Skala-Darstellung auf der Bühne:** Durchschnitt (große Zahl + Skala bzw. Sterne) und Verteilung (Donut per CSS
`conic-gradient`, je Wert eine eigene Farbe aus `--c0…--c5` in fester Reihenfolge, bei mehr Werten gemischt; Legende mit „% (Anzahl)“ und den Beschriftungen der Enden) nebeneinander
(`Results.scaleLayout()` / `Results.donut()`). Setting `scale_view` (`Slide::SCALE_VIEWS`: `both` | `average` | `chart`,
Dropdown im Formular) zeigt nur einen Teil, dann zentriert; im JSON `results.view`, die Daten bleiben vollständig.
Gilt nur für Presenter/Embed, Auswertung und PDF zeigen immer beides.
- **Nur Kommentar ohne Bewertung/Auswahl** (Skala/Sterne und Auswahlfolien, Setting `comment_only` zusätzlich zu `comments`, `Slide::hasCommentOnly()`; im Formular ein Dropdown
`comment_mode`: kein Kommentarfeld | Kommentar optional, Bewertung Pflicht | auch Kommentar ohne Bewertung genügt, `SlidesTable::sanitizeSettings()` übersetzt es in
`comments`/`comment_only`): die Bewertung ist dann nicht mehr Pflicht (die Radios sind nicht `required`), ein nicht leerer Kommentar genügt. `VoteService::scaleRows()` speichert eine Zeile **ohne** `numeric_value`: zählt als Teilnahme (einmal pro Person),
geht aber nicht in Verteilung und Durchschnitt ein. Weder Bewertung noch Kommentar = Fehler, es gibt keinen leeren „Überspringen“-Knopf.
`ResultsService::scaleResults()` liefert die Zahl als `commentOnly` (Bühne: „· N× nur Kommentar“, Auswertung, PDF; private Folien strippen sie
mit `withoutContents()`). Der Kommentar läuft wie die anderen durch, `value` ist `null` (mit `comment_ratings` zeigt die Bühne „Ohne Bewertung“, damit
die Box gleich hoch bleibt). Nachträglich bearbeiten geht, aber der Kommentar darf dann nicht leer werden (`editText()`).
**Auswahlfolien** (Mehrfachauswahl wie Einzelauswahl) verhalten sich genauso: Zeile ohne `slide_option_id` (`ResultsService::choice()` zählt sie nur als `commentOnly`, nicht in Stimmen/Prozenten); `commentSettings()` in `SlidesTable` ist für beide Typen gleich. Tests: `VoteServiceTest`, `ParticipateControllerTest`.
- **Enthaltung bei Auswahlfolien:** kein eigenes Feature, sondern eine normale Option (zählt in Prozenten mit, wie bei Vereinsabstimmungen üblich).
Im Folienformular fügt der Button „Option ‚Enthaltung‘ hinzufügen“ (`data-add-option`, `initAddOption()` in `plenario.js`, idempotent, nur mit JS sichtbar) die Zeile ein.
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
`submit()`, in der Folien-Sperre, legt nie eine neue Antwort an.
## Neuen Folientyp hinzufügen (Checkliste)
0. Bilder: `Slide::supportsImage()` entscheidet, ob der Typ ein Bild tragen kann (Standard ja).
1. Konstante + Label + Beschreibung + `DEFAULT_SETTINGS` in `src/Model/Entity/Slide.php`
2. Settings-Sanitizing in `SlidesTable::sanitizeSettings()`
3. Validierung/Speicherung in `VoteService::submit()` (eigene `…Rows()`-Methode)
4. Aggregation in `ResultsService::forSlide()` + Docblock der JSON-Struktur
5. Formularfelder in `templates/Slides/form.php`, Eingabe in `templates/Participate/view.php`
6. Renderer in `webroot/js/plenario.js` (`Results.<type>`), Styles in `plenario.css`, Badge-Farbe;
Ausgabe im PDF-Export (`templates/Admin/export.php`)
7. Tests in `tests/TestCase/Service/VoteServiceTest.php` (Quiz: `QuizTest.php`, Q&A: `QaTest.php`)
8. Nach neuen Spalten lokal `bin/cake cache clear_all`, sonst nutzt das ORM das alte Schema aus dem Cache
+32
View File
@@ -0,0 +1,32 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"timezone": "Europe/Berlin",
"labels": ["dependencies"],
"prConcurrentLimit": 5,
"lockFileMaintenance": {
"enabled": true,
"schedule": ["before 6am on monday"]
},
"packageRules": [
{
"description": "CakePHP core and its official plugins in one PR (also proposes the next minor, e.g. 5.4.* -> 5.5.*)",
"matchPackageNames": ["cakephp/**"],
"groupName": "CakePHP",
"rangeStrategy": "replace"
},
{
"description": "Dev tools (phpunit, phpcs, bake, debug_kit) as one PR",
"matchDepTypes": ["require-dev"],
"groupName": "dev dependencies",
"matchPackageNames": [
"!cakephp/**"
]
},
{
"description": "Keep the PHP constraint in step with the CI matrix; never bump it automatically",
"matchPackageNames": ["php"],
"enabled": false
}
]
}
+152
View File
@@ -0,0 +1,152 @@
<?php
// Generates webroot/favicon.svg, favicon.ico, apple-touch-icon.png and resources/mail/logo.png (needs ext-gd). Run after a logo change:
// php resources/favicon/generate.php webroot
// Mirrors .brand__mark in webroot/css/plenario.css:
// rounded square (radius 6/22), conic gradient 40/25/20/15 % from 12 o'clock, clockwise.
declare(strict_types=1);
$out = rtrim($argv[1] ?? 'webroot', '/\\');
$colors = ['#4b3fe0', '#e0457b', '#12a08a', '#f29a1f'];
$stops = [0.40, 0.65, 0.85, 1.00];
$radiusRatio = 6 / 22;
// ---- SVG ---------------------------------------------------------------------------------
$size = 32;
$c = $size / 2;
$R = 24; // larger than the corner distance, the clip path trims it
$point = function (float $fraction) use ($c, $R): array {
$a = deg2rad($fraction * 360);
return [round($c + $R * sin($a), 3), round($c - $R * cos($a), 3)];
};
$paths = '';
$prev = 0.0;
foreach ($stops as $i => $stop) {
[$x1, $y1] = $point($prev);
[$x2, $y2] = $point($stop);
$large = ($stop - $prev) > 0.5 ? 1 : 0;
$paths .= sprintf(
" <path fill=\"%s\" d=\"M%d %d L%s %s A%d %d 0 %d 1 %s %s Z\"/>\n",
$colors[$i],
$c,
$c,
$x1,
$y1,
$R,
$R,
$large,
$x2,
$y2,
);
$prev = $stop;
}
$rx = round($size * $radiusRatio, 2);
$svg = <<<SVG
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {$size} {$size}" width="{$size}" height="{$size}">
<title>PlenarIO</title>
<clipPath id="r"><rect width="{$size}" height="{$size}" rx="{$rx}"/></clipPath>
<g clip-path="url(#r)">
{$paths} </g>
</svg>
SVG;
file_put_contents($out . '/favicon.svg', $svg);
// ---- PNG / ICO (GD, 4x4 supersampling) ---------------------------------------------------
$rgb = fn(string $hex): array => [hexdec(substr($hex, 1, 2)), hexdec(substr($hex, 3, 2)), hexdec(substr($hex, 5, 2))];
$palette = array_map($rgb, $colors);
$render = function (int $n, float $padding = 0.0) use ($stops, $palette, $radiusRatio): string {
$img = imagecreatetruecolor($n, $n);
imagealphablending($img, false);
imagesavealpha($img, true);
$ss = 4;
$inner = $n * (1 - 2 * $padding);
$r = $inner * $radiusRatio;
$offset = $n * $padding;
for ($y = 0; $y < $n; $y++) {
for ($x = 0; $x < $n; $x++) {
$sum = [0.0, 0.0, 0.0];
$cover = 0;
for ($sy = 0; $sy < $ss; $sy++) {
for ($sx = 0; $sx < $ss; $sx++) {
$px = $x + ($sx + 0.5) / $ss - $offset;
$py = $y + ($sy + 0.5) / $ss - $offset;
if ($px < 0 || $py < 0 || $px > $inner || $py > $inner) {
continue;
}
// rounded corners
$cx = min(max($px, $r), $inner - $r);
$cy = min(max($py, $r), $inner - $r);
if (($px - $cx) ** 2 + ($py - $cy) ** 2 > $r ** 2) {
continue;
}
$angle = atan2($px - $inner / 2, -($py - $inner / 2)); // 0 = top, clockwise
$f = fmod($angle / (2 * M_PI) + 1, 1);
$k = 0;
while ($k < 3 && $f >= $stops[$k]) {
$k++;
}
foreach ($palette[$k] as $j => $v) {
$sum[$j] += $v;
}
$cover++;
}
}
$total = $ss * $ss;
if ($cover === 0) {
$col = imagecolorallocatealpha($img, 0, 0, 0, 127);
} else {
$col = imagecolorallocatealpha(
$img,
(int)round($sum[0] / $cover),
(int)round($sum[1] / $cover),
(int)round($sum[2] / $cover),
(int)round(127 * (1 - $cover / $total)),
);
}
imagesetpixel($img, $x, $y, $col);
}
}
ob_start();
imagepng($img, null, 9);
$png = (string)ob_get_clean();
return $png;
};
// favicon.ico with 16, 32 and 48 px (PNG compressed entries)
$sizes = [16, 32, 48];
$images = array_map(fn(int $n): string => $render($n), $sizes);
$ico = pack('vvv', 0, 1, count($sizes));
$offset = 6 + 16 * count($sizes);
foreach ($sizes as $i => $n) {
$ico .= pack('CCCCvvVV', $n, $n, 0, 0, 1, 32, strlen($images[$i]), $offset);
$offset += strlen($images[$i]);
}
file_put_contents($out . '/favicon.ico', $ico . implode('', $images));
// Logo for e-mails (resources/mail/logo.png, attached inline by PollMailer): mail clients show no SVG.
// 96 px, displayed at 32 px for sharp edges on high-DPI screens.
$mailDir = dirname(__DIR__) . '/mail';
if (!is_dir($mailDir)) {
mkdir($mailDir, 0775, true);
}
file_put_contents($mailDir . '/logo.png', $render(96));
// iOS ignores transparency (fills black) and rounds the corners itself: opaque full-bleed square.
$apple = imagecreatetruecolor(180, 180);
$stopsPx = $stops;
for ($y = 0; $y < 180; $y++) {
for ($x = 0; $x < 180; $x++) {
$angle = atan2($x + 0.5 - 90, -($y + 0.5 - 90));
$f = fmod($angle / (2 * M_PI) + 1, 1);
$k = 0;
while ($k < 3 && $f >= $stopsPx[$k]) {
$k++;
}
imagesetpixel($apple, $x, $y, imagecolorallocate($apple, ...$palette[$k]));
}
}
imagepng($apple, $out . '/apple-touch-icon.png', 9);
echo "ok\n";
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+81
View File
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Service\ImageService;
use Cake\Command\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
/**
* Removes image files that no slide refers to any more (aborted uploads, crashes while deleting).
* Idempotent, safe to run at any time, e.g. from cron.
*
* Usage: bin/cake images_cleanup [--dry-run]
*/
class ImagesCleanupCommand extends Command
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'images_cleanup';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Löscht Bild- und Audiodateien, die zu keiner Folie mehr gehören.'))
->addOption('dry-run', [
'help' => __('Nur anzeigen, nichts löschen.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
/** @var \App\Model\Table\SlidesTable $slides */
$slides = $this->fetchTable('Slides');
$referenced = [];
$rows = $slides->find()
->select(['poll_id', 'image'])
->where(['image IS NOT' => null])
->disableHydration()
->all();
foreach ($rows as $row) {
$referenced[(int)$row['poll_id']][] = (string)$row['image'];
}
// The countdown audio of a poll shares the upload directory with its images.
$audio = $this->fetchTable('Polls')->find()
->select(['id', 'audio'])
->where(['audio IS NOT' => null])
->disableHydration()
->all();
foreach ($audio as $row) {
$referenced[(int)$row['id']][] = (string)$row['audio'];
}
$dryRun = (bool)$args->getOption('dry-run');
$removed = (new ImageService())->cleanup($referenced, $dryRun);
foreach ($removed as $path) {
$io->out(($dryRun ? __('Verwaist: {0}', $path) : __('Gelöscht: {0}', $path)));
}
$io->success($dryRun
? __('{0} verwaiste Datei(en) gefunden (nichts gelöscht).', count($removed))
: __('{0} verwaiste Datei(en) entfernt.', count($removed)));
return static::CODE_SUCCESS;
}
}
+79
View File
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Core\Configure;
/**
* Sends the reminders (`polls remind`), then deletes expired polls (POLL_RETENTION_DAYS after creation,
* see Poll::expiresAt()). Idempotent, made for cron:
*
* 17 3 * * * cd /path/to/plenario && php bin/cake.php polls cleanup --quiet
*
* Usage: bin/cake polls cleanup [--dry-run]
*/
class PollsCleanupCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls cleanup';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Der Cronjob: erinnert Besitzer bald ablaufender Umfragen, löscht abgelaufene und danach verwaiste Bilddateien.'))
->addOption('dry-run', [
'help' => __('Nur anzeigen, nichts löschen.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
if ((int)Configure::read('Plenario.retention.days', 90) <= 0) {
$io->out(__('Umfragen laufen nie ab (POLL_RETENTION_DAYS=0), nichts zu tun.'));
return static::CODE_SUCCESS;
}
// Reminder first, so owners hear about it before the deletion (idempotent: once per poll).
$remind = $this->executeCommand(PollsRemindCommand::class, $args->getOption('dry-run') ? ['--dry-run'] : [], $io);
/** @var list<\App\Model\Entity\Poll> $expired */
$expired = $this->polls()->find('expired')->orderBy(['Polls.id' => 'ASC'])->all()->toList();
if ($args->getOption('dry-run')) {
foreach ($expired as $poll) {
$io->out(__('Abgelaufen: #{0} {1} ({2}), seit {3}', $poll->id, $poll->title, $poll->email, $this->formatDate($poll->expiresAt())));
}
$io->success(__('{0} abgelaufene Umfrage(n) gefunden (nichts gelöscht).', count($expired)));
return static::CODE_SUCCESS;
}
$deleted = $this->deletePolls($expired, $io);
$io->success(__('{0} abgelaufene Umfrage(n) gelöscht.', $deleted));
// Sweep image files a crash may have left behind (cheap, idempotent).
$this->executeCommand(ImagesCleanupCommand::class, [], $io);
return $deleted === count($expired) && $remind === static::CODE_SUCCESS ? static::CODE_SUCCESS : static::CODE_ERROR;
}
}
+156
View File
@@ -0,0 +1,156 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Model\Entity\Poll;
use App\Model\Table\PollsTable;
use Cake\Command\Command;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOutput;
use Cake\I18n\DateTime;
use Cake\Routing\Router;
/**
* Shared helpers of the `polls …` admin commands (list, show, delete, cleanup).
*/
abstract class PollsCommand extends Command
{
/**
* @return \App\Model\Table\PollsTable
*/
protected function polls(): PollsTable
{
/** @var \App\Model\Table\PollsTable $polls */
$polls = $this->fetchTable('Polls');
return $polls;
}
/**
* Machine-readable form of a poll (for `--json`). Never contains the admin token.
*
* @param \App\Model\Entity\Poll $poll Poll
* @return array<string, mixed> Dates as ISO 8601 (server time zone), null where empty
*/
protected function pollData(Poll $poll): array
{
$date = fn(?DateTime $d): ?string => $d?->format(DATE_ATOM);
return [
'id' => $poll->id,
'title' => $poll->title,
'email' => $poll->email,
'joinCode' => $poll->join_code,
'joinUrl' => $this->joinLink($poll),
'created' => $date($poll->created),
'lastAdminAccess' => $date($poll->last_admin_access),
'expiresAt' => $date($poll->expiresAt()),
'expired' => $poll->isExpired(),
'reminderSentAt' => $date($poll->expiry_reminded_at),
];
}
/**
* Prints data as JSON only: nothing else on stdout, no markup interpretation (titles may contain "<").
*
* @param \Cake\Console\ConsoleIo $io Console
* @param mixed $data JSON serialisable data
* @return void
*/
protected function printJson(ConsoleIo $io, mixed $data): void
{
$io->setOutputAs(ConsoleOutput::RAW);
$io->out((string)json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
/**
* Finds a poll by numeric id or join code ("K7P2QX", "k7p-2qx").
*
* @param string $reference Id or join code
* @return \App\Model\Entity\Poll|null
*/
protected function findPoll(string $reference): ?Poll
{
$reference = trim($reference);
if ($reference !== '' && ctype_digit($reference)) {
$poll = $this->polls()->find()->where(['Polls.id' => (int)$reference])->first();
if ($poll !== null) {
/** @var \App\Model\Entity\Poll $poll */
return $poll;
}
}
/** @var \App\Model\Entity\Poll|null $poll */
$poll = $this->polls()->find('byJoinCode', code: $reference)->first();
return $poll;
}
/**
* Absolute admin link (contains the secret token: show it only on explicit request).
*
* @param \App\Model\Entity\Poll $poll Poll
* @return string|null Null if the token cannot be decrypted (e.g. SECURITY_SALT changed)
*/
protected function adminLink(Poll $poll): ?string
{
$token = $this->polls()->decryptToken($poll);
return $token === null ? null : Router::url(['_name' => 'admin', 'token' => $token], true);
}
/**
* @param \App\Model\Entity\Poll $poll Poll
* @return string Absolute participant link
*/
protected function joinLink(Poll $poll): string
{
return Router::url(['_name' => 'participate', 'code' => $poll->join_code], true);
}
/**
* @param \Cake\I18n\DateTime|null $date Date
* @return string "2026-11-16 14:30" in the server's time zone, "-" if empty
*/
protected function formatDate(?DateTime $date): string
{
return $date === null ? '-' : $date->format('Y-m-d H:i');
}
/**
* @param \App\Model\Entity\Poll $poll Poll
* @return string Expiry date, with a marker once it has passed
*/
protected function formatExpiry(Poll $poll): string
{
$expires = $poll->expiresAt();
if ($expires === null) {
return __('nie');
}
return $this->formatDate($expires) . ($expires->isPast() ? ' ' . __('(abgelaufen)') : '');
}
/**
* Deletes polls including slides, answers and images, one transaction per poll.
*
* @param iterable<\App\Model\Entity\Poll> $polls Polls
* @param \Cake\Console\ConsoleIo $io Console
* @return int Number of deleted polls
*/
protected function deletePolls(iterable $polls, ConsoleIo $io): int
{
$deleted = 0;
foreach ($polls as $poll) {
if ($this->polls()->delete($poll)) {
$deleted++;
$io->out(__('Gelöscht: #{0} {1} ({2})', $poll->id, $poll->title, $poll->email));
} else {
$io->err(__('Konnte #{0} nicht löschen.', $poll->id));
}
}
return $deleted;
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
/**
* Deletes polls for good (slides, answers and images included). Unknown polls are an error (exit code 1).
*
* Usage: bin/cake polls delete <id|code> [--yes]
*/
class PollsDeleteCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls delete';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Löscht Umfragen endgültig, samt Folien, Antworten und Bildern.'))
->addArgument('poll', [
'help' => __('ID oder Beitrittscode der Umfrage.'),
'required' => true,
])
->addOption('yes', [
'short' => 'y',
'help' => __('Ohne Rückfrage löschen.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$reference = (string)$args->getArgument('poll');
$poll = $this->findPoll($reference);
if ($poll === null) {
$io->err(__('Umfrage "{0}" nicht gefunden.', $reference));
return static::CODE_ERROR;
}
$io->out(__('#{0} {1} ({2}), angelegt {3}', $poll->id, $poll->title, $poll->email, $this->formatDate($poll->created)));
if (!$args->getOption('yes') && $io->askChoice(__('Diese Umfrage endgültig löschen?'), ['y', 'n'], 'n') !== 'y') {
$io->out(__('Abgebrochen.'));
return static::CODE_ERROR;
}
return $this->deletePolls([$poll], $io) === 1 ? static::CODE_SUCCESS : static::CODE_ERROR;
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
/**
* Lists polls with owner, activity and expiry date. Never prints admin links.
*
* Usage: bin/cake polls list [--expired] [--email=<part>] [--sort=created|activity|title]
*/
class PollsListCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls list';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Zeigt alle Umfragen mit E-Mail-Adresse, Ablaufdatum und Erinnerung.'))
->addOption('expired', [
'help' => __('Nur abgelaufene Umfragen.'),
'boolean' => true,
])
->addOption('email', [
'help' => __('Nur Umfragen, deren E-Mail-Adresse diesen Text enthält.'),
])
->addOption('json', [
'help' => __('Ausgabe als JSON statt als Tabelle (für Skripte).'),
'boolean' => true,
])
->addOption('sort', [
'help' => __('Sortierung (aufsteigend).'),
'default' => 'created',
'choices' => ['created', 'activity', 'title'],
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$query = $this->polls()->find()
->select([
'Polls.id', 'Polls.title', 'Polls.email', 'Polls.join_code', 'Polls.current_slide_id',
'Polls.paused_slide_id', 'Polls.last_admin_access', 'Polls.expiry_reminded_at', 'Polls.created',
])
->orderBy(['Polls.id' => 'ASC']);
if ($args->getOption('expired')) {
$query->find('expired');
}
$email = $args->getOption('email');
if (is_string($email) && $email !== '') {
$query->where(['Polls.email LIKE' => '%' . addcslashes(strtolower($email), '%_\\') . '%']);
}
/** @var list<\App\Model\Entity\Poll> $polls */
$polls = $query->all()->toList();
$sort = (string)$args->getOption('sort');
if ($sort !== 'created') {
usort($polls, fn($a, $b): int => match ($sort) {
'activity' => ($a->last_admin_access ?? $a->created) <=> ($b->last_admin_access ?? $b->created),
default => strcasecmp($a->title, $b->title),
});
}
if ($args->getOption('json')) {
$this->printJson($io, array_map($this->pollData(...), $polls));
return static::CODE_SUCCESS;
}
if ($polls === []) {
$io->out(__('Keine Umfragen gefunden.'));
return static::CODE_SUCCESS;
}
$rows = [[__('ID'), __('Code'), __('Titel'), __('E-Mail'), __('Angelegt'), __('Letzter Admin-Besuch'), __('Läuft ab'), __('Erinnert')]];
foreach ($polls as $poll) {
$rows[] = [
(string)$poll->id,
$poll->join_code,
mb_strimwidth($poll->title, 0, 40, '…'),
$poll->email,
$this->formatDate($poll->created),
$this->formatDate($poll->last_admin_access),
$this->formatExpiry($poll),
$this->formatDate($poll->expiry_reminded_at),
];
}
$io->helper('Table')->output($rows);
$expired = count(array_filter($polls, fn($poll): bool => $poll->isExpired()));
$io->out(__('{0} Umfrage(n), davon {1} abgelaufen.', count($polls), $expired));
return static::CODE_SUCCESS;
}
}
+159
View File
@@ -0,0 +1,159 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Mailer\PollMailer;
use App\Model\Entity\Poll;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\I18n\DateTime;
use Cake\Mailer\Transport\SmtpTransport;
use Cake\Mailer\TransportFactory;
use ReflectionClass;
use function Cake\Core\env;
/**
* Mails the owners of polls that expire soon (POLL_REMINDER_DAYS before the end), once per poll.
* Idempotent: a poll is marked after a successful send; a failed send is retried at the next run.
* `polls cleanup` runs this first, a separate cron entry is not needed.
*
* With an id or code the reminder goes to that one poll right now (for testing the mail): regardless of the
* reminder window, of an earlier reminder and of POLL_REMINDER_DAYS. A forced reminder does not set the
* "reminded" marker, so the regular reminder still goes out when it is due.
*
* Usage: bin/cake polls remind [<id|code>] [--dry-run]
*/
class PollsRemindCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls remind';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Erinnert Besitzer per E-Mail, bevor ihre Umfrage automatisch gelöscht wird.'))
->addArgument('poll', [
'help' => __('Optional: ID oder Beitrittscode. Verschickt die Erinnerung sofort und erzwungen an diese Umfrage (zum Testen), ohne sie als erinnert zu markieren.'),
'required' => false,
])
->addOption('dry-run', [
'help' => __('Nur anzeigen, nichts verschicken.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$dryRun = (bool)$args->getOption('dry-run');
$reference = $args->getArgument('poll');
$forced = $reference !== null;
if ($forced) {
$poll = $this->findPoll((string)$reference);
if ($poll === null) {
$io->err(__('Umfrage „{0}“ nicht gefunden.', $reference));
return static::CODE_ERROR;
}
if ($poll->expiresAt() === null) {
$io->err(__('Umfragen laufen nie ab (POLL_RETENTION_DAYS=0), die Mail braucht ein Ablaufdatum.'));
return static::CODE_ERROR;
}
$due = [$poll];
} elseif (Poll::reminderLeadDays() === 0) {
$io->out(__('Erinnerungen sind aus (POLL_REMINDER_DAYS=0 oder Umfragen laufen nie ab).'));
return static::CODE_SUCCESS;
} else {
/** @var list<\App\Model\Entity\Poll> $due */
$due = $this->polls()->find('reminderDue')->orderBy(['Polls.id' => 'ASC'])->all()->toList();
}
if (!$dryRun && $due !== []) {
$io->out($this->describeTransport());
}
$sent = 0;
$failed = 0;
foreach ($due as $poll) {
$label = __('#{0} {1} ({2}), läuft ab {3}', $poll->id, $poll->title, $poll->email, $this->formatDate($poll->expiresAt()));
if ($dryRun) {
$io->out(__('Würde erinnern: {0}', $label));
continue;
}
$adminUrl = $this->adminLink($poll);
if ($adminUrl === null) {
$io->err(__('Admin-Link nicht entschlüsselbar, keine Erinnerung: {0}', $label));
$failed++;
continue;
}
if (!(new PollMailer())->sendSafely('expiryReminder', [$poll, $adminUrl])) {
$io->err(__('E-Mail fehlgeschlagen: {0}', $label));
$failed++;
continue;
}
if (!$forced) {
// Only the marker column; the poll may have been changed meanwhile.
$this->polls()->updateAll(['expiry_reminded_at' => DateTime::now()], ['id' => $poll->id]);
}
$io->out(($forced ? __('Erinnert (erzwungen, nicht markiert): {0}', $label) : __('Erinnert: {0}', $label)));
$sent++;
}
$io->success($dryRun
? __('{0} Erinnerung(en) wären fällig (nichts verschickt).', count($due))
: __('{0} Erinnerung(en) verschickt, {1} fehlgeschlagen.', $sent, $failed));
return $failed === 0 ? static::CODE_SUCCESS : static::CODE_ERROR;
}
/**
* One line about the mail transport in use (never the password), so a misconfiguration is visible at once.
*
* @return string
*/
protected function describeTransport(): string
{
$transport = TransportFactory::get('default');
$config = $transport->getConfig();
$class = (new ReflectionClass($transport))->getShortName();
if ($transport instanceof SmtpTransport) {
return __(
'Mail-Transport: {0} {1}:{2}, Benutzer {3}, TLS {4}',
$class,
$config['host'],
$config['port'],
$config['username'] ?? __('(keiner)'),
$config['tls'] ? __('ja') : __('nein'),
);
}
if (trim((string)env('SMTP_HOST', '')) !== '') {
return __(
'WARNUNG: SMTP_HOST ist gesetzt, aber der Transport ist {0}. Vermutlich überschreibt config/app_local.php ' .
'den Transport (auf Servern config/app_local.php löschen, Konfiguration nur über .env). Es wird nichts verschickt.',
$class,
);
}
return __('Mail-Transport: {0} (kein SMTP, SMTP_HOST nicht gesetzt)', $class);
}
}
+133
View File
@@ -0,0 +1,133 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Model\Entity\Slide;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Routing\Router;
/**
* Creates a fresh demo poll with one slide of every interactive type, e.g. as target of the JMeter load test
* (tests/load/plenario.jmx). Every run creates a NEW poll (new id and join code); the first slide, a choice
* question, is live and open for voting. Remove them again with `bin/cake polls delete`.
*
* Usage: bin/cake polls seed [--title "..."] [--email "..."] [--json]
*/
class PollsSeedCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls seed';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Legt eine neue Demo-Umfrage mit Beispielfolien an (z. B. für den Lasttest). Jeder Aufruf erzeugt eine neue Umfrage.'))
->addOption('title', [
'help' => __('Titel der Umfrage.'),
'default' => 'Lasttest',
])
->addOption('email', [
'help' => __('E-Mail-Adresse des Besitzers (es wird nichts verschickt).'),
'default' => 'lasttest@example.org',
])
->addOption('json', [
'help' => __('Ausgabe als JSON statt als Text (für Skripte), inkl. Admin-Link.'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$polls = $this->polls();
$slides = $this->fetchTable('Slides');
$result = $polls->getConnection()->transactional(function () use ($polls, $slides, $args): array {
[$poll, $token] = $polls->createPoll([
'title' => (string)$args->getOption('title'),
'email' => (string)$args->getOption('email'),
]);
if ($token === null) {
return [$poll, null, 0];
}
$first = null;
$count = 0;
foreach ($this->definitions() as [$type, $question, $options, $correct]) {
$slide = $slides->newEntity([
'type' => $type,
'question' => $question,
'settings' => Slide::DEFAULT_SETTINGS[$type] ?? [],
]);
$slide->poll_id = $poll->id;
$slides->saveOrFail($slide);
if ($options !== []) {
$slides->syncOptions($slide, $options, $correct);
}
$first ??= $slide;
$count++;
}
$poll->showSlide($first->id);
$polls->saveOrFail($poll);
return [$poll, $token, $count];
});
[$poll, $token, $count] = $result;
if ($token === null) {
$io->err(__('Umfrage konnte nicht angelegt werden: {0}', (string)json_encode($poll->getErrors())));
return static::CODE_ERROR;
}
$adminUrl = Router::url(['_name' => 'admin', 'token' => $token], true);
if ($args->getOption('json')) {
$this->printJson($io, $this->pollData($poll) + ['slides' => $count, 'adminUrl' => $adminUrl]);
return static::CODE_SUCCESS;
}
$io->out([
__('Umfrage #{0} angelegt mit {1} Folien (erste Folie live, Abstimmung offen).', $poll->id, $count),
__('Beitrittscode: {0}', $poll->join_code),
__('Teilnahme-Link: {0}', $this->joinLink($poll)),
__('Admin-Link: {0}', $adminUrl),
__('Lasttest: jmeter -n -t tests/load/plenario.jmx -Jcode={0} …', $poll->join_code),
]);
return static::CODE_SUCCESS;
}
/**
* @return list<array{0: string, 1: string, 2: list<string>, 3: list<string>}> Type, question, options, correct options
*/
protected function definitions(): array
{
return [
[Slide::TYPE_CHOICE, 'Wie gefällt dir PlenarIO?', ['Super', 'Gut', 'Geht so', 'Gar nicht'], []],
[Slide::TYPE_WORDCLOUD, 'Was fällt dir zu Live-Umfragen ein?', [], []],
[Slide::TYPE_OPEN, 'Was wünschst du dir für heute?', [], []],
[Slide::TYPE_SCALE, 'Wie zufrieden bist du?', [], []],
[Slide::TYPE_QUIZ, 'Wie viele Kontinente gibt es?', ['7', '5', '6', '8'], ['7']],
[Slide::TYPE_QA, 'Stell deine Frage', [], []],
[Slide::TYPE_ORDER, 'Bringe die Planeten in die richtige Reihenfolge', ['Merkur', 'Venus', 'Erde', 'Mars'], []],
];
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
/**
* Details of one poll. The secret admin link is only printed with --link.
*
* Usage: bin/cake polls show <id|code> [--link]
*/
class PollsShowCommand extends PollsCommand
{
/**
* @return string
*/
public static function defaultName(): string
{
return 'polls show';
}
/**
* @param \Cake\Console\ConsoleOptionParser $parser Parser
* @return \Cake\Console\ConsoleOptionParser
*/
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
return $parser
->setDescription(__('Zeigt Details einer Umfrage, auf Wunsch mit dem geheimen Admin-Link.'))
->addArgument('poll', [
'help' => __('ID oder Beitrittscode der Umfrage.'),
'required' => true,
])
->addOption('json', [
'help' => __('Ausgabe als JSON statt als Text (für Skripte).'),
'boolean' => true,
])
->addOption('link', [
'help' => __('Auch den Admin-Link ausgeben (enthält das geheime Token!).'),
'boolean' => true,
]);
}
/**
* @param \Cake\Console\Arguments $args Arguments
* @param \Cake\Console\ConsoleIo $io Console
* @return int
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$poll = $this->findPoll((string)$args->getArgument('poll'));
if ($poll === null) {
$io->err(__('Umfrage nicht gefunden.'));
return static::CODE_ERROR;
}
$slides = $this->fetchTable('Slides')->find()->where(['poll_id' => $poll->id])->count();
if ($args->getOption('json')) {
$data = $this->pollData($poll) + ['slides' => $slides, 'adminUrl' => null];
if ($args->getOption('link')) {
$data['adminUrl'] = $this->adminLink($poll);
if ($data['adminUrl'] === null) {
$io->err(__('Der Admin-Link lässt sich nicht entschlüsseln (SECURITY_SALT geändert?).'));
return static::CODE_ERROR;
}
}
$this->printJson($io, $data);
return static::CODE_SUCCESS;
}
$io->out([
__('ID: {0}', $poll->id),
__('Titel: {0}', $poll->title),
__('E-Mail: {0}', $poll->email),
__('Beitrittscode: {0}', $poll->join_code),
__('Teilnahme-Link: {0}', $this->joinLink($poll)),
__('Folien: {0}', $slides),
__('Angelegt: {0}', $this->formatDate($poll->created)),
__('Letzter Besuch: {0}', $this->formatDate($poll->last_admin_access)),
__('Läuft ab: {0}', $this->formatExpiry($poll)),
__('Erinnerung: {0}', $poll->expiry_reminded_at === null ? __('nicht verschickt') : $this->formatDate($poll->expiry_reminded_at)),
]);
if ($args->getOption('link')) {
$link = $this->adminLink($poll);
if ($link === null) {
$io->err(__('Der Admin-Link lässt sich nicht entschlüsseln (SECURITY_SALT geändert?).'));
return static::CODE_ERROR;
}
$io->out(__('Admin-Link: {0}', $link));
} else {
$io->out(__('Admin-Link: (mit --link anzeigen)'));
}
return static::CODE_SUCCESS;
}
}
+161 -12
View File
@@ -7,6 +7,8 @@ use App\Mailer\PollMailer;
use App\Model\Entity\Slide;
use App\Model\Table\ResponsesTable;
use App\Model\Table\SlidesTable;
use App\Service\AudioService;
use App\Service\ImageException;
use App\Service\PollStateService;
use App\Service\QaService;
use App\Service\ReportService;
@@ -20,6 +22,8 @@ use Cake\Routing\Router;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use Psr\Http\Message\UploadedFileInterface;
use Throwable;
/**
* Poll level admin actions: dashboard, settings, presenter mode, export.
@@ -59,7 +63,15 @@ class AdminController extends AdminAppController
// Created on first visit, so every slide has its embed URL ready to copy.
$embedKey = $this->Polls->ensureEmbedKey($this->poll);
$this->set(compact('slides', 'responseCounts', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
$hasPrepared = $this->Responses->hasPrepared($this->poll->id);
$this->setPollInterval();
// Answers are not the only thing a reset undoes: a started quiz, closed slides or a running presentation too.
$canReset = $responseCounts !== []
|| $this->poll->isStarted()
|| array_filter($slides, fn(Slide $slide) => !$slide->isFresh()) !== [];
$this->set(compact('slides', 'responseCounts', 'canReset', 'hasPrepared', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
}
/**
@@ -80,6 +92,53 @@ class AdminController extends AdminAppController
return $this->redirect($this->adminUrl());
}
/**
* Countdown music of the presentation: uploads a new file (replaces the old one) or, with
* `remove` = 1, deletes it. Old files are deleted after saving, never before.
*
* @return \Cake\Http\Response|null
*/
public function audio(): ?Response
{
$this->request->allowMethod(['post']);
$service = new AudioService();
$old = $this->poll->audio;
$upload = $this->request->getUploadedFile('audio');
$hasUpload = $upload instanceof UploadedFileInterface && $upload->getError() !== UPLOAD_ERR_NO_FILE;
$back = $this->adminUrl() + ['#' => 'audio'];
if ($hasUpload) {
try {
$new = $service->store($upload, $this->poll->id);
} catch (ImageException $e) {
$this->Flash->error($e->getMessage());
return $this->redirect($back);
}
} elseif (filter_var($this->request->getData('remove'), FILTER_VALIDATE_BOOLEAN)) {
$new = null;
} else {
$this->Flash->error(__('Bitte wähle eine Audiodatei aus.'));
return $this->redirect($back);
}
$this->poll->set('audio', $new);
try {
$this->Polls->saveOrFail($this->poll);
} catch (Throwable $e) {
$service->delete($this->poll->id, $new);
throw $e;
}
if ($old !== null && $old !== $new) {
$service->delete($this->poll->id, $old);
}
$this->Flash->success($new === null ? __('Audiodatei entfernt.') : __('Audiodatei gespeichert.'));
return $this->redirect($back);
}
/**
* Invalidates the current admin link and mails a new one.
*
@@ -117,20 +176,59 @@ class AdminController extends AdminAppController
}
/**
* Deletes all responses of all slides; slides, settings and the presentation are kept
* (e.g. to run the poll with another group).
* Deletes all responses of all slides and puts the presentation back to "not started"; slides and settings
* are kept (e.g. to run the poll with another group). Prepared Q&A questions stay unless
* `keep_prepared` is sent as 0.
*
* @return \Cake\Http\Response|null
*/
public function reset(): ?Response
{
$this->request->allowMethod(['post']);
(new ResetService())->poll($this->poll);
$keepPrepared = $this->request->getData('keep_prepared', '1') !== '0';
(new ResetService())->poll($this->poll, $keepPrepared);
$this->Flash->success(__('Alle Antworten wurden gelöscht.'));
return $this->redirect($this->adminUrl());
}
/**
* Clones the whole presentation (slides, settings, images) without any responses into a new poll with
* its own admin link, which is mailed to the owner like after creating a poll.
*
* @return \Cake\Http\Response|null
*/
public function cloneAll(): ?Response
{
$this->request->allowMethod(['post']);
if (!$this->throttle('create', 'Plenario.throttle.createPerHour')) {
$this->Flash->error(__('Zu viele Umfragen in kurzer Zeit. Bitte versuche es später noch einmal.'));
return $this->redirect($this->adminUrl());
}
try {
[$copy, $token] = $this->Polls->clonePoll($this->poll, $this->Slides->listForPoll($this->poll->id));
} catch (Throwable) {
$token = null;
}
if ($token === null) {
$this->Flash->error(__('Die Umfrage konnte nicht kopiert werden.'));
return $this->redirect($this->adminUrl());
}
$adminUrl = $this->adminUrlFor($token);
$sent = (new PollMailer())->sendSafely('adminLink', [$copy, $adminUrl, $this->joinUrl($copy)]);
if ($sent) {
$this->Flash->success(__('Kopie angelegt, ohne Antworten. Der Admin-Link der Kopie wurde per E-Mail verschickt – speichere dir diese Seite als Lesezeichen.'));
} else {
$this->Flash->warning(__('Kopie angelegt, ohne Antworten. Die E-Mail mit dem Admin-Link konnte nicht verschickt werden – speichere dir diese Seite unbedingt als Lesezeichen!'));
}
return $this->redirect($this->adminUrlFor($token));
}
/**
* Deletes the whole poll incl. slides and responses.
*
@@ -159,7 +257,16 @@ class AdminController extends AdminAppController
*/
public function present(): void
{
if ($this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$this->prepareStage(true);
}
/**
* @param bool $start Show the first slide if the presentation has not been started yet
* @return void
*/
private function prepareStage(bool $start): void
{
if ($start && $this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$first = $this->Slides->find()
->where(['poll_id' => $this->poll->id, 'is_hidden' => false])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
@@ -176,6 +283,19 @@ class AdminController extends AdminAppController
$this->setPollInterval();
}
/**
* Speaker view for a second window or screen: current slide, preview of the next one and the
* same controls as the presenter screen. Unlike present() it never starts the presentation.
*
* @return void
*/
public function speaker(): void
{
$this->prepareStage(false);
$this->set('speaker', true);
$this->viewBuilder()->setTemplate('present');
}
/**
* JSON state for the presenter screen.
*
@@ -186,13 +306,26 @@ class AdminController extends AdminAppController
return $this->json((new PollStateService())->forPresenter($this->poll));
}
/**
* Fingerprint of the dashboard content (JSON `{version}`), polled by the dashboard so the
* live marker follows the presenter. See PollStateService::dashboardVersion().
*
* @return \Cake\Http\Response
*/
public function live(): Response
{
return $this->json(['version' => (new PollStateService())->dashboardVersion($this->poll)]);
}
/**
* Presenter controls. Field `action`:
* goto (+ slide_id), next, prev, stop (pause), resume (continue after a pause), and the slide actions of
* SlideControlService (open, close, toggle, stage, question).
*
* On a Q&A slide that is being discussed, next/prev step through the questions
* first (like builds in presentation software). While paused, next/prev resume
* first (like builds in presentation software); on a slide with a countdown (quiz, or any slide with a time limit), next starts it and then ends it
* before moving on, on an open ordering slide next closes it (reveals the solution),
* prev always goes to the previous slide. While paused, next/prev resume
* the slide that was live before.
*
* Answers with the new state as JSON for XHR requests, otherwise redirects back.
@@ -208,12 +341,28 @@ class AdminController extends AdminAppController
$ids = array_map(fn(Slide $s) => $s->id, $slides);
$index = array_search($this->poll->current_slide_id, $ids, true);
$current = $index === false ? null : $slides[$index];
if (
$current !== null
&& $current->isQa()
&& in_array($action, ['next', 'prev'], true)
&& (new QaService())->moveFocus($current, $action === 'next' ? 1 : -1)
) {
// Q&A: forward first walks through the stages (collect → vote → discuss), then through the questions,
// only after the last one it goes to the next slide. Back only steps through the questions.
if ($current !== null && $current->isQa() && in_array($action, ['next', 'prev'], true)) {
$qa = new QaService();
if ($qa->moveFocus($current, $action === 'next' ? 1 : -1) || ($action === 'next' && $qa->advance($current))) {
$action = 'none';
}
}
// Forward on a slide with a countdown (every quiz, any other slide with a time limit) is a build step too:
// start it, then end it, only then the next slide.
// Back never touches it, so a clicker can page through the slides afterwards.
if ($current !== null && $current->usesPhases() && $action === 'next') {
$phase = $current->quizPhase();
if ($phase !== Slide::QUIZ_FINISHED) {
(new SlideControlService())->apply($current, $phase === Slide::QUIZ_READY ? 'open' : 'close');
$action = 'none';
}
}
// An ordering slide without countdown: forward first closes the voting (reveals the solution).
if ($current !== null && $current->isOrder() && $action === 'next' && $current->isVotingOpen()) {
(new SlideControlService())->apply($current, 'close');
$action = 'none';
}
+53
View File
@@ -6,6 +6,8 @@ namespace App\Controller;
use App\Model\Entity\Poll;
use App\Model\Entity\Slide;
use App\Model\Table\PollsTable;
use App\Service\AudioService;
use App\Service\ImageService;
use App\Service\PollStateService;
use App\Service\VoteException;
use App\Service\VoteService;
@@ -49,6 +51,10 @@ class ParticipateController extends AppController
public function beforeFilter(EventInterface $event): void
{
parent::beforeFilter($event);
if (in_array($this->request->getParam('action'), ['image', 'audio'], true)) {
// Cacheable static content: no participant id, no cookie.
return;
}
$pid = (string)$this->request->getCookie(self::COOKIE, '');
if (!preg_match('/^[a-f0-9]{32}$/', $pid)) {
@@ -95,6 +101,53 @@ class ParticipateController extends AppController
$this->setPollInterval();
}
/**
* Serves the image of a slide of this poll. The file name is random and changes with every new
* image, so the answer can be cached for good; unknown or replaced images are 404.
*
* @param string $code Join code
* @param string $file Stored file name
* @return \Cake\Http\Response
*/
public function image(string $code, string $file): Response
{
$poll = $this->loadPoll($code);
$path = $this->fetchTable('Slides')->exists(['poll_id' => $poll->id, 'image' => $file])
? (new ImageService())->path($poll->id, $file)
: null;
if ($path === null) {
throw new NotFoundException(__('Bild nicht gefunden.'));
}
return $this->response
->withFile($path)
->withHeader('Content-Type', 'image/webp')
->withHeader('Cache-Control', 'private, max-age=31536000, immutable');
}
/**
* Serves the countdown audio of this poll (random file name, cached for good, supports range
* requests so browsers can loop and seek). Content type is fixed by the extension, never sniffed.
*
* @param string $code Join code
* @param string $file Stored file name
* @return \Cake\Http\Response
*/
public function audio(string $code, string $file): Response
{
$poll = $this->loadPoll($code);
$path = $poll->audio === $file ? (new AudioService())->path($poll->id, $file) : null;
if ($path === null) {
throw new NotFoundException(__('Audiodatei nicht gefunden.'));
}
return $this->response
->withFile($path)
->withHeader('Content-Type', AudioService::contentType($file))
->withHeader('X-Content-Type-Options', 'nosniff')
->withHeader('Cache-Control', 'private, max-age=31536000, immutable');
}
/**
* @param string $code Join code
* @return \Cake\Http\Response
+158 -10
View File
@@ -5,12 +5,17 @@ namespace App\Controller;
use App\Model\Entity\Slide;
use App\Model\Table\SlidesTable;
use App\Service\ImageException;
use App\Service\ImageService;
use App\Service\QaService;
use App\Service\ResetService;
use App\Service\ResultsService;
use App\Service\YouTubeService;
use Cake\Core\Configure;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Response;
use Psr\Http\Message\UploadedFileInterface;
use Throwable;
/**
* Slide CRUD below /admin/{token}/slides.
@@ -48,11 +53,13 @@ class SlidesController extends AdminAppController
$optionsText = $type === Slide::TYPE_CHOICE ? "\n" : '';
$quizOptions = [];
$orderOptions = [];
$preparedText = '';
if ($this->request->is('post')) {
$optionsText = (string)$this->request->getData('options_text', '');
$quizOptions = $this->postedQuizOptions();
$orderOptions = $this->postedOrderOptions();
$preparedText = (string)$this->request->getData('prepared_text', '');
if ($this->saveSlide($slide, $optionsText)) {
$this->Flash->success(__('Folie angelegt.'));
@@ -60,7 +67,7 @@ class SlidesController extends AdminAppController
}
}
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions'));
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'preparedText'));
$this->render('form');
return null;
@@ -76,11 +83,13 @@ class SlidesController extends AdminAppController
$optionsText = implode("\n", array_map(fn($o) => $o->label, $slide->slide_options ?? []));
$quizOptions = array_map(fn($o) => ['label' => $o->label, 'correct' => $o->is_correct], $slide->slide_options ?? []);
$orderOptions = array_map(fn($o) => $o->label, $slide->slide_options ?? []);
$preparedText = $slide->isQa() ? implode("\n", (new QaService())->preparedQuestions($slide)) : '';
if ($this->request->is(['post', 'put', 'patch'])) {
$optionsText = (string)$this->request->getData('options_text', '');
$quizOptions = $this->postedQuizOptions();
$orderOptions = $this->postedOrderOptions();
$preparedText = (string)$this->request->getData('prepared_text', $preparedText);
if ($this->saveSlide($slide, $optionsText)) {
$this->Flash->success(__('Folie gespeichert.'));
@@ -89,7 +98,7 @@ class SlidesController extends AdminAppController
}
$hasResponses = $this->Slides->Responses->exists(['slide_id' => $slide->id]);
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'hasResponses'));
$this->set(compact('slide', 'optionsText', 'quizOptions', 'orderOptions', 'preparedText', 'hasResponses'));
$this->render('form');
return null;
@@ -111,6 +120,9 @@ class SlidesController extends AdminAppController
$this->Slides->deleteOrFail($slide);
$this->Slides->normalizePositions($this->poll->id);
});
// After the commit (a rolled back deletion keeps its image). Model.afterDeleteCommit does not fire
// inside this transaction, so the file is removed here.
(new ImageService())->delete($this->poll->id, $slide->image);
$this->Flash->success(__('Folie gelöscht.'));
return $this->redirect($this->adminUrl());
@@ -197,7 +209,7 @@ class SlidesController extends AdminAppController
}
/**
* All answers of an open question or the ratings of a scale
* All answers of an open question, the ratings of a scale or the comments of a choice slide
* (also anonymous/internal feedback, which is never shown on the stage).
*
* @param string $id Slide id
@@ -206,7 +218,7 @@ class SlidesController extends AdminAppController
public function answers(string $id): void
{
$slide = $this->loadSlide($id);
if (!in_array($slide->type, [Slide::TYPE_OPEN, Slide::TYPE_SCALE], true)) {
if (!in_array($slide->type, [Slide::TYPE_OPEN, Slide::TYPE_SCALE], true) && !$slide->hasComments()) {
throw new NotFoundException(__('Folie nicht gefunden.'));
}
$results = new ResultsService();
@@ -285,16 +297,22 @@ class SlidesController extends AdminAppController
$data = (array)$this->request->getData();
// The type of an existing slide cannot change (would invalidate responses).
$data['type'] = $slide->type;
$fields = ['type', 'question', 'description', 'settings', 'is_voting_open'];
if ($slide->isQuiz() || $slide->isQa()) {
// Quiz and Q&A voting is controlled by the presenter only.
$fields = array_values(array_diff($fields, ['is_voting_open']));
}
// The upload is handled by prepareImage(); the marshaller must not see the file object.
unset($data['image']);
// is_voting_open is presenter state (SlideControlService), never editable via the form.
$fields = ['type', 'question', 'description', 'settings'];
$youtube = $slide->isYouTube() ? $this->prepareYouTube($data) : ['errors' => [], 'warning' => null];
// A slide that has not been presented yet starts again after the (possibly changed) time limit is known:
// with a countdown it waits for the presenter, without it is open.
$fresh = $slide->isNew() || $slide->isFresh();
$this->Slides->patchEntity($slide, $data, ['fields' => $fields, 'associated' => []]);
if ($fresh) {
$slide->startFresh();
}
foreach ($youtube['errors'] as $field => $message) {
$slide->setError($field, $message);
}
$image = $this->prepareImage($slide, $data);
$labels = SlidesTable::parseOptionLines($optionsText);
$correct = [];
@@ -322,11 +340,136 @@ class SlidesController extends AdminAppController
}
}
if ($slide->hasErrors()) {
$this->Flash->error(__('Bitte prüfe deine Eingaben.'));
$this->discardImage($slide, $image);
$this->Flash->error(__('Bitte prüfe deine Eingaben.') . ($image['new'] !== null ? ' ' . __('Das Bild musst du danach erneut auswählen.') : ''));
return false;
}
try {
$saved = $this->persistSlide($slide, $labels, $correct, $youtube);
} catch (Throwable $e) {
$this->discardImage($slide, $image);
throw $e;
}
if (!$saved) {
$this->discardImage($slide, $image);
return false;
}
// Committed: the replaced (or removed) image is no longer referenced.
if ($image['old'] !== null && $image['old'] !== $slide->image) {
(new ImageService())->delete($this->poll->id, $image['old']);
}
return true;
}
/**
* Prepares the image of a posted slide: stores a new upload (scaled to WebP), takes over alternative
* text and layout, or removes the image (`remove_image`). The values are set on the entity;
* use discardImage() if the slide is not saved after all.
*
* @param \App\Model\Entity\Slide $slide Slide with the posted data patched
* @param array<string, mixed> $data Request data
* @return array{new: string|null, old: string|null, original: array<string, mixed>}
* `new` = file stored for this request, `old` = file the slide had before
*/
protected function prepareImage(Slide $slide, array $data): array
{
$fields = ['image', 'image_alt', 'image_layout', 'image_width', 'image_height'];
$original = [];
foreach ($fields as $field) {
$original[$field] = $slide->get($field);
}
$state = ['new' => null, 'old' => $slide->image, 'original' => $original];
if (!Slide::supportsImage($slide->type)) {
return $state;
}
// Collected and set at the end: patching a field resets its errors.
$errors = [];
$upload = $this->request->getUploadedFile('image');
$hasUpload = $upload instanceof UploadedFileInterface && $upload->getError() !== UPLOAD_ERR_NO_FILE;
$remove = !$hasUpload && filter_var($data['remove_image'] ?? false, FILTER_VALIDATE_BOOLEAN);
if ($hasUpload) {
if (!$slide->hasImage() && $this->Slides->countImages($this->poll->id) >= (int)Configure::read('Plenario.images.maxPerPoll', 20)) {
$errors['image'] = __(
'Pro Umfrage sind höchstens {0} Folien mit Bild möglich. Entferne bei einer anderen Folie das Bild.',
(int)Configure::read('Plenario.images.maxPerPoll', 20),
);
} else {
try {
$stored = (new ImageService())->store($upload, $this->poll->id);
$state['new'] = $stored['name'];
$slide->patch(['image' => $stored['name'], 'image_width' => $stored['width'], 'image_height' => $stored['height']], ['guard' => false]);
} catch (ImageException $e) {
$errors['image'] = $e->getMessage();
}
}
} elseif ($remove) {
$slide->patch(['image' => null, 'image_alt' => null, 'image_layout' => null, 'image_width' => null, 'image_height' => null], ['guard' => false]);
}
if (!$slide->hasImage()) {
$this->setErrors($slide, $errors);
return $state;
}
$layout = $data['image_layout'] ?? null;
$slide->patch([
// Presentation images are decoration: no description is asked for (alt="").
'image_alt' => '',
'image_layout' => in_array($layout, Slide::IMAGE_LAYOUTS, true) ? $layout : null,
], ['guard' => false]);
$this->setErrors($slide, $errors);
return $state;
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* @param array<string, string> $errors Field => message
* @return void
*/
protected function setErrors(Slide $slide, array $errors): void
{
foreach ($errors as $field => $message) {
$slide->setError($field, $message);
}
}
/**
* Throws away the image stored for this request and restores the previous image values
* of the entity (the slide was not saved, the form is shown again).
*
* @param \App\Model\Entity\Slide $slide Slide
* @param array{new: string|null, old: string|null, original: array<string, mixed>} $image State of prepareImage()
* @return void
*/
protected function discardImage(Slide $slide, array $image): void
{
if ($image['new'] !== null) {
(new ImageService())->delete($this->poll->id, $image['new']);
}
$errors = $slide->getErrors();
$slide->patch($image['original'], ['guard' => false]);
$slide->setErrors($errors);
}
/**
* Saves the slide and its options in one transaction.
*
* @param \App\Model\Entity\Slide $slide Slide
* @param list<string> $labels Option labels
* @param list<string> $correct Labels of the correct options
* @param array{errors: array<string, string>, warning: string|null} $youtube Result of prepareYouTube()
* @return bool
*/
protected function persistSlide(Slide $slide, array $labels, array $correct, array $youtube): bool
{
return (bool)$this->Slides->getConnection()->transactional(function () use ($slide, $labels, $correct, $youtube): bool {
if (!$this->Slides->save($slide)) {
return false;
@@ -334,6 +477,11 @@ class SlidesController extends AdminAppController
if ($slide->type === Slide::TYPE_CHOICE || $slide->isQuiz() || $slide->isOrder()) {
$this->Slides->syncOptions($slide, $labels, $correct);
}
// Without the field (stage no longer "collect") the prepared questions stay untouched.
$prepared = $this->request->getData('prepared_text');
if ($slide->isQa() && is_string($prepared)) {
(new QaService())->syncPrepared($slide, QaService::parsePrepared($prepared));
}
if ($slide->isQa() && $slide->qaStage() === Slide::QA_VOTE && !$slide->hasQaUpvotes()) {
// Upvotes were switched off while voting: continue with the discussion.
(new QaService())->setStage($slide, Slide::QA_DISCUSS);
+41
View File
@@ -13,6 +13,28 @@ use Throwable;
*/
class PollMailer extends Mailer
{
/**
* Content-ID of the logo that layout/email/html/default.php references as `cid:plenario-logo`.
*/
public const LOGO_CID = 'plenario-logo';
/**
* @param array<string, mixed>|string|null $profile Mailer profile, see parent
*/
public function __construct(array|string|null $profile = null)
{
parent::__construct($profile);
// Inline attachment: shown without "load images" prompts and independent of a public base URL.
$this->addAttachments([
'logo.png' => [
'file' => RESOURCES . 'mail' . DS . 'logo.png',
'mimetype' => 'image/png',
'contentId' => static::LOGO_CID,
'contentDisposition' => false,
],
]);
}
/**
* Sends a mail like send(), but logs transport errors instead of throwing them,
* so the user gets a friendly hint and the action itself still succeeds.
@@ -53,6 +75,25 @@ class PollMailer extends Mailer
->setTemplate('admin_link');
}
/**
* Reminder shortly before the poll is deleted automatically (sent once, by `polls remind`).
*
* @param \App\Model\Entity\Poll $poll Poll
* @param string $adminUrl Absolute admin URL (contains the token)
* @return void
*/
public function expiryReminder(Poll $poll, string $adminUrl): void
{
$expires = $poll->expiresAt();
$this
->setTo($poll->email)
->setSubject(__('Deine Umfrage „{0}“ wird bald gelöscht', $poll->title))
->setEmailFormat('both')
->setViewVars(compact('poll', 'adminUrl', 'expires'))
->viewBuilder()
->setTemplate('expiry_reminder');
}
/**
* Recovery mail listing all admin links of an e-mail address.
*
+78
View File
@@ -3,6 +3,7 @@ declare(strict_types=1);
namespace App\Model\Entity;
use Cake\Core\Configure;
use Cake\I18n\DateTime;
use Cake\ORM\Entity;
@@ -19,7 +20,9 @@ use Cake\ORM\Entity;
* @property int|null $paused_slide_id
* @property bool $is_active
* @property int $comment_speed Speed of rotating scale comments in percent, see COMMENT_SPEEDS
* @property string|null $audio File name of the audio played during quiz countdowns (see AudioService)
* @property \Cake\I18n\DateTime|null $last_admin_access
* @property \Cake\I18n\DateTime|null $expiry_reminded_at When the reminder before the expiry was mailed
* @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime $modified
* @property array<\App\Model\Entity\Slide> $slides
@@ -34,6 +37,14 @@ class Poll extends Entity
*/
public const COMMENT_SPEEDS = [50, 75, 100, 125, 150, 200];
/**
* @return bool
*/
public function hasAudio(): bool
{
return $this->audio !== null && $this->audio !== '';
}
/**
* Only harmless fields are mass assignable. Tokens, join code and the
* current slide are always set explicitly in code.
@@ -69,6 +80,53 @@ class Poll extends Entity
return trim(chunk_split($this->join_code, 3, ' '));
}
/**
* Polls live `Plenario.retention.days` days from their creation, then `bin/cake polls cleanup`
* deletes them (a reminder mail goes out beforehand, see reminderAt()). Computed, not stored:
* changing the setting applies to all polls at once.
*
* @return \Cake\I18n\DateTime|null Null if polls never expire (setting 0)
*/
public function expiresAt(): ?DateTime
{
$days = (int)Configure::read('Plenario.retention.days', 90);
return $days > 0 ? $this->created->addDays($days) : null;
}
/**
* @return int Days before the expiry date the reminder goes out (0 = no reminder). Always shorter than the
* lifetime, otherwise the reminder would be due the moment a poll is created.
*/
public static function reminderLeadDays(): int
{
$days = (int)Configure::read('Plenario.retention.days', 90);
$lead = (int)Configure::read('Plenario.retention.reminderDays', 14);
return $days > 0 ? max(0, min($lead, $days - 1)) : 0;
}
/**
* @return \Cake\I18n\DateTime|null When the reminder becomes due, null without expiry or reminder
*/
public function reminderAt(): ?DateTime
{
$expires = $this->expiresAt();
$lead = static::reminderLeadDays();
return $expires === null || $lead === 0 ? null : $expires->subDays($lead);
}
/**
* @return bool Past its expiry date
*/
public function isExpired(): bool
{
$expires = $this->expiresAt();
return $expires !== null && $expires->isPast();
}
/**
* Shows a slide to the participants (from PlenarIO itself: no embed timeout).
*
@@ -109,6 +167,18 @@ class Poll extends Entity
$this->embed_seen_at = null;
}
/**
* Back to "not started": neither live nor paused. Idempotent.
*
* @return void
*/
public function notStarted(): void
{
$this->current_slide_id = null;
$this->paused_slide_id = null;
$this->embed_seen_at = null;
}
/**
* A slide leaves the presentation (deleted or hidden). If it was live or is the one a pause
* resumes, the poll pauses and resumes with $resumeSlideId instead (null: no slides left =
@@ -128,6 +198,14 @@ class Poll extends Entity
$this->embed_seen_at = null;
}
/**
* @return bool Live or paused, i.e. not in the state notStarted() sets
*/
public function isStarted(): bool
{
return $this->current_slide_id !== null || $this->paused_slide_id !== null;
}
/**
* @return bool Paused after a slide had been live (not: not started yet)
*/
+151 -13
View File
@@ -19,6 +19,11 @@ use Cake\ORM\Entity;
* @property int $position
* @property bool $is_hidden Prepared, but skipped in the presentation (never live)
* @property array<string, mixed>|null $settings
* @property string|null $image File name of the slide image in the poll's upload directory (see ImageService)
* @property string|null $image_alt Always '' (decorative): images are shown on the stage, no description is asked for
* @property string|null $image_layout top|side|full, null = default of the type (see imageLayout())
* @property int|null $image_width Pixels of the stored (scaled) image
* @property int|null $image_height
* @property bool $is_voting_open
* @property \Cake\I18n\DateTime|null $voting_started_at Quiz: start of the voting window
* @property \Cake\I18n\DateTime|null $voting_ends_at Quiz: deadline (null = closed manually)
@@ -56,6 +61,13 @@ class Slide extends Entity
*/
public const QUIZ_TIME_LIMITS = [0, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300];
/**
* Selectable time limits of every slide with a countdown (same list as for quizzes).
*
* @var list<int>
*/
public const TIME_LIMITS = self::QUIZ_TIME_LIMITS;
/**
* Display styles of a scale: numbered steps or a star rating (always starts at 1 star).
*/
@@ -101,14 +113,17 @@ class Slide extends Entity
* @var array<string, array<string, mixed>>
*/
public const DEFAULT_SETTINGS = [
self::TYPE_CHOICE => ['multiple' => false],
// comments: optional comment field (stored in text_value of the participant's first row),
// comments rotate in the presentation like those of a scale
self::TYPE_CHOICE => ['multiple' => false, 'comments' => false, 'comment_only' => false, 'time_limit' => 0],
// allow_downvotes only takes effect together with allow_upvotes
self::TYPE_WORDCLOUD => ['allow_upvotes' => true, 'allow_downvotes' => true],
self::TYPE_WORDCLOUD => ['allow_upvotes' => true, 'allow_downvotes' => true, 'time_limit' => 0],
// private: anonymous feedback, answers only visible in the admin area (never on the stage)
self::TYPE_OPEN => ['private' => false],
self::TYPE_OPEN => ['private' => false, 'time_limit' => 0],
// private: internal feedback, ratings only visible in the admin area (never on the stage)
// comments: optional comment field, comments rotate in the presentation (unless private)
// comment_ratings: show the rating next to each comment in the presentation
// comment_only: with comments, a comment alone is enough (row without numeric_value, not part of the average)
// (time per comment depends on its length, see Comments.delay() in plenario.js)
// style: numbers or stars (SCALE_*), stars always start at scale_min = 1
// scale_view: parts of the result shown in the presentation (presenter/embed, SCALE_VIEWS);
@@ -116,8 +131,9 @@ class Slide extends Entity
self::TYPE_SCALE => [
'style' => self::SCALE_NUMBERS,
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
'comments' => false, 'comment_ratings' => false,
'comments' => false, 'comment_only' => false, 'comment_ratings' => false,
'scale_view' => self::SCALE_VIEW_BOTH,
'time_limit' => 0,
],
self::TYPE_CONTENT => [],
// time_limit in seconds, 0 = no limit (presenter ends the quiz)
@@ -129,10 +145,23 @@ class Slide extends Entity
// max_upvotes_per_question: own upvotes per question (0 = no limit besides the budget);
// allow_self_upvote: upvotes on own questions (for prioritizing topics, off by default)
self::TYPE_QA => ['upvote_share' => 25, 'max_upvotes_per_question' => 0, 'allow_self_upvote' => false],
// time_limit (all slides with answers but Q&A): seconds, 0 = no countdown. With a countdown the slide waits
// ("ready") until the presenter starts it, like a quiz (see usesPhases()).
// The correct order is the order of the slide_options (position), revealed when voting closes.
self::TYPE_ORDER => [],
// ranking: no correct order, everyone sorts by personal preference; the presenter sees the
// average ranking live (nothing to hide), participants never get results
self::TYPE_ORDER => ['ranking' => false, 'time_limit' => 0],
];
/**
* Where the image of a slide goes: above the results, next to the text (presenter only,
* participants' phones always show it on top) or - content slides - as large as possible.
*/
public const IMAGE_TOP = 'top';
public const IMAGE_SIDE = 'side';
public const IMAGE_FULL = 'full';
public const IMAGE_LAYOUTS = [self::IMAGE_TOP, self::IMAGE_SIDE, self::IMAGE_FULL];
/**
* @var array<string, bool>
*/
@@ -144,6 +173,55 @@ class Slide extends Entity
'is_voting_open' => true,
];
/**
* Whether slides of this type can carry an image (everything but YouTube, which has its own media).
*
* @param string $type Slide type
* @return bool
*/
public static function supportsImage(string $type): bool
{
return $type !== self::TYPE_YOUTUBE;
}
/**
* Whether slides of this type can have a countdown: every type that collects answers except Q&A (its three
* stages take as long as the discussion needs). A quiz always has the ready/running/finished phases.
*
* @param string $type Slide type
* @return bool
*/
public static function supportsTimer(string $type): bool
{
return in_array($type, [
self::TYPE_CHOICE, self::TYPE_WORDCLOUD, self::TYPE_OPEN, self::TYPE_SCALE, self::TYPE_QUIZ, self::TYPE_ORDER,
], true);
}
/**
* @return bool
*/
public function hasImage(): bool
{
return $this->image !== null && $this->image !== '';
}
/**
* Layout of the image: the chosen one, otherwise by type - next to the text on content slides,
* above the question's answers elsewhere. "full" only exists for content slides.
*
* @return string One of IMAGE_LAYOUTS
*/
public function imageLayout(): string
{
$layout = $this->image_layout;
if (!in_array($layout, self::IMAGE_LAYOUTS, true) || ($layout === self::IMAGE_FULL && $this->type !== self::TYPE_CONTENT)) {
return $this->type === self::TYPE_CONTENT ? self::IMAGE_SIDE : self::IMAGE_TOP;
}
return $layout;
}
/**
* @return array<string, string> type => human readable label
*/
@@ -291,7 +369,18 @@ class Slide extends Entity
*/
public function isOrderRevealed(): bool
{
return $this->isOrder() && !$this->isVotingOpen();
// Not yet started (phase "ready") is closed too, but nothing may be resolved before the countdown ran.
return $this->isOrder() && !$this->isRanking() && !$this->isVotingOpen() && $this->phase() !== self::QUIZ_READY;
}
/**
* Ordering slide without a correct order (personal ranking, e.g. "sort by your importance").
*
* @return bool
*/
public function isRanking(): bool
{
return $this->isOrder() && (bool)$this->setting('ranking');
}
/**
@@ -398,6 +487,28 @@ class Slide extends Entity
return in_array($this->type, [self::TYPE_WORDCLOUD, self::TYPE_QA], true);
}
/**
* Whether the slide goes through the phases ready (shows only the question), running (countdown, answers
* accepted) and finished: every quiz, and any other slide with a time limit.
*
* @return bool
*/
public function usesPhases(): bool
{
return $this->isQuiz() || (self::supportsTimer($this->type) && (int)$this->setting('time_limit') > 0);
}
/**
* Phase of a slide with a countdown (one of the QUIZ_* constants), null for slides without.
*
* @param \Cake\I18n\DateTime|null $now Reference time (default: now)
* @return string|null
*/
public function phase(?DateTime $now = null): ?string
{
return $this->usesPhases() ? $this->quizPhase($now) : null;
}
/**
* Phase of a quiz: ready (not started yet), running, finished (time up or
* closed by the presenter). Results and correct answers are only revealed
@@ -435,13 +546,14 @@ class Slide extends Entity
/**
* Sets the state of a slide that has not been presented yet (new slide, copy):
* a quiz waits for the presenter to start it, Q&A collects questions, others are open.
* a quiz or a slide with a countdown waits for the presenter to start it, Q&A collects questions,
* others are open.
*
* @return void
*/
public function startFresh(): void
{
$this->is_voting_open = !$this->isQuiz();
$this->is_voting_open = !$this->usesPhases();
$this->voting_started_at = null;
$this->voting_ends_at = null;
$this->stage = $this->isQa() ? self::QA_COLLECT : null;
@@ -449,8 +561,23 @@ class Slide extends Entity
}
/**
* Opens or closes voting. Opening a quiz that is not running (re)starts its
* voting window and timer; opening a running quiz changes nothing.
* Whether the slide is in the state startFresh() sets (nothing started, closed or discussed yet).
* A reset has nothing to do for such a slide unless it has answers.
*
* @return bool
*/
public function isFresh(): bool
{
return $this->is_voting_open === !$this->usesPhases()
&& $this->voting_started_at === null
&& $this->voting_ends_at === null
&& $this->stage === ($this->isQa() ? self::QA_COLLECT : null)
&& $this->focus_response_id === null;
}
/**
* Opens or closes voting. Opening a slide with a countdown that is not running (re)starts its
* voting window and timer; opening a running one changes nothing.
*
* @param bool $open Open or close
* @param \Cake\I18n\DateTime|null $now Reference time (default: now)
@@ -459,7 +586,7 @@ class Slide extends Entity
public function setVotingOpen(bool $open, ?DateTime $now = null): void
{
$now ??= DateTime::now();
if ($open && $this->isQuiz() && !$this->isVotingOpen($now)) {
if ($open && $this->usesPhases() && !$this->isVotingOpen($now)) {
$limit = (int)$this->setting('time_limit');
$this->voting_started_at = $now;
$this->voting_ends_at = $limit > 0 ? $now->addSeconds($limit) : null;
@@ -500,13 +627,24 @@ class Slide extends Entity
}
/**
* Scale with an optional comment field for participants.
* Multiple choice or scale with an optional comment field for participants.
*
* @return bool
*/
public function hasComments(): bool
{
return $this->type === self::TYPE_SCALE && (bool)$this->setting('comments');
return in_array($this->type, [self::TYPE_CHOICE, self::TYPE_SCALE], true) && (bool)$this->setting('comments');
}
/**
* Scale or multiple choice with a comment field where a comment alone is enough
* (the rating or selection is optional).
*
* @return bool
*/
public function hasCommentOnly(): bool
{
return $this->hasComments() && (bool)$this->setting('comment_only');
}
/**
+105
View File
@@ -4,13 +4,20 @@ declare(strict_types=1);
namespace App\Model\Table;
use App\Model\Entity\Poll;
use App\Service\AudioService;
use App\Service\ImageService;
use ArrayObject;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Event\EventInterface;
use Cake\I18n\DateTime;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Utility\Security;
use Cake\Validation\Validator;
use RuntimeException;
use Throwable;
/**
* Polls ("presentations"). Access control works exclusively via the secret
@@ -54,6 +61,20 @@ class PollsTable extends Table
]);
}
/**
* After the poll is gone for good, so are the image files of its slides (the slides remove
* their own; this also sweeps what a crash left behind).
*
* @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event Event
* @param \Cake\Datasource\EntityInterface $entity Deleted poll
* @param \ArrayObject<string, mixed> $options Options
* @return void
*/
public function afterDeleteCommit(EventInterface $event, EntityInterface $entity, ArrayObject $options): void
{
(new ImageService())->deletePoll((int)$entity->get('id'));
}
/**
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
@@ -238,6 +259,51 @@ class PollsTable extends Table
return [$poll, $token];
}
/**
* Clones a poll: new poll (same e-mail, new admin token and join code) with a copy of all slides,
* but without any responses, and not started. Nothing is left behind if copying fails.
*
* @param \App\Model\Entity\Poll $poll Original
* @param list<\App\Model\Entity\Slide> $slides Slides of the original incl. slide_options, in order
* @return array{0: \App\Model\Entity\Poll, 1: string|null} The new poll and its plain token (null on failure)
*/
public function clonePoll(Poll $poll, array $slides): array
{
$copy = $this->newPoll([
'title' => mb_substr(__('{0} (Kopie)', $poll->title), 0, 200),
'email' => $poll->email,
]);
if ($copy->hasErrors()) {
return [$copy, null];
}
$copy->set('comment_speed', $poll->comment_speed);
$token = null;
$audio = new AudioService();
$audioCopy = null;
try {
$this->getConnection()->transactional(function () use ($poll, $copy, $slides, $audio, &$token, &$audioCopy): void {
[, $token] = $this->insertPoll($copy);
if ($token === null) {
throw new RuntimeException('Poll could not be saved');
}
$this->Slides->copyAllToPoll($slides, $copy->id);
// The copy gets its own audio file: deleting one poll never takes the music of the other.
$audioCopy = $poll->hasAudio() ? $audio->copy($copy->id, (string)$poll->audio, $poll->id) : null;
if ($audioCopy !== null) {
$copy->set('audio', $audioCopy);
$this->saveOrFail($copy);
}
});
} catch (Throwable $e) {
$audio->delete((int)$copy->id, $audioCopy);
throw $e;
}
return [$copy, $token];
}
/**
* @param \Cake\ORM\Query\SelectQuery $query Query
* @param string $token Plain admin token
@@ -258,6 +324,45 @@ class PollsTable extends Table
return $query->where(['Polls.join_code' => static::normalizeJoinCode($code)]);
}
/**
* Polls past their expiry date (created + retention, see Poll::expiresAt()); none if the retention is 0.
*
* @param \Cake\ORM\Query\SelectQuery $query Query
* @return \Cake\ORM\Query\SelectQuery
*/
public function findExpired(SelectQuery $query): SelectQuery
{
$days = (int)Configure::read('Plenario.retention.days', 90);
if ($days <= 0) {
return $query->where('1 = 0');
}
return $query->where(['Polls.created <' => DateTime::now()->subDays($days)]);
}
/**
* Polls whose reminder is due and not yet sent: inside the last `reminderDays` before the expiry,
* but not expired yet (then it is too late, they are deleted).
*
* @param \Cake\ORM\Query\SelectQuery $query Query
* @return \Cake\ORM\Query\SelectQuery
*/
public function findReminderDue(SelectQuery $query): SelectQuery
{
$lead = Poll::reminderLeadDays();
if ($lead === 0) {
return $query->where('1 = 0');
}
$days = (int)Configure::read('Plenario.retention.days', 90);
$now = DateTime::now();
return $query->where([
'Polls.expiry_reminded_at IS' => null,
'Polls.created <=' => $now->subDays($days - $lead),
'Polls.created >=' => $now->subDays($days),
]);
}
/**
* @param \Cake\ORM\Query\SelectQuery $query Query
* @param string $key Embed key
+14 -2
View File
@@ -165,13 +165,25 @@ class ResponsesTable extends Table
{
$row = $this->find()
->select(['n' => $this->find()->func()->count('DISTINCT participant_hash')])
->where(['slide_id' => $slideId])
->where(['slide_id' => $slideId, 'participant_hash !=' => VoteService::PREPARED_HASH])
->disableHydration()
->first();
return (int)($row['n'] ?? 0);
}
/**
* @param int $pollId Poll id
* @return bool Whether the poll has Q&A questions entered beforehand
*/
public function hasPrepared(int $pollId): bool
{
return $this->find()
->innerJoinWith('Slides')
->where(['Slides.poll_id' => $pollId, 'Responses.participant_hash' => VoteService::PREPARED_HASH])
->count() > 0;
}
/**
* Number of responding participants per slide of a poll.
*
@@ -186,7 +198,7 @@ class ResponsesTable extends Table
'n' => $this->find()->func()->count('DISTINCT Responses.participant_hash'),
])
->innerJoinWith('Slides')
->where(['Slides.poll_id' => $pollId])
->where(['Slides.poll_id' => $pollId, 'Responses.participant_hash !=' => VoteService::PREPARED_HASH])
->groupBy(['Responses.slide_id'])
->disableHydration()
->all();
+149 -18
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Model\Table;
use App\Model\Entity\Slide;
use App\Service\ImageService;
use App\Service\YouTubeService;
use ArrayObject;
use Cake\Database\Expression\QueryExpression;
@@ -12,6 +13,7 @@ use Cake\Event\EventInterface;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Throwable;
/**
* @property \App\Model\Table\PollsTable&\Cake\ORM\Association\BelongsTo $Polls
@@ -109,6 +111,17 @@ class SlidesTable extends Table
}
}
/**
* Number of slides of a poll that carry an image (they count against `Plenario.images.maxPerPoll`).
*
* @param int $pollId Poll id
* @return int
*/
public function countImages(int $pollId): int
{
return $this->find()->where(['poll_id' => $pollId, 'image IS NOT' => null])->count();
}
/**
* Assign the next free position for new slides.
*
@@ -142,6 +155,7 @@ class SlidesTable extends Table
switch ($type) {
case Slide::TYPE_CHOICE:
$settings['multiple'] = filter_var($input['multiple'] ?? false, FILTER_VALIDATE_BOOLEAN);
$settings = array_merge($settings, static::commentSettings($input));
break;
case Slide::TYPE_WORDCLOUD:
$settings['allow_upvotes'] = filter_var($input['allow_upvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
@@ -161,16 +175,16 @@ class SlidesTable extends Table
$settings['min_label'] = mb_substr(trim((string)($input['min_label'] ?? '')), 0, 60);
$settings['max_label'] = mb_substr(trim((string)($input['max_label'] ?? '')), 0, 60);
$settings['private'] = filter_var($input['private'] ?? false, FILTER_VALIDATE_BOOLEAN);
$settings['comments'] = filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN);
$settings = array_merge($settings, static::commentSettings($input));
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN);
$view = $input['scale_view'] ?? null;
$settings['scale_view'] = in_array($view, Slide::SCALE_VIEWS, true) ? $view : Slide::SCALE_VIEW_BOTH;
break;
case Slide::TYPE_ORDER:
$settings['ranking'] = filter_var($input['ranking'] ?? false, FILTER_VALIDATE_BOOLEAN);
break;
case Slide::TYPE_QUIZ:
$limit = (int)($input['time_limit'] ?? $settings['time_limit']);
if (in_array($limit, Slide::QUIZ_TIME_LIMITS, true)) {
$settings['time_limit'] = $limit;
}
// The time limit is validated for every slide with a countdown below.
break;
case Slide::TYPE_QA:
$share = (int)($input['upvote_share'] ?? $settings['upvote_share']);
@@ -197,10 +211,35 @@ class SlidesTable extends Table
$settings['autoplay'] = filter_var($input['autoplay'] ?? false, FILTER_VALIDATE_BOOLEAN);
break;
}
if (Slide::supportsTimer($type)) {
$limit = (int)($input['time_limit'] ?? $settings['time_limit']);
$settings['time_limit'] = in_array($limit, Slide::TIME_LIMITS, true)
? $limit
: Slide::DEFAULT_SETTINGS[$type]['time_limit'];
}
return $settings;
}
/**
* Comment settings of choice and scale slides. The form sends one dropdown `comment_mode`
* (off | rating: optional comment | only: a comment alone is enough); the plain flags
* `comments`/`comment_only` stay accepted.
*
* @param array<string, mixed> $input Raw settings
* @return array{comments: bool, comment_only: bool}
*/
protected static function commentSettings(array $input): array
{
$mode = $input['comment_mode'] ?? match (true) {
!filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN) => 'off',
filter_var($input['comment_only'] ?? false, FILTER_VALIDATE_BOOLEAN) => 'only',
default => 'rating',
};
return ['comments' => in_array($mode, ['rating', 'only'], true), 'comment_only' => $mode === 'only'];
}
/**
* Parses a textarea (one option per line) into a clean list of labels.
*
@@ -336,30 +375,122 @@ class SlidesTable extends Table
*/
public function duplicate(Slide $slide): Slide
{
$copy = $this->newEmptyEntity();
$copy->poll_id = $slide->poll_id;
$copy->type = $slide->type;
$images = new ImageService();
$copy = $this->prepareCopy($slide, $slide->poll_id, $slide->position + 1, $images);
$copy->question = mb_substr(__('{0} (Kopie)', $slide->question), 0, 500);
try {
return $this->persistCopy($slide, $copy);
} catch (Throwable $e) {
// Rolled back: the copied file belongs to no slide.
$images->delete($slide->poll_id, $copy->image);
throw $e;
}
}
/**
* Copies all slides of a poll (settings, options, correct answers, images, hidden flag) into another poll,
* in the same order. Responses are not copied. All or nothing: on failure no slide and no image file remains.
*
* @param list<\App\Model\Entity\Slide> $slides Original slides incl. slide_options, in order
* @param int $targetPollId Poll that receives the copies
* @return void
*/
public function copyAllToPoll(array $slides, int $targetPollId): void
{
$images = new ImageService();
$files = [];
try {
$this->getConnection()->transactional(function () use ($slides, $targetPollId, $images, &$files): void {
foreach ($slides as $index => $slide) {
$copy = $this->prepareCopy($slide, $targetPollId, $index + 1, $images);
if ($copy->image !== null) {
$files[] = $copy->image;
}
$copy->is_hidden = $slide->is_hidden;
$this->saveOrFail($copy);
$this->copyOptions($slide, $copy);
}
});
} catch (Throwable $e) {
foreach ($files as $file) {
$images->delete($targetPollId, $file);
}
throw $e;
}
}
/**
* Builds an unsaved copy of a slide for a poll; a fresh slide (nothing started) with its own image file.
*
* @param \App\Model\Entity\Slide $slide Original
* @param int $pollId Poll of the copy
* @param int $position Position of the copy
* @param \App\Service\ImageService $images Image storage
* @return \App\Model\Entity\Slide
*/
protected function prepareCopy(Slide $slide, int $pollId, int $position, ImageService $images): Slide
{
$copy = $this->newEmptyEntity();
$copy->poll_id = $pollId;
$copy->type = $slide->type;
$copy->question = $slide->question;
$copy->description = $slide->description;
$copy->settings = $slide->settings;
$copy->position = $slide->position + 1;
$copy->position = $position;
$copy->startFresh();
// The copy gets its own file, so deleting one slide never takes the image of the other.
$imageCopy = $slide->hasImage() ? $images->copy($pollId, (string)$slide->image, $slide->poll_id) : null;
if ($imageCopy !== null) {
$copy->image = $imageCopy;
$copy->image_alt = $slide->image_alt;
$copy->image_layout = $slide->image_layout;
$copy->image_width = $slide->image_width;
$copy->image_height = $slide->image_height;
}
return $copy;
}
/**
* Copies the options (with the correct answers) of a slide to its saved copy.
*
* @param \App\Model\Entity\Slide $slide Original incl. slide_options
* @param \App\Model\Entity\Slide $copy Saved copy
* @return void
*/
protected function copyOptions(Slide $slide, Slide $copy): void
{
foreach ($slide->slide_options ?? [] as $option) {
$newOption = $this->SlideOptions->newEntity([
'label' => $option->label,
'position' => $option->position,
]);
$newOption->set('slide_id', $copy->id);
$newOption->set('is_correct', $option->is_correct);
$this->SlideOptions->saveOrFail($newOption);
}
}
/**
* Saves a duplicated slide behind its original, together with the copies of the options.
*
* @param \App\Model\Entity\Slide $slide Original incl. slide_options
* @param \App\Model\Entity\Slide $copy Prepared copy
* @return \App\Model\Entity\Slide
*/
protected function persistCopy(Slide $slide, Slide $copy): Slide
{
return $this->getConnection()->transactional(function () use ($slide, $copy): Slide {
$this->updateAll(
['position' => new QueryExpression('position + 1')],
['poll_id' => $slide->poll_id, 'position >' => $slide->position],
);
$this->saveOrFail($copy);
foreach ($slide->slide_options ?? [] as $option) {
$newOption = $this->SlideOptions->newEntity([
'label' => $option->label,
'position' => $option->position,
]);
$newOption->set('slide_id', $copy->id);
$newOption->set('is_correct', $option->is_correct);
$this->SlideOptions->saveOrFail($newOption);
}
$this->copyOptions($slide, $copy);
$this->normalizePositions($slide->poll_id);
return $this->get($copy->id, contain: ['SlideOptions']);
+210
View File
@@ -0,0 +1,210 @@
<?php
declare(strict_types=1);
namespace App\Service;
use Cake\Core\Configure;
use Psr\Http\Message\UploadedFileInterface;
/**
* Stores the audio file of a presentation (played in the presenter view while a quiz countdown runs).
*
* Audio is not re-encoded: the format is recognised by its leading bytes (never by the client-sent
* name or type), the file is stored under a random name with a fixed extension, and served with a
* fixed content type by ParticipateController::audio(). Files live next to the slide images in
* `{Plenario.images.path}/{poll id}/`, so deleting a poll removes them as well; `bin/cake images_cleanup`
* sweeps leftovers of both kinds.
*
* Deleting is idempotent: a missing file is fine.
*/
class AudioService
{
/**
* Accepted formats: extension => content type.
*
* @var array<string, string>
*/
public const FORMATS = [
'mp3' => 'audio/mpeg',
'ogg' => 'audio/ogg',
'wav' => 'audio/wav',
'm4a' => 'audio/mp4',
];
/**
* Whether a stored name has the shape generated by store() (guards file system access).
*
* @param string $name File name
* @return bool
*/
public static function isValidName(string $name): bool
{
return (bool)preg_match('/^[a-f0-9]{24}\.(mp3|ogg|wav|m4a)$/', $name);
}
/**
* Content type for a stored name.
*
* @param string $name File name
* @return string
*/
public static function contentType(string $name): string
{
return self::FORMATS[pathinfo($name, PATHINFO_EXTENSION)] ?? 'application/octet-stream';
}
/**
* Recognises MP3 (ID3 tag or frame sync), Ogg, WAV and MPEG-4 audio by the first bytes.
*
* @param string $bytes File content
* @return string|null Extension (a key of FORMATS) or null for anything else
*/
public static function detectFormat(string $bytes): ?string
{
if (strlen($bytes) < 12) {
return null;
}
if (str_starts_with($bytes, 'OggS')) {
return 'ogg';
}
if (str_starts_with($bytes, 'RIFF') && substr($bytes, 8, 4) === 'WAVE') {
return 'wav';
}
if (substr($bytes, 4, 4) === 'ftyp') {
return 'm4a';
}
if (str_starts_with($bytes, 'ID3')) {
return 'mp3';
}
// Frame sync: 11 set bits, then a valid version and layer (not reserved).
$second = ord($bytes[1]);
if (ord($bytes[0]) === 0xFF && ($second & 0xE0) === 0xE0 && ($second & 0x18) !== 0x08 && ($second & 0x06) !== 0x00) {
return 'mp3';
}
return null;
}
/**
* Validates and stores an upload.
*
* @param \Psr\Http\Message\UploadedFileInterface $file Uploaded file
* @param int $pollId Poll the audio belongs to
* @return string Stored file name
* @throws \App\Service\ImageException If the file cannot be used
*/
public function store(UploadedFileInterface $file, int $pollId): string
{
$this->assertUploaded($file);
$bytes = (string)$file->getStream();
$extension = self::detectFormat($bytes);
if ($extension === null) {
throw new ImageException(__('Bitte wähle eine Audiodatei im Format MP3, M4A, OGG oder WAV aus.'));
}
$name = bin2hex(random_bytes(12)) . '.' . $extension;
$directory = $this->directory($pollId);
if (!is_dir($directory) && !@mkdir($directory, 0775, true) && !is_dir($directory)) {
throw new ImageException(__('Die Audiodatei konnte nicht gespeichert werden (Upload-Verzeichnis nicht beschreibbar).'));
}
// Write under a temporary name first: a half written file must never be served.
$temporary = $directory . DS . $name . '.tmp';
if (@file_put_contents($temporary, $bytes) !== strlen($bytes) || !@rename($temporary, $directory . DS . $name)) {
@unlink($temporary);
throw new ImageException(__('Die Audiodatei konnte nicht gespeichert werden.'));
}
return $name;
}
/**
* Copies a stored file (duplicated slides get their own file).
*
* @param int $pollId Poll id that receives the copy
* @param string $name Source file name
* @param int|null $sourcePollId Poll id of the source file (default: the same poll)
* @return string|null Name of the copy, null if the source is gone or the copy failed
*/
public function copy(int $pollId, string $name, ?int $sourcePollId = null): ?string
{
$source = $this->path($sourcePollId ?? $pollId, $name);
if ($source === null) {
return null;
}
$directory = $this->directory($pollId);
if (!is_dir($directory) && !@mkdir($directory, 0775, true) && !is_dir($directory)) {
return null;
}
$copy = bin2hex(random_bytes(12)) . '.' . pathinfo($name, PATHINFO_EXTENSION);
return @copy($source, $directory . DS . $copy) ? $copy : null;
}
/**
* Absolute path of a stored file, null if the name is invalid or the file does not exist.
*
* @param int $pollId Poll id
* @param string $name File name
* @return string|null
*/
public function path(int $pollId, string $name): ?string
{
if (!self::isValidName($name)) {
return null;
}
$path = $this->directory($pollId) . DS . $name;
return is_file($path) ? $path : null;
}
/**
* Deletes one file. Idempotent, ignores unknown names and missing files.
*
* @param int $pollId Poll id
* @param string|null $name File name
* @return void
*/
public function delete(int $pollId, ?string $name): void
{
if ($name === null || !self::isValidName($name)) {
return;
}
@unlink($this->directory($pollId) . DS . $name);
}
/**
* @param int $pollId Poll id
* @return string
*/
protected function directory(int $pollId): string
{
return rtrim((string)Configure::read('Plenario.images.path'), '/\\') . DS . $pollId;
}
/**
* @param \Psr\Http\Message\UploadedFileInterface $file Uploaded file
* @return void
*/
protected function assertUploaded(UploadedFileInterface $file): void
{
switch ($file->getError()) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new ImageException(__(
'Die Datei ist größer, als der Server erlaubt ({0}). Bitte wähle eine kleinere Audiodatei.',
(string)ini_get('upload_max_filesize'),
));
default:
throw new ImageException(__('Die Audiodatei konnte nicht hochgeladen werden. Bitte versuche es noch einmal.'));
}
$max = (int)Configure::read('Plenario.audio.maxUploadBytes', 10 * 1024 * 1024);
if (($file->getSize() ?? 0) > $max) {
throw new ImageException(__('Die Audiodatei ist zu groß (höchstens {0} MB).', (int)round($max / 1024 / 1024)));
}
if (($file->getSize() ?? 0) === 0) {
throw new ImageException(__('Die Datei ist leer.'));
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Service;
use RuntimeException;
/**
* Thrown when an uploaded image is rejected. The message is safe to show to the admin.
*/
class ImageException extends RuntimeException
{
}
+398
View File
@@ -0,0 +1,398 @@
<?php
declare(strict_types=1);
namespace App\Service;
use Cake\Core\Configure;
use GdImage;
use Psr\Http\Message\UploadedFileInterface;
/**
* Stores the images of slides.
*
* Uploads are decoded, rotated upright (EXIF orientation), scaled down to `Plenario.images.maxEdge`
* and written as WebP. Re-encoding drops all metadata (GPS position of phone photos!) and defuses
* files that are valid in two formats. Only the result is kept, never the original.
*
* Files live outside webroot in `{Plenario.images.path}/{poll id}/{random name}.webp` and are served
* by ParticipateController::image(). Replacing an image creates a new random name, so the URL changes
* and browsers can cache images forever.
*
* Deleting is idempotent: a missing file is fine. The database is the source of truth; files left
* behind by a crash are removed by `bin/cake images_cleanup`.
*/
class ImageService
{
/**
* Source formats that are accepted (animated GIFs are not, see assertNotAnimated()).
*
* @var array<int, string>
*/
protected const TYPES = [
IMAGETYPE_JPEG => 'jpeg',
IMAGETYPE_PNG => 'png',
IMAGETYPE_GIF => 'gif',
IMAGETYPE_WEBP => 'webp',
];
/**
* Decoded pixels, to keep the memory use of the decoder in check (a bitmap needs 4 bytes per pixel).
*/
protected const MAX_PIXELS = 40_000_000;
/**
* Whether the PHP installation can process images (GD with WebP).
*
* @return bool
*/
public static function isAvailable(): bool
{
return extension_loaded('gd') && function_exists('imagewebp') && function_exists('imagecreatefromstring');
}
/**
* Whether a stored name has the shape generated by store() (guards file system access).
*
* @param string $name File name
* @return bool
*/
public static function isValidName(string $name): bool
{
return (bool)preg_match('/^[a-f0-9]{24}\.webp$/', $name);
}
/**
* Validates, scales and stores an upload.
*
* @param \Psr\Http\Message\UploadedFileInterface $file Uploaded file
* @param int $pollId Poll the image belongs to
* @return array{name: string, width: int, height: int}
* @throws \App\Service\ImageException If the file cannot be used
*/
public function store(UploadedFileInterface $file, int $pollId): array
{
if (!self::isAvailable()) {
throw new ImageException(__('Auf diesem Server können keine Bilder verarbeitet werden (PHP-Erweiterung GD mit WebP fehlt).'));
}
$this->assertUploaded($file);
$bytes = (string)$file->getStream();
$info = @getimagesizefromstring($bytes);
$type = $info === false ? null : (self::TYPES[$info[2]] ?? null);
if ($info === false || $type === null) {
throw new ImageException(__('Bitte wähle ein Bild im Format JPEG, PNG, WebP oder GIF aus.'));
}
if ($info[0] < 1 || $info[1] < 1 || $info[0] * $info[1] > self::MAX_PIXELS) {
throw new ImageException(__('Das Bild hat zu viele Pixel. Bitte wähle ein kleineres Bild (höchstens 40 Megapixel).'));
}
if ($type === 'gif') {
$this->assertNotAnimated($bytes);
}
$image = @imagecreatefromstring($bytes);
if (!$image instanceof GdImage) {
throw new ImageException(__('Das Bild konnte nicht gelesen werden. Ist die Datei beschädigt?'));
}
if ($type === 'jpeg') {
$image = $this->orient($image, self::jpegOrientation($bytes));
}
$image = $this->scale($image, (int)Configure::read('Plenario.images.maxEdge', 1600));
$name = bin2hex(random_bytes(12)) . '.webp';
$directory = $this->directory($pollId);
if (!is_dir($directory) && !@mkdir($directory, 0775, true) && !is_dir($directory)) {
throw new ImageException(__('Das Bild konnte nicht gespeichert werden (Upload-Verzeichnis nicht beschreibbar).'));
}
// Write under a temporary name first: a half written file must never be served.
$temporary = $directory . DS . $name . '.tmp';
$written = @imagewebp($image, $temporary, (int)Configure::read('Plenario.images.quality', 82));
$width = imagesx($image);
$height = imagesy($image);
if (!$written || !@rename($temporary, $directory . DS . $name)) {
@unlink($temporary);
throw new ImageException(__('Das Bild konnte nicht gespeichert werden.'));
}
return ['name' => $name, 'width' => $width, 'height' => $height];
}
/**
* Copies a stored image (duplicated slides get their own file, so deleting one never affects the other).
*
* @param int $pollId Poll id that receives the copy
* @param string $name Source file name
* @param int|null $sourcePollId Poll id of the source file (default: the same poll)
* @return string|null Name of the copy, null if the source file is gone or the copy failed
*/
public function copy(int $pollId, string $name, ?int $sourcePollId = null): ?string
{
$source = $this->path($sourcePollId ?? $pollId, $name);
if ($source === null) {
return null;
}
$directory = $this->directory($pollId);
if (!is_dir($directory) && !@mkdir($directory, 0775, true) && !is_dir($directory)) {
return null;
}
$copy = bin2hex(random_bytes(12)) . '.webp';
return @copy($source, $directory . DS . $copy) ? $copy : null;
}
/**
* Absolute path of a stored image, null if the name is invalid or the file does not exist.
*
* @param int $pollId Poll id
* @param string $name File name
* @return string|null
*/
public function path(int $pollId, string $name): ?string
{
if (!self::isValidName($name)) {
return null;
}
$path = $this->directory($pollId) . DS . $name;
return is_file($path) ? $path : null;
}
/**
* Deletes one image file. Idempotent, ignores unknown names and missing files.
*
* @param int $pollId Poll id
* @param string|null $name File name
* @return void
*/
public function delete(int $pollId, ?string $name): void
{
if ($name === null || !self::isValidName($name)) {
return;
}
@unlink($this->directory($pollId) . DS . $name);
}
/**
* Deletes all images of a poll (and its directory).
*
* @param int $pollId Poll id
* @return void
*/
public function deletePoll(int $pollId): void
{
$directory = $this->directory($pollId);
foreach (glob($directory . DS . '*') ?: [] as $file) {
if (is_file($file)) {
@unlink($file);
}
}
@rmdir($directory);
}
/**
* Removes files that no slide refers to (left behind by aborted uploads, crashes or deleted polls).
*
* @param array<int, list<string>> $referenced Used file names per poll id
* @param bool $dryRun Only report, delete nothing
* @return list<string> Removed paths relative to the upload directory
*/
public function cleanup(array $referenced, bool $dryRun = false): array
{
$removed = [];
$root = $this->root();
foreach (glob($root . DS . '*', GLOB_ONLYDIR) ?: [] as $directory) {
$pollId = basename($directory);
if (!ctype_digit($pollId)) {
continue;
}
$used = $referenced[(int)$pollId] ?? [];
foreach (glob($directory . DS . '*') ?: [] as $file) {
if (is_file($file) && !in_array(basename($file), $used, true)) {
if (!$dryRun) {
@unlink($file);
}
$removed[] = $pollId . '/' . basename($file);
}
}
if (!$dryRun) {
// Only succeeds for an empty directory.
@rmdir($directory);
}
}
return $removed;
}
/**
* @return string Upload root directory
*/
protected function root(): string
{
return rtrim((string)Configure::read('Plenario.images.path'), '/\\');
}
/**
* @param int $pollId Poll id
* @return string
*/
protected function directory(int $pollId): string
{
return $this->root() . DS . $pollId;
}
/**
* @param \Psr\Http\Message\UploadedFileInterface $file Uploaded file
* @return void
*/
protected function assertUploaded(UploadedFileInterface $file): void
{
switch ($file->getError()) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new ImageException(__(
'Die Datei ist größer, als der Server erlaubt ({0}). Bitte wähle ein kleineres Bild.',
(string)ini_get('upload_max_filesize'),
));
default:
throw new ImageException(__('Das Bild konnte nicht hochgeladen werden. Bitte versuche es noch einmal.'));
}
$max = (int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024);
if (($file->getSize() ?? 0) > $max) {
throw new ImageException(__('Das Bild ist zu groß (höchstens {0} MB).', (int)round($max / 1024 / 1024)));
}
if (($file->getSize() ?? 0) === 0) {
throw new ImageException(__('Die Datei ist leer.'));
}
}
/**
* GD cannot keep animations, so an animated GIF would silently become a still image.
*
* @param string $bytes GIF file
* @return void
*/
protected function assertNotAnimated(string $bytes): void
{
// Every frame starts with a graphic control extension followed by an image descriptor.
if (preg_match_all('/\x21\xF9\x04.{4}\x00[\x2C\x21]/s', $bytes) > 1) {
throw new ImageException(__('Animierte GIFs werden nicht unterstützt. Bitte wähle ein Standbild (JPEG, PNG oder WebP).'));
}
}
/**
* Rotates/flips a decoded image according to the EXIF orientation (1-8).
*
* @param \GdImage $image Image
* @param int $orientation EXIF orientation
* @return \GdImage
*/
protected function orient(GdImage $image, int $orientation): GdImage
{
// GD rotates counter-clockwise, EXIF names the rotation that is needed to display it upright.
// 5 and 7 are mirrored first (flip, then rotate), 2 and 4 are plain mirrors.
$angle = [3 => 180, 4 => 180, 5 => 90, 6 => 270, 7 => 270, 8 => 90][$orientation] ?? 0;
$mirror = in_array($orientation, [2, 4, 5, 7], true);
if ($mirror) {
imageflip($image, IMG_FLIP_HORIZONTAL);
}
if ($angle !== 0) {
$rotated = imagerotate($image, $angle, 0);
if ($rotated instanceof GdImage) {
return $rotated;
}
}
return $image;
}
/**
* Scales an image down so that its longer edge is at most `$maxEdge` pixels (never up).
* The result is a true color image with alpha channel, ready for WebP.
*
* @param \GdImage $image Image
* @param int $maxEdge Longest edge in pixels
* @return \GdImage
*/
protected function scale(GdImage $image, int $maxEdge): GdImage
{
imagepalettetotruecolor($image);
imagealphablending($image, false);
imagesavealpha($image, true);
$width = imagesx($image);
$height = imagesy($image);
$longest = max($width, $height);
if ($longest <= $maxEdge) {
return $image;
}
$factor = $maxEdge / $longest;
$scaled = imagescale($image, max(1, (int)round($width * $factor)), max(1, (int)round($height * $factor)), IMG_BICUBIC);
if (!$scaled instanceof GdImage) {
return $image;
}
imagealphablending($scaled, false);
imagesavealpha($scaled, true);
return $scaled;
}
/**
* Reads the EXIF orientation of a JPEG without the exif extension (it is not always installed).
*
* @param string $bytes JPEG file
* @return int Orientation 1-8, 1 = upright/unknown
*/
public static function jpegOrientation(string $bytes): int
{
$length = strlen($bytes);
$offset = 2;
// Walk the marker segments until the one holding the Exif data (APP1).
while ($offset + 4 <= $length && $bytes[$offset] === "\xFF") {
$marker = ord($bytes[$offset + 1]);
if ($marker === 0xDA || $marker === 0xD9) {
break;
}
$size = unpack('n', substr($bytes, $offset + 2, 2))[1] ?? 0;
if ($marker === 0xE1 && substr($bytes, $offset + 4, 6) === "Exif\0\0") {
return self::tiffOrientation(substr($bytes, $offset + 10, max(0, $size - 8)));
}
$offset += 2 + $size;
}
return 1;
}
/**
* @param string $tiff TIFF structure of the Exif segment
* @return int Orientation 1-8
*/
protected static function tiffOrientation(string $tiff): int
{
if (strlen($tiff) < 14) {
return 1;
}
$little = substr($tiff, 0, 2) === 'II';
$short = $little ? 'v' : 'n';
$long = $little ? 'V' : 'N';
$first = unpack($long, substr($tiff, 4, 4))[1] ?? 0;
if ($first < 8 || $first + 2 > strlen($tiff)) {
return 1;
}
$entries = unpack($short, substr($tiff, $first, 2))[1] ?? 0;
for ($i = 0; $i < $entries; $i++) {
$entry = $first + 2 + $i * 12;
if ($entry + 12 > strlen($tiff)) {
break;
}
if ((unpack($short, substr($tiff, $entry, 2))[1] ?? 0) === 0x0112) {
$value = unpack($short, substr($tiff, $entry + 8, 2))[1] ?? 1;
return $value >= 1 && $value <= 8 ? $value : 1;
}
}
return 1;
}
}
+91 -8
View File
@@ -9,6 +9,7 @@ use App\Model\Table\PollsTable;
use App\Model\Table\ResponsesTable;
use App\Model\Table\SlidesTable;
use Cake\ORM\Locator\LocatorAwareTrait;
use Cake\Routing\Router;
/**
* Builds the JSON state polled by the presenter screen (/admin/{token}/state)
@@ -56,6 +57,33 @@ class PollStateService
$this->results = new ResultsService();
}
/**
* Cheap fingerprint of everything the admin dashboard shows (live/paused slide, slide settings
* and status, answer counts). The dashboard polls it and reloads its lists when it changes.
*
* @param \App\Model\Entity\Poll $poll Poll
* @return string
*/
public function dashboardVersion(Poll $poll): string
{
$slides = $this->Slides->find()
->select([
'n' => $this->Slides->find()->func()->count('*'),
'latest' => $this->Slides->find()->func()->max('modified'),
])
->where(['poll_id' => $poll->id])
->disableHydration()
->first();
return md5(json_encode([
(int)$poll->is_active,
$poll->current_slide_id,
$poll->paused_slide_id,
$slides,
$this->Responses->countParticipantsPerSlide($poll->id),
], JSON_THROW_ON_ERROR));
}
/**
* @param \App\Model\Entity\Poll $poll Poll
* @return \App\Model\Entity\Slide|null
@@ -103,9 +131,48 @@ class PollStateService
], $slides),
'index' => $index,
'count' => count($slides),
'next' => $this->nextPreview($poll, $slides, $index),
'hiddenCount' => $this->Slides->find()->where(['poll_id' => $poll->id, 'is_hidden' => true])->count(),
'slide' => $current ? $this->slidePayload($current) : null,
'results' => $current ? $this->results->forSlide($current) : null,
'slide' => $current ? $this->slidePayload($current, $poll) : null,
'results' => $current ? $this->results->forStage($current) : null,
];
}
/**
* Preview of the slide that comes next for the speaker view: the one behind the live slide, the
* paused one while paused (that is where "continue" goes), the first one before the start.
* Labels only: never `is_correct` and never the options of an order slide (they are stored in the
* correct order), so nothing leaks that is not allowed in the JSON before the slide is resolved.
*
* @param \App\Model\Entity\Poll $poll Poll
* @param list<\App\Model\Entity\Slide> $slides Visible slides in presentation order
* @param int|null $index Index of the live slide in `$slides`
* @return array<string, mixed>|null Null after the last slide
*/
private function nextPreview(Poll $poll, array $slides, ?int $index): ?array
{
if ($index !== null) {
$next = $slides[$index + 1] ?? null;
} else {
$next = $slides[0] ?? null;
foreach ($slides as $slide) {
if ($poll->paused_slide_id !== null && $slide->id === $poll->paused_slide_id) {
$next = $slide;
}
}
}
if ($next === null) {
return null;
}
return [
'id' => $next->id,
'type' => $next->type,
'typeLabel' => $next->typeLabel(),
'question' => $next->question,
'description' => (string)$next->description,
'options' => $next->isOrder() ? [] : array_map(fn($o) => $o->label, $next->slide_options ?? []),
'hasImage' => $next->hasImage(),
];
}
@@ -128,8 +195,8 @@ class PollStateService
'isHidden' => $slide->is_hidden,
'index' => null,
'count' => null,
'slide' => $this->slidePayload($slide),
'results' => $this->results->forSlide($slide),
'slide' => $this->slidePayload($slide, $poll),
'results' => $this->results->forStage($slide),
];
}
@@ -181,8 +248,10 @@ class PollStateService
$words !== null || $qa !== null ? 0 : (int)$hasResponded,
$slide?->modified?->toUnixString() ?? 0,
]),
'slide' => $showResults ? $this->slidePayload($slide) : null,
'slide' => $showResults ? $this->slidePayload($slide, $poll) : null,
'results' => $showResults ? $this->participantResults($slide) : null,
// Countdown of a slide that is not a quiz (a quiz has its own state below)
'timer' => $slide !== null && !$slide->isQuiz() && $slide->usesPhases() ? $this->results->timer($slide) : null,
'words' => $words,
'quiz' => $quiz,
'qa' => $qa,
@@ -217,7 +286,7 @@ class PollStateService
*
* @param \App\Model\Entity\Slide $slide Ordering slide incl. slide_options
* @param string $participantHash Participant hash
* @return array{revealed: bool, answer: list<int>|null, isCorrect: bool|null}
* @return array{ranking: bool, revealed: bool, answer: list<int>|null, isCorrect: bool|null}
*/
public function orderState(Slide $slide, string $participantHash): array
{
@@ -233,6 +302,7 @@ class PollStateService
$correct = $slide->optionIds();
return [
'ranking' => $slide->isRanking(),
'revealed' => $revealed,
'answer' => $answer,
'isCorrect' => $answer === null ? null : $answer === $correct,
@@ -354,7 +424,7 @@ class PollStateService
* Poll part of the presenter and embed state.
*
* @param \App\Model\Entity\Poll $poll Poll
* @return array{title: string, joinCode: string, joinCodeFormatted: string, isActive: bool, isPaused: bool}
* @return array{title: string, joinCode: string, joinCodeFormatted: string, isActive: bool, isPaused: bool, commentSpeed: float|int, audioUrl: string|null}
*/
protected function pollPayload(Poll $poll): array
{
@@ -366,14 +436,19 @@ class PollStateService
'isPaused' => $poll->isPaused(),
// Factor for the rotating scale comments on stage (1 = normal, 2 = twice as fast)
'commentSpeed' => ($poll->comment_speed ?? 100) / 100,
// Music for quiz countdowns: looped by the presenter view while a quiz runs (participants never play it)
'audioUrl' => $poll->hasAudio()
? Router::url(['_name' => 'participate:audio', 'code' => $poll->join_code, 'file' => $poll->audio])
: null,
];
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* @param \App\Model\Entity\Poll $poll Poll of the slide (the image URL contains its join code)
* @return array<string, mixed>
*/
public function slidePayload(Slide $slide): array
public function slidePayload(Slide $slide, Poll $poll): array
{
return [
'id' => $slide->id,
@@ -388,6 +463,14 @@ class PollStateService
'embedUrl' => $slide->youtubeEmbedUrl(),
'watchUrl' => $slide->youtubeWatchUrl(),
] : null,
// Image of the slide: URL (random file name), alternative text ('' = decorative), layout (top|side|full)
'image' => $slide->hasImage() ? [
'url' => Router::url(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image]),
'alt' => (string)$slide->image_alt,
'layout' => $slide->imageLayout(),
'width' => $slide->image_width,
'height' => $slide->image_height,
] : null,
];
}
}
+92
View File
@@ -27,6 +27,9 @@ class QaService
{
use LocatorAwareTrait;
/** Maximum number of questions the admin can prepare per slide. */
public const MAX_PREPARED = 50;
protected SlidesTable $Slides;
protected ResponsesTable $Responses;
@@ -44,6 +47,95 @@ class QaService
$this->Responses = $responses;
}
/**
* Texts of the questions the admin entered beforehand, in entry order.
*
* @param \App\Model\Entity\Slide $slide Q&A slide
* @return list<string>
*/
public function preparedQuestions(Slide $slide): array
{
$rows = $this->Responses->questionsOf($slide->id)
->select(['text_value'])
->where(['Responses.participant_hash' => VoteService::PREPARED_HASH])
->orderBy(['Responses.id' => 'ASC'])
->disableHydration()
->all();
return array_values(array_map(fn($row) => (string)$row['text_value'], $rows->toArray()));
}
/**
* Textarea (one question per line) into clean question texts: whitespace collapsed,
* cut to the maximum length, duplicates (case-insensitive) and empty lines dropped.
*
* @param string $raw Textarea content
* @return list<string>
*/
public static function parsePrepared(string $raw): array
{
$texts = [];
foreach (preg_split('/\R/', $raw) ?: [] as $line) {
$text = mb_substr(trim((string)preg_replace('/\s+/u', ' ', $line)), 0, VoteService::MAX_TEXT_LENGTH);
if ($text !== '') {
$texts[mb_strtolower($text)] ??= $text;
}
}
return array_slice(array_values($texts), 0, self::MAX_PREPARED);
}
/**
* Makes the prepared questions of a slide match `$texts`: unchanged ones keep their id, removed
* ones disappear (with leftover upvotes), new ones are added. Questions already asked by
* participants are not added twice. Only allowed while collecting: later, upvotes and the
* discussion hang on the existing questions. Idempotent.
*
* @param \App\Model\Entity\Slide $slide Q&A slide
* @param list<string> $texts Clean texts, see parsePrepared()
* @return void
*/
public function syncPrepared(Slide $slide, array $texts): void
{
if ($slide->qaStage() !== Slide::QA_COLLECT) {
return;
}
$wanted = [];
foreach ($texts as $text) {
$wanted[mb_strtolower($text)] = $text;
}
$existing = [];
$rows = $this->Responses->questionsOf($slide->id)
->select(['id', 'text_value', 'participant_hash'])
->orderBy(['Responses.id' => 'ASC'])
->disableHydration()
->all();
foreach ($rows as $row) {
$key = mb_strtolower((string)$row['text_value']);
if ($row['participant_hash'] !== VoteService::PREPARED_HASH) {
// Asked by a participant already.
unset($wanted[$key]);
continue;
}
if (isset($wanted[$key]) && !isset($existing[$key])) {
$existing[$key] = true;
unset($wanted[$key]);
continue;
}
$this->Responses->deleteAll(['slide_id' => $slide->id, 'parent_id' => $row['id']]);
$this->Responses->deleteAll(['id' => $row['id']]);
}
foreach ($wanted as $text) {
$this->Responses->saveOrFail($this->Responses->newEntity([
'slide_id' => $slide->id,
'participant_hash' => VoteService::PREPARED_HASH,
'text_value' => $text,
]));
}
}
/**
* Questions of a slide, most upvoted first (ties: oldest first).
*
+32 -23
View File
@@ -10,9 +10,9 @@ use App\Model\Table\SlidesTable;
use Cake\ORM\Locator\LocatorAwareTrait;
/**
* Deletes responses of a slide or of the whole poll. Everything else (slides, settings,
* the presentation's current slide) stays; only quiz and Q&A slides go back to their
* start, since their phases make no sense without answers.
* Deletes responses of a slide or of the whole poll. Everything else (slides, settings) stays;
* every slide goes back to the state of a new one (Slide::startFresh()),
* and resetting the poll puts the presentation back to "not started".
* Idempotent: resetting twice gives the same result.
*/
class ResetService
@@ -37,44 +37,53 @@ class ResetService
}
/**
* Deletes all responses of a slide. A quiz goes back to "not started"
* (so it can be played again), a Q&A slide back to collecting questions.
* Deletes all responses of a slide and puts it back to the state of a new slide: a quiz is
* "not started" (so it can be played again), a Q&A slide collects questions, all others are open.
*
* Questions the admin entered beforehand (Q&A) are kept unless $keepPrepared is false;
* only the upvotes on them are removed.
*
* @param \App\Model\Entity\Slide $slide Slide
* @param bool $keepPrepared Keep prepared Q&A questions
* @return void
*/
public function slide(Slide $slide): void
public function slide(Slide $slide, bool $keepPrepared = true): void
{
$this->Slides->getConnection()->transactional(function () use ($slide): void {
$this->Responses->deleteAll(['slide_id' => $slide->id]);
if ($slide->isQa()) {
(new QaService())->reset($slide);
return;
}
if ($slide->isQuiz()) {
$slide->is_voting_open = false;
$slide->voting_started_at = null;
$slide->voting_ends_at = null;
$this->Slides->saveOrFail($slide);
$this->Slides->getConnection()->transactional(function () use ($slide, $keepPrepared): void {
$conditions = ['slide_id' => $slide->id];
if ($keepPrepared) {
$conditions['participant_hash !='] = VoteService::PREPARED_HASH;
}
$this->Responses->deleteAll($conditions);
// Back to the state of a new slide: quiz ready, Q&A collecting, everything else open.
$slide->startFresh();
$this->Slides->saveOrFail($slide);
});
}
/**
* Deletes the responses of all slides of the poll (see slide()).
* The presentation stays where it is.
* Deletes the responses of all slides of the poll (see slide()) and puts the
* presentation back to "not started" (no live and no paused slide). Idempotent.
*
* @param \App\Model\Entity\Poll $poll Poll
* @param bool $keepPrepared Keep prepared Q&A questions
* @return void
*/
public function poll(Poll $poll): void
public function poll(Poll $poll, bool $keepPrepared = true): void
{
$this->Slides->getConnection()->transactional(function () use ($poll): void {
$this->Slides->getConnection()->transactional(function () use ($poll, $keepPrepared): void {
foreach ($this->Slides->find()->where(['poll_id' => $poll->id])->all() as $slide) {
/** @var \App\Model\Entity\Slide $slide */
$this->slide($slide);
$this->slide($slide, $keepPrepared);
}
if ($poll->current_slide_id === null && $poll->paused_slide_id === null) {
return;
}
$poll->notStarted();
/** @var \App\Model\Table\PollsTable $polls */
$polls = $this->fetchTable('Polls');
$polls->saveOrFail($poll);
});
}
}
+144 -11
View File
@@ -12,13 +12,16 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* rendered by webroot/js/plenario.js (presenter + participant views).
*
* Shape (always present): ['type' => string, 'participants' => int, ...]
* - choice: 'options' => [['id', 'label', 'count', 'percent']]
* - choice: 'options' => [['id', 'label', 'count', 'percent']], 'votes' (int),
* 'comments' => [['id', 'text', 'value' (always null)]] oldest first (only with the comment
* field, else []; presentation only, participants never get results of choice slides)
* - wordcloud: 'words' => [['key' (lower case), 'text', 'count', 'down', 'weight' (0..1)]]
* (count = participants who named or upvoted the word, down = downvotes,
* weight follows count)
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1);
* 'commentOnly' (int: participants who sent only a comment without a rating, not part of buckets/average);
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
* 'value' is null unless the setting comment_ratings is on;
* 'view' (both|average|chart): parts shown in the presentation (setting scale_view,
@@ -76,9 +79,12 @@ class ResultsService
'type' => $slide->type,
'participants' => $slide->isInteractive() ? $this->Responses->countParticipants($slide->id) : 0,
];
if ($slide->usesPhases()) {
$result['timer'] = $this->timer($slide);
}
return $result + match ($slide->type) {
Slide::TYPE_CHOICE => $this->choice($slide),
Slide::TYPE_CHOICE => $this->choice($slide, $limit),
Slide::TYPE_WORDCLOUD => $this->wordcloud($slide),
Slide::TYPE_OPEN => $this->open($slide, $limit),
Slide::TYPE_SCALE => $this->scale($slide, $limit, $withRatings),
@@ -89,12 +95,54 @@ class ResultsService
};
}
/**
* Results for the stage (presenter view and embed). A slide with a countdown that has not been started yet
* shows only its question: no answers, no counts, no solution (`ready`), whatever is stored for it.
* The evaluation (admin, PDF) uses forSlide(), which is never gated.
*
* @param \App\Model\Entity\Slide $slide Slide
* @return array<string, mixed>
*/
public function forStage(Slide $slide): array
{
if ($slide->phase() === Slide::QUIZ_READY && !$slide->isQuiz()) {
return [
'type' => $slide->type,
'participants' => 0,
'ready' => true,
'timer' => $this->timer($slide),
];
}
return $this->forSlide($slide);
}
/**
* Countdown of a slide: phase (ready|running|finished), the limit and the seconds left while running.
*
* @param \App\Model\Entity\Slide $slide Slide with a countdown
* @return array{phase: string|null, timeLimit: int, remaining: int|null}
*/
public function timer(Slide $slide): array
{
$phase = $slide->phase();
return [
'phase' => $phase,
'timeLimit' => (int)$slide->setting('time_limit'),
'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null,
];
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* @return array<string, mixed>
*/
protected function order(Slide $slide): array
{
if ($slide->isRanking()) {
return $this->ranking($slide);
}
if (!$slide->isOrderRevealed()) {
return [
'revealed' => false,
@@ -140,10 +188,73 @@ class ResultsService
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* Personal ranking (no correct order): items by average position over all submitted orders,
* live while voting is open. `score` is 100 for a unanimous first place and 0 for a unanimous last place.
*
* @param \App\Model\Entity\Slide $slide Ordering slide with ranking setting
* @return array<string, mixed>
*/
protected function choice(Slide $slide): array
protected function ranking(Slide $slide): array
{
$options = array_values($slide->slide_options ?? []);
$sums = array_fill_keys($slide->optionIds(), 0);
$total = 0;
$answers = $this->Responses->find()
->select(['text_value'])
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null])
->disableHydration()
->all();
foreach ($answers as $row) {
$given = VoteService::parseOrder($row['text_value']);
if (count($given) !== count($sums)) {
continue;
}
$total++;
foreach ($given as $index => $id) {
if (isset($sums[$id])) {
$sums[$id] += $index + 1;
}
}
}
if ($total === 0) {
// Nobody has ranked yet: the entries in a neutral (shuffled) order, so the order of entry says nothing.
$items = array_map(fn($option) => [
'id' => $option->id,
'label' => $option->label,
'average' => null,
'score' => 0,
], $slide->shuffledOptions('slide:' . $slide->id));
return ['ranking' => true, 'revealed' => false, 'items' => $items];
}
$count = count($options);
$items = [];
foreach ($options as $option) {
$average = $sums[$option->id] / $total;
$items[] = [
'id' => $option->id,
'label' => $option->label,
'average' => round($average, 2),
'score' => $count < 2 ? 100 : round(($count - $average) / ($count - 1) * 100, 1),
];
}
// Best average first; usort is stable, so ties keep the order of the entries.
usort($items, fn($a, $b) => $a['average'] <=> $b['average']);
foreach ($items as $i => $item) {
$items[$i]['position'] = $i + 1;
}
return ['ranking' => true, 'revealed' => false, 'items' => $items];
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* @param int|null $limit Max. comments (newest), null = all
* @return array<string, mixed>
*/
protected function choice(Slide $slide, ?int $limit = null): array
{
$counts = $this->Responses->find()
->select(['slide_option_id', 'n' => $this->Responses->find()->func()->count('*')])
@@ -166,7 +277,16 @@ class ResultsService
];
}
return ['options' => $options, 'votes' => $total];
$comments = [];
foreach ($slide->hasComments() ? $this->comments($slide, $limit) : [] as $comment) {
// No option next to the comment: with several choices it would only be a guess anyway.
$comments[] = ['id' => $comment['id'], 'text' => $comment['text'], 'value' => null];
}
// Comment only: taking part without a selection, not part of the counts
$commentOnly = $this->Responses->find()->where(['slide_id' => $slide->id, 'slide_option_id IS' => null])->count();
return ['options' => $options, 'votes' => $total, 'comments' => $comments, 'commentOnly' => $commentOnly];
}
/**
@@ -182,6 +302,12 @@ class ResultsService
'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null,
'revealed' => $phase === Slide::QUIZ_FINISHED,
];
if ($phase === Slide::QUIZ_READY) {
// Answers are only shown once the quiz has been started.
$result['options'] = [];
return $result;
}
if ($phase !== Slide::QUIZ_FINISHED) {
$result['options'] = array_map(fn($option) => [
'id' => $option->id,
@@ -364,6 +490,7 @@ class ResultsService
if (isset($results['buckets'])) {
$results['buckets'] = [];
$results['average'] = null;
$results['commentOnly'] = 0;
$results['comments'] = [];
}
@@ -371,18 +498,20 @@ class ResultsService
}
/**
* Comments of a scale with their rating, oldest first; the unfiltered call
* Comments of a scale with their rating (choice: without value), oldest first; the unfiltered call
* (ratings regardless of comment_ratings) is only for the admin area.
*
* @param \App\Model\Entity\Slide $slide Scale slide
* @param \App\Model\Entity\Slide $slide Scale or choice slide
* @param int|null $limit Max. comments (the newest ones), null = all
* @return list<array{id: int, text: string, value: int, created: string}>
* @return list<array{id: int, text: string, value: int|null, created: string}>
*/
public function comments(Slide $slide, ?int $limit = null): array
{
// Scale: the rating row carries the comment. Choice: the comment sits in the first of the
// participant's rows. Without a rating or selection the row holds only the comment.
$query = $this->Responses->find()
->select(['id', 'text_value', 'numeric_value', 'created'])
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null, 'numeric_value IS NOT' => null])
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null])
->orderBy(['id' => 'DESC']);
if ($limit !== null) {
$query->limit($limit);
@@ -393,7 +522,7 @@ class ResultsService
$comments[] = [
'id' => (int)$row->id,
'text' => (string)$row->text_value,
'value' => (int)$row->numeric_value,
'value' => $row->numeric_value === null ? null : (int)$row->numeric_value,
'created' => $row->created->toIso8601String(),
];
}
@@ -405,7 +534,7 @@ class ResultsService
* Distribution and average of a scale.
*
* @param \App\Model\Entity\Slide $slide Scale slide
* @return array{buckets: list<array{value: int, count: int, percent: float|int}>, average: float|null, min: int, max: int, minLabel: string, maxLabel: string, stars: bool}
* @return array{buckets: list<array{value: int, count: int, percent: float|int}>, average: float|null, min: int, max: int, minLabel: string, maxLabel: string, stars: bool, commentOnly: int}
*/
public function scaleResults(Slide $slide): array
{
@@ -420,6 +549,9 @@ class ResultsService
->combine('numeric_value', 'n')
->toArray();
// Comment only: taking part without a rating, never part of the average or the distribution
$commentOnly = $this->Responses->find()->where(['slide_id' => $slide->id, 'numeric_value IS' => null])->count();
$total = 0;
$sum = 0;
foreach ($counts as $value => $count) {
@@ -444,6 +576,7 @@ class ResultsService
'minLabel' => (string)$slide->setting('min_label'),
'maxLabel' => (string)$slide->setting('max_label'),
'stars' => $slide->isStarRating(),
'commentOnly' => $commentOnly,
];
}
}
+59 -9
View File
@@ -49,6 +49,12 @@ class VoteService
public const MAX_TEXT_LENGTH = 500;
public const MAX_QA_QUESTIONS = 10;
/**
* participant_hash of questions entered by the admin beforehand (e.g. received by mail).
* Not a hex HMAC, so no participant can ever own, edit or delete them.
*/
public const PREPARED_HASH = 'prepared';
/**
* Word cloud: terms per request and terms a participant may name or upvote per slide.
*/
@@ -130,20 +136,20 @@ class VoteService
/**
* Whether the participant may change the text of their answer afterwards (e.g. to fix a typo):
* the answer of an open question and the comment of a scale with comment field.
* the answer of an open question and the comment of a choice or scale slide with comment field.
*
* @param \App\Model\Entity\Slide $slide Slide
* @return bool
*/
public static function hasEditableText(Slide $slide): bool
{
return $slide->type === Slide::TYPE_OPEN || ($slide->type === Slide::TYPE_SCALE && $slide->hasComments());
return $slide->type === Slide::TYPE_OPEN || $slide->hasComments();
}
/**
* Replaces the text of the participant's own answer as long as voting on the slide is open
* (see hasEditableText()). Open question: `text`, must not be empty. Scale: `comment`, the
* rating itself stays unchanged and an empty comment removes it. Same preconditions as submit().
* (see hasEditableText()). Open question: `text`, must not be empty. Choice/scale: `comment`, the
* selection or rating itself stays unchanged and an empty comment removes it. Same preconditions as submit().
*
* @param \App\Model\Entity\Poll $poll Poll
* @param \App\Model\Entity\Slide $slide Slide
@@ -161,13 +167,26 @@ class VoteService
$text = $slide->type === Slide::TYPE_OPEN ? $this->openRows($data)[0]['text_value'] : self::comment($data);
$this->Responses->getConnection()->transactional(function () use ($slide, $participantHash, $text): void {
$this->lockSlide($slide);
// A multiple choice answer has several rows; the comment always lives in the first one.
$row = $this->Responses->find()
->where(['slide_id' => $slide->id, 'participant_hash' => $participantHash])
->orderBy(['id' => 'ASC'])
->first();
if ($row === null) {
throw new VoteException($slide->type === Slide::TYPE_OPEN
? __('Du hast hier noch nicht geantwortet.')
: __('Bitte gib zuerst deine Bewertung ab.'));
throw new VoteException(match ($slide->type) {
Slide::TYPE_OPEN => __('Du hast hier noch nicht geantwortet.'),
Slide::TYPE_CHOICE => __('Bitte gib zuerst deine Auswahl ab.'),
default => __('Bitte gib zuerst deine Bewertung ab.'),
});
}
$withoutAnswer = match ($slide->type) {
Slide::TYPE_SCALE => $row->numeric_value === null,
Slide::TYPE_CHOICE => $row->slide_option_id === null,
default => false,
};
if ($withoutAnswer && $text === null) {
// Without a rating or selection the comment is the whole answer.
throw new VoteException(__('Ohne Bewertung oder Auswahl darf der Kommentar nicht leer sein.'));
}
$row->text_value = $text;
$this->Responses->saveOrFail($row);
@@ -175,7 +194,7 @@ class VoteService
}
/**
* Text of the participant's own answer: open answer or scale comment (null: none or not answered yet).
* Text of the participant's own answer: open answer or choice/scale comment (null: none or not answered yet).
*
* @param \App\Model\Entity\Slide $slide Slide
* @param string $participantHash Participant hash
@@ -186,6 +205,7 @@ class VoteService
$row = $this->Responses->find()
->select(['text_value'])
->where(['slide_id' => $slide->id, 'participant_hash' => $participantHash])
->orderBy(['id' => 'ASC'])
->disableHydration()
->first();
@@ -215,6 +235,8 @@ class VoteService
throw new VoteException(match (true) {
$slide->isQuiz() && $slide->voting_started_at === null => __('Das Quiz hat noch nicht begonnen.'),
$slide->isQuiz() => __('Die Zeit für dieses Quiz ist abgelaufen.'),
$slide->usesPhases() && $slide->voting_started_at === null => __('Die Abstimmung hat noch nicht begonnen.'),
$slide->usesPhases() => __('Die Zeit für diese Frage ist abgelaufen.'),
$slide->isQa() => __('Die Fragerunde läuft – Fragen und Stimmen sind nicht mehr möglich.'),
default => __('Die Abstimmung zu dieser Frage ist geschlossen.'),
});
@@ -268,6 +290,15 @@ class VoteService
$validIds = $slide->optionIds();
$selected = array_values(array_intersect($selected, $validIds));
if ($selected === [] && $slide->hasCommentOnly()) {
// Comment only: no selection, but a comment is required (this is not a way to skip).
$comment = self::comment($data);
if ($comment === null) {
throw new VoteException(__('Bitte wähle eine Antwort aus oder schreibe einen Kommentar.'));
}
return [['slide_option_id' => null, 'text_value' => $comment]];
}
if ($selected === []) {
throw new VoteException(__('Bitte wähle eine Antwort aus.'));
}
@@ -275,7 +306,15 @@ class VoteService
throw new VoteException(__('Bitte wähle nur eine Antwort aus.'));
}
return array_map(fn(int $id) => ['slide_option_id' => $id], $selected);
// The optional comment goes into the first row only, so it is stored once per participant;
// counts group by option and ignore text_value.
$comment = $slide->hasComments() ? self::comment($data) : null;
return array_map(
fn(int $id, int $index) => ['slide_option_id' => $id, 'text_value' => $index === 0 ? $comment : null],
$selected,
array_keys($selected),
);
}
/**
@@ -661,6 +700,17 @@ class VoteService
*/
protected function scaleRows(Slide $slide, array $data): array
{
if (self::stringField($data, 'value') === '' && $slide->hasCommentOnly()) {
// Comment only: no rating, but a comment is required (this is not a way to skip).
$comment = self::comment($data);
if ($comment === null) {
throw new VoteException($slide->isStarRating()
? __('Bitte vergib Sterne oder schreibe einen Kommentar.')
: __('Bitte wähle einen Wert oder schreibe einen Kommentar.'));
}
return [['numeric_value' => null, 'text_value' => $comment]];
}
$value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT);
$min = (int)$slide->setting('scale_min');
$max = (int)$slide->setting('scale_max');
+2
View File
@@ -38,5 +38,7 @@ class AppView extends View
public function initialize(): void
{
$this->addHelper('Format');
// No generated oninvalid/oninput handlers: the CSP blocks inline event handlers.
$this->addHelper('Form', ['autoSetCustomValidity' => false]);
}
}
+38 -1
View File
@@ -103,6 +103,21 @@ $bar = function (float $percent, bool $ok = false): string {
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($r['commentOnly'])) : ?>
<p class="muted"><?= __('{0}× nur Kommentar (nicht in den Stimmen)', (int)$r['commentOnly']) ?></p>
<?php endif; ?>
<?php if ($slide->hasComments()) : ?>
<h3><?= __n('{0} Kommentar', '{0} Kommentare', count($r['comments']), count($r['comments'])) ?></h3>
<?php if ($r['comments'] === []) : ?>
<p class="empty"><?= __('Keine Kommentare.') ?></p>
<?php else : ?>
<ol class="list">
<?php foreach ($r['comments'] as $comment) : ?>
<li><?= nl2br(h($comment['text'])) ?></li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php endif; ?>
<?php elseif ($slide->type === 'quiz') : ?>
<?php if (!$r['revealed']) : ?>
@@ -125,7 +140,26 @@ $bar = function (float $percent, bool $ok = false): string {
<?php endif; ?>
<?php elseif ($slide->type === 'order') : ?>
<?php if (!$r['revealed']) : ?>
<?php if (!empty($r['ranking'])) : ?>
<?php if ($participants === 0) : ?>
<p class="empty"><?= __('Noch keine Antworten') ?></p>
<?php else : ?>
<p><span class="stat"><?= (int)$participants ?></span> <?= __('Einschätzungen, sortiert nach durchschnittlichem Platz') ?></p>
<table>
<thead><tr><th class="num"><?= __('Rang') ?></th><th><?= __('Eintrag') ?></th><th class="num"><?= __('Ø Platz') ?></th><th></th></tr></thead>
<tbody>
<?php foreach ($r['items'] as $item) : ?>
<tr>
<td class="num"><?= (int)$item['position'] ?>.</td>
<td><?= h($item['label']) ?></td>
<td class="num"><?= $number((float)$item['average'], 1) ?></td>
<td class="bar"><?= $bar((float)$item['score'], true) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php elseif (!$r['revealed']) : ?>
<p class="empty"><?= __('Die Abstimmung ist noch offen, die Auflösung gibt es erst nach dem Schließen.') ?></p>
<?php else : ?>
<p><span class="stat"><?= __('{0} von {1}', (int)$r['correctCount'], $participants) ?></span> <?= __('komplett richtig sortiert') ?></p>
@@ -174,6 +208,9 @@ $bar = function (float $percent, bool $ok = false): string {
<span class="muted"><?= !empty($r['stars'])
? __('von {0} Sternen', (int)$r['max'])
: __('auf einer Skala von {0} bis {1}', (int)$r['min'], (int)$r['max']) ?></span>
<?php if (!empty($r['commentOnly'])) : ?>
· <span class="muted"><?= __('{0}× nur Kommentar (nicht im Durchschnitt)', (int)$r['commentOnly']) ?></span>
<?php endif; ?>
</p>
<table>
<thead><tr><th><?= !empty($r['stars']) ? __('Sterne') : __('Wert') ?></th><th class="num"><?= __('Anzahl') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead>
+173 -64
View File
@@ -11,12 +11,23 @@
* @var array<string, string> $typeDescriptions
* @var string $joinUrl
* @var string $embedKey
* @var int $pollIntervalMs
*/
$this->assign('title', $poll->title);
$this->assign('noindex', '1');
$url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $adminToken] + $params;
$hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide->isInteractive() && $slide->isPrivate()) !== [];
?>
<?php // Phone/tablet: the sidebar (participation, settings, …) becomes a menu drawer opened from the header, right of the colour scheme switch. ?>
<?php $this->start('headerMenu'); ?>
<button type="button" class="theme-switch menu-toggle" data-drawer-toggle hidden aria-expanded="false" aria-controls="admin-menu"
aria-label="<?= h(__('Menü: Teilnahme, Einstellungen und mehr')) ?>" title="<?= h(__('Menü')) ?>">
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M4 6h16M4 12h16M4 18h16"/>
</svg>
</button>
<?php $this->end(); ?>
<div class="admin-head" data-refresh="head" data-live>
<div>
<p class="eyebrow"><?= __('Verwaltung') ?></p>
@@ -34,8 +45,20 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
</p>
</div>
<div class="admin-head__actions">
<a class="button button--primary" target="_blank" rel="noopener"
href="<?= $this->Url->build($url('admin:present')) ?>">▶ <?= __('Präsentieren') ?></a>
<div class="split">
<a class="button button--primary split__main" target="_blank" rel="noopener"
href="<?= $this->Url->build($url('admin:present')) ?>">▶ <?= __('Präsentieren') ?></a>
<button type="button" class="button button--primary split__toggle" data-menu-toggle aria-haspopup="true" aria-expanded="false"
aria-controls="present-menu" title="<?= h(__('Weitere Ansichten')) ?>">
<span aria-hidden="true">▾</span><span class="sr-only"><?= __('Weitere Ansichten') ?></span>
</button>
<div class="split__menu" id="present-menu" data-menu hidden>
<a class="split__item" target="_blank" rel="noopener" href="<?= $this->Url->build($url('admin:speaker')) ?>">
⧉ <?= __('Referentenansicht') ?>
<small><?= __('Aktuelle und nächste Folie im eigenen Fenster, startet die Präsentation nicht') ?></small>
</a>
</div>
</div>
<?php if ($poll->current_slide_id !== null) : ?>
<?= $this->Form->postButton('⏸ ' . __('Pause'), $url('admin:control'), [
'data' => ['action' => 'stop'],
@@ -52,7 +75,9 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
<?= __('Diese URL ist dein Zugang zur Umfrage. Wer sie kennt, kann alles bearbeiten.') ?>
</div>
<div class="grid grid--sidebar">
<div class="grid grid--sidebar"
data-dashboard-live="<?= $this->Url->build($url('admin:live')) ?>"
data-interval="<?= (int)$pollIntervalMs ?>">
<section>
<div class="section-head">
<h2><?= __('Folien') ?></h2>
@@ -84,6 +109,7 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
<div class="slide-item__meta">
<span class="badge badge--type-<?= h($slide->type) ?>"><?= h($slide->typeLabel()) ?></span>
<?php if ($isCurrent) : ?><span class="badge badge--live"><?= __('live') ?></span><?php endif; ?>
<?php if ($slide->hasImage()) : ?><span class="badge" title="<?= h(__('Die Folie hat ein Bild')) ?>">🖼 <?= __('Bild') ?></span><?php endif; ?>
<?php if ($slide->is_hidden) : ?><span class="badge badge--off" title="<?= __('Wird beim Präsentieren übersprungen und fehlt im PDF-Export') ?>"><?= __('ausgeblendet') ?></span><?php endif; ?>
<?php if ($slide->isInteractive()) : ?>
<span class="muted"><?= __n('{0} Antwort', '{0} Antworten', $count, $count) ?></span>
@@ -93,6 +119,12 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
'running' => __('Quiz läuft'),
'finished' => __('Quiz beendet'),
][$slide->quizPhase()]) ?></span>
<?php elseif ($slide->usesPhases()) : ?>
<span class="muted">· ⏱ <?= __('{0} s', (int)$slide->setting('time_limit')) ?> · <?= h([
'ready' => __('noch nicht gestartet'),
'running' => __('Countdown läuft'),
'finished' => __('beendet'),
][$slide->phase()]) ?></span>
<?php elseif ($slide->isQa()) : ?>
<span class="muted">· <?= h([
'collect' => __('Fragen sammeln'),
@@ -102,6 +134,8 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
$perQuestion = (int)$slide->setting('max_upvotes_per_question'); ?>
<?= __('Stimmen für {0} % der Fragen pro Person', (int)$slide->setting('upvote_share')) ?><?= $perQuestion > 0 ? ' · ' . __n('{0} pro Frage', '{0} pro Frage', $perQuestion, $perQuestion) : '' ?><?= $slide->setting('allow_self_upvote') ? ' · ' . __('auch für eigene Fragen') : '' ?>
<?php endif; ?></span>
<?php elseif ($slide->isRanking()) : ?>
<span class="muted">· <?= $slide->is_voting_open ? __('Eigene Einschätzung') : __('Eigene Einschätzung, Abstimmung geschlossen') ?></span>
<?php elseif ($slide->isOrder() && !$slide->is_voting_open) : ?>
<span class="muted">· <?= __('Abstimmung geschlossen, aufgelöst') ?></span>
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
@@ -118,7 +152,7 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
$slide->slide_options,
))) ?></p>
<?php elseif ($slide->isOrder() && $slide->slide_options) : ?>
<p class="slide-item__options muted"><?= h(implode(' → ', array_map(
<p class="slide-item__options muted"><?= h(implode($slide->isRanking() ? ' · ' : ' → ', array_map(
fn($o) => $o->label,
$slide->slide_options,
))) ?></p>
@@ -143,8 +177,12 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
]) ?>
<?php endif; ?>
<?php if (($slide->type === 'open' || $slide->isPrivate() || $slide->hasComments()) && $count > 0) :
$answersLabel = $slide->type === 'scale' ? __('Auswertung') : __('Antworten'); ?>
<a class="button button--small button--icon" href="<?= $this->Url->build($url('slides:answers', ['id' => $slide->id])) ?>"
$answersLabel = match ($slide->type) {
'scale' => __('Auswertung'),
'choice' => __('Kommentare'),
default => __('Antworten'),
}; ?>
<a class="button button--small button--icon" data-modal href="<?= $this->Url->build($url('slides:answers', ['id' => $slide->id])) ?>"
title="<?= h($answersLabel) ?>" aria-label="<?= h(__('{0} der Folie „{1}“ ansehen', $answersLabel, $slide->question)) ?>">📊</a>
<?php endif; ?>
<a class="button button--small button--icon" data-modal href="<?= $this->Url->build($url('slides:edit', ['id' => $slide->id])) ?>"
@@ -170,12 +208,14 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
'data-confirm' => $isCurrent ? __('Diese Folie ist gerade live. Ausblenden und die Umfrage pausieren?') : null,
]) ?>
<?php endif; ?>
<?php if ($count > 0) : ?>
<?php if ($count > 0 || !$slide->isFresh()) : ?>
<?= $this->Form->postButton('↺', $url('slides:reset', ['id' => $slide->id]), [
'class' => 'button button--small button--icon',
'title' => __('Zurücksetzen: alle Antworten dieser Folie löschen'),
'aria-label' => __('Antworten der Folie „{0}“ zurücksetzen', $slide->question),
'data-confirm' => __('Alle {0} Antworten dieser Folie löschen?', $count),
'title' => __('Zurücksetzen: Antworten löschen und Folie wie neu starten'),
'aria-label' => __('Folie „{0}“ zurücksetzen', $slide->question),
'data-confirm' => $count > 0
? __('Alle {0} Antworten dieser Folie löschen und die Folie zurücksetzen?', $count)
: __('Folie zurücksetzen?'),
]) ?>
<?php endif; ?>
<?= $this->Form->postButton('🗑', $url('slides:delete', ['id' => $slide->id]), [
@@ -202,19 +242,107 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
</div>
</section>
<aside class="sidebar">
<section class="card">
<h2><?= __('Teilnahme') ?></h2>
<aside class="sidebar" id="admin-menu" aria-label="<?= h(__('Menü')) ?>">
<div class="sidebar__bar" data-drawer-bar>
<strong><?= __('Menü') ?></strong>
<button type="button" class="modal__close sidebar__close" data-drawer-close
aria-label="<?= h(__('Menü schließen')) ?>" title="<?= h(__('Schließen (Esc)')) ?>">✕</button>
</div>
<details class="card collapsible" open>
<summary><h2><?= __('Teilnahme') ?></h2></summary>
<p class="join-code"><?= h($poll->formattedJoinCode()) ?></p>
<img class="qr" src="<?= $this->Url->build($url('admin:qr')) ?>" alt="<?= __('QR-Code zur Teilnahme') ?>" width="160" height="160">
<div class="qr-wrap">
<img class="qr" src="<?= $this->Url->build($url('admin:qr')) ?>" alt="<?= __('QR-Code zur Teilnahme') ?>" width="160" height="160">
<button type="button" class="button button--small qr-wrap__download" data-qr-download
data-filename="plenario-qr-<?= h($poll->join_code) ?>.png" hidden><?= __('Als PNG speichern') ?></button>
</div>
<div class="copy-field">
<input type="text" readonly value="<?= h($joinUrl) ?>" aria-label="<?= __('Teilnahme-Link') ?>" data-copy-source>
<button type="button" class="button button--small" data-copy><?= __('Kopieren') ?></button>
</div>
</section>
</details>
<section class="card" id="export">
<h2><?= __('Ergebnisse als PDF') ?></h2>
<details class="card collapsible" open>
<summary><h2><?= __('Einstellungen') ?></h2></summary>
<?= $this->Form->create($poll, ['url' => $url('admin:settings'), 'type' => 'post']) ?>
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
<?= $this->Form->control('is_active', [
'type' => 'checkbox',
'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'),
]) ?>
<?= $this->Form->control('comment_speed', [
'type' => 'select',
'label' => __('Tempo der Kommentare in der Präsentation'),
'options' => [
50 => __('Viel langsamer (doppelt so lange)'),
75 => __('Langsamer'),
100 => __('Normal'),
125 => __('Schneller'),
150 => __('Deutlich schneller'),
200 => __('Sehr schnell (halb so lange)'),
],
'aria-describedby' => 'comment-speed-hint',
]) ?>
<p class="hint" id="comment-speed-hint"><?= __('Gilt für die Kommentare von Skala-Folien, die nacheinander durchlaufen. Die Anzeigedauer richtet sich weiter nach der Textlänge und wird mit diesem Faktor verkürzt oder verlängert.') ?></p>
<?= $this->Form->button(__('Speichern'), ['class' => 'button']) ?>
<?= $this->Form->end() ?>
<section class="card-section">
<h3 id="audio"><?= __('Musik zum Quiz-Countdown') ?></h3>
<?php
$audioMb = (int)round((int)\Cake\Core\Configure::read('Plenario.audio.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
$audioUrl = $poll->hasAudio()
? $this->Url->build(['_name' => 'participate:audio', 'code' => $poll->join_code, 'file' => $poll->audio])
: null;
?>
<p class="hint" id="audio-hint"><?= __('Läuft in der Präsentation, solange ein Quiz läuft, und wiederholt sich bei Bedarf. Teilnehmende hören nichts.') ?></p>
<?= $this->Form->create(null, ['url' => $url('admin:audio'), 'type' => 'file', 'class' => 'image-fields', 'data-audio-form' => '']) ?>
<input type="file" id="audio-file" name="audio" class="sr-only" aria-describedby="audio-hint"
accept="audio/mpeg,audio/mp4,audio/ogg,audio/wav,.mp3,.m4a,.ogg,.wav">
<?php if ($audioUrl === null) : ?>
<label class="image-drop image-drop--compact" for="audio-file" data-audio-drop>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M9 18V5l11-2v13"/><circle cx="6.5" cy="18" r="2.5"/><circle cx="17.5" cy="16" r="2.5"/>
</svg>
<span class="image-drop__title"><?= __('Audiodatei auswählen') ?><span data-audio-drop-extra hidden> <?= __('oder hierher ziehen') ?></span></span>
<span class="image-drop__hint"><?= __('MP3, M4A, OGG, WAV · bis {0} MB', $audioMb) ?></span>
</label>
<?php else : ?>
<div class="image-fields__row audio-row" data-audio-drop>
<audio controls preload="none" class="audio-row__player" src="<?= h($audioUrl) ?>"></audio>
<div class="image-fields__buttons">
<label class="button button--small" for="audio-file"><?= __('Ersetzen') ?></label>
<button type="submit" name="remove" value="1" class="button button--danger button--small"
data-confirm="<?= h(__('Die Audiodatei entfernen?')) ?>"><?= __('Entfernen') ?></button>
</div>
</div>
<?php endif; ?>
<?php // Without JavaScript the chosen file is sent with this button; with it, choosing a file sends it right away. ?>
<button type="submit" class="button button--small" data-audio-submit><?= __('Hochladen') ?></button>
<?= $this->Form->end() ?>
</section>
<section class="card-section">
<h3 id="embed"><?= __('In Präsentation einbetten') ?></h3>
<p class="hint"><?= __('Jede Folie hat einen eigenen Einbett-Link (unter „Einbett-Link“ in der Folienliste). Füge ihn z. B. in Canva als Einbettung auf einer Folie ein.') ?></p>
<p class="hint"><?= __('Sobald die eingebettete Folie im Vortrag zu sehen ist, wird sie live geschaltet. Bei allen anderen Folien sehen Teilnehmende eine Pause-Seite.') ?></p>
<p class="hint"><?= __('Der Link zeigt nur diese Folie und kann sie live schalten – die Umfrage bearbeiten kann damit niemand.') ?></p>
<?= $this->Form->postButton(__('Neue Einbett-Links erzeugen'), $url('admin:rotate-embed'), [
'class' => 'button button--small',
'data-confirm' => __('Neue Einbett-Links erzeugen? Alle bisher eingebetteten Folien funktionieren danach nicht mehr.'),
]) ?>
</section>
<section class="card-section">
<h3 id="clone"><?= __('Umfrage kopieren') ?></h3>
<p class="hint"><?= __('Legt eine neue Umfrage mit allen Folien, Einstellungen und Bildern an – ohne Antworten und noch nicht gestartet. Die Kopie bekommt einen eigenen Teilnahme-Code und Admin-Link, der an dieselbe E-Mail-Adresse geschickt wird.') ?></p>
<?= $this->Form->postButton(__('Umfrage kopieren'), $url('admin:clone'), [
'class' => 'button button--small',
'data-confirm' => __('Die Umfrage mit allen Folien (ohne Antworten) kopieren?'),
]) ?>
</section>
</details>
<details class="card collapsible" id="export">
<summary><h2><?= __('Ergebnisse als PDF') ?></h2></summary>
<p class="hint"><?= __('Alle Folien mit Abstimmung und ihre Ergebnisse in einem Dokument, z. B. fürs Protokoll.') ?></p>
<?= $this->Form->create(null, ['url' => $url('admin:export'), 'type' => 'get']) ?>
<?php if ($hasInternal) : ?>
@@ -238,47 +366,13 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
<?php endif; ?>
<?= $this->Form->button(__('PDF herunterladen'), ['class' => 'button']) ?>
<?= $this->Form->end() ?>
</section>
</details>
<section class="card" id="embed">
<h2><?= __('In Präsentation einbetten') ?></h2>
<p class="hint"><?= __('Jede Folie hat einen eigenen Einbett-Link (unter „Einbett-Link“ in der Folienliste). Füge ihn z. B. in Canva als Einbettung auf einer Folie ein.') ?></p>
<p class="hint"><?= __('Sobald die eingebettete Folie im Vortrag zu sehen ist, wird sie live geschaltet. Bei allen anderen Folien sehen Teilnehmende eine Pause-Seite.') ?></p>
<p class="hint"><?= __('Der Link zeigt nur diese Folie und kann sie live schalten – die Umfrage bearbeiten kann damit niemand.') ?></p>
<?= $this->Form->postButton(__('Neue Einbett-Links erzeugen'), $url('admin:rotate-embed'), [
'class' => 'button button--small',
'data-confirm' => __('Neue Einbett-Links erzeugen? Alle bisher eingebetteten Folien funktionieren danach nicht mehr.'),
]) ?>
</section>
<section class="card">
<h2><?= __('Einstellungen') ?></h2>
<?= $this->Form->create($poll, ['url' => $url('admin:settings'), 'type' => 'post']) ?>
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
<?= $this->Form->control('is_active', [
'type' => 'checkbox',
'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'),
]) ?>
<?= $this->Form->control('comment_speed', [
'type' => 'select',
'label' => __('Tempo der Kommentare in der Präsentation'),
'options' => [
50 => __('Viel langsamer (doppelt so lange)'),
75 => __('Langsamer'),
100 => __('Normal'),
125 => __('Schneller'),
150 => __('Deutlich schneller'),
200 => __('Sehr schnell (halb so lange)'),
],
'aria-describedby' => 'comment-speed-hint',
]) ?>
<p class="hint" id="comment-speed-hint"><?= __('Gilt für die Kommentare von Skala-Folien, die nacheinander durchlaufen. Die Anzeigedauer richtet sich weiter nach der Textlänge und wird mit diesem Faktor verkürzt oder verlängert.') ?></p>
<?= $this->Form->button(__('Speichern'), ['class' => 'button']) ?>
<?= $this->Form->end() ?>
</section>
<section class="card card--danger">
<h2><?= __('Sicherheit') ?></h2>
<details class="card card--danger collapsible">
<summary><h2><?= __('Sicherheit') ?></h2></summary>
<?php if ($poll->expiresAt() !== null) : ?>
<p class="hint"><?= __('Diese Umfrage wird am {0} automatisch gelöscht. Sichere die Ergebnisse vorher als PDF.', h($poll->expiresAt()->i18nFormat('dd.MM.yyyy'))) ?></p>
<?php endif; ?>
<p class="hint"><?= __('Link versehentlich geteilt? Erzeuge einen neuen – der alte wird sofort ungültig.') ?></p>
<?= $this->Form->postButton(__('Neuen Admin-Link erzeugen'), $url('admin:rotate'), [
'class' => 'button button--small',
@@ -286,15 +380,28 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
]) ?>
<h3><?= __('Umfrage zurücksetzen') ?></h3>
<p class="hint"><?= __('Löscht alle Antworten aller Folien, z. B. für eine neue Gruppe. Folien und Einstellungen bleiben erhalten.') ?></p>
<?php if ($responseCounts !== []) : ?>
<p class="hint"><?= $this->Html->link(__('Ergebnisse vorher als PDF sichern'), '#export') ?></p>
<?= $this->Form->postButton(__('Alle Antworten löschen'), $url('admin:reset'), [
<p class="hint"><?= __('Löscht alle Antworten aller Folien und setzt die Präsentation auf „nicht gestartet“ zurück, z. B. für eine neue Gruppe. Folien und Einstellungen bleiben erhalten.') ?></p>
<?php if ($canReset) : ?>
<?php if ($responseCounts !== []) : ?>
<p class="hint"><?= $this->Html->link(__('Ergebnisse vorher als PDF sichern'), '#export') ?></p>
<?php endif; ?>
<?= $this->Form->create(null, ['url' => $url('admin:reset')]) ?>
<?php if ($hasPrepared) : ?>
<?= $this->Form->control('keep_prepared', [
'type' => 'checkbox',
'checked' => true,
'label' => __('Vorab eingetragene Fragen (Fragen & Antworten) behalten'),
]) ?>
<?php endif; ?>
<?= $this->Form->button(__('Umfrage zurücksetzen'), [
'class' => 'button button--small button--danger',
'data-confirm' => __('Alle Antworten aller Folien unwiderruflich löschen?'),
'data-confirm' => $responseCounts !== []
? __('Umfrage zurücksetzen? Alle Antworten aller Folien werden unwiderruflich gelöscht und die Präsentation wird auf „nicht gestartet“ gestellt.')
: __('Alle Folien zurücksetzen und die Präsentation auf „nicht gestartet“ stellen?'),
]) ?>
<?= $this->Form->end() ?>
<?php else : ?>
<p class="hint"><em><?= __('Noch nichts zurückzusetzen: Es gibt keine Antworten.') ?></em></p>
<p class="hint"><em><?= __('Noch nichts zurückzusetzen: keine Antworten, alle Folien im Ausgangszustand, Präsentation nicht gestartet.') ?></em></p>
<?php endif; ?>
<h3><?= __('Umfrage löschen') ?></h3>
@@ -306,10 +413,12 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
]) ?>
<?= $this->Form->button(__('Endgültig löschen'), ['class' => 'button button--danger']) ?>
<?= $this->Form->end() ?>
</section>
</details>
</aside>
</div>
<div class="drawer-backdrop" data-drawer-close aria-hidden="true"></div>
<?php // Slide form in a dialog (loaded via fetch, see [data-modal] in plenario.js); without JS the links open the full page. ?>
<dialog class="modal" data-modal-dialog aria-labelledby="modal-title">
<button type="button" class="modal__close" data-modal-close
+32 -8
View File
@@ -3,7 +3,8 @@
* Presenter screen. Rendered empty and filled by webroot/js/plenario.js
* (Plenario.presenter) from /admin/{token}/state.
*
* Keyboard: ←/→ slides, P pause/resume (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark.
* Keyboard: ←/→ (also ↑/↓ and PageUp/PageDown, as sent by presenter remotes) slides, B (Break) pause/resume (P works too) (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark.
* The speaker view (admin:speaker) is this page plus a preview of the next slide, meant for the presenter's own screen.
* Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first.
*
* @var \App\View\AppView $this
@@ -12,11 +13,13 @@
* @var string $joinUrl
* @var string $joinBaseUrl
* @var int $pollIntervalMs
* @var bool|null $speaker Speaker view (second window): adds the preview of the next slide
*/
$speaker = $speaker ?? false;
$this->assign('title', $poll->title);
$host = preg_replace('#^https?://#', '', $joinBaseUrl);
?>
<div class="stage"
<div class="stage<?= $speaker ? ' stage--speaker' : '' ?>"
data-presenter
data-state-url="<?= $this->Url->build(['_name' => 'admin:state', 'token' => $adminToken]) ?>"
data-control-url="<?= $this->Url->build(['_name' => 'admin:control', 'token' => $adminToken]) ?>"
@@ -34,27 +37,48 @@ $host = preg_replace('#^https?://#', '', $joinBaseUrl);
</header>
<main class="stage__main">
<?php if ($speaker) : ?>
<p class="stage__label"><?= __('Aktuelle Folie') ?></p>
<?php endif; ?>
<p class="stage__status" data-status></p>
<h1 class="stage__question" data-question><?= __('Lade …') ?></h1>
<div class="stage__description formatted" data-description></div>
<div class="stage__timer" data-stage-timer></div>
<div class="stage__media" data-media hidden></div>
<figure class="stage__image" data-image hidden></figure>
<div class="stage__results" data-results></div>
</main>
<?php if ($speaker) : ?>
<aside class="stage__next" data-next aria-label="<?= h(__('Nächste Folie')) ?>">
<p class="stage__label stage__next-label"><?= __('Als Nächstes') ?> <span data-next-meta></span></p>
<h2 class="stage__next-question" data-next-question></h2>
<div class="stage__next-description formatted" data-next-description></div>
<ul class="stage__next-options" data-next-options></ul>
<p class="stage__next-note muted" data-next-note></p>
</aside>
<?php endif; ?>
<footer class="stage__controls">
<a class="ctrl" href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>" title="<?= __('Zur Verwaltung') ?>">✎</a>
<button type="button" class="ctrl" data-action="prev" aria-keyshortcuts="ArrowLeft PageUp" title="<?= __('Vorherige Folie (←)') ?>">
<?php if (!$speaker) : ?>
<a class="ctrl" href="<?= $this->Url->build(['_name' => 'admin:speaker', 'token' => $adminToken]) ?>" target="_blank" rel="noopener"
title="<?= __('Referentenansicht in neuem Fenster öffnen (mit Vorschau der nächsten Folie)') ?>">
<span aria-hidden="true">⧉</span><span class="sr-only"><?= __('Referentenansicht öffnen') ?></span>
</a>
<?php endif; ?>
<button type="button" class="ctrl" data-action="prev" aria-keyshortcuts="ArrowLeft ArrowUp PageUp" title="<?= __('Vorherige Folie (←)') ?>">
<span aria-hidden="true">←</span><span class="sr-only"><?= __('Vorherige Folie') ?></span>
</button>
<span class="ctrl-counter" data-counter>–</span>
<button type="button" class="ctrl" data-action="next" aria-keyshortcuts="ArrowRight PageDown Space" title="<?= __('Nächste Folie (→ oder Leertaste)') ?>">
<button type="button" class="ctrl" data-action="next" aria-keyshortcuts="ArrowRight ArrowDown PageDown Space" title="<?= __('Nächste Folie (→ oder Leertaste)') ?>">
<span aria-hidden="true">→</span><span class="sr-only"><?= __('Nächste Folie') ?></span>
</button>
<button type="button" class="ctrl" data-action="stop" data-pause aria-keyshortcuts="P" title="<?= __('Pause: Teilnehmende sehen eine Pause-Seite (P)') ?>"
data-title-pause="<?= h(__('Pause: Teilnehmende sehen eine Pause-Seite (P)')) ?>"
data-title-resume="<?= h(__('Fortsetzen: pausierte Folie wieder zeigen (P)')) ?>">
<button type="button" class="ctrl" data-action="stop" data-pause aria-keyshortcuts="B P" title="<?= __('Pause: Teilnehmende sehen eine Pause-Seite (B)') ?>"
data-title-pause="<?= h(__('Pause: Teilnehmende sehen eine Pause-Seite (B)')) ?>"
data-title-resume="<?= h(__('Fortsetzen: pausierte Folie wieder zeigen (B)')) ?>">
<span aria-hidden="true" data-pause-icon>⏸</span><span class="sr-only" data-pause-label><?= __('Pause') ?></span>
<kbd class="ctrl__key" aria-hidden="true">[P]</kbd>
<kbd class="ctrl__key" aria-hidden="true">[B]</kbd>
</button>
<button type="button" class="ctrl ctrl--wide" data-action="toggle" data-voting aria-keyshortcuts="V" title="<?= __('Abstimmung öffnen/schließen (V)') ?>">
<span data-label></span> <kbd class="ctrl__key" aria-hidden="true">[V]</kbd>
+1
View File
@@ -42,6 +42,7 @@ $host = preg_replace('#^https?://#', '', $joinBaseUrl);
<h1 class="stage__question" data-question><?= h($slide->question) ?></h1>
<div class="stage__description formatted" data-description></div>
<div class="stage__media" data-media hidden></div>
<figure class="stage__image" data-image hidden></figure>
<div class="stage__results" data-results></div>
</main>
+38 -29
View File
@@ -18,6 +18,7 @@ $this->assign('bodyClass', 'participant');
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
$words = $state['words'] ?? null;
$quiz = $state['quiz'] ?? null;
$timer = $state['timer'] ?? null;
$qa = $state['qa'] ?? null;
$order = $state['order'] ?? null;
$countdown = function (?int $remaining): string {
@@ -40,27 +41,6 @@ $countdown = function (?int $remaining): string {
<p class="eyebrow eyebrow--poll center"><?= h($poll->title) ?></p>
<?php // Icon buttons in the header, next to the theme switch. Hidden unless the browser supports the API (no fullscreen on iPhone). ?>
<?php $this->start('headerTools'); ?>
<button type="button" class="theme-switch" data-fullscreen-toggle hidden aria-pressed="false"
data-label-on="<?= h(__('Vollbild beenden')) ?>" data-label-off="<?= h(__('Vollbild')) ?>"
aria-label="<?= h(__('Vollbild')) ?>" title="<?= h(__('Vollbild')) ?>">
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>
</svg>
</button>
<button type="button" class="theme-switch" data-wakelock-toggle hidden aria-pressed="false"
data-label-on="<?= h(__('Display bleibt an – tippen zum Ausschalten')) ?>"
data-label-off="<?= h(__('Display bleibt nicht an – tippen zum Anlassen')) ?>"
aria-label="<?= h(__('Display anlassen')) ?>" title="<?= h(__('Display anlassen')) ?>">
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>
</svg>
</button>
<?php $this->end(); ?>
<?php if (!$poll->is_active) : ?>
<section class="card center">
<h1><?= __('Diese Umfrage ist geschlossen.') ?></h1>
@@ -110,6 +90,7 @@ $countdown = function (?int $remaining): string {
<?php if ($slide->description) : ?>
<div class="prose formatted"><?= $this->Format->text($slide->description) ?></div>
<?php endif; ?>
<?= $this->element('slide_image', compact('slide', 'poll')) ?>
</section>
<?php else : ?>
@@ -118,7 +99,15 @@ $countdown = function (?int $remaining): string {
<?php if ($slide->description) : ?>
<div class="muted formatted"><?= $this->Format->text($slide->description) ?></div>
<?php endif; ?>
<?= $this->element('slide_image', compact('slide', 'poll')) ?>
<?php if ($timer !== null && $timer['phase'] === 'ready') : ?>
<div class="waiting center">
<div class="pulse" aria-hidden="true"></div>
<p class="muted"><?= __('Die Abstimmung startet gleich. Die Antwortmöglichkeiten erscheinen, sobald es losgeht.') ?></p>
</div>
<?php else : ?>
<?= $timer !== null && $timer['phase'] === 'running' ? $countdown($timer['remaining']) : '' ?>
<?php if ($quiz !== null) : ?>
<?php if ($quiz['phase'] === 'ready') : ?>
<div class="waiting center">
@@ -159,14 +148,20 @@ $countdown = function (?int $remaining): string {
<p class="muted"><?= __('Unten siehst du die richtige Reihenfolge – ✓ markiert, was du richtig platziert hast.') ?></p>
<?php elseif ($order['revealed']) : ?>
<p class="muted"><?= __('Die Abstimmung ist geschlossen – du hast keine Reihenfolge eingereicht.') ?></p>
<?php elseif ($order['ranking'] && !$state['hasResponded'] && !$slide->isVotingOpen()) : ?>
<p class="muted"><?= __('Die Abstimmung ist geschlossen.') ?></p>
<?php elseif ($state['hasResponded']) : ?>
<p class="done">✓ <?= __('Deine Reihenfolge ist angekommen.') ?></p>
<p class="muted"><?= __('Die Auflösung gibt es, sobald die Abstimmung geschlossen wird.') ?></p>
<?php if (!$order['ranking']) : ?>
<p class="muted"><?= __('Die Auflösung gibt es, sobald die Abstimmung geschlossen wird.') ?></p>
<?php endif; ?>
<?php else :
$items = $slide->shuffledOptions($participantHash); ?>
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form order-form', 'data-order-form' => true]) ?>
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
<p class="hint" id="order-hint"><?= __('Bring die Einträge in die richtige Reihenfolge – oben steht der erste. Ziehe sie am Griff ⠿ oder nutze die Pfeile.') ?></p>
<p class="hint" id="order-hint"><?= $order['ranking']
? __('Sortiere die Einträge nach deiner persönlichen Einschätzung – oben steht der wichtigste. Hier gibt es kein Richtig oder Falsch. Ziehe sie am Griff ⠿ oder nutze die Pfeile.')
: __('Bring die Einträge in die richtige Reihenfolge – oben steht der erste. Ziehe sie am Griff ⠿ oder nutze die Pfeile.') ?></p>
<noscript><p class="muted"><?= __('Zum Sortieren wird JavaScript benötigt.') ?></p></noscript>
<ol class="order-list" data-order-list aria-describedby="order-hint">
<?php foreach ($items as $index => $option) : ?>
@@ -266,7 +261,9 @@ $countdown = function (?int $remaining): string {
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>
: ($slide->type === 'choice'
? __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Auswahl bleibt.')
: __('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>
@@ -285,11 +282,19 @@ $countdown = function (?int $remaining): string {
<label class="choice">
<input type="<?= $multiple ? 'checkbox' : 'radio' ?>"
name="<?= $multiple ? 'option_ids[]' : 'option_id' ?>"
value="<?= (int)$option->id ?>" <?= $multiple ? '' : 'required' ?>>
value="<?= (int)$option->id ?>" <?= $multiple || $slide->hasCommentOnly() ? '' : 'required' ?>>
<span><?= h($option->label) ?></span>
</label>
<?php endforeach; ?>
</div>
<?php if ($slide->hasComments()) : ?>
<label class="scale-comment" for="choice-comment"><?= __('Kommentar (optional)') ?></label>
<?php if ($slide->hasCommentOnly()) : ?>
<p class="hint"><?= __('Du kannst auch nur einen Kommentar abgeben, ohne etwas auszuwählen.') ?></p>
<?php endif; ?>
<textarea id="choice-comment" name="comment" rows="3" maxlength="500"
placeholder="<?= __('Möchtest du deine Auswahl begründen?') ?>"></textarea>
<?php endif; ?>
<?php elseif ($slide->type === 'open') : ?>
<textarea name="text" rows="4" maxlength="500" required
@@ -307,7 +312,7 @@ $countdown = function (?int $remaining): string {
<div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = 1; $v <= $maxValue; $v++) : ?>
<label class="stars__star">
<input type="radio" name="value" value="<?= $v ?>" required>
<input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasCommentOnly() ? '' : 'required' ?>>
<span class="stars__icon" aria-hidden="true">★</span>
<span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span>
</label>
@@ -317,7 +322,7 @@ $countdown = function (?int $remaining): string {
<div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?>
<label class="scale__step">
<input type="radio" name="value" value="<?= $v ?>" required>
<input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasCommentOnly() ? '' : 'required' ?>>
<span><?= $v ?></span>
</label>
<?php endfor; ?>
@@ -329,6 +334,9 @@ $countdown = function (?int $remaining): string {
</div>
<?php if ($slide->hasComments()) : ?>
<label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label>
<?php if ($slide->hasCommentOnly()) : ?>
<p class="hint"><?= __('Du kannst auch nur einen Kommentar abgeben, ohne zu bewerten.') ?></p>
<?php endif; ?>
<textarea id="scale-comment" name="comment" rows="3" maxlength="500"
placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea>
<?php endif; ?>
@@ -342,6 +350,7 @@ $countdown = function (?int $remaining): string {
<?= $this->Form->button(__('Absenden'), ['class' => 'button button--primary button--block']) ?>
<?= $this->Form->end() ?>
<?php endif; ?>
<?php endif; ?>
</section>
<section class="card results-card" data-results-card <?= $state['results'] ? '' : 'hidden' ?>>
@@ -353,8 +362,8 @@ $countdown = function (?int $remaining): string {
} ?></h2>
<?php if ($words !== null && $words['allowUpvotes'] && $slide->is_voting_open) : ?>
<p class="hint" data-upvote-hint><?= $words['allowDownvotes']
? __('Tippe auf einen Begriff, um ihn zu unterstützen, oder auf „−“, um ihn abzulehnen.')
: __('Tippe auf einen Begriff, um ihn zu unterstützen.') ?></p>
? __('Tippe auf „+“, um einen Begriff zu unterstützen, oder auf „−“, um ihn abzulehnen.')
: __('Tippe auf „+“, um einen Begriff zu unterstützen.') ?></p>
<?php endif; ?>
<div data-results></div>
</section>
+27 -6
View File
@@ -9,24 +9,31 @@
* @var \App\Model\Entity\Slide $slide
* @var list<array{text: string, created: string}> $answers
* @var array<string, mixed>|null $scale Distribution of a scale slide, null for open questions
* @var list<array{id: int, text: string, value: int, created: string}> $comments Comments of a scale, oldest first
* @var list<array{id: int, text: string, value: int|null, created: string}> $comments Comments of a scale or choice slide, oldest first
*/
use Cake\I18n\DateTime;
$this->assign('title', $slide->question);
$this->assign('noindex', '1');
$count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) : count($answers);
$isChoice = $slide->type === 'choice';
$count = match (true) {
$scale !== null => array_sum(array_column($scale['buckets'], 'count')),
$isChoice => count($comments),
default => count($answers),
};
?>
<p><a href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>">← <?= __('Zurück zur Verwaltung') ?></a></p>
<section class="card">
<section class="card" data-modal-content>
<p class="eyebrow">
<?= h($slide->typeLabel()) ?>
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $scale !== null ? __('Internes Feedback') : __('Anonymes Feedback') ?><?php endif; ?>
</p>
<h1><?= h($slide->question) ?></h1>
<h1 id="modal-title"><?= h($slide->question) ?></h1>
<?php if ($scale !== null) : ?>
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?></p>
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?><?php if (!empty($scale['commentOnly'])) : ?> · <?= __('{0}× nur Kommentar', (int)$scale['commentOnly']) ?><?php endif; ?></p>
<?php elseif ($isChoice) : ?>
<p class="muted"><?= __n('{0} Kommentar, neueste zuerst', '{0} Kommentare, neueste zuerst', $count, $count) ?></p>
<?php else : ?>
<p class="muted"><?= __n('{0} Antwort, neueste zuerst', '{0} Antworten, neueste zuerst', $count, $count) ?></p>
<?php endif; ?>
@@ -79,12 +86,26 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
$created = new DateTime($comment['created']); ?>
<li>
<?= h($comment['text']) ?>
<time datetime="<?= h($comment['created']) ?>"><?= __('Bewertung') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
<time datetime="<?= h($comment['created']) ?>"><?php if ($comment['value'] !== null) : ?><?= __('Bewertung') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?><?php else : ?><?= __('ohne Bewertung') ?><?php endif; ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php endif; ?>
<?php elseif ($isChoice) : ?>
<?php if ($comments === []) : ?>
<p class="empty"><?= __('Noch keine Kommentare.') ?></p>
<?php else : ?>
<ol class="answers-page" reversed>
<?php foreach (array_reverse($comments) as $comment) :
$created = new DateTime($comment['created']); ?>
<li>
<?= h($comment['text']) ?>
<time datetime="<?= h($comment['created']) ?>"><?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php elseif ($answers === []) : ?>
<p class="empty"><?= __('Noch keine Antworten.') ?></p>
<?php else : ?>
+47 -18
View File
@@ -10,6 +10,7 @@
* @var string $optionsText
* @var list<array{label: string, correct: bool}> $quizOptions
* @var list<string> $orderOptions Ordering slide: labels in the correct order
* @var string $preparedText Q&A slide: questions entered beforehand, one per line
* @var bool|null $hasResponses
*/
@@ -30,7 +31,7 @@ $optionsError = $slide->getError('options_text');
<p class="eyebrow"><?= h($slide->typeLabel()) ?></p>
<h1 id="modal-title"><?= $isNew ? __('Neue Folie') : __('Folie bearbeiten') ?></h1>
<?= $this->Form->create($slide, ['url' => $formUrl]) ?>
<?= $this->Form->create($slide, ['url' => $formUrl, 'type' => 'file']) ?>
<?= $this->Form->hidden('type') ?>
<?php if ($slide->isYouTube()) :
$urlError = $slide->getError('youtube_url');
@@ -115,10 +116,16 @@ $optionsError = $slide->getError('options_text');
]) ?>
<p class="hint" id="description-format"><?= __('Formatierung wie bei WhatsApp: *fett*, _kursiv_, ~durchgestrichen~, Aufzählung mit „- “ am Zeilenanfang.') ?></p>
<?= $this->element('slide_image_fields', compact('slide', 'poll')) ?>
<?php if ($slide->type === 'choice') : ?>
<div class="input textarea<?= $optionsError ? ' error' : '' ?>">
<label for="options-text"><?= __('Antwortoptionen (eine pro Zeile, max. 20)') ?></label>
<textarea id="options-text" name="options_text" rows="6" required><?= h($optionsText) ?></textarea>
<?php // Shortcut for formal votes; needs JavaScript, so it stays hidden without it. ?>
<button type="button" class="button button--small button--ghost" hidden
data-add-option="<?= h(__('Enthaltung')) ?>" data-add-option-target="options-text"
data-add-option-max="20">+ <?= __('Option „Enthaltung“ hinzufügen') ?></button>
<?php if ($optionsError) : ?>
<div class="error-message"><?= h(implode(' ', (array)$optionsError)) ?></div>
<?php endif; ?>
@@ -131,6 +138,17 @@ $optionsError = $slide->getError('options_text');
'label' => __('Mehrfachauswahl erlauben'),
'checked' => (bool)$settings['multiple'],
]) ?>
<?= $this->Form->control('settings.comment_mode', [
'type' => 'select',
'label' => __('Kommentarfeld'),
'options' => [
'off' => __('Kein Kommentarfeld'),
'rating' => __('Kommentar optional, die Auswahl ist Pflicht'),
'only' => __('Kommentar optional, auch ein Kommentar ohne Auswahl genügt'),
],
'value' => empty($settings['comments']) ? 'off' : (empty($settings['comment_only']) ? 'rating' : 'only'),
]) ?>
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander unter dem Ergebnis durch (nicht bei den Teilnehmenden). Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein.') ?></p>
<?php elseif ($slide->type === 'open') : ?>
<?= $this->Form->control('settings.private', [
'type' => 'checkbox',
@@ -193,10 +211,15 @@ $optionsError = $slide->getError('options_text');
'value' => $settings['scale_view'],
]) ?>
<p class="hint"><?= __('Die Auswertung in der Verwaltung und der PDF-Export enthalten immer beides.') ?></p>
<?= $this->Form->control('settings.comments', [
'type' => 'checkbox',
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
'checked' => (bool)$settings['comments'],
<?= $this->Form->control('settings.comment_mode', [
'type' => 'select',
'label' => __('Kommentarfeld'),
'options' => [
'off' => __('Kein Kommentarfeld'),
'rating' => __('Kommentar optional, die Bewertung ist Pflicht'),
'only' => __('Kommentar optional, auch ein Kommentar ohne Bewertung genügt'),
],
'value' => empty($settings['comments']) ? 'off' : (empty($settings['comment_only']) ? 'rating' : 'only'),
]) ?>
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden), jeder so lange, wie man zum Lesen braucht: kurze etwa 5 Sekunden, lange bis zu 30 Sekunden. Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein. Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p>
<?= $this->Form->control('settings.comment_ratings', [
@@ -213,8 +236,8 @@ $optionsError = $slide->getError('options_text');
<?php elseif ($slide->type === 'quiz') :
$quizError = $slide->getError('quiz_options');
$rows = $quizOptions;
// Always offer a few empty rows (more via "Antwort hinzufügen" with JS).
$rowCount = min(\App\Model\Table\SlidesTable::MAX_QUIZ_OPTIONS, max(4, count($rows) + 1));
// Offer the two required rows (more via "Antwort hinzufügen" with JS), plus one spare when editing.
$rowCount = min(\App\Model\Table\SlidesTable::MAX_QUIZ_OPTIONS, max(2, count($rows) + 1));
$rows = array_pad($rows, $rowCount, ['label' => '', 'correct' => false]);
?>
<fieldset class="quiz-options<?= $quizError ? ' error' : '' ?>" data-quiz-options
@@ -265,12 +288,12 @@ $optionsError = $slide->getError('options_text');
<?php elseif ($slide->isOrder()) :
$orderError = $slide->getError('order_options');
$max = \App\Model\Table\SlidesTable::MAX_ORDER_OPTIONS;
$rows = array_pad($orderOptions, min($max, max(4, count($orderOptions) + 1)), '');
$rows = array_pad($orderOptions, min($max, max(2, count($orderOptions) + 1)), '');
?>
<fieldset class="order-options<?= $orderError ? ' error' : '' ?>" data-order-options data-max="<?= $max ?>"
aria-describedby="order-options-hint<?= $orderError ? ' order-options-error' : '' ?>">
<legend><?= __('Einträge in der richtigen Reihenfolge') ?></legend>
<p class="hint" id="order-options-hint"><?= __('Mindestens zwei, maximal {0} Einträge – von oben (zuerst) nach unten. Teilnehmende bekommen sie gemischt und müssen sie sortieren. Leere Zeilen werden ignoriert.', $max) ?></p>
<legend><?= __('Einträge') ?></legend>
<p class="hint" id="order-options-hint"><?= __('Mindestens zwei, maximal {0} Einträge. Bei einer Folie mit richtiger Lösung von oben (zuerst) nach unten eintragen. Teilnehmende bekommen sie gemischt und müssen sie sortieren. Leere Zeilen werden ignoriert.', $max) ?></p>
<p class="hint" data-order-hint hidden><?= __('Zum Umsortieren den Griff ⠿ ziehen, oder Griff fokussieren und Pfeiltasten nutzen.') ?></p>
<ol class="order-options__list" data-order-list>
<?php foreach ($rows as $i => $label) : ?>
@@ -294,7 +317,12 @@ $optionsError = $slide->getError('options_text');
<p class="hint"><?= __('Achtung: Umbenannte oder entfernte Einträge zählen bei bisherigen Antworten als falsch. Eine neue Reihenfolge gilt sofort für die Auswertung.') ?></p>
<?php endif; ?>
</fieldset>
<p class="hint"><?= __('Aufgelöst wird, sobald du die Abstimmung schließt: Dann siehst du, wie viele richtig lagen, und jede Person sieht, ob ihre Reihenfolge stimmt.') ?></p>
<?= $this->Form->control('settings.ranking', [
'type' => 'checkbox',
'label' => __('Keine richtige Reihenfolge – Teilnehmende sortieren nach eigener Einschätzung (z. B. nach Wichtigkeit)'),
'checked' => (bool)$settings['ranking'],
]) ?>
<p class="hint"><?= __('Ohne Haken wird aufgelöst, sobald du die Abstimmung schließt: Dann siehst du, wie viele richtig lagen, und jede Person sieht, ob ihre Reihenfolge stimmt. Mit Haken zählt die Reihenfolge der Einträge oben nicht: Die Präsentation zeigt live die gemeinsame Rangfolge (nach dem durchschnittlichen Platz), Teilnehmende sehen kein Ergebnis.') ?></p>
<?php elseif ($slide->type === 'qa') :
$upvoteOptions = [];
foreach (range(1, \App\Model\Entity\Slide::QA_MAX_UPVOTES) as $n) {
@@ -330,16 +358,17 @@ $optionsError = $slide->getError('options_text');
'aria-describedby' => 'qa-self-upvote-hint',
]) ?>
<p class="hint" id="qa-self-upvote-hint"><?= __('Sinnvoll, wenn ihr Themen priorisiert („Was besprechen wir heute?“). Bei normalen Fragerunden lieber aus: Sonst landen oft die Fragen derjenigen vorn, die alle Stimmen sich selbst geben.') ?></p>
<?php if ($slide->qaStage() === \App\Model\Entity\Slide::QA_COLLECT) : ?>
<div class="input textarea">
<label for="prepared-text"><?= __('Vorab eingereichte Fragen (optional, eine pro Zeile, max. {0})', \App\Service\QaService::MAX_PREPARED) ?></label>
<textarea id="prepared-text" name="prepared_text" rows="5" aria-describedby="prepared-hint"><?= h($preparedText) ?></textarea>
<p class="hint" id="prepared-hint"><?= __('Z. B. Fragen, die dich vorab per E-Mail erreicht haben. Sie erscheinen wie Fragen der Teilnehmenden, ohne dass jemand sie bearbeiten kann. Gleiche Fragen werden nur einmal aufgenommen. Zeilen, die du hier entfernst, verschwinden wieder.') ?></p>
</div>
<?php endif; ?>
<p class="hint"><?= __('Ablauf in der Präsentation: 1. Fragen sammeln, 2. abstimmen, 3. besprechen – die Frage mit den meisten Upvotes zuerst. Ohne Upvotes entfällt Schritt 2. Du schaltest die Schritte selbst weiter.') ?></p>
<?php endif; ?>
<?php if ($slide->isInteractive() && !$slide->isQuiz() && !$slide->isQa()) : ?>
<?= $this->Form->control('is_voting_open', [
'type' => 'checkbox',
'label' => __('Abstimmung geöffnet'),
'checked' => $isNew ? true : $slide->is_voting_open,
]) ?>
<?php endif; ?>
<?= $this->element('slide_time_limit', ['slide' => $slide]) ?>
<div class="form-actions">
<?= $this->Form->button($isNew ? __('Folie anlegen') : __('Speichern'), ['class' => 'button button--primary']) ?>
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* Favicon links shared by all layouts. The SVG is the logo (same shape as .brand__mark in plenario.css) and wins
* wherever it is supported; favicon.ico is the fallback, apple-touch-icon.png is the iOS home screen icon.
*
* @var \App\View\AppView $this
*/
$asset = fn(string $file): string => $this->Url->assetUrl($file, ['pathPrefix' => '']);
?>
<link rel="icon" href="<?= h($asset('favicon.ico')) ?>" sizes="32x32">
<link rel="icon" href="<?= h($asset('favicon.svg')) ?>" type="image/svg+xml">
<link rel="apple-touch-icon" href="<?= h($asset('apple-touch-icon.png')) ?>">
+19
View File
@@ -0,0 +1,19 @@
<?php
/**
* The image of a slide on the participant's page (always above the content, whatever the stage layout).
* Width and height reserve the space, so the page does not jump while the image loads.
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Slide $slide
* @var \App\Model\Entity\Poll $poll
*/
if (!$slide->hasImage()) {
return;
}
?>
<figure class="slide-image">
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
alt="<?= h((string)$slide->image_alt) ?>"
<?= $slide->image_width && $slide->image_height ? 'width="' . (int)$slide->image_width . '" height="' . (int)$slide->image_height . '"' : '' ?>
decoding="async">
</figure>
+122
View File
@@ -0,0 +1,122 @@
<?php
/**
* Image section of the slide form: dropzone or current image (replace / remove), placement tiles.
* Works without JavaScript (label opens the file dialog, checkbox removes); JavaScript adds
* preview, drag and drop and the remove toggle. Not for slide types without image support (YouTube).
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Slide $slide
* @var \App\Model\Entity\Poll $poll
*/
use App\Model\Entity\Slide;
use App\Service\ImageService;
use Cake\Core\Configure;
if (!Slide::supportsImage($slide->type)) {
return;
}
$request = $this->getRequest();
$posted = $request->is(['post', 'put', 'patch']);
$hasImage = $slide->hasImage();
// After a failed save the posted values are shown again.
$layout = $posted && in_array($request->getData('image_layout'), Slide::IMAGE_LAYOUTS, true)
? (string)$request->getData('image_layout')
: $slide->imageLayout();
$layouts = [
Slide::IMAGE_TOP => [__('Oben'), '<rect class="img" x="4" y="3" width="40" height="13" rx="2"/><rect x="4" y="20" width="30" height="3" rx="1.5"/><rect x="4" y="26" width="22" height="3" rx="1.5"/>'],
Slide::IMAGE_SIDE => [__('Daneben'), '<rect class="img" x="4" y="3" width="18" height="26" rx="2"/><rect x="27" y="6" width="17" height="3" rx="1.5"/><rect x="27" y="12" width="13" height="3" rx="1.5"/><rect x="27" y="18" width="17" height="3" rx="1.5"/>'],
];
if ($slide->type === Slide::TYPE_CONTENT) {
$layouts[Slide::IMAGE_FULL] = [__('Vollbild'), '<rect class="img" x="4" y="3" width="40" height="26" rx="2"/>'];
}
$imageError = $slide->getError('image');
$maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
$imageUrl = $hasImage
? $this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])
: '';
?>
<div class="image-section" data-image-fields<?= $hasImage ? ' data-has-image' : '' ?>>
<fieldset class="image-fields">
<legend><?= __('Bild') ?> <span class="image-fields__optional"><?= __('(optional)') ?></span></legend>
<?php if (!ImageService::isAvailable()) : ?>
<p class="hint"><?= __('Bilder sind auf diesem Server nicht verfügbar (PHP-Erweiterung GD mit WebP fehlt).') ?></p>
<?php else : ?>
<?php if ($imageError) : ?>
<div class="error-message" id="image-error" role="alert"><?= h(implode(' ', (array)$imageError)) ?></div>
<?php endif; ?>
<?php // One file input for both states; the labels below open it, so it can stay visually hidden. ?>
<input type="file" id="image-file" name="image" class="sr-only" accept="image/jpeg,image/png,image/webp,image/gif"
aria-describedby="image-hint<?= $imageError ? ' image-error' : '' ?>" <?= $imageError ? 'aria-invalid="true"' : '' ?>>
<label class="image-drop" for="image-file" data-image-drop<?= $hasImage ? ' hidden' : '' ?>>
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="1.5"/><path d="M21 16l-5-5-8 9"/>
</svg>
<span class="image-drop__title"><?= __('Bild auswählen') ?><span data-image-drop-extra hidden> <?= __('oder hierher ziehen') ?></span></span>
<span class="image-drop__hint"><?= __('JPEG, PNG, WebP oder GIF, bis {0} MB', $maxMb) ?></span>
</label>
<div class="image-fields__row" data-image-row<?= $hasImage ? '' : ' hidden' ?>>
<figure class="image-fields__current" data-image-figure>
<img src="<?= h($imageUrl) ?>" alt="" data-image-original="<?= h($imageUrl) ?>"
<?= $hasImage ? 'width="' . (int)$slide->image_width . '" height="' . (int)$slide->image_height . '"' : '' ?>>
</figure>
<div class="image-fields__side">
<p class="image-fields__info" role="status" aria-live="polite" data-image-info
data-text-current="<?= h(__('Aktuelles Bild')) ?><?= $hasImage ? h(' · ' . __('{0} × {1} Pixel', (int)$slide->image_width, (int)$slide->image_height)) : '' ?>"
data-text-new="<?= h(__('Neues Bild wird beim Speichern übernommen:')) ?>"
data-text-removed="<?= h(__('Das Bild wird beim Speichern entfernt.')) ?>"><?= $hasImage ? h(__('Aktuelles Bild') . ' · ' . __('{0} × {1} Pixel', (int)$slide->image_width, (int)$slide->image_height)) : '' ?></p>
<div class="image-fields__buttons">
<label class="button button--small" for="image-file" data-image-pick
data-label-replace="<?= h(__('Ersetzen')) ?>" data-label-choose="<?= h(__('Anderes Bild wählen')) ?>"><?= __('Ersetzen') ?></label>
<?php if ($hasImage) : ?>
<?php // Without JavaScript the checkbox does the job; with it, the button toggles the same checkbox. ?>
<div class="image-fields__remove" data-image-remove>
<?= $this->Form->control('remove_image', [
'type' => 'checkbox',
'label' => __('Bild entfernen'),
'value' => '1',
'hiddenField' => false,
'checked' => false,
]) ?>
</div>
<?php endif; ?>
<button type="button" class="button button--danger button--small" hidden data-image-remove-button
data-label-remove="<?= h(__('Entfernen')) ?>" data-label-undo="<?= h(__('Rückgängig')) ?>"
data-label-discard="<?= h(__('Auswahl verwerfen')) ?>">
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 11v5M14 11v5"/>
</svg>
<span data-label><?= __('Entfernen') ?></span>
</button>
</div>
</div>
</div>
<div class="image-fields__help" id="image-hint">
<details>
<summary><?= __('Was passiert mit dem Bild?') ?></summary>
<p class="hint"><?= __('JPEG, PNG, WebP oder GIF (nicht animiert), bis {0} MB. Das Bild wird automatisch auf höchstens 1600 Pixel verkleinert und als WebP gespeichert, Kameradaten wie der Aufnahmeort werden dabei entfernt.', $maxMb) ?></p>
</details>
</div>
<fieldset class="image-layout" data-image-layout>
<legend><?= __('Platzierung in der Präsentation') ?></legend>
<div class="image-layout__tiles">
<?php foreach ($layouts as $value => [$text, $shapes]) : ?>
<label class="image-layout__tile">
<input type="radio" name="image_layout" value="<?= h($value) ?>" class="sr-only" <?= $layout === $value ? 'checked' : '' ?>>
<svg viewBox="0 0 48 32" width="72" height="48" fill="currentColor" aria-hidden="true"><?= $shapes ?></svg>
<span><?= h($text) ?></span>
</label>
<?php endforeach; ?>
</div>
<p class="hint"><?= __('Auf dem Smartphone der Teilnehmenden steht das Bild immer oben.') ?></p>
</fieldset>
<?php endif; ?>
</fieldset>
</div>
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* Countdown of a slide (not for quizzes, which have their own field, nor Q&A): without a limit the slide is
* open as soon as it is live; with one it first shows only the question, the next step starts the countdown.
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Slide $slide
*/
use App\Model\Entity\Slide;
if ($slide->isQuiz() || !Slide::supportsTimer($slide->type)) {
return;
}
$limits = [];
foreach (Slide::TIME_LIMITS as $seconds) {
$limits[$seconds] = match (true) {
$seconds === 0 => __('Kein Countdown'),
$seconds < 60 => __('{0} Sekunden', $seconds),
$seconds % 60 === 0 => __n('{0} Minute', '{0} Minuten', intdiv($seconds, 60), intdiv($seconds, 60)),
default => __('{0} Minuten', number_format($seconds / 60, 1, ',', '')),
};
}
?>
<?= $this->Form->control('settings.time_limit', [
'type' => 'select',
'options' => $limits,
'label' => __('Countdown'),
'value' => $slide->getSettings()['time_limit'],
'aria-describedby' => 'time-limit-hint',
]) ?>
<p class="hint" id="time-limit-hint"><?= __('Mit Countdown zeigt die Präsentation zuerst nur die Frage. „Weiter“ startet den Countdown und die Abstimmung, am Ende (oder mit „Weiter“) wird geschlossen und das Ergebnis gezeigt. Ohne Countdown ist die Folie sofort offen.') ?></p>
+5 -2
View File
@@ -11,7 +11,10 @@
<p style="margin:24px 0;">
<a href="<?= h($adminUrl) ?>" style="display:inline-block;background:#4b3fe0;color:#ffffff;text-decoration:none;padding:12px 20px;border-radius:8px;font-weight:600;"><?= __('Umfrage verwalten') ?></a>
</p>
<p style="font-size:13px;color:#5b5f7a;word-break:break-all;"><?= h($adminUrl) ?></p>
<p style="font-size:13px;color:#5d6280;word-break:break-all;"><?= h($adminUrl) ?></p>
<p><strong><?= __('Wichtig:') ?></strong> <?= __('Wer diesen Link kennt, kann die Umfrage bearbeiten. Gib ihn nicht weiter.') ?></p>
<p><?= __('Teilnehmende erreichen die Umfrage unter {0} mit dem Code <strong>{1}</strong>.', '<a href="' . h($joinUrl) . '">' . h($joinUrl) . '</a>', h($poll->formattedJoinCode())) ?></p>
<p style="font-size:13px;color:#5b5f7a;"><?= __('Du hast diese Umfrage nicht angelegt? Dann kannst du diese E-Mail ignorieren.') ?></p>
<?php if ($poll->expiresAt() !== null) : ?>
<p><?= __('Hinweis: Die Umfrage wird am {0} automatisch gelöscht. Vorher erinnern wir dich per E-Mail.', h($poll->expiresAt()->format('d.m.Y'))) ?></p>
<?php endif; ?>
<p style="font-size:13px;color:#5d6280;"><?= __('Du hast diese Umfrage nicht angelegt? Dann kannst du diese E-Mail ignorieren.') ?></p>
+17
View File
@@ -0,0 +1,17 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @var string $adminUrl
* @var \Cake\I18n\DateTime $expires
*/
?>
<p><?= __('Hallo,') ?></p>
<p><?= __('deine Umfrage <strong>{0}</strong> wird am <strong>{1}</strong> automatisch gelöscht, einschließlich aller Folien, Antworten und Bilder.', h($poll->title), h($expires->format('d.m.Y'))) ?></p>
<p><?= __('Möchtest du die Ergebnisse behalten, sichere sie vorher in der Verwaltung als PDF:') ?></p>
<p style="margin:24px 0;">
<a href="<?= h($adminUrl) ?>" style="display:inline-block;background:#4b3fe0;color:#ffffff;text-decoration:none;padding:12px 20px;border-radius:8px;font-weight:600;"><?= __('Umfrage öffnen') ?></a>
</p>
<p style="font-size:13px;color:#5d6280;word-break:break-all;"><?= h($adminUrl) ?></p>
<p><strong><?= __('Wichtig:') ?></strong> <?= __('Wer diesen Link kennt, kann die Umfrage bearbeiten. Gib ihn nicht weiter.') ?></p>
<p style="font-size:13px;color:#5d6280;"><?= __('Du brauchst die Umfrage nicht mehr? Dann musst du nichts tun.') ?></p>
+2 -2
View File
@@ -10,8 +10,8 @@
<?php foreach ($links as $link) : ?>
<li style="margin-bottom:12px;">
<a href="<?= h($link['url']) ?>" style="color:#4b3fe0;font-weight:600;"><?= h($link['title']) ?></a><br>
<span style="font-size:13px;color:#5b5f7a;"><?= __('angelegt am {0}', h($link['created'])) ?></span>
<span style="font-size:13px;color:#5d6280;"><?= __('angelegt am {0}', h($link['created'])) ?></span>
</li>
<?php endforeach; ?>
</ul>
<p style="font-size:13px;color:#5b5f7a;"><?= __('Du hast diese E-Mail nicht angefordert? Dann kannst du sie ignorieren – deine Links bleiben unverändert gültig.') ?></p>
<p style="font-size:13px;color:#5d6280;"><?= __('Du hast diese E-Mail nicht angefordert? Dann kannst du sie ignorieren – deine Links bleiben unverändert gültig.') ?></p>
+5
View File
@@ -21,4 +21,9 @@
<?= __('Teilnehmende erreichen die Umfrage unter {0} mit dem Code {1}.', $joinUrl, $poll->formattedJoinCode()) ?>
<?php if ($poll->expiresAt() !== null) : ?>
<?= __('Hinweis: Die Umfrage wird am {0} automatisch gelöscht. Vorher erinnern wir dich per E-Mail.', $poll->expiresAt()->format('d.m.Y')) ?>
<?php endif; ?>
<?= __('Du hast diese Umfrage nicht angelegt? Dann kannst du diese E-Mail ignorieren.') ?>
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @var string $adminUrl
* @var \Cake\I18n\DateTime $expires
*/
?>
<?= __('Hallo,') ?>
<?= __('deine Umfrage "{0}" wird am {1} automatisch gelöscht, einschließlich aller Folien, Antworten und Bilder.', $poll->title, $expires->format('d.m.Y')) ?>
<?= __('Möchtest du die Ergebnisse behalten, sichere sie vorher in der Verwaltung als PDF:') ?>
<?= $adminUrl ?>
<?= __('Wichtig: Wer diesen Link kennt, kann die Umfrage bearbeiten. Gib ihn nicht weiter.') ?>
<?= __('Du brauchst die Umfrage nicht mehr? Dann musst du nichts tun.') ?>
+2 -2
View File
@@ -17,7 +17,7 @@ $title = $this->fetch('title');
<?php endif; ?>
<title><?= $title ? h($title) . ' · ' : '' ?>PlenarIO</title>
<?= $this->element('theme_init') ?>
<?= $this->Html->meta('icon') ?>
<?= $this->element('favicon') ?>
<?= $this->Html->css(['normalize.min', 'plenario']) ?>
<?= $this->fetch('meta') ?>
<?= $this->fetch('css') ?>
@@ -33,8 +33,8 @@ $title = $this->fetch('title');
<a href="<?= $this->Url->build(['_name' => 'recover']) ?>"><?= __('Admin-Link verloren?') ?></a>
</nav>
<div class="header-tools">
<?= $this->fetch('headerTools') ?>
<?= $this->element('theme_switch') ?>
<?= $this->fetch('headerMenu') ?>
</div>
</div>
</header>
+18 -3
View File
@@ -1,17 +1,32 @@
<?php
/**
* HTML mail layout. Colors mirror the web tokens in webroot/css/plenario.css (light theme):
* --bg #f5f6fb, --surface #fff, --text #1d1f33, --muted #5d6280, --primary #4b3fe0.
* Inline styles and a table for the brand row: mail clients ignore stylesheets and flexbox.
*
* @var \App\View\AppView $this
*/
use App\Mailer\PollMailer;
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="color-scheme" content="light">
<title><?= $this->fetch('title') ?></title>
</head>
<body style="margin:0;padding:24px;background:#f4f5fb;font-family:Segoe UI,Helvetica,Arial,sans-serif;color:#1d1f33;">
<div style="max-width:560px;margin:0 auto;background:#ffffff;border-radius:12px;padding:32px;">
<p style="margin:0 0 24px;font-size:20px;font-weight:700;color:#4b3fe0;">PlenarIO</p>
<body style="margin:0;padding:24px;background:#f5f6fb;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1d1f33;">
<div style="max-width:560px;margin:0 auto;background:#ffffff;border-radius:12px;padding:32px;color:#1d1f33;">
<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:0 0 24px;">
<tr>
<td style="padding:0 10px 0 0;vertical-align:middle;">
<img src="cid:<?= PollMailer::LOGO_CID ?>" width="32" height="32" alt="" style="display:block;border:0;border-radius:8px;">
</td>
<td style="vertical-align:middle;font-size:20px;font-weight:800;line-height:1;color:#1d1f33;">Plenar<span style="color:#4b3fe0;">IO</span></td>
</tr>
</table>
<?= $this->fetch('content') ?>
</div>
</body>
+1 -1
View File
@@ -13,7 +13,7 @@
<meta name="robots" content="noindex">
<title><?= h($this->fetch('title')) ?> · PlenarIO</title>
<?= $this->element('theme_init') ?>
<?= $this->Html->meta('icon') ?>
<?= $this->element('favicon') ?>
<?= $this->Html->css(['normalize.min', 'plenario']) ?>
</head>
<body>
+2
View File
@@ -31,6 +31,8 @@
.banner--info { border-color: #dde0ee; background: #eef0f8; color: #1d1f33; }
.slide { border-top: 1px solid #dde0ee; padding-top: 4mm; margin-top: 5mm; page-break-inside: avoid; }
.slide--long { page-break-inside: auto; }
/* Every slide starts on a new page (the first one follows the title block). */
.slide + .slide { page-break-before: always; border-top: 0; padding-top: 0; margin-top: 0; }
.eyebrow { font-size: 8pt; text-transform: uppercase; letter-spacing: .5pt; color: #4b3fe0; margin-bottom: 1mm; }
.tag { color: #a86400; }
.tag--internal { color: #c42b4b; }
+1 -1
View File
@@ -14,7 +14,7 @@
<meta name="csrf-token" content="<?= h((string)$this->request->getAttribute('csrfToken')) ?>">
<title><?= h($this->fetch('title')) ?> · PlenarIO</title>
<?= $this->element('theme_init', ['key' => 'plenario-theme-present', 'fallback' => 'dark']) ?>
<?= $this->Html->meta('icon') ?>
<?= $this->element('favicon') ?>
<?= $this->Html->css(['normalize.min', 'plenario']) ?>
</head>
<body class="present">
@@ -0,0 +1,284 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Command;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Core\Configure;
use Cake\I18n\DateTime;
use Cake\TestSuite\EmailTrait;
use Cake\TestSuite\TestCase;
/**
* `bin/cake polls list|show|delete|remind|cleanup` and the poll expiry (counted from creation).
*/
class PollsCommandsTest extends TestCase
{
use ConsoleIntegrationTestTrait;
use EmailTrait;
use PlenarioTestTrait;
protected function setUp(): void
{
parent::setUp();
Configure::write('Plenario.retention.days', 90);
Configure::write('Plenario.retention.reminderDays', 14);
Configure::write('App.fullBaseUrl', 'https://plenario.test');
// The commands act on all polls: start without leftovers of other tests (fixtures are empty).
$this->slidesTable()->deleteAll('1 = 1');
$this->pollsTable()->deleteAll('1 = 1');
}
/**
* @param int $id Poll id
* @param int $days Age of the poll in days
*/
private function age(int $id, int $days): void
{
$this->pollsTable()->updateAll(['created' => DateTime::now()->subDays($days)], ['id' => $id]);
}
public function testExpiryCountsFromCreationNotFromAdminVisits(): void
{
[$poll] = $this->createPoll();
$this->assertSame($poll->created->addDays(90)->format('Y-m-d'), $poll->expiresAt()->format('Y-m-d'));
$this->assertSame($poll->created->addDays(76)->format('Y-m-d'), $poll->reminderAt()->format('Y-m-d'));
$this->age($poll->id, 91);
// A visit in the admin area changes nothing.
$this->pollsTable()->updateAll(['last_admin_access' => DateTime::now()], ['id' => $poll->id]);
$this->assertTrue($this->pollsTable()->get($poll->id)->isExpired());
}
public function testSeedCreatesNewPollWithLiveFirstSlideEveryTime(): void
{
$this->exec('polls seed --json');
$this->assertExitSuccess();
$first = json_decode(implode('', $this->_out->messages()), true);
$this->exec('polls seed --json');
$second = json_decode(implode('', $this->_out->messages()), true);
$this->assertNotSame($first['id'], $second['id']);
$this->assertNotSame($first['joinCode'], $second['joinCode']);
$this->assertSame(7, $second['slides']);
$poll = $this->pollsTable()->get($second['id']);
$slide = $this->slidesTable()->get($poll->current_slide_id);
$this->assertSame('choice', $slide->type);
$this->assertTrue($slide->isVotingOpen());
}
public function testSettingsAreRespected(): void
{
[$poll] = $this->createPoll();
$this->age($poll->id, 1000);
Configure::write('Plenario.retention.days', 0);
$this->assertNull($this->pollsTable()->get($poll->id)->expiresAt());
$this->assertSame(0, $this->pollsTable()->find('expired')->count());
$this->assertSame(0, $this->pollsTable()->find('reminderDue')->count());
// The reminder lead is always shorter than the lifetime.
Configure::write('Plenario.retention.days', 10);
Configure::write('Plenario.retention.reminderDays', 30);
$this->assertSame(9, $poll::reminderLeadDays());
}
public function testListShowsOwnerAndExpiredFilter(): void
{
[$old] = $this->createPoll('Alte Umfrage', 'alt@example.org');
$this->createPoll('Neue Umfrage', 'neu@example.org');
$this->age($old->id, 120);
$this->exec('polls list');
$this->assertExitSuccess();
$this->assertOutputContains('alt@example.org');
$this->assertOutputContains('neu@example.org');
$this->assertOutputContains('(abgelaufen)');
$this->exec('polls list --expired');
$this->assertOutputContains('alt@example.org');
$this->assertOutputNotContains('neu@example.org');
$this->exec('polls list --email=NEU@');
$this->assertOutputContains('neu@example.org');
$this->assertOutputNotContains('alt@example.org');
}
public function testShowPrintsAdminLinkOnlyOnRequest(): void
{
[$poll, $token] = $this->createPoll('Titel', 'owner@example.org');
$this->exec('polls show ' . $poll->join_code);
$this->assertExitSuccess();
$this->assertOutputContains('owner@example.org');
$this->assertOutputNotContains($token);
$this->exec('polls show ' . $poll->id . ' --link');
$this->assertExitSuccess();
$this->assertOutputContains('https://plenario.test/admin/' . $token);
$this->exec('polls show 99999');
$this->assertExitError();
}
public function testListAndShowAsJson(): void
{
[$old, $token] = $this->createPoll('Alt <b>&</b>', 'alt@example.org');
$this->createPoll('Neu', 'neu@example.org');
$this->age($old->id, 120);
$this->exec('polls list --json');
$this->assertExitSuccess();
$rows = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertCount(2, $rows);
$this->assertSame('Alt <b>&</b>', $rows[0]['title']);
$this->assertSame('alt@example.org', $rows[0]['email']);
$this->assertTrue($rows[0]['expired']);
$this->assertFalse($rows[1]['expired']);
$this->assertNull($rows[1]['reminderSentAt']);
$this->assertArrayNotHasKey('adminUrl', $rows[0]);
$this->assertStringNotContainsString($token, implode('', $this->_out->messages()));
$this->exec('polls list --json --expired');
$this->assertCount(1, json_decode(implode("
", $this->_out->messages()), true));
$this->exec('polls list --json --email=gibtsnicht');
$this->assertSame([], json_decode(implode("
", $this->_out->messages()), true));
$this->exec('polls show ' . $old->id . ' --json');
$data = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertSame($old->id, $data['id']);
$this->assertNull($data['adminUrl']);
$this->assertStringNotContainsString($token, implode('', $this->_out->messages()));
$this->exec('polls show ' . $old->id . ' --json --link');
$data = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertSame('https://plenario.test/admin/' . $token, $data['adminUrl']);
}
public function testDeleteRemovesPollWithSlides(): void
{
[$poll] = $this->createPoll();
$this->createSlide($poll);
$this->exec('polls delete ' . $poll->id . ' --yes');
$this->assertExitSuccess();
$this->assertSame(0, $this->pollsTable()->find()->where(['id' => $poll->id])->count());
$this->assertSame(0, $this->slidesTable()->find()->where(['poll_id' => $poll->id])->count());
// Again: unknown poll is an error, nothing else happens.
$this->exec('polls delete ' . $poll->id . ' --yes');
$this->assertExitError();
}
public function testReminderGoesOutOnceInTheLastDaysBeforeExpiry(): void
{
[$young, $youngToken] = $this->createPoll('Jung', 'jung@example.org');
[$due, $dueToken] = $this->createPoll('Bald weg', 'bald@example.org');
[$gone] = $this->createPoll('Abgelaufen', 'weg@example.org');
$this->age($young->id, 75);
$this->age($due->id, 77);
$this->age($gone->id, 91);
$this->exec('polls remind --dry-run');
$this->assertExitSuccess();
$this->assertOutputContains('bald@example.org');
$this->assertOutputNotContains('jung@example.org');
$this->assertOutputNotContains('weg@example.org');
$this->assertNull($this->pollsTable()->get($due->id)->expiry_reminded_at);
$this->exec('polls remind');
$this->assertExitSuccess();
$this->assertOutputContains('1 Erinnerung(en) verschickt');
$this->assertNotNull($this->pollsTable()->get($due->id)->expiry_reminded_at);
$this->assertNull($this->pollsTable()->get($young->id)->expiry_reminded_at);
// Second run: nothing more to send.
$this->exec('polls remind');
$this->assertOutputContains('0 Erinnerung(en) verschickt');
// Reminder switched off.
Configure::write('Plenario.retention.reminderDays', 0);
$this->age($young->id, 80);
$this->exec('polls remind');
$this->assertOutputContains('Erinnerungen sind aus');
$this->assertNull($this->pollsTable()->get($young->id)->expiry_reminded_at);
$this->assertNotEmpty($youngToken . $dueToken);
}
public function testRemindCanBeForcedForOnePoll(): void
{
[$young] = $this->createPoll('Frisch', 'frisch@example.org');
[$other] = $this->createPoll('Anderer', 'anderer@example.org');
// Not in the reminder window at all, yet it is sent on request, to this poll only.
$this->exec('polls remind ' . $young->join_code);
$this->assertExitSuccess();
$this->assertOutputContains('erzwungen');
$this->assertMailCount(1);
$this->assertMailSentTo('frisch@example.org');
$this->assertNull($this->pollsTable()->get($young->id)->expiry_reminded_at, 'a forced reminder does not mark the poll');
// Sendable again (also after a regular reminder), still not marked.
$this->pollsTable()->updateAll(['expiry_reminded_at' => DateTime::now()], ['id' => $young->id]);
$this->exec('polls remind ' . $young->id);
$this->assertExitSuccess();
$this->assertMailCount(2);
// Dry run sends nothing.
$this->exec('polls remind ' . $other->id . ' --dry-run');
$this->assertOutputContains('Würde erinnern');
$this->assertMailCount(2);
// Works with reminders switched off, fails without an expiry date and for unknown polls.
Configure::write('Plenario.retention.reminderDays', 0);
$this->exec('polls remind ' . $other->id);
$this->assertExitSuccess();
$this->assertMailCount(3);
$this->exec('polls remind 99999');
$this->assertExitError();
$this->assertErrorContains('nicht gefunden');
Configure::write('Plenario.retention.days', 0);
$this->exec('polls remind ' . $other->id);
$this->assertExitError();
$this->assertMailCount(3);
}
public function testCleanupRemindsThenDeletesOnlyExpiredPollsAndIsIdempotent(): void
{
[$old] = $this->createPoll('Alt');
[$soon] = $this->createPoll('Bald');
[$fresh] = $this->createPoll('Frisch');
$this->createSlide($old);
$this->age($old->id, 91);
$this->age($soon->id, 80);
$this->age($fresh->id, 10);
$this->exec('polls cleanup --dry-run');
$this->assertExitSuccess();
$this->assertSame(3, $this->pollsTable()->find()->count());
$this->assertNull($this->pollsTable()->get($soon->id)->expiry_reminded_at);
$this->exec('polls cleanup');
$this->assertExitSuccess();
$this->assertEqualsCanonicalizing(
[$soon->id, $fresh->id],
$this->pollsTable()->find()->all()->extract('id')->toList(),
);
$this->assertNotNull($this->pollsTable()->get($soon->id)->expiry_reminded_at);
$this->assertSame(0, $this->slidesTable()->find()->where(['poll_id' => $old->id])->count());
$this->exec('polls cleanup');
$this->assertExitSuccess();
$this->assertSame(2, $this->pollsTable()->find()->count());
}
}
@@ -107,7 +107,7 @@ class AdminControllerTest extends TestCase
$slide = $this->slidesTable()->find()->contain(['SlideOptions'])->firstOrFail();
$this->assertSame($poll->id, $slide->poll_id);
$this->assertSame(['Pizza', 'Pasta'], array_map(fn($o) => $o->label, $slide->slide_options));
$this->assertSame(['multiple' => true], $slide->settings);
$this->assertSame(['multiple' => true, 'comments' => false, 'comment_only' => false, 'time_limit' => 0], $slide->settings);
$this->assertSame(1, $slide->position);
}
@@ -172,6 +172,24 @@ class AdminControllerTest extends TestCase
$this->assertSame(Slide::QUIZ_READY, $slide->quizPhase());
}
public function testForwardOnQaWalksThroughStagesBeforeNextSlide(): void
{
[$poll, $token] = $this->createPoll();
$qa = $this->createSlide($poll, Slide::TYPE_QA, [], []);
$this->createSlide($poll);
$this->goLive($poll, $qa);
$this->post("/admin/$token/control", ['action' => 'next']);
$this->assertSame(Slide::QA_VOTE, $this->slidesTable()->get($qa->id)->qaStage());
$this->post("/admin/$token/control", ['action' => 'next']);
$this->assertSame(Slide::QA_DISCUSS, $this->slidesTable()->get($qa->id)->qaStage());
$this->assertSame($qa->id, $this->pollsTable()->get($poll->id)->current_slide_id);
// No questions to step through: now it goes to the next slide.
$this->post("/admin/$token/control", ['action' => 'next']);
$this->assertNotSame($qa->id, $this->pollsTable()->get($poll->id)->current_slide_id);
}
public function testEditKeepsVotesOfUnchangedOptions(): void
{
[$poll, $token] = $this->createPoll();
@@ -64,6 +64,8 @@ class AdminFragmentTest extends TestCase
$this->assertResponseNotContains('onclick=');
$this->assertResponseContains('data-confirm=');
// Required fields (settings form) must not get generated oninvalid/oninput handlers, the CSP blocks them.
$this->assertDoesNotMatchRegularExpression('/\son[a-z]+="/', (string)$this->_response->getBody());
}
public function testSlideFormFragmentIsTheDialogContent(): void
@@ -0,0 +1,213 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Poll;
use App\Model\Entity\Slide;
use App\Model\Table\SlidesTable;
use App\Service\ResultsService;
use App\Service\VoteException;
use App\Service\VoteService;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Multiple choice slides with an optional comment field (stored once per participant in the first row).
*/
class ChoiceCommentsTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
/**
* @param array<string, mixed> $settings Extra settings
* @return array{0: \App\Model\Entity\Poll, 1: string, 2: \App\Model\Entity\Slide}
*/
protected function choiceWithComments(array $settings = ['comments' => true, 'multiple' => true]): array
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE, ['settings' => $settings], ['Ja', 'Nein', 'Vielleicht']);
$poll = $this->goLive($poll, $slide);
return [$poll, $token, $slide];
}
protected function hash(string $char, Poll $poll): string
{
return VoteService::participantHash(str_repeat($char, 32), $poll->id);
}
public function testSettingIsSanitized(): void
{
$this->assertTrue(SlidesTable::sanitizeSettings(Slide::TYPE_CHOICE, ['comments' => '1'])['comments']);
$this->assertFalse(SlidesTable::sanitizeSettings(Slide::TYPE_CHOICE, [])['comments']);
}
public function testFormShowsAndSavesCommentSetting(): void
{
[, $token] = $this->createPoll();
$this->get("/admin/$token/slides/add?type=choice");
$this->assertResponseContains('name="settings[comment_mode]"');
$this->post("/admin/$token/slides/add?type=choice", [
'type' => 'choice',
'question' => 'Was nehmen wir?',
'options_text' => "Ja\nNein",
'settings' => ['comments' => '1'],
]);
$slide = $this->slidesTable()->find()->firstOrFail();
$this->assertTrue($slide->hasComments());
}
public function testParticipantPageShowsCommentFieldOnlyWhenEnabled(): void
{
[$poll] = $this->choiceWithComments();
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('name="comment"');
[$other] = $this->choiceWithComments(['multiple' => true]);
$this->get('/p/' . $other->join_code);
$this->assertResponseNotContains('name="comment"');
}
public function testCommentIsStoredOnceInFirstRowAndCountsStayCorrect(): void
{
[$poll, , $slide] = $this->choiceWithComments();
$options = array_map(fn($o) => $o->id, $slide->slide_options);
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_ids' => [$options[0], $options[2]],
'comment' => ' Weil <deshalb> ',
]);
$rows = $this->slidesTable()->Responses->find()->where(['slide_id' => $slide->id])->orderBy(['id' => 'ASC'])->all()->toList();
$this->assertCount(2, $rows);
$this->assertSame('Weil <deshalb>', $rows[0]->text_value);
$this->assertNull($rows[1]->text_value);
$results = (new ResultsService())->forSlide($slide);
$this->assertSame([1, 0, 1], array_column($results['options'], 'count'));
$this->assertSame(2, $results['votes']);
$this->assertSame(1, $results['participants']);
$this->assertSame(['Weil <deshalb>'], array_column($results['comments'], 'text'));
$this->assertSame([null], array_column($results['comments'], 'value'));
}
public function testCommentIsIgnoredWithoutCommentField(): void
{
[$poll, , $slide] = $this->choiceWithComments(['multiple' => false]);
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_id' => $slide->slide_options[0]->id,
'comment' => 'Eingeschmuggelt',
]);
$row = $this->slidesTable()->Responses->find()->where(['slide_id' => $slide->id])->firstOrFail();
$this->assertNull($row->text_value);
$this->assertSame([], (new ResultsService())->forSlide($slide)['comments']);
}
public function testTooLongCommentIsRejected(): void
{
[$poll, , $slide] = $this->choiceWithComments();
$this->expectException(VoteException::class);
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_ids' => [$slide->slide_options[0]->id],
'comment' => str_repeat('x', VoteService::MAX_TEXT_LENGTH + 1),
]);
}
public function testCommentCanBeEditedAddedAndRemoved(): void
{
[$poll, , $slide] = $this->choiceWithComments();
$hash = $this->hash('a', $poll);
$votes = new VoteService();
$votes->submit($poll, $slide, $hash, [
'option_ids' => [$slide->slide_options[0]->id, $slide->slide_options[1]->id],
]);
$this->assertNull($votes->ownText($slide, $hash));
$votes->editText($poll, $slide, $hash, ['comment' => 'Nachgereicht']);
$this->assertSame('Nachgereicht', $votes->ownText($slide, $hash));
$votes->editText($poll, $slide, $hash, ['comment' => 'Korrigiert']);
$this->assertSame(['Korrigiert'], array_column((new ResultsService())->comments($slide), 'text'));
$this->assertSame(2, $this->slidesTable()->Responses->find()->where(['slide_id' => $slide->id])->count());
$votes->editText($poll, $slide, $hash, ['comment' => '']);
$this->assertNull($votes->ownText($slide, $hash));
$this->assertSame([], (new ResultsService())->comments($slide));
}
public function testEditRequiresAnAnswer(): void
{
[$poll, , $slide] = $this->choiceWithComments();
$this->expectException(VoteException::class);
(new VoteService())->editText($poll, $slide, $this->hash('z', $poll), ['comment' => 'Ohne Auswahl']);
}
public function testPresenterGetsCommentsButParticipantsNever(): void
{
[$poll, $token, $slide] = $this->choiceWithComments();
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_ids' => [$slide->slide_options[0]->id],
'comment' => 'Sichtbar auf der Bühne',
]);
$this->get("/admin/$token/state");
$results = json_decode((string)$this->_response->getBody(), true)['results'];
$this->assertSame(['Sichtbar auf der Bühne'], array_column($results['comments'], 'text'));
$this->get('/p/' . $poll->join_code . '/state');
$state = json_decode((string)$this->_response->getBody(), true);
$this->assertNull($state['results']);
$this->assertStringNotContainsString('Sichtbar auf der Bühne', (string)$this->_response->getBody());
}
public function testAnswersPageListsCommentsOfChoiceSlides(): void
{
[$poll, $token, $slide] = $this->choiceWithComments();
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_ids' => [$slide->slide_options[0]->id],
'comment' => 'Erster <Kommentar>',
]);
$this->get("/admin/$token/slides/{$slide->id}/answers");
$this->assertResponseOk();
$this->assertResponseContains('Erster &lt;Kommentar&gt;');
}
public function testAnswersPageIsNotFoundForChoiceWithoutComments(): void
{
[, $token, $slide] = $this->choiceWithComments(['multiple' => false]);
$this->get("/admin/$token/slides/{$slide->id}/answers");
$this->assertResponseCode(404);
}
public function testExportContainsComments(): void
{
[$poll, $token, $slide] = $this->choiceWithComments();
(new VoteService())->submit($poll, $slide, $this->hash('a', $poll), [
'option_ids' => [$slide->slide_options[0]->id],
'comment' => 'Im PDF enthalten',
]);
$this->assertStringContainsString('Im PDF enthalten', $this->exportHtml($token));
}
}
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Service\VoteService;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Cloning a whole poll without responses (admin:clone).
*/
class ClonePollTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
public function testCopiesSlidesButNoResponses(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CHOICE, ['description' => '*Wichtig*'], ['Rot', 'Grün']);
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ, [], ['Richtig', 'Falsch']);
$hidden = $this->createSlide($poll, Slide::TYPE_OPEN);
$hidden->is_hidden = true;
$this->slidesTable()->saveOrFail($hidden);
$poll = $this->goLive($poll, $first);
(new VoteService())->submit($poll, $first, VoteService::participantHash(str_repeat('a', 32), $poll->id), [
'option_id' => $first->slide_options[0]->id,
]);
$this->post("/admin/$token/clone");
$polls = $this->pollsTable()->find()->orderBy(['id' => 'ASC'])->all()->toList();
$this->assertCount(2, $polls);
$copy = $polls[1];
$this->assertNotSame($poll->join_code, $copy->join_code);
$this->assertSame($poll->email, $copy->email);
$this->assertStringEndsWith('(Kopie)', $copy->title);
$this->assertNull($copy->current_slide_id, 'copy is not started');
$this->assertSame($first->id, $this->pollsTable()->get($poll->id)->current_slide_id, 'original stays live');
$slides = $this->slidesTable()->listForPoll($copy->id);
$this->assertSame([1, 2, 3], array_map(fn($s) => $s->position, $slides));
$this->assertSame(
[$first->question, $quiz->question, $hidden->question],
array_map(fn($s) => $s->question, $slides),
);
$this->assertSame('*Wichtig*', $slides[0]->description);
$this->assertSame(['Rot', 'Grün'], array_map(fn($o) => $o->label, $slides[0]->slide_options));
$this->assertSame([true, false], array_map(fn($o) => $o->is_correct, $slides[1]->slide_options));
$this->assertTrue($slides[2]->is_hidden);
$this->assertSame(Slide::QUIZ_READY, $slides[1]->quizPhase());
$responses = TableRegistry::getTableLocator()->get('Responses');
$this->assertSame(0, $responses->find()->matching('Slides', fn($q) => $q->where(['Slides.poll_id' => $copy->id]))->count());
$this->assertSame(1, $responses->find()->where(['slide_id' => $first->id])->count(), 'original keeps its votes');
$this->assertCount(3, $this->slidesTable()->listForPoll($poll->id));
}
public function testRedirectsToAdminOfTheCopyOnlyViaPost(): void
{
[, $token] = $this->createPoll();
$this->get("/admin/$token/clone");
$this->assertResponseCode(404);
$this->post("/admin/$token/clone");
$this->assertResponseCode(302);
$this->assertRedirectContains('/admin/');
$this->assertHeaderNotContains('Location', $token);
}
public function testDashboardOffersCloneAndMenu(): void
{
[, $token] = $this->createPoll();
$this->get("/admin/$token");
$this->assertResponseContains("/admin/$token/clone");
$this->assertResponseContains('data-drawer-toggle');
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* The logo as favicon: links in every layout and the files behind them.
*/
class FaviconTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
public function testAllLayoutsLinkTheIcons(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll);
// default, present and error layout
foreach (['/', '/admin/' . $token . '/present', '/does-not-exist'] as $url) {
$this->get($url);
// Root-relative, no "img/" prefix (static files live directly in webroot/).
$this->assertResponseRegExp('#<link rel="icon" href="/favicon\.svg(\?[^"]*)?" type="image/svg\+xml">#', $url);
$this->assertResponseRegExp('#<link rel="icon" href="/favicon\.ico(\?[^"]*)?" sizes="32x32">#', $url);
$this->assertResponseRegExp('#<link rel="apple-touch-icon" href="/apple-touch-icon\.png(\?[^"]*)?">#', $url);
}
}
public function testIconFilesAreValid(): void
{
$svg = (string)file_get_contents(WWW_ROOT . 'favicon.svg');
$this->assertStringContainsString('<svg', $svg);
$this->assertNotFalse(simplexml_load_string($svg), 'favicon.svg is not well-formed XML');
// ICO: reserved 0, type 1, three images; each entry's data starts with the PNG signature.
$ico = (string)file_get_contents(WWW_ROOT . 'favicon.ico');
$header = unpack('vreserved/vtype/vcount', $ico);
$this->assertSame([0, 1, 3], [$header['reserved'], $header['type'], $header['count']]);
for ($i = 0; $i < $header['count']; $i++) {
$entry = unpack('Voffset', $ico, 6 + 16 * $i + 12);
$this->assertSame("\x89PNG", substr($ico, $entry['offset'], 4));
}
$this->assertSame([180, 180], array_slice(getimagesize(WWW_ROOT . 'apple-touch-icon.png'), 0, 2));
}
}
+64 -2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Service\PollStateService;
use App\Service\ResultsService;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
@@ -35,7 +37,7 @@ class OrderSlideTest extends TestCase
$this->assertResponseContains('name="order_options[]"');
$this->assertResponseContains('data-order-options');
$data = ['type' => 'order', 'question' => 'Sortiere nach Größe', 'is_voting_open' => '1'];
$data = ['type' => 'order', 'question' => 'Sortiere nach Größe', 'is_voting_open' => '0'];
$this->post("/admin/$token/slides/add?type=order", $data + ['order_options' => ['Maus', '', '']]);
$this->assertResponseOk();
$this->assertResponseContains('Bitte gib mindestens zwei Einträge an.');
@@ -47,7 +49,7 @@ class OrderSlideTest extends TestCase
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->contain(['SlideOptions'])->firstOrFail();
$this->assertSame(['Maus', 'Katze', 'Elefant'], array_map(fn($o) => $o->label, $slide->slide_options));
$this->assertTrue($slide->is_voting_open);
$this->assertTrue($slide->is_voting_open, 'the form cannot close voting, only the presenter can');
$ids = array_map(fn($o) => $o->id, $slide->slide_options);
// Reordering in the editor keeps the options (ids), only the positions change.
@@ -90,4 +92,64 @@ class OrderSlideTest extends TestCase
$this->assertStringContainsString('1 von 1', $html);
$this->assertStringContainsString('komplett richtig sortiert', $html);
}
public function testNextRevealsAnOpenOrderSlideBeforeMovingOn(): void
{
[$poll, $token] = $this->createPoll();
$order = $this->createSlide($poll, Slide::TYPE_ORDER, [], ['Eins', 'Zwei', 'Drei']);
$next = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->goLive($poll, $order);
// First forward closes the voting (solution), the slide stays live.
$this->post("/admin/$token/control", ['action' => 'next']);
$poll = $this->pollsTable()->get($poll->id);
$this->assertSame($order->id, $poll->current_slide_id);
$this->assertFalse($this->slidesTable()->get($order->id)->isVotingOpen());
// A second forward (and a repeated one) really moves on.
$this->post("/admin/$token/control", ['action' => 'next']);
$this->assertSame($next->id, $this->pollsTable()->get($poll->id)->current_slide_id);
}
public function testRankingHasNoSolutionAndShowsAverageOrder(): void
{
[$poll, $token] = $this->createPoll();
$this->post("/admin/$token/slides/add?type=order", [
'type' => 'order', 'question' => 'Was ist dir wichtig?',
'settings' => ['ranking' => '1'], 'order_options' => ['Eins', 'Zwei', 'Drei'],
]);
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->contain(['SlideOptions'])->firstOrFail();
$this->assertTrue($slide->isRanking());
$this->goLive($poll, $slide);
[$a, $b, $c] = array_map(fn($o) => $o->id, $slide->slide_options);
// Two people rank Drei first; the stored order of the entries has no meaning.
foreach (['c' => [$c, $a, $b], 'd' => [$c, $b, $a]] as $pid => $order) {
$this->cookie('plenario_pid', str_repeat($pid, 32));
$this->post('/p/' . $poll->join_code . '/vote', ['slide_id' => $slide->id, 'order' => $order]);
}
// Participant: confirmation only, no results, no verdict - even after closing.
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('Deine Reihenfolge ist angekommen.');
$this->assertResponseNotContains('Auflösung gibt es');
$this->post("/admin/$token/control", ['action' => 'toggle']);
$this->get('/p/' . $poll->join_code);
$this->assertResponseNotContains('deine Reihenfolge stimmt');
$this->assertResponseNotContains('Leider');
$state = (new PollStateService())->forParticipant($this->pollsTable()->get($poll->id), str_repeat('c', 32));
$this->assertNull($state['results']);
$this->assertFalse($state['order']['revealed']);
// Presenter/export: items by average position, Drei first.
$results = (new ResultsService())->forSlide($this->slidesTable()->get($slide->id, contain: ['SlideOptions']));
$this->assertTrue($results['ranking']);
// Eins and Zwei tie at 2.5 and keep the order of the entries.
$this->assertSame(['Drei', 'Eins', 'Zwei'], array_column($results['items'], 'label'));
$this->assertSame(1.0, (float)$results['items'][0]['average']);
$this->assertSame(100.0, (float)$results['items'][0]['score']);
$html = $this->exportHtml($token);
$this->assertStringContainsString('Einschätzungen, sortiert nach', $html);
}
}
@@ -238,4 +238,29 @@ class ParticipateControllerTest extends TestCase
$this->assertFlashMessage('Diese Antwort kann nicht mehr geändert werden.');
$this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack']));
}
public function testScaleCommentOnlyWithoutRating(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseNotContains('auch nur einen Kommentar');
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('auch nur einen Kommentar');
$this->assertResponseNotContains('required>');
$this->cookie('plenario_pid', self::PID);
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'comment' => 'Keine Meinung dazu']);
$this->assertFlashMessage('Danke für deine Antwort!');
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('Keine Meinung dazu');
}
}
+169
View File
@@ -0,0 +1,169 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Command\ImagesCleanupCommand;
use App\Service\AudioService;
use App\Service\PollStateService;
use App\Test\TestCase\ImageTestTrait;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\TestSuite\StubConsoleOutput;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
use Laminas\Diactoros\UploadedFile;
/**
* Countdown music of a presentation: upload, replace, remove, delivery, state and copying.
*/
class PollAudioTest extends TestCase
{
use ImageTestTrait;
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
protected function tearDown(): void
{
$this->clearImages();
parent::tearDown();
}
/**
* Writes a small file with the given leading bytes.
*
* @param string $head First bytes
* @return string Path
*/
protected function makeAudio(string $head = "ID3\x03\x00\x00\x00\x00\x00\x00"): string
{
$path = tempnam(sys_get_temp_dir(), 'plen');
file_put_contents($path, $head . str_repeat("\x00", 2000));
$this->imageFiles[] = $path;
return $path;
}
protected function upload(string $token, ?string $path, array $data = []): void
{
$this->_request['files'] = $path === null ? [] : [
'audio' => new UploadedFile($path, (int)filesize($path), UPLOAD_ERR_OK, 'musik.mp3', 'audio/mpeg'),
];
try {
$this->post("/admin/$token/audio", $data);
} finally {
$this->_request['files'] = [];
}
}
public function testUploadServeReplaceAndRemove(): void
{
[$poll, $token] = $this->createPoll();
$this->upload($token, $this->makeAudio());
$this->assertRedirect(['_name' => 'admin', 'token' => $token, '#' => 'audio']);
$first = (string)$this->pollsTable()->get($poll->id)->audio;
$this->assertMatchesRegularExpression('/^[a-f0-9]{24}\.mp3$/', $first);
$this->assertSame([$first], $this->storedImages($poll->id));
$this->get("/admin/$token");
$this->assertResponseOk();
$this->assertResponseContains('<audio controls');
$this->assertResponseContains('Audiodatei entfernen');
// The presenter state carries the URL, the participant page never plays it but the file is served.
$fresh = $this->pollsTable()->get($poll->id);
$state = (new PollStateService())->forPresenter($fresh);
$this->assertStringContainsString("/p/{$poll->join_code}/audio/$first", (string)$state['poll']['audioUrl']);
$this->get("/p/{$poll->join_code}/audio/$first");
$this->assertResponseOk();
$this->assertContentType('audio/mpeg');
$this->assertHeader('X-Content-Type-Options', 'nosniff');
// Replacing: new random name, the old file is gone and no longer served.
$this->upload($token, $this->makeAudio("RIFF\x00\x00\x00\x00WAVE"));
$second = (string)$this->pollsTable()->get($poll->id)->audio;
$this->assertMatchesRegularExpression('/^[a-f0-9]{24}\.wav$/', $second);
$this->assertSame([$second], $this->storedImages($poll->id));
$this->get("/p/{$poll->join_code}/audio/$first");
$this->assertResponseCode(404);
// Removing is explicit and repeatable.
foreach ([1, 2] as $ignored) {
$this->post("/admin/$token/audio", ['remove' => '1']);
$this->assertRedirect();
$this->assertNull($this->pollsTable()->get($poll->id)->audio);
$this->assertSame([], $this->storedImages($poll->id));
}
}
public function testRejectsOtherFilesAndEmptyRequests(): void
{
[$poll, $token] = $this->createPoll();
$this->upload($token, $this->makeAudio('<html><script>alert(1)</script>'));
$this->assertRedirect();
$this->assertNull($this->pollsTable()->get($poll->id)->audio);
$this->assertSame([], $this->storedImages($poll->id));
$this->upload($token, null);
$this->assertRedirect();
$this->assertNull($this->pollsTable()->get($poll->id)->audio);
}
public function testFileOfAnotherPollIsNotServed(): void
{
[$poll, $token] = $this->createPoll();
[$other] = $this->createPoll();
$this->upload($token, $this->makeAudio());
$file = (string)$this->pollsTable()->get($poll->id)->audio;
$this->get("/p/{$other->join_code}/audio/$file");
$this->assertResponseCode(404);
}
public function testFormatDetection(): void
{
$this->assertSame('mp3', AudioService::detectFormat("\xFF\xFB\x90\x00" . str_repeat("\x00", 20)));
$this->assertSame('mp3', AudioService::detectFormat("ID3\x04" . str_repeat("\x00", 20)));
$this->assertSame('ogg', AudioService::detectFormat('OggS' . str_repeat("\x00", 20)));
$this->assertSame('m4a', AudioService::detectFormat("\x00\x00\x00\x20ftypM4A " . str_repeat("\x00", 20)));
$this->assertNull(AudioService::detectFormat('GIF89a' . str_repeat("\x00", 20)));
$this->assertNull(AudioService::detectFormat("\xFF\xE1\x00\x00" . str_repeat("\x00", 20)), 'reserved layer');
$this->assertNull(AudioService::detectFormat('short'));
}
public function testCloneCopiesTheFileAndCleanupKeepsIt(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll, 'quiz');
$this->upload($token, $this->makeAudio());
$original = (string)$this->pollsTable()->get($poll->id)->audio;
$slides = $this->slidesTable()->listForPoll($poll->id);
[$copy] = $this->pollsTable()->clonePoll($this->pollsTable()->get($poll->id), $slides);
$copied = (string)$this->pollsTable()->get($copy->id)->audio;
$this->assertNotSame($original, $copied, 'own file per poll');
$this->assertSame([$copied], $this->storedImages($copy->id));
$this->assertSame([$original], $this->storedImages($poll->id));
// The sweep for leftovers must not take the music.
$command = new ImagesCleanupCommand();
$command->execute(new Arguments([], ['dry-run' => false], []), new ConsoleIo(new StubConsoleOutput(), new StubConsoleOutput()));
$this->assertSame([$original], $this->storedImages($poll->id));
$this->assertSame([$copied], $this->storedImages($copy->id));
}
}
+109 -6
View File
@@ -52,9 +52,11 @@ class PollResetTest extends TestCase
$quiz->setVotingOpen(true);
$quiz->is_voting_open = false;
$order->is_voting_open = false;
$choice->is_voting_open = false;
$qa->stage = Slide::QA_DISCUSS;
$qa->is_voting_open = false;
$this->slidesTable()->saveManyOrFail([$quiz, $order, $qa]);
$this->slidesTable()->saveManyOrFail([$quiz, $order, $qa, $choice]);
$poll->showSlide($qa->id);
$poll->pause();
$this->pollsTable()->saveOrFail($poll);
@@ -66,23 +68,63 @@ class PollResetTest extends TestCase
$this->assertSame(0, $responses->find()->where(['slide_id IN' => [$choice->id, $quiz->id, $order->id, $qa->id]])->count());
$this->assertSame(1, $responses->find()->where(['slide_id' => $foreign->id])->count(), 'other polls stay untouched');
// The presentation stays where it is (paused on the choice slide).
// The presentation is back to "not started".
$poll = $this->pollsTable()->get($poll->id);
$this->assertNull($poll->current_slide_id);
$this->assertSame($choice->id, $poll->paused_slide_id);
$this->assertNull($poll->paused_slide_id);
$slides = $this->slidesTable();
$this->assertSame(Slide::QUIZ_READY, $slides->get($quiz->id)->quizPhase());
$this->assertNull($slides->get($quiz->id)->voting_started_at);
$this->assertFalse($slides->get($order->id)->is_voting_open, 'open/closed is kept');
$this->assertTrue($slides->get($order->id)->is_voting_open, 'ordering is open again, solution hidden');
$this->assertSame(Slide::QA_COLLECT, $slides->get($qa->id)->qaStage());
$this->assertTrue($slides->get($qa->id)->is_voting_open);
$this->assertTrue($slides->get($choice->id)->is_voting_open);
$this->assertTrue($slides->get($choice->id)->is_voting_open, 'closed slides are open again');
// Idempotent: a second reset changes nothing and does not fail.
$this->post("/admin/$token/reset");
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$this->assertSame($choice->id, $this->pollsTable()->get($poll->id)->paused_slide_id);
$this->assertNull($this->pollsTable()->get($poll->id)->paused_slide_id);
}
public function testResetStopsLivePresentation(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll, Slide::TYPE_CHOICE);
$second = $this->createSlide($poll, Slide::TYPE_CHOICE);
$poll = $this->goLive($poll, $second);
(new VoteService())->submit($poll, $second, VoteService::participantHash(str_repeat('a', 32), $poll->id), [
'option_id' => $second->slide_options[0]->id,
]);
$this->post("/admin/$token/reset");
$reloaded = $this->pollsTable()->get($poll->id);
$this->assertNull($reloaded->current_slide_id);
$this->assertNull($reloaded->paused_slide_id);
}
public function testResetKeepsPreparedQuestionsUnlessAsked(): void
{
[$poll, $token] = $this->createPoll();
$qa = $this->createSlide($poll, Slide::TYPE_QA);
$responses = TableRegistry::getTableLocator()->get('Responses');
$question = $responses->saveOrFail($responses->newEntity([
'slide_id' => $qa->id,
'participant_hash' => VoteService::PREPARED_HASH,
'text_value' => 'Vorbereitet?',
], ['accessibleFields' => ['*' => true]]));
$responses->saveOrFail($responses->newEntity([
'slide_id' => $qa->id,
'participant_hash' => VoteService::participantHash(str_repeat('a', 32), $poll->id),
'parent_id' => $question->id,
], ['accessibleFields' => ['*' => true]]));
$this->post("/admin/$token/reset");
$this->assertSame(1, $responses->find()->where(['slide_id' => $qa->id])->count());
$this->assertSame(1, $responses->find()->where(['id' => $question->id])->count());
$this->post("/admin/$token/reset", ['keep_prepared' => '0']);
$this->assertSame(0, $responses->find()->where(['slide_id' => $qa->id])->count());
}
public function testResetRequiresPost(): void
@@ -107,4 +149,65 @@ class PollResetTest extends TestCase
$this->get("/admin/$token");
$this->assertResponseContains("/admin/$token/reset\"");
}
public function testDashboardOffersResetWithoutAnswersWhenSlidesWereTouched(): void
{
[$poll, $token] = $this->createPoll();
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ);
$quiz->startFresh();
$this->slidesTable()->saveOrFail($quiz);
$choice = $this->createSlide($poll, Slide::TYPE_CHOICE);
$this->get("/admin/$token");
$this->assertResponseContains('Noch nichts zurückzusetzen');
// Quiz started, nobody answered yet.
$quiz->setVotingOpen(true);
$this->slidesTable()->saveOrFail($quiz);
$this->get("/admin/$token");
$this->assertResponseContains("/admin/$token/reset\"");
$this->assertResponseContains("/admin/$token/slides/{$quiz->id}/reset");
$this->assertResponseNotContains("/admin/$token/slides/{$choice->id}/reset");
// Closed slide.
$quiz->startFresh();
$this->slidesTable()->saveOrFail($quiz);
$choice->is_voting_open = false;
$this->slidesTable()->saveOrFail($choice);
$this->get("/admin/$token");
$this->assertResponseContains("/admin/$token/reset\"");
$this->assertResponseContains("/admin/$token/slides/{$choice->id}/reset");
// Presentation running.
$choice->startFresh();
$this->slidesTable()->saveOrFail($choice);
$this->goLive($poll, $choice);
$this->get("/admin/$token");
$this->assertResponseContains("/admin/$token/reset\"");
}
public function testDashboardLiveVersionFollowsThePresenter(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CHOICE);
$second = $this->createSlide($poll, Slide::TYPE_CHOICE);
$version = function () use ($token): string {
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
$this->get("/admin/$token/live");
$this->assertResponseOk();
return json_decode((string)$this->_response->getBody(), true)['version'];
};
$start = $version();
$this->assertSame($start, $version(), 'stable while nothing happens');
$poll = $this->goLive($poll, $first);
$live = $version();
$this->assertNotSame($start, $live, 'live slide changed');
$this->goLive($poll, $second);
$this->assertNotSame($live, $version(), 'live marker moved');
$this->assertStringNotContainsString($token, (string)$this->_response->getBody());
}
}
@@ -0,0 +1,123 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Service\PollStateService;
use App\Service\QaService;
use App\Service\VoteService;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Questions the admin enters beforehand on a Q&A slide (textarea `prepared_text`).
*/
class QaPreparedTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
public function testParsePreparedCleansLines(): void
{
$texts = QaService::parsePrepared(" Wann geht's los? \n\nwann geht's LOS?\r\nZweite Frage");
$this->assertSame(["Wann geht's los?", 'Zweite Frage'], $texts);
}
public function testCreatingSlideStoresPreparedQuestions(): void
{
[$poll, $token] = $this->createPoll();
$this->post("/admin/$token/slides/add", [
'type' => Slide::TYPE_QA,
'question' => 'Fragen',
'prepared_text' => "Frage A\nFrage B",
]);
$this->assertRedirect();
$slide = $this->slidesTable()->listForPoll($poll->id)[0];
$this->assertSame(['Frage A', 'Frage B'], (new QaService())->preparedQuestions($slide));
}
public function testEditSyncsAndIsIdempotent(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA);
$url = "/admin/$token/slides/{$slide->id}/edit";
$data = ['question' => 'Fragen', 'prepared_text' => "Frage A\nFrage B"];
$this->post($url, $data);
$responses = TableRegistry::getTableLocator()->get('Responses');
$ids = $responses->find()->where(['slide_id' => $slide->id])->all()->extract('id')->toList();
$this->assertCount(2, $ids);
$this->post($url, $data);
$this->assertSame($ids, $responses->find()->where(['slide_id' => $slide->id])->all()->extract('id')->toList());
$this->post($url, ['prepared_text' => "Frage B\nFrage C"] + $data);
$this->assertSame(['Frage B', 'Frage C'], (new QaService())->preparedQuestions($slide));
}
public function testParticipantQuestionsAreKeptAndNotDuplicated(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA);
$poll = $this->goLive($poll, $slide);
$hash = VoteService::participantHash(str_repeat('a', 32), $poll->id);
(new VoteService())->submit($poll, $slide, $hash, ['question' => 'Eigene Frage']);
$this->post("/admin/$token/slides/{$slide->id}/edit", [
'question' => 'Fragen',
'prepared_text' => "eigene frage\nVorab",
]);
$this->post("/admin/$token/slides/{$slide->id}/edit", ['question' => 'Fragen', 'prepared_text' => '']);
$responses = TableRegistry::getTableLocator()->get('Responses');
$this->assertSame(
['Eigene Frage'],
$responses->find()->where(['slide_id' => $slide->id])->all()->extract('text_value')->toList(),
);
}
public function testPreparedQuestionsAppearForParticipantsButNotAsOwn(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA);
(new QaService())->syncPrepared($slide, ['Vorab']);
$poll = $this->goLive($poll, $slide);
$slide = $this->slidesTable()->get($slide->id);
$hash = VoteService::participantHash(str_repeat('b', 32), $poll->id);
$qa = (new PollStateService())->qaState($slide, $hash);
$this->assertCount(1, $qa['questions']);
$this->assertSame([], $qa['mine']);
$this->assertSame(0, TableRegistry::getTableLocator()->get('Responses')->countParticipants($slide->id));
}
public function testNotChangedOutsideCollectStage(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA);
(new QaService())->syncPrepared($slide, ['Vorab']);
(new QaService())->setStage($slide, Slide::QA_VOTE);
$this->post("/admin/$token/slides/{$slide->id}/edit", ['question' => 'Fragen', 'prepared_text' => '']);
$this->assertSame(['Vorab'], (new QaService())->preparedQuestions($slide));
}
}
@@ -0,0 +1,95 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Poll;
use App\Model\Entity\Slide;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Stepping through a presentation with a clicker (only next/prev): a quiz is started and ended before moving on.
*/
class QuizClickerTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
/**
* @return array<string, mixed>
*/
protected function control(string $token, string $action): array
{
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
$this->post("/admin/$token/control", ['action' => $action]);
$this->assertResponseOk();
return json_decode((string)$this->_response->getBody(), true);
}
protected function createQuiz(Poll $poll, array $data = []): Slide
{
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ, $data);
$quiz->startFresh();
return $this->slidesTable()->saveOrFail($quiz);
}
public function testNextStartsAndEndsQuizBeforeMovingOn(): void
{
[$poll, $token] = $this->createPoll();
$intro = $this->createSlide($poll, Slide::TYPE_CONTENT);
$quiz = $this->createQuiz($poll, ['settings' => ['time_limit' => 0] + Slide::DEFAULT_SETTINGS[Slide::TYPE_QUIZ]]);
$outro = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->goLive($poll, $intro);
// Arriving at the quiz does not start it.
$state = $this->control($token, 'next');
$this->assertSame($quiz->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_READY, $this->slidesTable()->get($quiz->id)->quizPhase());
// Next: start. Next: end. Next: next slide.
$state = $this->control($token, 'next');
$this->assertSame($quiz->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_RUNNING, $this->slidesTable()->get($quiz->id)->quizPhase());
$state = $this->control($token, 'next');
$this->assertSame($quiz->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($quiz->id)->quizPhase());
$state = $this->control($token, 'next');
$this->assertSame($outro->id, $state['slide']['id']);
// Back never restarts the quiz: it is passed through and stays finished.
$state = $this->control($token, 'prev');
$this->assertSame($quiz->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($quiz->id)->quizPhase());
$state = $this->control($token, 'prev');
$this->assertSame($intro->id, $state['slide']['id']);
}
public function testPrevOnUnstartedQuizJustGoesBack(): void
{
[$poll, $token] = $this->createPoll();
$intro = $this->createSlide($poll, Slide::TYPE_CONTENT);
$quiz = $this->createQuiz($poll);
$this->goLive($poll, $quiz);
$state = $this->control($token, 'prev');
$this->assertSame($intro->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_READY, $this->slidesTable()->get($quiz->id)->quizPhase());
}
}
@@ -0,0 +1,333 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Test\TestCase\ImageTestTrait;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\Core\Configure;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Images on slides: upload and scaling, alternative text, quota, serving, and what happens to the
* file when the image is replaced, removed or the slide (or poll) is deleted or duplicated.
*/
class SlideImageTest extends TestCase
{
use ImageTestTrait;
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
protected function tearDown(): void
{
$this->clearImages();
parent::tearDown();
}
/**
* Creates a content slide with an uploaded image through the form.
*
* @return array{0: \App\Model\Entity\Poll, 1: string, 2: \App\Model\Entity\Slide}
*/
protected function slideWithImage(array $data = []): array
{
[$poll, $token] = $this->createPoll();
$this->postWithImage("/admin/$token/slides/add?type=content", $data + [
'type' => 'content',
'question' => 'Mit Bild',
], $this->makeImage(3000, 2000));
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->first();
return [$poll, $token, $slide];
}
public function testUploadStoresScaledImageWithAltAndLayout(): void
{
[$poll, $token, $slide] = $this->slideWithImage(['image_layout' => 'full']);
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$this->assertNotNull($slide);
$this->assertTrue($slide->hasImage());
$this->assertSame([1600, 1067], [$slide->image_width, $slide->image_height]);
$this->assertSame(Slide::IMAGE_FULL, $slide->imageLayout());
$this->assertSame([$slide->image], $this->storedImages($poll->id));
}
public function testPlacementIsOnlyOfferedWithAnImage(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$empty = $this->createSlide($poll, Slide::TYPE_CONTENT, ['question' => 'Ohne Bild']);
// The placement fieldset is always rendered (usable without JavaScript); the script shows it only
// for an existing image or a chosen file, marked by data-has-image.
$this->get("/admin/$token/slides/{$slide->id}/edit");
$this->assertResponseContains('data-image-layout');
$this->assertResponseContains('data-has-image');
$this->get("/admin/$token/slides/{$empty->id}/edit");
$this->assertResponseContains('data-image-layout');
$this->assertResponseNotContains('data-has-image');
}
public function testLayoutDefaultsByType(): void
{
[$poll, , $content] = $this->slideWithImage();
$this->assertSame(Slide::IMAGE_SIDE, $content->imageLayout());
$choice = $this->createSlide($poll, Slide::TYPE_CHOICE, ['image' => 'a', 'image_layout' => 'full']);
$this->assertSame(Slide::IMAGE_TOP, $choice->imageLayout(), 'full exists for content slides only');
}
public function testNoDescriptionIsNeeded(): void
{
[$poll, $token] = $this->createPoll();
$this->postWithImage("/admin/$token/slides/add?type=content", [
'type' => 'content',
'question' => 'Ohne Beschreibung',
], $this->makeImage());
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
$this->assertTrue($slide->hasImage());
$this->assertSame('', $slide->image_alt);
$this->assertSame([$slide->image], $this->storedImages($poll->id));
}
public function testRejectsFilesThatAreNoImages(): void
{
[$poll, $token] = $this->createPoll();
$path = tempnam(sys_get_temp_dir(), 'plen');
$this->imageFiles[] = $path;
file_put_contents($path, 'just text');
$this->postWithImage("/admin/$token/slides/add?type=content", [
'type' => 'content',
'question' => 'Kein Bild',
], $path, UPLOAD_ERR_OK, 'text.jpg');
$this->assertResponseContains('JPEG, PNG, WebP oder GIF');
$this->assertSame(0, $this->slidesTable()->find()->where(['poll_id' => $poll->id])->count());
}
public function testFailedSaveKeepsTheOldImage(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$old = $slide->image;
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
'question' => '',
], $this->makeImage(100, 100));
$this->assertResponseContains('Bitte prüfe deine Eingaben');
$this->assertSame([$old], $this->storedImages($poll->id));
$this->assertSame($old, $this->slidesTable()->get($slide->id)->image);
}
public function testQuotaPerPoll(): void
{
Configure::write('Plenario.images.maxPerPoll', 1);
[$poll, $token] = $this->slideWithImage();
$this->postWithImage("/admin/$token/slides/add?type=content", [
'type' => 'content',
'question' => 'Zweites Bild',
], $this->makeImage());
$this->assertResponseContains('höchstens 1 Folien mit Bild');
$this->assertCount(1, $this->storedImages($poll->id));
$this->assertSame(1, $this->slidesTable()->find()->where(['poll_id' => $poll->id])->count());
}
public function testReplacingAnImageDeletesTheOldFile(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$old = $slide->image;
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
'question' => 'Mit Bild',
], $this->makeImage(300, 200));
$slide = $this->slidesTable()->get($slide->id);
$this->assertNotSame($old, $slide->image);
$this->assertSame([$slide->image], $this->storedImages($poll->id));
$this->assertSame([300, 200], [$slide->image_width, $slide->image_height]);
}
public function testEditingWithoutUploadKeepsImageAndAllowsAltChange(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
'question' => 'Mit Bild',
'image_layout' => 'top',
], $this->makeImage(), UPLOAD_ERR_NO_FILE);
$after = $this->slidesTable()->get($slide->id);
$this->assertSame($slide->image, $after->image);
$this->assertSame(Slide::IMAGE_TOP, $after->imageLayout());
$this->assertSame([$slide->image], $this->storedImages($poll->id));
}
public function testRemoveImage(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$this->post("/admin/$token/slides/{$slide->id}/edit", ['question' => 'Mit Bild', 'remove_image' => '1']);
$this->post("/admin/$token/slides/{$slide->id}/edit", ['question' => 'Mit Bild', 'remove_image' => '1']);
$after = $this->slidesTable()->get($slide->id);
$this->assertFalse($after->hasImage());
$this->assertSame([], $this->storedImages($poll->id));
}
public function testDeletingTheSlideDeletesTheFile(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$other = $this->createSlide($poll, Slide::TYPE_OPEN);
$this->post("/admin/$token/slides/{$other->id}/delete");
$this->assertCount(1, $this->storedImages($poll->id), 'another slide does not touch the image');
$this->post("/admin/$token/slides/{$slide->id}/delete");
$this->assertSame([], $this->storedImages($poll->id));
}
public function testDeletingThePollDeletesAllImages(): void
{
[$poll, $token] = $this->slideWithImage();
$this->postWithImage("/admin/$token/slides/add?type=content", [
'type' => 'content',
'question' => 'Zweites',
], $this->makeImage());
$this->assertCount(2, $this->storedImages($poll->id));
$this->post("/admin/$token/delete", ['confirm_code' => $poll->join_code]);
$this->assertSame([], $this->storedImages($poll->id));
$this->assertDirectoryDoesNotExist($this->uploadRoot() . DS . $poll->id);
}
public function testDuplicateGetsItsOwnFile(): void
{
[$poll, $token, $slide] = $this->slideWithImage(['image_layout' => 'top']);
$this->post("/admin/$token/slides/{$slide->id}/duplicate");
$slides = $this->slidesTable()->listForPoll($poll->id);
$copy = $slides[1];
$this->assertTrue($copy->hasImage());
$this->assertNotSame($slide->image, $copy->image);
$this->assertSame(Slide::IMAGE_TOP, $copy->imageLayout());
$this->assertCount(2, $this->storedImages($poll->id));
$this->post("/admin/$token/slides/{$copy->id}/delete");
$this->assertSame([$slide->image], $this->storedImages($poll->id), 'the original keeps its image');
}
public function testResetKeepsImages(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$this->post("/admin/$token/reset");
$this->assertTrue($this->slidesTable()->get($slide->id)->hasImage());
$this->assertCount(1, $this->storedImages($poll->id));
}
public function testYouTubeSlidesIgnoreImages(): void
{
$this->assertFalse(Slide::supportsImage(Slide::TYPE_YOUTUBE));
$this->assertTrue(Slide::supportsImage(Slide::TYPE_QUIZ));
}
public function testImageIsServedForTheOwnPollOnly(): void
{
[$poll, , $slide] = $this->slideWithImage();
[$otherPoll] = $this->createPoll('Andere');
$this->get(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image]);
$this->assertResponseOk();
$this->assertContentType('image/webp');
$this->assertHeaderContains('Cache-Control', 'immutable');
$this->assertHeaderContains('Cache-Control', 'private');
$this->assertSame(IMAGETYPE_WEBP, getimagesizefromstring((string)$this->_response->getBody())[2]);
$this->assertCookieNotSet('plenario_pid');
$this->get(['_name' => 'participate:image', 'code' => $otherPoll->join_code, 'file' => $slide->image]);
$this->assertResponseCode(404);
$this->get('/p/' . $poll->join_code . '/img/' . str_repeat('a', 24) . '.webp');
$this->assertResponseCode(404);
$this->get('/p/' . $poll->join_code . '/img/..%2F..%2Fapp.php');
$this->assertResponseCode(404);
}
public function testImageIsGoneWhenReplaced(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$old = $slide->image;
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
'question' => 'Mit Bild',
], $this->makeImage(300, 200));
$this->get(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $old]);
$this->assertResponseCode(404);
}
public function testPresenterStateAndParticipantPageShowTheImage(): void
{
[$poll, $token, $slide] = $this->slideWithImage();
$poll = $this->goLive($poll, $slide);
$this->get("/admin/$token/state");
$payload = json_decode((string)$this->_response->getBody(), true)['slide'];
$this->assertSame('', $payload['image']['alt']);
$this->assertSame('side', $payload['image']['layout']);
$this->assertSame("/p/{$poll->join_code}/img/{$slide->image}", $payload['image']['url']);
$this->get('/p/' . $poll->join_code);
$this->assertResponseOk();
$this->assertResponseContains('/p/' . $poll->join_code . '/img/' . $slide->image);
$this->assertResponseContains('alt=""');
$this->assertResponseContains('width="1600" height="1067"');
}
public function testSlideWithoutImageHasNoImagePayload(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_OPEN);
$this->goLive($poll, $slide);
$this->get("/admin/$token/state");
$this->assertNull(json_decode((string)$this->_response->getBody(), true)['slide']['image']);
}
public function testEditFormShowsImageFields(): void
{
[, $token, $slide] = $this->slideWithImage();
$this->get("/admin/$token/slides/{$slide->id}/edit");
$this->assertResponseOk();
$this->assertResponseContains('enctype="multipart/form-data"');
$this->assertResponseContains('name="remove_image"');
$this->assertResponseContains('value="full"');
}
}
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Speaker view (second window): preview of the next slide, no side effects, no solutions in the JSON.
*/
class SpeakerViewTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
/**
* @return array<string, mixed>
*/
protected function state(string $token): array
{
$this->get("/admin/$token/state");
$this->assertResponseOk();
return json_decode((string)$this->_response->getBody(), true);
}
public function testSpeakerPageDoesNotStartThePresentation(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll, Slide::TYPE_CHOICE);
for ($i = 0; $i < 2; $i++) {
$this->get("/admin/$token/speaker");
$this->assertResponseOk();
$this->assertResponseContains('data-next');
$this->assertNull($this->pollsTable()->get($poll->id)->current_slide_id);
}
$this->get("/admin/$token/present");
$this->assertResponseNotContains('data-next-question');
}
public function testSpeakerPageNeedsTheToken(): void
{
$this->get('/admin/' . str_repeat('x', 30) . '/speaker');
$this->assertResponseCode(404);
}
public function testNextIsTheSlideBehindTheLiveOne(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CHOICE);
$second = $this->createSlide($poll, Slide::TYPE_CHOICE, ['question' => 'Zweite?']);
$hidden = $this->createSlide($poll, Slide::TYPE_CONTENT);
$hidden->is_hidden = true;
$this->slidesTable()->saveOrFail($hidden);
$this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['question' => 'Letzte?']);
$this->assertSame($first->id, $this->state($token)['next']['id'], 'before the start: the first slide');
$this->goLive($poll, $first);
$next = $this->state($token)['next'];
$this->assertSame($second->id, $next['id']);
$this->assertSame('Zweite?', $next['question']);
$this->assertSame(['Ja', 'Nein'], $next['options']);
$this->goLive($poll, $second);
$this->assertSame('Letzte?', $this->state($token)['next']['question'], 'hidden slides are skipped');
$last = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_WORDCLOUD])->firstOrFail();
$this->goLive($poll, $last);
$this->assertNull($this->state($token)['next'], 'nothing after the last slide');
}
public function testPreviewRevealsNoSolution(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->createSlide($poll, Slide::TYPE_QUIZ, [], ['Richtig', 'Falsch']);
$this->createSlide($poll, Slide::TYPE_ORDER, [], ['Eins', 'Zwei', 'Drei']);
$this->goLive($poll, $first);
$quiz = $this->state($token)['next'];
$this->assertSame(['Richtig', 'Falsch'], $quiz['options']);
$this->assertStringNotContainsString('is_correct', json_encode($quiz));
$order = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_ORDER])->firstOrFail();
$quizSlide = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_QUIZ])->firstOrFail();
$this->goLive($poll, $quizSlide);
$this->assertSame([], $this->state($token)['next']['options'], 'the stored order is the solution');
$this->assertSame($order->id, $this->state($token)['next']['id']);
}
}
@@ -0,0 +1,241 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Poll;
use App\Model\Entity\Slide;
use App\Service\PollStateService;
use App\Service\ResultsService;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Slides with a countdown that are not quizzes: they wait ("ready") showing only the question, the
* presenter's next step starts the countdown, the next one ends it, the third moves on.
*/
class TimedSlideTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
/**
* @return array<string, mixed>
*/
protected function control(string $token, string $action): array
{
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
$this->post("/admin/$token/control", ['action' => $action]);
$this->assertResponseOk();
return json_decode((string)$this->_response->getBody(), true);
}
/**
* A fresh slide of the given type with a time limit (waits for the presenter).
*/
protected function createTimed(Poll $poll, string $type = Slide::TYPE_CHOICE, int $limit = 30): Slide
{
$slide = $this->createSlide($poll, $type, ['settings' => ['time_limit' => $limit] + Slide::DEFAULT_SETTINGS[$type]]);
$slide->startFresh();
return $this->slidesTable()->saveOrFail($slide);
}
public function testSlideWithoutLimitStaysOpenAndHasNoPhases(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll);
$slide->startFresh();
$this->assertFalse($slide->usesPhases());
$this->assertNull($slide->phase());
$this->assertTrue($slide->isVotingOpen());
$this->assertTrue($slide->isFresh());
}
public function testTimedSlideWaitsUntilStartedAndShowsNoResults(): void
{
[$poll] = $this->createPoll();
$slide = $this->createTimed($poll);
$poll = $this->goLive($poll, $slide);
$this->assertTrue($slide->usesPhases());
$this->assertSame(Slide::QUIZ_READY, $slide->phase());
$this->assertFalse($slide->isVotingOpen());
$this->assertTrue($slide->isFresh());
// Presenter: only the question, no answers, no counts.
$state = (new PollStateService())->forPresenter($poll);
$this->assertTrue($state['results']['ready']);
$this->assertSame(0, $state['results']['participants']);
$this->assertArrayNotHasKey('options', $state['results']);
$this->assertSame(Slide::QUIZ_READY, $state['results']['timer']['phase']);
// Participants know about the timer, can not vote yet.
$participant = (new PollStateService())->forParticipant($poll, str_repeat('a', 32));
$this->assertSame(Slide::QUIZ_READY, $participant['timer']['phase']);
$this->assertFalse($participant['isVotingOpen']);
$this->post('/p/' . $poll->join_code . '/vote', ['slide_id' => $slide->id, 'option_id' => $slide->slide_options[0]->id]);
$this->assertRedirect();
$this->assertFlashMessage('Die Abstimmung hat noch nicht begonnen.');
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('Die Abstimmung startet gleich');
$this->assertResponseNotContains('name="option_id"');
}
public function testOrderSolutionDoesNotLeakBeforeTheCountdownStarts(): void
{
[$poll] = $this->createPoll();
$slide = $this->createTimed($poll, Slide::TYPE_ORDER);
$poll = $this->goLive($poll, $slide);
$this->assertFalse($slide->isOrderRevealed());
$state = (new PollStateService())->forPresenter($poll);
$this->assertTrue($state['results']['ready']);
$this->assertArrayNotHasKey('items', $state['results']);
$participant = (new PollStateService())->forParticipant($poll, str_repeat('b', 32));
$this->assertFalse($participant['order']['revealed']);
$this->assertNull($participant['results']);
}
public function testNextStartsEndsAndMovesOn(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createTimed($poll);
$after = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->goLive($poll, $slide);
// 1st: start the countdown, the slide stays.
$state = $this->control($token, 'next');
$this->assertSame($slide->id, $state['slide']['id']);
$running = $this->slidesTable()->get($slide->id);
$this->assertSame(Slide::QUIZ_RUNNING, $running->phase());
$this->assertNotNull($running->voting_ends_at);
$this->assertSame(Slide::QUIZ_RUNNING, $state['results']['timer']['phase']);
$this->assertGreaterThan(0, $state['results']['timer']['remaining']);
$this->assertArrayNotHasKey('ready', $state['results']);
// 2nd: end it, results stay on stage.
$state = $this->control($token, 'next');
$this->assertSame($slide->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($slide->id)->phase());
// 3rd: next slide. Back goes straight back without restarting.
$state = $this->control($token, 'next');
$this->assertSame($after->id, $state['slide']['id']);
$state = $this->control($token, 'prev');
$this->assertSame($slide->id, $state['slide']['id']);
$this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($slide->id)->phase());
}
public function testSlideWithoutLimitMovesOnWithTheFirstNext(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll);
$after = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->goLive($poll, $slide);
$state = $this->control($token, 'next');
$this->assertSame($after->id, $state['slide']['id']);
}
public function testRestartingTheCountdownWithTheToggle(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createTimed($poll, Slide::TYPE_WORDCLOUD, 10);
$this->goLive($poll, $slide);
$this->control($token, 'toggle');
$this->assertSame(Slide::QUIZ_RUNNING, $this->slidesTable()->get($slide->id)->phase());
$this->control($token, 'toggle');
$this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($slide->id)->phase());
$this->control($token, 'toggle');
$reopened = $this->slidesTable()->get($slide->id);
$this->assertSame(Slide::QUIZ_RUNNING, $reopened->phase());
$this->assertLessThanOrEqual(10, $reopened->remainingSeconds());
}
public function testRunningVotingResultsAreShownLive(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createTimed($poll);
$poll = $this->goLive($poll, $slide);
$this->control($token, 'next');
$this->cookie('plenario_pid', str_repeat('c', 32));
$this->post('/p/' . $poll->join_code . '/vote', ['slide_id' => $slide->id, 'option_id' => $slide->slide_options[0]->id]);
$this->assertRedirect();
$state = (new PollStateService())->forPresenter($this->pollsTable()->get($poll->id));
$this->assertArrayNotHasKey('ready', $state['results']);
$this->assertSame(1, $state['results']['participants']);
$this->assertSame(1, $state['results']['options'][0]['count']);
}
public function testExpiredCountdownClosesTheSlide(): void
{
[$poll] = $this->createPoll();
$slide = $this->createTimed($poll);
$slide->setVotingOpen(true);
$slide->voting_ends_at = $slide->voting_started_at->subSeconds(1);
$this->slidesTable()->saveOrFail($slide);
$poll = $this->goLive($poll, $slide);
$state = (new PollStateService())->forPresenter($poll);
$this->assertSame(Slide::QUIZ_FINISHED, $state['results']['timer']['phase']);
$this->assertFalse($state['slide']['isVotingOpen']);
}
public function testFormSavesTheLimitAndStartsTheNewSlideReady(): void
{
[$poll, $token] = $this->createPoll();
$this->post("/admin/$token/slides/add?type=choice", [
'type' => 'choice', 'question' => 'Mit Zeit?', 'options_text' => "Ja\nNein", 'settings' => ['time_limit' => '45'],
]);
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
$this->assertSame(45, $slide->setting('time_limit'));
$this->assertSame(Slide::QUIZ_READY, $slide->phase());
// Removing the countdown from a slide nobody started opens it again.
$this->post("/admin/$token/slides/{$slide->id}/edit", [
'type' => 'choice', 'question' => 'Mit Zeit?', 'options_text' => "Ja\nNein", 'settings' => ['time_limit' => '0'],
]);
$slide = $this->slidesTable()->get($slide->id);
$this->assertNull($slide->phase());
$this->assertTrue($slide->isVotingOpen());
// An invalid limit falls back to "none".
$this->post("/admin/$token/slides/{$slide->id}/edit", [
'type' => 'choice', 'question' => 'Mit Zeit?', 'options_text' => "Ja\nNein", 'settings' => ['time_limit' => '7'],
]);
$this->assertSame(0, $this->slidesTable()->get($slide->id)->setting('time_limit'));
// Q&A has no countdown.
$this->assertFalse(Slide::supportsTimer(Slide::TYPE_QA));
$this->assertArrayNotHasKey('time_limit', Slide::DEFAULT_SETTINGS[Slide::TYPE_QA]);
}
public function testEvaluationIsNotGatedByTheCountdown(): void
{
[$poll] = $this->createPoll();
$slide = $this->createTimed($poll);
$results = (new ResultsService())->forSlide($slide);
$this->assertArrayNotHasKey('ready', $results);
$this->assertSame(Slide::QUIZ_READY, $results['timer']['phase']);
}
}
+106
View File
@@ -0,0 +1,106 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase;
use Cake\Core\Configure;
use Laminas\Diactoros\UploadedFile;
/**
* Helpers for tests with slide images: generated pictures and a throw-away upload directory.
* Call clearImages() from tearDown().
*/
trait ImageTestTrait
{
/**
* @var list<string>
*/
protected array $imageFiles = [];
/**
* Writes a picture to a temporary file.
*
* @param int $width Width in pixels
* @param int $height Height in pixels
* @param string $format jpeg|png|gif|webp
* @return string Path
*/
protected function makeImage(int $width = 400, int $height = 300, string $format = 'jpeg'): string
{
$image = imagecreatetruecolor($width, $height);
imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, (int)imagecolorallocate($image, 200, 40, 40));
imagefilledellipse($image, intdiv($width, 2), intdiv($height, 2), intdiv($width, 2), intdiv($height, 2), (int)imagecolorallocate($image, 250, 250, 250));
$path = tempnam(sys_get_temp_dir(), 'plen');
match ($format) {
'png' => imagepng($image, $path),
'gif' => imagegif($image, $path),
'webp' => imagewebp($image, $path),
default => imagejpeg($image, $path),
};
$this->imageFiles[] = $path;
return $path;
}
/**
* Posts a form with an uploaded file in the field `image` (the test request carries files
* separately from the form data).
*
* @param string $url URL
* @param array<string, mixed> $data Form data
* @param string|null $path File to upload, null = no upload field at all
* @param int $error Upload error code (UPLOAD_ERR_NO_FILE = field left empty)
* @param string $name Client file name
* @return void
*/
protected function postWithImage(string $url, array $data, ?string $path, int $error = UPLOAD_ERR_OK, string $name = 'bild.jpg'): void
{
$this->_request['files'] = $path === null ? [] : [
'image' => new UploadedFile($path, (int)filesize($path), $error, $name, 'image/jpeg'),
];
try {
$this->post($url, $data);
} finally {
$this->_request['files'] = [];
}
}
/**
* @return string The upload directory of the tests
*/
protected function uploadRoot(): string
{
return (string)Configure::read('Plenario.images.path');
}
/**
* Files stored for a poll.
*
* @param int $pollId Poll id
* @return list<string> File names
*/
protected function storedImages(int $pollId): array
{
$files = array_map('basename', glob($this->uploadRoot() . DS . $pollId . DS . '*') ?: []);
sort($files);
return $files;
}
/**
* Removes temporary pictures and the upload directory of the tests.
*
* @return void
*/
protected function clearImages(): void
{
foreach ($this->imageFiles as $file) {
@unlink($file);
}
$this->imageFiles = [];
foreach (glob($this->uploadRoot() . DS . '*', GLOB_ONLYDIR) ?: [] as $directory) {
array_map('unlink', glob($directory . DS . '*') ?: []);
@rmdir($directory);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Mailer;
use App\Mailer\PollMailer;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\EmailTrait;
use Cake\TestSuite\TestCase;
class PollMailerTest extends TestCase
{
use EmailTrait;
use PlenarioTestTrait;
public function testHtmlMailShowsLogoAndWebColors(): void
{
[$poll] = $this->createPoll('Retro', 'owner@example.org');
$this->assertTrue((new PollMailer())->sendSafely('expiryReminder', [$poll, 'https://example.org/admin/x']));
$this->assertMailCount(1);
$this->assertMailContainsAttachment('logo.png');
// The logo is referenced by Content-ID, not by a URL that images-off clients would block.
$this->assertMailContainsHtml('src="cid:' . PollMailer::LOGO_CID . '"');
// Brand and text colors as on the web (--text, --primary, --muted), not the old off-by-a-bit values.
$this->assertMailContainsHtml('Plenar<span style="color:#4b3fe0;">IO</span>');
$this->assertMailContainsHtml('color:#5d6280');
$this->assertMailContainsHtml('background:#f5f6fb');
}
}
+188
View File
@@ -0,0 +1,188 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Service;
use App\Service\ImageException;
use App\Service\ImageService;
use App\Test\TestCase\ImageTestTrait;
use Cake\TestSuite\TestCase;
use Laminas\Diactoros\UploadedFile;
/**
* Scaling, validation and file handling of slide images.
*/
class ImageServiceTest extends TestCase
{
use ImageTestTrait;
protected ImageService $images;
protected function setUp(): void
{
parent::setUp();
$this->images = new ImageService();
}
protected function tearDown(): void
{
$this->clearImages();
parent::tearDown();
}
protected function file(string $path, int $error = UPLOAD_ERR_OK): UploadedFile
{
return new UploadedFile($path, (int)filesize($path), $error, 'bild.jpg', 'image/jpeg');
}
public function testLargeImageIsScaledDownAndStoredAsWebp(): void
{
$stored = $this->images->store($this->file($this->makeImage(3200, 2000)), 7);
$this->assertSame(1600, $stored['width']);
$this->assertSame(1000, $stored['height']);
$this->assertTrue(ImageService::isValidName($stored['name']));
$path = $this->images->path(7, $stored['name']);
$this->assertNotNull($path);
$info = getimagesize($path);
$this->assertSame(IMAGETYPE_WEBP, $info[2]);
$this->assertSame([1600, 1000], [$info[0], $info[1]]);
}
public function testSmallImageIsNotEnlarged(): void
{
$stored = $this->images->store($this->file($this->makeImage(300, 200, 'png')), 7);
$this->assertSame([300, 200], [$stored['width'], $stored['height']]);
}
public function testAcceptsGifAndWebp(): void
{
foreach (['gif', 'webp'] as $format) {
$stored = $this->images->store($this->file($this->makeImage(40, 30, $format)), 7);
$this->assertSame([40, 30], [$stored['width'], $stored['height']], $format);
}
}
public function testExifOrientationIsApplied(): void
{
// A landscape JPEG that says "rotate by 90°" ends up as a portrait picture.
$jpeg = (string)file_get_contents($this->makeImage(200, 100));
$path = $this->makeImage(1, 1);
file_put_contents($path, substr($jpeg, 0, 2) . $this->exifOrientation(6) . substr($jpeg, 2));
$this->assertSame(6, ImageService::jpegOrientation((string)file_get_contents($path)));
$stored = $this->images->store($this->file($path), 7);
$this->assertSame([100, 200], [$stored['width'], $stored['height']]);
}
public function testJpegWithoutExifIsUpright(): void
{
$this->assertSame(1, ImageService::jpegOrientation((string)file_get_contents($this->makeImage(20, 10))));
$this->assertSame(1, ImageService::jpegOrientation('not a jpeg'));
}
public function testRejectsNonImages(): void
{
$path = tempnam(sys_get_temp_dir(), 'plen');
$this->imageFiles[] = $path;
file_put_contents($path, '<?php echo 1;');
$this->expectException(ImageException::class);
$this->images->store($this->file($path), 7);
}
public function testRejectsSvg(): void
{
$path = tempnam(sys_get_temp_dir(), 'plen');
$this->imageFiles[] = $path;
file_put_contents($path, '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><script>alert(1)</script></svg>');
$this->expectException(ImageException::class);
$this->images->store($this->file($path), 7);
}
public function testRejectsAnimatedGif(): void
{
$header = 'GIF89a' . "\x01\x00\x01\x00" . "\x80\x00\x00" . "\x00\x00\x00\xFF\xFF\xFF";
$frame = "\x21\xF9\x04\x00\x0A\x00\x00\x00" . "\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00" . "\x02\x02\x44\x01\x00";
$path = tempnam(sys_get_temp_dir(), 'plen');
$this->imageFiles[] = $path;
file_put_contents($path, $header . $frame . $frame . "\x3B");
$this->expectException(ImageException::class);
$this->expectExceptionMessage('Animierte GIFs');
$this->images->store($this->file($path), 7);
}
public function testRejectsUploadErrors(): void
{
$path = $this->makeImage();
$this->expectException(ImageException::class);
$this->images->store($this->file($path, UPLOAD_ERR_PARTIAL), 7);
}
public function testDeleteCopyAndPollCleanup(): void
{
$first = $this->images->store($this->file($this->makeImage()), 7)['name'];
$copy = $this->images->copy(7, $first);
$this->assertNotNull($copy);
$this->assertNotSame($first, $copy);
$this->assertCount(2, $this->storedImages(7));
$this->images->delete(7, $first);
$this->images->delete(7, $first);
$this->images->delete(7, null);
$this->images->delete(7, '../../evil.php');
$this->assertSame([$copy], $this->storedImages(7));
$this->assertNull($this->images->copy(7, $first), 'copy of a missing file');
$this->images->deletePoll(7);
$this->images->deletePoll(7);
$this->assertSame([], $this->storedImages(7));
$this->assertDirectoryDoesNotExist($this->uploadRoot() . DS . '7');
}
public function testPathRejectsForeignNames(): void
{
$name = $this->images->store($this->file($this->makeImage()), 7)['name'];
$this->assertNotNull($this->images->path(7, $name));
$this->assertNull($this->images->path(8, $name), 'other poll');
$this->assertNull($this->images->path(7, '../7/' . $name));
$this->assertNull($this->images->path(7, 'image.php'));
}
public function testCleanupRemovesOrphansOnly(): void
{
$kept = $this->images->store($this->file($this->makeImage()), 7)['name'];
$orphan = $this->images->store($this->file($this->makeImage()), 7)['name'];
$gone = $this->images->store($this->file($this->makeImage()), 8)['name'];
$this->assertEqualsCanonicalizing(['7/' . $orphan, '8/' . $gone], $this->images->cleanup([7 => [$kept]], true));
$this->assertCount(2, $this->storedImages(7), 'dry run deletes nothing');
$removed = $this->images->cleanup([7 => [$kept]]);
$this->assertEqualsCanonicalizing(['7/' . $orphan, '8/' . $gone], $removed);
$this->assertSame([$kept], $this->storedImages(7));
$this->assertSame([], $this->storedImages(8));
$this->assertSame([], $this->images->cleanup([7 => [$kept]]), 'second run changes nothing');
}
/**
* An Exif segment (big endian) that only contains the orientation.
*
* @param int $orientation 1-8
* @return string
*/
protected function exifOrientation(int $orientation): string
{
$tiff = "MM\x00\x2A\x00\x00\x00\x08" . "\x00\x01" . "\x01\x12\x00\x03\x00\x00\x00\x01" . pack('n', $orientation) . "\x00\x00" . "\x00\x00\x00\x00";
return "\xFF\xE1" . pack('n', 2 + 6 + strlen($tiff)) . "Exif\x00\x00" . $tiff;
}
}
+1 -1
View File
@@ -129,7 +129,7 @@ class OrderTest extends TestCase
$state = $this->participantState($poll, 'p1');
$this->assertTrue($state['hasResponded']);
$this->assertNull($state['results']);
$this->assertSame(['revealed' => false, 'answer' => null, 'isCorrect' => null], $state['order']);
$this->assertSame(['ranking' => false, 'revealed' => false, 'answer' => null, 'isCorrect' => null], $state['order']);
}
public function testClosingRevealsResultsToEveryone(): void
+16
View File
@@ -110,6 +110,22 @@ class QuizTest extends TestCase
$this->assertSame(Slide::QUIZ_FINISHED, $slide->quizPhase());
}
public function testReadyQuizHidesAnswerOptions(): void
{
[$poll, $slide] = $this->createQuiz();
$results = (new ResultsService())->forSlide($slide);
$this->assertSame('ready', $results['phase']);
$this->assertSame([], $results['options']);
$state = $this->participantState($poll, 'p1');
$this->assertStringNotContainsString('Berlin', (string)json_encode($state));
$slide = $this->setOpen($slide, true);
$results = (new ResultsService())->forSlide($slide);
$this->assertSame(['Berlin', 'Hamburg', 'München'], array_column($results['options'], 'label'));
}
public function testRunningQuizHidesCountsAndCorrectAnswers(): void
{
[$poll, $slide] = $this->createQuiz();
+89 -2
View File
@@ -71,6 +71,93 @@ class VoteServiceTest extends TestCase
(new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']);
}
public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide);
$service = new VoteService();
$service->submit($poll, $slide, 'p1', ['value' => '4']);
$service->submit($poll, $slide, 'p2', ['comment' => 'Kann ich nicht beurteilen']);
$results = (new ResultsService())->forSlide($slide);
$this->assertSame(2, $results['participants']);
$this->assertSame(1, $results['commentOnly']);
$this->assertSame(4.0, (float)$results['average']);
$this->assertSame(1, array_sum(array_column($results['buckets'], 'count')));
$this->assertSame(['Kann ich nicht beurteilen'], array_column($results['comments'], 'text'));
$this->assertSame([null], array_column((new ResultsService())->comments($slide), 'value'));
// Only once per person, like any answer.
$this->expectExceptionMessage('bereits abgestimmt');
$service->submit($poll, $slide, 'p2', ['value' => '2']);
}
public function testScaleWithoutRatingNeedsCommentOnlySetting(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('zwischen 1 und 5');
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => 'Nur Kommentar']);
}
public function testScaleNeedsRatingOrComment(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('oder schreibe einen Kommentar');
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => ' ']);
}
public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide);
$service = new VoteService();
$service->submit($poll, $slide, 'p1', ['comment' => 'Erst']);
$service->editText($poll, $slide, 'p1', ['comment' => 'Dann']);
$this->assertSame('Dann', $service->ownText($slide, 'p1'));
$this->expectExceptionMessage('nicht leer sein');
$service->editText($poll, $slide, 'p1', ['comment' => '']);
}
public function testChoiceCommentOnlyIsNotCountedAsVote(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE, ['settings' => ['comments' => true, 'comment_only' => true]], ['A', 'B']);
$poll = $this->goLive($poll, $slide);
$service = new VoteService();
$service->submit($poll, $slide, 'p1', ['option_id' => $slide->slide_options[0]->id]);
$service->submit($poll, $slide, 'p2', ['comment' => 'Keine passt']);
$results = (new ResultsService())->forSlide($slide);
$this->assertSame(2, $results['participants']);
$this->assertSame(1, $results['votes']);
$this->assertSame(1, $results['commentOnly']);
$this->assertEquals([100, 0], array_column($results['options'], 'percent'));
$this->assertSame(['Keine passt'], array_column($results['comments'], 'text'));
$service->editText($poll, $slide, 'p2', ['comment' => 'Keine passt wirklich']);
$this->expectExceptionMessage('nicht leer sein');
$service->editText($poll, $slide, 'p2', ['comment' => '']);
}
public function testChoiceWithoutSelectionNeedsCommentOnlySetting(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE, ['settings' => ['comments' => true]], ['A', 'B']);
$poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('Bitte wähle eine Antwort aus.');
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => 'Nur Kommentar']);
}
public function testMultipleChoiceResults(): void
{
[$poll] = $this->createPoll();
@@ -143,9 +230,9 @@ class VoteServiceTest extends TestCase
public function testWordcloudSettingsSanitizing(): void
{
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '3', 'allow_upvotes' => '0']);
$this->assertSame(['allow_upvotes' => false, 'allow_downvotes' => true], $settings);
$this->assertSame(['allow_upvotes' => false, 'allow_downvotes' => true, 'time_limit' => 0], $settings);
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['allow_downvotes' => '0']);
$this->assertSame(['allow_upvotes' => true, 'allow_downvotes' => false], $settings);
$this->assertSame(['allow_upvotes' => true, 'allow_downvotes' => false, 'time_limit' => 0], $settings);
}
public function testWordcloudDownvotes(): void
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff. Show more