Make private slides start with hidden results instead of withholding them
CI / Deploy / test (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped

Anonymous/internal feedback now only presets "hide results" on the stage:
presenter and embed get the full results flagged private and can show them
on demand. Participants still never get results of private slides, the
public PDF export strips them via ResultsService::withoutContents().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 19:33:52 +01:00
1 parent d1facd32a6
commit ecb8f9d31c
11 files changed
+143 -95

No files matched your search

+2 -1
View File
@@ -26,7 +26,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* counts and the participant's correctness (`order`) only once voting is closed.
*
* Q&A slides have their own participant view (`qa`, see qaState()), never `results`.
* Private open questions (anonymous feedback) never show results to participants.
* Private slides (anonymous/internal feedback) never show results to participants,
* even though the presenter can show them on stage.
*/
class PollStateService
{
+5 -3
View File
@@ -90,14 +90,16 @@ class ReportService
*/
protected function resultsFor(Slide $slide, bool $includeInternal): array
{
// Public shape first: it never contains private data.
$results = $this->results->forSlide($slide);
$mayRead = !$slide->isPrivate() || $includeInternal;
if (!$mayRead) {
return ResultsService::withoutContents($results);
}
if ($slide->type === Slide::TYPE_OPEN && $mayRead) {
if ($slide->type === Slide::TYPE_OPEN) {
$results['answers'] = $this->results->answers($slide);
}
if ($slide->type === Slide::TYPE_SCALE && $mayRead) {
if ($slide->type === Slide::TYPE_SCALE) {
// Ratings next to comments: complete version always, public one only with the setting.
$showRatings = $includeInternal || (bool)$slide->setting('comment_ratings');
$comments = [];
+38 -32
View File
@@ -17,14 +17,14 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* (count = participants who named or upvoted the word, down = downvotes,
* weight follows count)
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
* private (anonymous feedback): 'answers' is always empty, texts only via answers()
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool);
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
* 'value' is null unless the setting comment_ratings is on;
* presentation only, emptied for participants in PollStateService);
* private (internal feedback): 'buckets' and 'comments' are always empty and 'average' null,
* ratings and comments only via scaleResults() / comments()
* open/scale with 'private' (anonymous/internal feedback): contents are included for the
* presenter/embed, which start with the results hidden and may show them on demand;
* participants never get results of these slides, the public PDF strips them (withoutContents())
* - quiz: 'phase' (ready|running|finished), 'timeLimit' (s, 0 = manual), 'remaining' (s|null),
* 'revealed' (bool), 'options' => [['id', 'label']] while not finished;
* once finished additionally per option 'count', 'percent', 'correct' (bool)
@@ -277,13 +277,12 @@ class ResultsService
{
return [
'private' => $slide->isPrivate(),
'answers' => $slide->isPrivate() ? [] : $this->answers($slide, self::MAX_ANSWERS),
'answers' => $this->answers($slide, self::MAX_ANSWERS),
];
}
/**
* Texts of an open question, newest first – also of private slides,
* so only for the admin area (never for the presenter screen or participants).
* Texts of an open question, newest first.
*
* @param \App\Model\Entity\Slide $slide Open question
* @param int|null $limit Max. answers, null = all
@@ -313,35 +312,43 @@ class ResultsService
*/
protected function scale(Slide $slide): array
{
if (!$slide->isPrivate()) {
$showRatings = (bool)$slide->setting('comment_ratings');
$comments = [];
foreach ($slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [] as $comment) {
$comments[] = [
'id' => $comment['id'],
'text' => $comment['text'],
'value' => $showRatings ? $comment['value'] : null,
];
}
return $this->scaleResults($slide) + ['private' => false, 'comments' => $comments];
$showRatings = (bool)$slide->setting('comment_ratings');
$comments = [];
foreach ($slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [] as $comment) {
$comments[] = [
'id' => $comment['id'],
'text' => $comment['text'],
'value' => $showRatings ? $comment['value'] : null,
];
}
return [
'buckets' => [],
'average' => null,
'min' => (int)$slide->setting('scale_min'),
'max' => (int)$slide->setting('scale_max'),
'minLabel' => (string)$slide->setting('min_label'),
'maxLabel' => (string)$slide->setting('max_label'),
'private' => true,
'comments' => [],
];
return $this->scaleResults($slide) + ['private' => $slide->isPrivate(), 'comments' => $comments];
}
/**
* Comments of a scale with their rating, oldest first – also of private slides,
* so the unfiltered call is only for the admin area.
* Results of a private slide without its contents: only type, participants and the scale range.
* Used where internal feedback must not appear (participants, public PDF export).
*
* @param array<string, mixed> $results Result of forSlide()
* @return array<string, mixed>
*/
public static function withoutContents(array $results): array
{
if (isset($results['answers'])) {
$results['answers'] = [];
}
if (isset($results['buckets'])) {
$results['buckets'] = [];
$results['average'] = null;
$results['comments'] = [];
}
return $results;
}
/**
* Comments of a scale with their rating, 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 int|null $limit Max. comments (the newest ones), null = all
@@ -371,8 +378,7 @@ class ResultsService
}
/**
* Distribution and average of a scale – also of private slides,
* so only for the admin area (never for the presenter screen or participants).
* 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}