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

+9 -9
View File
@@ -61,29 +61,29 @@ class QaSlideTest extends TestCase
[$poll, $token] = $this->createPoll();
$this->get("/admin/$token/slides/add?type=qa");
$this->assertResponseOk();
$this->assertResponseContains('Upvotes (Stimmen) pro Person');
$this->assertResponseContains('Stimmen pro Person');
$this->assertResponseNotContains('Abstimmung geöffnet');
$this->post("/admin/$token/slides/add?type=qa", [
'type' => 'qa',
'question' => 'Eure Fragen an den Vorstand',
'settings' => ['max_upvotes' => '5'],
'settings' => ['upvote_share' => '25'],
]);
$this->assertRedirect();
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
$this->assertSame([Slide::TYPE_QA, 5, Slide::QA_COLLECT, true], [
$slide->type, $slide->setting('max_upvotes'), $slide->stage, $slide->is_voting_open,
$this->assertSame([Slide::TYPE_QA, 25, Slide::QA_COLLECT, true], [
$slide->type, $slide->setting('upvote_share'), $slide->stage, $slide->is_voting_open,
]);
$this->get("/admin/$token");
$this->assertResponseContains('Fragen sammeln');
$this->assertResponseContains('max. 5 Upvotes pro Person');
$this->assertResponseContains('Stimmen für 25 % der Fragen pro Person');
}
public function testSwitchingOffUpvotesSkipsTheVotingStage(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['max_upvotes' => 2]]);
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['upvote_share' => 50]]);
$this->goLive($poll, $slide);
(new QaService())->setStage($slide, Slide::QA_VOTE);
@@ -94,11 +94,11 @@ class QaSlideTest extends TestCase
// Switched off while voting: the round continues with the discussion.
$this->post("/admin/$token/slides/{$slide->id}/edit", [
'question' => $slide->question,
'settings' => ['max_upvotes' => '0', 'max_upvotes_per_question' => '0'],
'settings' => ['upvote_share' => '0', 'max_upvotes_per_question' => '0'],
]);
$this->assertRedirect();
$slide = $this->slidesTable()->get($slide->id);
$this->assertSame([0, Slide::QA_DISCUSS, false], [$slide->setting('max_upvotes'), $slide->qaStage(), $slide->is_voting_open]);
$this->assertSame([0, Slide::QA_DISCUSS, false], [$slide->setting('upvote_share'), $slide->qaStage(), $slide->is_voting_open]);
$this->get("/admin/$token");
$this->assertResponseContains('ohne Upvotes');
@@ -115,7 +115,7 @@ class QaSlideTest extends TestCase
public function testFullRoundTrip(): void
{
[$poll, $token] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['max_upvotes' => 1]]);
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['upvote_share' => 50]]);
$next = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->goLive($poll, $slide);
$code = $poll->join_code;