Add Q&A slide type
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:
1 parent
ea944b080f
commit
f0c6687100
21 files changed
+1327
-27
No files matched your search
@@ -24,6 +24,10 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
* once finished additionally per option 'count', 'percent', 'correct' (bool)
|
||||
* and 'correctCount' (participants with a correct answer).
|
||||
* Counts and correct answers are NEVER part of the result before the quiz is finished.
|
||||
* - qa: 'stage' (collect|vote|discuss), 'maxUpvotes', 'upvotes' (total),
|
||||
* 'questions' => [['id', 'text', 'votes']] most upvoted first (ties: oldest first),
|
||||
* 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null).
|
||||
* Presenter only – participants get their own view, see PollStateService::qaState().
|
||||
*/
|
||||
class ResultsService
|
||||
{
|
||||
@@ -60,6 +64,7 @@ class ResultsService
|
||||
Slide::TYPE_OPEN => $this->open($slide),
|
||||
Slide::TYPE_SCALE => $this->scale($slide),
|
||||
Slide::TYPE_QUIZ => $this->quiz($slide),
|
||||
Slide::TYPE_QA => $this->qa($slide),
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
@@ -134,6 +139,30 @@ class ResultsService
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \App\Model\Entity\Slide $slide Slide
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function qa(Slide $slide): array
|
||||
{
|
||||
$questions = (new QaService())->rankedQuestions($slide);
|
||||
$focusIndex = null;
|
||||
foreach ($questions as $index => $question) {
|
||||
if ($question['id'] === $slide->focus_response_id) {
|
||||
$focusIndex = $index;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'stage' => $slide->qaStage(),
|
||||
'maxUpvotes' => (int)$slide->setting('max_upvotes'),
|
||||
'upvotes' => array_sum(array_column($questions, 'votes')),
|
||||
'questions' => $questions,
|
||||
'focusId' => $focusIndex === null ? null : $slide->focus_response_id,
|
||||
'focusIndex' => $focusIndex,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \App\Model\Entity\Slide $slide Slide
|
||||
* @return array<string, mixed>
|
||||
|
||||
Reference in new issue
Block a user