Remove per-participant word limit from word clouds
Participants can now always submit any number of words. Drops the max_words setting, its form field, the limit checks in VoteService and the remaining/limitReached state; existing max_words values in stored settings are ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cc813f87b
commit
bd17a97487
10 files changed
+26
-87
No files matched your search
@@ -89,10 +89,10 @@ class VoteServiceTest extends TestCase
|
||||
$this->assertEqualsWithDelta(66.7, $results['options'][0]['percent'], 0.01);
|
||||
}
|
||||
|
||||
public function testWordcloudGroupsCaseInsensitivelyAndLimitsWords(): void
|
||||
public function testWordcloudGroupsCaseInsensitively(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['max_words' => 2]]);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$service = new VoteService();
|
||||
@@ -100,16 +100,16 @@ class VoteServiceTest extends TestCase
|
||||
$service->submit($poll, $slide, 'p2', ['words' => ['kaffee', '', 'KAFFEE']]);
|
||||
|
||||
$results = (new ResultsService())->forSlide($slide);
|
||||
$this->assertSame(['Kaffee', 'tee'], array_column($results['words'], 'text'));
|
||||
$this->assertSame(['kaffee', 'tee'], array_column($results['words'], 'key'));
|
||||
$this->assertSame([2, 1], array_column($results['words'], 'count'));
|
||||
$this->assertSame(['Kaffee', 'tee', 'Wasser'], array_column($results['words'], 'text'));
|
||||
$this->assertSame(['kaffee', 'tee', 'wasser'], array_column($results['words'], 'key'));
|
||||
$this->assertSame([2, 1, 1], array_column($results['words'], 'count'));
|
||||
$this->assertEquals(1, $results['words'][0]['weight']);
|
||||
}
|
||||
|
||||
public function testWordcloudAcceptsWordsOneByOneAndCountsRepeatsAsUpvote(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['max_words' => 0]]);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$service = new VoteService();
|
||||
@@ -140,44 +140,24 @@ class VoteServiceTest extends TestCase
|
||||
$service->submit($poll, $slide, 'p1', ['word' => 'KAFFEE']);
|
||||
}
|
||||
|
||||
public function testWordcloudLimitCountsAcrossSubmits(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['max_words' => 2]]);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$service = new VoteService();
|
||||
$service->submit($poll, $slide, 'p1', ['word' => 'Kaffee']);
|
||||
$service->submit($poll, $slide, 'p1', ['word' => 'Tee']);
|
||||
|
||||
$state = (new PollStateService())->wordState($slide, 'p1');
|
||||
$this->assertSame(['kaffee', 'tee'], $state['mine']);
|
||||
$this->assertSame(0, $state['remaining']);
|
||||
$this->assertTrue($state['limitReached']);
|
||||
|
||||
$this->expectExceptionMessage('Du hast bereits alle 2 Begriffe abgegeben.');
|
||||
$service->submit($poll, $slide, 'p1', ['word' => 'Wasser']);
|
||||
}
|
||||
|
||||
public function testWordcloudSettingsSanitizing(): void
|
||||
{
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '-3', 'allow_upvotes' => '0']);
|
||||
$this->assertSame(['max_words' => 0, 'allow_upvotes' => false, 'allow_downvotes' => true], $settings);
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '999', 'allow_downvotes' => '0']);
|
||||
$this->assertSame(['max_words' => 50, 'allow_upvotes' => true, 'allow_downvotes' => false], $settings);
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '3', 'allow_upvotes' => '0']);
|
||||
$this->assertSame(['allow_upvotes' => false, 'allow_downvotes' => true], $settings);
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['allow_downvotes' => '0']);
|
||||
$this->assertSame(['allow_upvotes' => true, 'allow_downvotes' => false], $settings);
|
||||
}
|
||||
|
||||
public function testWordcloudDownvotes(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['max_words' => 1]]);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$service = new VoteService();
|
||||
$service->submit($poll, $slide, 'p1', ['word' => 'Kaffee']);
|
||||
$service->submit($poll, $slide, 'p2', ['word' => 'kaffee']);
|
||||
$service->submit($poll, $slide, 'p3', ['word' => 'Kaffee', 'vote' => 'down']);
|
||||
// Downvotes do not count towards max_words.
|
||||
$service->submit($poll, $slide, 'p3', ['word' => 'Tee']);
|
||||
|
||||
$results = (new ResultsService())->forSlide($slide);
|
||||
|
||||
Reference in new issue
Block a user