Allow upvoting own Q&A questions as an opt-in setting
The new Q&A setting allow_self_upvote (off by default) lets participants spend their upvote budget on their own questions, e.g. for prioritizing topics. Without it, participants now see a short hint why their own questions cannot be upvoted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ec0b13cae8
commit
affc9a5ece
10 files changed
+59
-12
No files matched your search
@@ -151,9 +151,38 @@ class QaTest extends TestCase
|
||||
$this->assertArrayNotHasKey('votes', $state['qa']['questions'][0]);
|
||||
$this->assertSame([$b => 2, $a => 1], $state['qa']['upvoted']);
|
||||
$this->assertSame(0, $state['qa']['votesLeft']);
|
||||
$this->assertFalse($state['qa']['allowSelfUpvote']);
|
||||
$this->assertTrue($state['hasResponded']);
|
||||
}
|
||||
|
||||
public function testSelfUpvoteOnlyWithSetting(): void
|
||||
{
|
||||
[, $slide] = $this->createQa();
|
||||
$this->assertFalse($slide->setting('allow_self_upvote'));
|
||||
$table = $this->slidesTable();
|
||||
$this->assertTrue($table->patchEntity($slide, ['type' => 'qa', 'settings' => ['allow_self_upvote' => '1']])->setting('allow_self_upvote'));
|
||||
$this->assertFalse($table->patchEntity($slide, ['type' => 'qa', 'settings' => ['max_upvotes' => '2']])->setting('allow_self_upvote'));
|
||||
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_QA, ['settings' => ['max_upvotes' => 3, 'allow_self_upvote' => true]]);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
$a = $this->ask($poll, $slide, 'p1', 'Thema A');
|
||||
$b = $this->ask($poll, $slide, 'p2', 'Thema B');
|
||||
$slide = $this->stage($slide, Slide::QA_VOTE);
|
||||
|
||||
// Own questions take votes from the same budget, stacked and withdrawn like any other.
|
||||
$this->vote($poll, $slide, 'p1', $a);
|
||||
$this->vote($poll, $slide, 'p1', $a);
|
||||
$this->vote($poll, $slide, 'p1', $b);
|
||||
$this->assertVoteFails('Du hast alle 3 Stimmen vergeben. Nimm eine zurück, um eine andere Frage zu unterstützen.', fn() => $this->vote($poll, $slide, 'p1', $a));
|
||||
$this->vote($poll, $slide, 'p1', $a, 'remove');
|
||||
|
||||
$state = (new PollStateService())->forParticipant($poll, 'p1')['qa'];
|
||||
$this->assertTrue($state['allowSelfUpvote']);
|
||||
$this->assertSame([$a => 1, $b => 1], $state['upvoted']);
|
||||
$this->assertSame(1, $state['votesLeft']);
|
||||
}
|
||||
|
||||
public function testDiscussStepsThroughQuestionsByRank(): void
|
||||
{
|
||||
[$poll, $slide] = $this->createQa(3);
|
||||
|
||||
Reference in new issue
Block a user