Share repeated controller and service code
CI / Deploy / test (push) Successful in 53s
CI / Deploy / deploy (push) Skipped

- AppController: joinUrl(), adminUrlFor(), setPollInterval() and protect()
  instead of copies in Admin-, Home-, Participate- and EmbedController.
- PollMailer::sendSafely() replaces two try/catch blocks around mail sending.
- Slide::optionIds() replaces five identical array_map() calls.
- PollStateService: one pollPayload() for presenter and embed; the vote
  action passes the already loaded slide instead of loading it again.
- ResultsService::forSlide() takes the answer/comment limit and the rating
  flag, so ReportService no longer queries answers, comments and the scale
  distribution twice and the export loads the slides only once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 22:50:56 +01:00
1 parent ad537b9b34
commit 3e44ded107
14 files changed
+189 -137

No files matched your search

+12 -1
View File
@@ -272,6 +272,17 @@ class Slide extends Entity
return $this->isOrder() && !$this->isVotingOpen();
}
/**
* Ids of the answer options in their stored order (choice, quiz: display order;
* ordering slides: the correct order).
*
* @return list<int>
*/
public function optionIds(): array
{
return array_map(fn($option) => (int)$option->id, array_values($this->slide_options ?? []));
}
/**
* Options of an ordering slide in a stable pseudo-random order (same seed =
* same order, e.g. per participant across reloads). With two or more options
@@ -283,7 +294,7 @@ class Slide extends Entity
public function shuffledOptions(string $seed): array
{
$options = array_values($this->slide_options ?? []);
$correct = array_map(fn($option) => $option->id, $options);
$correct = $this->optionIds();
usort($options, fn($a, $b) => strcmp(
hash('sha256', $seed . '|' . $a->id),
hash('sha256', $seed . '|' . $b->id),