Add Q&A slide type
CI / Deploy / test (push) Successful in 48s
CI / Deploy / deploy (push) Skipped

Participants submit questions, upvote them and the presenter discusses
them one by one, most upvoted first.

- Stages collect -> vote -> discuss, switched manually by the presenter
  (V key or stepper, going back is possible)
- Configurable upvote budget per participant, freely distributable
  (several upvotes on one question are allowed), votes can be withdrawn
- Participants see all questions while collecting to avoid duplicates;
  no counts before the discussion
- While discussing, next/prev step through the questions before
  moving to the next slide
- Migration: slides.stage, slides.focus_response_id, responses.parent_id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 16:09:46 +01:00
1 parent ea944b080f
commit f0c6687100
21 files changed
+1327 -27

No files matched your search

+37 -1
View File
@@ -8,6 +8,7 @@ use App\Model\Entity\Slide;
use App\Model\Table\ResponsesTable;
use App\Model\Table\SlidesTable;
use App\Service\PollStateService;
use App\Service\QaService;
use App\Service\VoteService;
use Cake\Core\Configure;
use Cake\Http\Exception\BadRequestException;
@@ -158,7 +159,11 @@ class AdminController extends AdminAppController
/**
* Presenter controls. Field `action`:
* goto (+ slide_id), next, prev, open, close, toggle, stop
* goto (+ slide_id), next, prev, open, close, toggle, stop,
* Q&A: stage (+ stage: collect|vote|discuss), question (+ step: 1|-1)
*
* On a Q&A slide that is being discussed, next/prev step through the questions
* first (like builds in presentation software), toggle switches to the next stage.
*
* Answers with the new state as JSON for XHR requests, otherwise redirects back.
*
@@ -171,8 +176,36 @@ class AdminController extends AdminAppController
$slides = $this->Slides->listForPoll($this->poll->id);
$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];
$qa = new QaService();
if ($current !== null && $current->isQa()) {
if ($action === 'toggle') {
// No-op while discussing (last stage).
$qa->advance($current);
$action = 'none';
} elseif (in_array($action, ['next', 'prev'], true) && $qa->moveFocus($current, $action === 'next' ? 1 : -1)) {
$action = 'none';
}
}
switch ($action) {
case 'none':
break;
case 'stage':
case 'question':
if ($current === null || !$current->isQa()) {
throw new BadRequestException('Not a Q&A slide');
}
if ($action === 'question') {
$qa->moveFocus($current, (int)$this->request->getData('step') < 0 ? -1 : 1);
break;
}
$stage = (string)$this->request->getData('stage');
if (!in_array($stage, Slide::QA_STAGES, true)) {
throw new BadRequestException('Unknown stage');
}
$qa->setStage($current, $stage);
break;
case 'goto':
$target = (int)$this->request->getData('slide_id');
if (!in_array($target, $ids, true)) {
@@ -267,8 +300,11 @@ class AdminController extends AdminAppController
->where(['slide_id' => $slide->id])
->orderBy(['id' => 'ASC'])
->all();
$texts = [];
foreach ($responses as $response) {
$texts[$response->id] = (string)$response->text_value;
$answer = match (true) {
$response->parent_id !== null => __('Upvote: {0}', $texts[$response->parent_id] ?? ''),
$response->slide_option_id !== null => $labels[$response->slide_option_id] ?? '',
$response->text_value !== null && $response->numeric_value === VoteService::DOWNVOTE
=> __('Downvote: {0}', $response->text_value),