Make Q&A upvote budget a share of the questions
CI / Deploy / test (push) Successful in 58s
CI / Deploy / deploy (push) Skipped

The fixed number of votes per person does not fit varying question
counts. The budget is now `upvote_share` percent of the questions
(rounded up, at least one), so it grows with the number of questions.
A migration converts existing Q&A slides (no voting stays off, others
get 25 %).

On the stage the voting step no longer lists the questions but points
participants to their devices.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-11 23:53:32 +01:00
1 parent 3762b880cb
commit 575fb8649d
14 files changed
+171 -76

No files matched your search

+3 -3
View File
@@ -283,7 +283,7 @@ class PollStateService
* - discuss: all questions ranked with upvotes, `focusId` = question being discussed
* `upvoted` = own upvotes per question id (several per question are allowed),
* `allowSelfUpvote` = own questions may be upvoted too (setting `allow_self_upvote`).
* `maxUpvotes` = 0: no voting stage; `maxPerQuestion` = own upvotes allowed per question.
* `maxUpvotes` = upvote budget of the participant (share of the questions), 0: no voting stage; `maxPerQuestion` = own upvotes allowed per question.
*
* @param \App\Model\Entity\Slide $slide Q&A slide
* @param string $participantHash Participant hash
@@ -294,8 +294,8 @@ class PollStateService
{
$stage = $slide->qaStage();
$own = $this->Responses->qaVotesOf($slide->id, $participantHash);
$max = (int)$slide->setting('max_upvotes');
$questions = (new QaService())->rankedQuestions($slide);
$max = $slide->qaBudget(count($questions));
if ($stage === Slide::QA_DISCUSS) {
$focusId = in_array($slide->focus_response_id, array_column($questions, 'id'), true)
? $slide->focus_response_id
@@ -309,7 +309,7 @@ class PollStateService
return [
'stage' => $stage,
'maxUpvotes' => $max,
'maxPerQuestion' => $slide->qaUpvotesPerQuestion(),
'maxPerQuestion' => $slide->qaUpvotesPerQuestion($max),
'votesLeft' => max(0, $max - count($own['upvotes'])),
'allowSelfUpvote' => (bool)$slide->setting('allow_self_upvote'),
'mine' => $own['questions'],