= nl2br(h($slide->description)) ?>
- is_voting_open && !$words['limitReached']) : ?> + is_voting_open) : ?> = $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form word-form', 'data-word-form' => true]) ?> = $this->Form->hidden('slide_id', ['value' => $slide->id]) ?> -- = $words['remaining'] === null - ? __('Du kannst beliebig viele Begriffe abgeben.') - : __n('Du kannst noch einen Begriff abgeben.', 'Du kannst noch {0} Begriffe abgeben.', $words['remaining'], $words['remaining']) ?> -
+= __('Du kannst beliebig viele Begriffe abgeben.') ?>
= $words['allowDownvotes'] ? __('Tippe auf einen Begriff, um ihn zu unterstützen, oder auf „−“, um ihn abzulehnen.') : __('Tippe auf einen Begriff, um ihn zu unterstützen.') ?>
diff --git a/templates/Slides/form.php b/templates/Slides/form.php index aecf23a..575ef94 100644 --- a/templates/Slides/form.php +++ b/templates/Slides/form.php @@ -56,12 +56,6 @@ $optionsError = $slide->getError('options_text'); 'checked' => (bool)$settings['multiple'], ]) ?> type === 'wordcloud') : ?> - = $this->Form->control('settings.max_words', [ - 'type' => 'number', 'min' => 0, 'max' => 50, - 'label' => __('Begriffe pro Person (0 = unbegrenzt)'), - 'value' => $settings['max_words'], - ]) ?> -= __('Upvotes zählen mit: Wer einen vorhandenen Begriff unterstützt oder erneut eingibt, verbraucht einen Begriff.') ?>
= $this->Form->control('settings.allow_upvotes', [ 'type' => 'checkbox', 'label' => __('Upvotes erlauben (Teilnehmende sehen die Wortwolke live und können Begriffe per Klick unterstützen)'), diff --git a/tests/TestCase/Controller/ParticipateControllerTest.php b/tests/TestCase/Controller/ParticipateControllerTest.php index bd1e4be..7f1c556 100644 --- a/tests/TestCase/Controller/ParticipateControllerTest.php +++ b/tests/TestCase/Controller/ParticipateControllerTest.php @@ -104,7 +104,7 @@ class ParticipateControllerTest extends TestCase [$poll] = $this->createPoll(); $poll->show_results_to_participants = false; $this->pollsTable()->saveOrFail($poll); - $slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['max_words' => 0, 'allow_upvotes' => true]]); + $slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['allow_upvotes' => true]]); $this->goLive($poll, $slide); $this->cookie('plenario_pid', self::PID); @@ -114,7 +114,6 @@ class ParticipateControllerTest extends TestCase $body = json_decode((string)$this->_response->getBody(), true); $this->assertTrue($body['ok']); $this->assertSame(['kaffee'], $body['state']['words']['mine']); - $this->assertNull($body['state']['words']['remaining']); // Cloud is visible despite show_results_to_participants=false, because upvotes are on. $this->assertSame('Kaffee', $body['state']['results']['words'][0]['text']); diff --git a/tests/TestCase/Service/VoteServiceTest.php b/tests/TestCase/Service/VoteServiceTest.php index fdf3fbb..a58661d 100644 --- a/tests/TestCase/Service/VoteServiceTest.php +++ b/tests/TestCase/Service/VoteServiceTest.php @@ -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); diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 5ad05d3..35f8ac7 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -554,7 +554,7 @@ function canUpvote(state) { return !!(wordForm && state.words && state.words.allowUpvotes - && state.isVotingOpen && !state.words.limitReached); + && state.isVotingOpen); } function renderResults(state) { @@ -626,18 +626,10 @@ function applyWordState(state) { if (state.version !== version || !state.words) { - // Limit reached, slide changed or voting closed. + // Slide changed or voting closed. window.location.reload(); return; } - var remaining = wordForm.querySelector('[data-words-remaining]'); - if (state.words.remaining === null) { - remaining.textContent = 'Du kannst beliebig viele Begriffe abgeben.'; - } else { - remaining.textContent = state.words.remaining === 1 - ? 'Du kannst noch einen Begriff abgeben.' - : 'Du kannst noch ' + state.words.remaining + ' Begriffe abgeben.'; - } renderResults(state); }