Remove per-participant word limit from word clouds #3
No files matched your search
@@ -92,11 +92,11 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
- Abgestimmt werden darf nur auf der **aktuellen** Folie (`polls.current_slide_id`), bei offener Abstimmung,
|
- Abgestimmt werden darf nur auf der **aktuellen** Folie (`polls.current_slide_id`), bei offener Abstimmung,
|
||||||
aktivem Poll und einmal pro Teilnehmer. Diese Logik gehört in `VoteService`, nicht in Controller.
|
aktivem Poll und einmal pro Teilnehmer. Diese Logik gehört in `VoteService`, nicht in Controller.
|
||||||
- Ausnahme Wortwolke: Begriffe werden einzeln abgegeben (AJAX, `vote` liefert dann JSON `{ok, message, state}`),
|
- Ausnahme Wortwolke: Begriffe werden einzeln abgegeben (AJAX, `vote` liefert dann JSON `{ok, message, state}`),
|
||||||
jeder Begriff einmal pro Person, max. `max_words` (0 = unbegrenzt). Einen vorhandenen Begriff erneut nennen
|
jeder Begriff einmal pro Person, beliebig viele Begriffe. Einen vorhandenen Begriff erneut nennen
|
||||||
bzw. in der Wolke anklicken = Upvote (gleiche Zeile in `responses`). Mit `allow_upvotes` sehen Teilnehmende
|
bzw. in der Wolke anklicken = Upvote (gleiche Zeile in `responses`). Mit `allow_upvotes` sehen Teilnehmende
|
||||||
die Wolke live (auch ohne `show_results_to_participants`); Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`).
|
die Wolke live (auch ohne `show_results_to_participants`); Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`).
|
||||||
Downvotes (`vote=down`, Setting `allow_downvotes`, nur zusammen mit Upvotes): Zeile mit `numeric_value = VoteService::DOWNVOTE` (-1),
|
Downvotes (`vote=down`, Setting `allow_downvotes`, nur zusammen mit Upvotes): Zeile mit `numeric_value = VoteService::DOWNVOTE` (-1),
|
||||||
nur auf fremde, vorhandene Begriffe, ein Rating pro Begriff und Person, zählen nicht zu `max_words`.
|
nur auf fremde, vorhandene Begriffe, ein Rating pro Begriff und Person.
|
||||||
Wortgröße richtet sich nur nach den Upvotes (`count`), Downvotes stehen separat in `down`.
|
Wortgröße richtet sich nur nach den Upvotes (`count`), Downvotes stehen separat in `down`.
|
||||||
- `Poll`/`Response` haben `_hidden` für sensible Felder; mass assignment über `_accessible` restriktiv halten.
|
- `Poll`/`Response` haben `_hidden` für sensible Felder; mass assignment über `_accessible` restriktiv halten.
|
||||||
- Alle POST-Formulare laufen über CSRF (`CsrfProtectionMiddleware`). JS sendet `X-CSRF-Token` aus `<meta name="csrf-token">`.
|
- Alle POST-Formulare laufen über CSRF (`CsrfProtectionMiddleware`). JS sendet `X-CSRF-Token` aus `<meta name="csrf-token">`.
|
||||||
|
|||||||
@@ -38,9 +38,8 @@ class Slide extends Entity
|
|||||||
*/
|
*/
|
||||||
public const DEFAULT_SETTINGS = [
|
public const DEFAULT_SETTINGS = [
|
||||||
self::TYPE_CHOICE => ['multiple' => false],
|
self::TYPE_CHOICE => ['multiple' => false],
|
||||||
// max_words: words per participant incl. upvotes (not downvotes), 0 = unlimited;
|
|
||||||
// allow_downvotes only takes effect together with allow_upvotes
|
// allow_downvotes only takes effect together with allow_upvotes
|
||||||
self::TYPE_WORDCLOUD => ['max_words' => 0, 'allow_upvotes' => true, 'allow_downvotes' => true],
|
self::TYPE_WORDCLOUD => ['allow_upvotes' => true, 'allow_downvotes' => true],
|
||||||
self::TYPE_OPEN => [],
|
self::TYPE_OPEN => [],
|
||||||
self::TYPE_SCALE => ['scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => ''],
|
self::TYPE_SCALE => ['scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => ''],
|
||||||
self::TYPE_CONTENT => [],
|
self::TYPE_CONTENT => [],
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ class SlidesTable extends Table
|
|||||||
$settings['multiple'] = filter_var($input['multiple'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
$settings['multiple'] = filter_var($input['multiple'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
break;
|
break;
|
||||||
case Slide::TYPE_WORDCLOUD:
|
case Slide::TYPE_WORDCLOUD:
|
||||||
$settings['max_words'] = max(0, min(50, (int)($input['max_words'] ?? 0)));
|
|
||||||
$settings['allow_upvotes'] = filter_var($input['allow_upvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
$settings['allow_upvotes'] = filter_var($input['allow_upvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
||||||
$settings['allow_downvotes'] = filter_var($input['allow_downvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
$settings['allow_downvotes'] = filter_var($input['allow_downvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class PollStateService
|
|||||||
$slide?->id ?? 0,
|
$slide?->id ?? 0,
|
||||||
(int)($slide?->is_voting_open ?? 0),
|
(int)($slide?->is_voting_open ?? 0),
|
||||||
// Word clouds are answered word by word without reload.
|
// Word clouds are answered word by word without reload.
|
||||||
$words !== null ? (int)$words['limitReached'] : (int)$hasResponded,
|
$words !== null ? 0 : (int)$hasResponded,
|
||||||
$slide?->modified?->toUnixString() ?? 0,
|
$slide?->modified?->toUnixString() ?? 0,
|
||||||
]),
|
]),
|
||||||
'slide' => $showResults ? $this->slidePayload($slide) : null,
|
'slide' => $showResults ? $this->slidePayload($slide) : null,
|
||||||
@@ -141,25 +141,19 @@ class PollStateService
|
|||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Word cloud slide
|
* @param \App\Model\Entity\Slide $slide Word cloud slide
|
||||||
* @param string $participantHash Participant hash
|
* @param string $participantHash Participant hash
|
||||||
* @return array{mine: list<string>, down: list<string>, max: int, remaining: int|null,
|
* @return array{mine: list<string>, down: list<string>, allowUpvotes: bool, allowDownvotes: bool}
|
||||||
* limitReached: bool, allowUpvotes: bool, allowDownvotes: bool}
|
* `mine` (named/upvoted) and `down` are lower case word keys
|
||||||
* `mine` (named/upvoted) and `down` are lower case word keys, `remaining` is null when unlimited
|
|
||||||
*/
|
*/
|
||||||
public function wordState(Slide $slide, string $participantHash): array
|
public function wordState(Slide $slide, string $participantHash): array
|
||||||
{
|
{
|
||||||
$votes = $this->Responses->wordVotesOf($slide->id, $participantHash);
|
$votes = $this->Responses->wordVotesOf($slide->id, $participantHash);
|
||||||
$mine = array_values(array_unique(array_map(VoteService::wordKey(...), $votes['up'])));
|
$mine = array_values(array_unique(array_map(VoteService::wordKey(...), $votes['up'])));
|
||||||
$down = array_values(array_unique(array_map(VoteService::wordKey(...), $votes['down'])));
|
$down = array_values(array_unique(array_map(VoteService::wordKey(...), $votes['down'])));
|
||||||
$max = (int)$slide->setting('max_words');
|
|
||||||
$remaining = $max > 0 ? max(0, $max - count($mine)) : null;
|
|
||||||
$allowUpvotes = (bool)$slide->setting('allow_upvotes');
|
$allowUpvotes = (bool)$slide->setting('allow_upvotes');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'mine' => $mine,
|
'mine' => $mine,
|
||||||
'down' => $down,
|
'down' => $down,
|
||||||
'max' => $max,
|
|
||||||
'remaining' => $remaining,
|
|
||||||
'limitReached' => $remaining === 0,
|
|
||||||
'allowUpvotes' => $allowUpvotes,
|
'allowUpvotes' => $allowUpvotes,
|
||||||
'allowDownvotes' => $allowUpvotes && (bool)$slide->setting('allow_downvotes'),
|
'allowDownvotes' => $allowUpvotes && (bool)$slide->setting('allow_downvotes'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ use Cake\Utility\Security;
|
|||||||
* - voting on the slide must be open
|
* - voting on the slide must be open
|
||||||
* - every participant can answer a slide exactly once, except word clouds:
|
* - every participant can answer a slide exactly once, except word clouds:
|
||||||
* there words are submitted one by one (each word once per participant,
|
* there words are submitted one by one (each word once per participant,
|
||||||
* at most `max_words` words, 0 = unlimited). Submitting a word that already
|
* any number of words). Submitting a word that already
|
||||||
* exists in the cloud is an upvote – both are stored as the same row.
|
* exists in the cloud is an upvote – both are stored as the same row.
|
||||||
* `vote=down` stores a downvote (numeric_value = DOWNVOTE) for an existing
|
* `vote=down` stores a downvote (numeric_value = DOWNVOTE) for an existing
|
||||||
* word of someone else. Each participant rates a word only once (up or down);
|
* word of someone else. Each participant rates a word only once (up or down).
|
||||||
* downvotes do not count towards `max_words`.
|
|
||||||
*/
|
*/
|
||||||
class VoteService
|
class VoteService
|
||||||
{
|
{
|
||||||
@@ -153,7 +152,7 @@ class VoteService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts `word` (string) or `words` (list). Words the participant already
|
* Accepts `word` (string) or `words` (list). Words the participant already
|
||||||
* submitted are skipped, the rest is cut to the remaining limit.
|
* submitted are skipped.
|
||||||
*
|
*
|
||||||
* @param \App\Model\Entity\Slide $slide Slide
|
* @param \App\Model\Entity\Slide $slide Slide
|
||||||
* @param string $participantHash Participant hash
|
* @param string $participantHash Participant hash
|
||||||
@@ -193,19 +192,6 @@ class VoteService
|
|||||||
$words[] = $word;
|
$words[] = $word;
|
||||||
}
|
}
|
||||||
|
|
||||||
$max = (int)$slide->setting('max_words');
|
|
||||||
if ($max > 0) {
|
|
||||||
$remaining = max(0, $max - count($existing));
|
|
||||||
if ($remaining === 0) {
|
|
||||||
throw new VoteException(__n(
|
|
||||||
'Du hast deinen Begriff bereits abgegeben.',
|
|
||||||
'Du hast bereits alle {0} Begriffe abgegeben.',
|
|
||||||
$max,
|
|
||||||
$max,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
$words = array_slice($words, 0, $remaining);
|
|
||||||
}
|
|
||||||
if ($words === []) {
|
if ($words === []) {
|
||||||
throw new VoteException(match (true) {
|
throw new VoteException(match (true) {
|
||||||
$duplicate => __('Diesen Begriff hast du schon genannt.'),
|
$duplicate => __('Diesen Begriff hast du schon genannt.'),
|
||||||
|
|||||||
@@ -51,14 +51,10 @@ $words = $state['words'] ?? null;
|
|||||||
<p class="muted"><?= nl2br(h($slide->description)) ?></p>
|
<p class="muted"><?= nl2br(h($slide->description)) ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($words !== null && $slide->is_voting_open && !$words['limitReached']) : ?>
|
<?php if ($words !== null && $slide->is_voting_open) : ?>
|
||||||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form word-form', 'data-word-form' => true]) ?>
|
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form word-form', 'data-word-form' => true]) ?>
|
||||||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||||||
<p class="hint" data-words-remaining>
|
<p class="hint"><?= __('Du kannst beliebig viele Begriffe abgeben.') ?></p>
|
||||||
<?= $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']) ?>
|
|
||||||
</p>
|
|
||||||
<div class="word-entry">
|
<div class="word-entry">
|
||||||
<input type="text" name="word" maxlength="40" class="word-input" required autofocus
|
<input type="text" name="word" maxlength="40" class="word-input" required autofocus
|
||||||
autocomplete="off" autocapitalize="off" spellcheck="false"
|
autocomplete="off" autocapitalize="off" spellcheck="false"
|
||||||
@@ -118,7 +114,7 @@ $words = $state['words'] ?? null;
|
|||||||
|
|
||||||
<section class="card results-card" data-results-card <?= $state['results'] ? '' : 'hidden' ?>>
|
<section class="card results-card" data-results-card <?= $state['results'] ? '' : 'hidden' ?>>
|
||||||
<h2><?= $words !== null ? __('Wortwolke') : __('Ergebnisse') ?></h2>
|
<h2><?= $words !== null ? __('Wortwolke') : __('Ergebnisse') ?></h2>
|
||||||
<?php if ($words !== null && $words['allowUpvotes'] && $slide->is_voting_open && !$words['limitReached']) : ?>
|
<?php if ($words !== null && $words['allowUpvotes'] && $slide->is_voting_open) : ?>
|
||||||
<p class="hint" data-upvote-hint><?= $words['allowDownvotes']
|
<p class="hint" data-upvote-hint><?= $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, oder auf „−“, um ihn abzulehnen.')
|
||||||
: __('Tippe auf einen Begriff, um ihn zu unterstützen.') ?></p>
|
: __('Tippe auf einen Begriff, um ihn zu unterstützen.') ?></p>
|
||||||
|
|||||||
@@ -56,12 +56,6 @@ $optionsError = $slide->getError('options_text');
|
|||||||
'checked' => (bool)$settings['multiple'],
|
'checked' => (bool)$settings['multiple'],
|
||||||
]) ?>
|
]) ?>
|
||||||
<?php elseif ($slide->type === 'wordcloud') : ?>
|
<?php elseif ($slide->type === 'wordcloud') : ?>
|
||||||
<?= $this->Form->control('settings.max_words', [
|
|
||||||
'type' => 'number', 'min' => 0, 'max' => 50,
|
|
||||||
'label' => __('Begriffe pro Person (0 = unbegrenzt)'),
|
|
||||||
'value' => $settings['max_words'],
|
|
||||||
]) ?>
|
|
||||||
<p class="hint"><?= __('Upvotes zählen mit: Wer einen vorhandenen Begriff unterstützt oder erneut eingibt, verbraucht einen Begriff.') ?></p>
|
|
||||||
<?= $this->Form->control('settings.allow_upvotes', [
|
<?= $this->Form->control('settings.allow_upvotes', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __('Upvotes erlauben (Teilnehmende sehen die Wortwolke live und können Begriffe per Klick unterstützen)'),
|
'label' => __('Upvotes erlauben (Teilnehmende sehen die Wortwolke live und können Begriffe per Klick unterstützen)'),
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ParticipateControllerTest extends TestCase
|
|||||||
[$poll] = $this->createPoll();
|
[$poll] = $this->createPoll();
|
||||||
$poll->show_results_to_participants = false;
|
$poll->show_results_to_participants = false;
|
||||||
$this->pollsTable()->saveOrFail($poll);
|
$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->goLive($poll, $slide);
|
||||||
|
|
||||||
$this->cookie('plenario_pid', self::PID);
|
$this->cookie('plenario_pid', self::PID);
|
||||||
@@ -114,7 +114,6 @@ class ParticipateControllerTest extends TestCase
|
|||||||
$body = json_decode((string)$this->_response->getBody(), true);
|
$body = json_decode((string)$this->_response->getBody(), true);
|
||||||
$this->assertTrue($body['ok']);
|
$this->assertTrue($body['ok']);
|
||||||
$this->assertSame(['kaffee'], $body['state']['words']['mine']);
|
$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.
|
// Cloud is visible despite show_results_to_participants=false, because upvotes are on.
|
||||||
$this->assertSame('Kaffee', $body['state']['results']['words'][0]['text']);
|
$this->assertSame('Kaffee', $body['state']['results']['words'][0]['text']);
|
||||||
|
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ class VoteServiceTest extends TestCase
|
|||||||
$this->assertEqualsWithDelta(66.7, $results['options'][0]['percent'], 0.01);
|
$this->assertEqualsWithDelta(66.7, $results['options'][0]['percent'], 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWordcloudGroupsCaseInsensitivelyAndLimitsWords(): void
|
public function testWordcloudGroupsCaseInsensitively(): void
|
||||||
{
|
{
|
||||||
[$poll] = $this->createPoll();
|
[$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);
|
$poll = $this->goLive($poll, $slide);
|
||||||
|
|
||||||
$service = new VoteService();
|
$service = new VoteService();
|
||||||
@@ -100,16 +100,16 @@ class VoteServiceTest extends TestCase
|
|||||||
$service->submit($poll, $slide, 'p2', ['words' => ['kaffee', '', 'KAFFEE']]);
|
$service->submit($poll, $slide, 'p2', ['words' => ['kaffee', '', 'KAFFEE']]);
|
||||||
|
|
||||||
$results = (new ResultsService())->forSlide($slide);
|
$results = (new ResultsService())->forSlide($slide);
|
||||||
$this->assertSame(['Kaffee', 'tee'], array_column($results['words'], 'text'));
|
$this->assertSame(['Kaffee', 'tee', 'Wasser'], array_column($results['words'], 'text'));
|
||||||
$this->assertSame(['kaffee', 'tee'], array_column($results['words'], 'key'));
|
$this->assertSame(['kaffee', 'tee', 'wasser'], array_column($results['words'], 'key'));
|
||||||
$this->assertSame([2, 1], array_column($results['words'], 'count'));
|
$this->assertSame([2, 1, 1], array_column($results['words'], 'count'));
|
||||||
$this->assertEquals(1, $results['words'][0]['weight']);
|
$this->assertEquals(1, $results['words'][0]['weight']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWordcloudAcceptsWordsOneByOneAndCountsRepeatsAsUpvote(): void
|
public function testWordcloudAcceptsWordsOneByOneAndCountsRepeatsAsUpvote(): void
|
||||||
{
|
{
|
||||||
[$poll] = $this->createPoll();
|
[$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);
|
$poll = $this->goLive($poll, $slide);
|
||||||
|
|
||||||
$service = new VoteService();
|
$service = new VoteService();
|
||||||
@@ -140,44 +140,24 @@ class VoteServiceTest extends TestCase
|
|||||||
$service->submit($poll, $slide, 'p1', ['word' => 'KAFFEE']);
|
$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
|
public function testWordcloudSettingsSanitizing(): void
|
||||||
{
|
{
|
||||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '-3', 'allow_upvotes' => '0']);
|
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '3', 'allow_upvotes' => '0']);
|
||||||
$this->assertSame(['max_words' => 0, 'allow_upvotes' => false, 'allow_downvotes' => true], $settings);
|
$this->assertSame(['allow_upvotes' => false, 'allow_downvotes' => true], $settings);
|
||||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['max_words' => '999', 'allow_downvotes' => '0']);
|
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_WORDCLOUD, ['allow_downvotes' => '0']);
|
||||||
$this->assertSame(['max_words' => 50, 'allow_upvotes' => true, 'allow_downvotes' => false], $settings);
|
$this->assertSame(['allow_upvotes' => true, 'allow_downvotes' => false], $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWordcloudDownvotes(): void
|
public function testWordcloudDownvotes(): void
|
||||||
{
|
{
|
||||||
[$poll] = $this->createPoll();
|
[$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);
|
$poll = $this->goLive($poll, $slide);
|
||||||
|
|
||||||
$service = new VoteService();
|
$service = new VoteService();
|
||||||
$service->submit($poll, $slide, 'p1', ['word' => 'Kaffee']);
|
$service->submit($poll, $slide, 'p1', ['word' => 'Kaffee']);
|
||||||
$service->submit($poll, $slide, 'p2', ['word' => 'kaffee']);
|
$service->submit($poll, $slide, 'p2', ['word' => 'kaffee']);
|
||||||
$service->submit($poll, $slide, 'p3', ['word' => 'Kaffee', 'vote' => 'down']);
|
$service->submit($poll, $slide, 'p3', ['word' => 'Kaffee', 'vote' => 'down']);
|
||||||
// Downvotes do not count towards max_words.
|
|
||||||
$service->submit($poll, $slide, 'p3', ['word' => 'Tee']);
|
$service->submit($poll, $slide, 'p3', ['word' => 'Tee']);
|
||||||
|
|
||||||
$results = (new ResultsService())->forSlide($slide);
|
$results = (new ResultsService())->forSlide($slide);
|
||||||
|
|||||||
+2
-10
@@ -554,7 +554,7 @@
|
|||||||
|
|
||||||
function canUpvote(state) {
|
function canUpvote(state) {
|
||||||
return !!(wordForm && state.words && state.words.allowUpvotes
|
return !!(wordForm && state.words && state.words.allowUpvotes
|
||||||
&& state.isVotingOpen && !state.words.limitReached);
|
&& state.isVotingOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderResults(state) {
|
function renderResults(state) {
|
||||||
@@ -626,18 +626,10 @@
|
|||||||
|
|
||||||
function applyWordState(state) {
|
function applyWordState(state) {
|
||||||
if (state.version !== version || !state.words) {
|
if (state.version !== version || !state.words) {
|
||||||
// Limit reached, slide changed or voting closed.
|
// Slide changed or voting closed.
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
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);
|
renderResults(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user