Add anonymous feedback option for open questions
CI / Deploy / test (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped

Open questions can be marked private: the presenter screen and embeds
only show the number of answers, participants never see results, and
the texts are readable on a new admin answers page and in the CSV.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 16:28:47 +01:00
1 parent 07a292d109
commit 367ff8548d
14 files changed
+310 -12

No files matched your search

+2
View File
@@ -25,6 +25,7 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* when their deadline has passed.
*
* Q&A slides have their own participant view (`qa`, see qaState()), never `results`.
* Private open questions (anonymous feedback) never show results to participants.
*/
class PollStateService
{
@@ -162,6 +163,7 @@ class PollStateService
$showResults = $slide !== null
&& $slide->isInteractive()
&& $qa === null
&& !$slide->isPrivate()
&& ($quiz !== null
? $quiz['phase'] === Slide::QUIZ_FINISHED
: ($poll->show_results_to_participants && ($hasResponded || !$isVotingOpen))
+28 -10
View File
@@ -16,7 +16,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* - 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
* - 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'
* - quiz: 'phase' (ready|running|finished), 'timeLimit' (s, 0 = manual), 'remaining' (s|null),
@@ -213,19 +214,36 @@ class ResultsService
*/
protected function open(Slide $slide): array
{
$rows = $this->Responses->find()
return [
'private' => $slide->isPrivate(),
'answers' => $slide->isPrivate() ? [] : $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).
*
* @param \App\Model\Entity\Slide $slide Open question
* @param int|null $limit Max. answers, null = all
* @return list<array{text: string, created: string}>
*/
public function answers(Slide $slide, ?int $limit = null): array
{
$query = $this->Responses->find()
->select(['text_value', 'created'])
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null])
->orderBy(['id' => 'DESC'])
->limit(self::MAX_ANSWERS)
->all();
$answers = [];
foreach ($rows as $row) {
$answers[] = ['text' => $row->text_value, 'created' => $row->created->toIso8601String()];
->orderBy(['id' => 'DESC']);
if ($limit !== null) {
$query->limit($limit);
}
return ['answers' => $answers];
$answers = [];
foreach ($query->all() as $row) {
$answers[] = ['text' => (string)$row->text_value, 'created' => $row->created->toIso8601String()];
}
return $answers;
}
/**