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
@@ -127,7 +127,7 @@ class PollStateService
|
||||
$slide?->id ?? 0,
|
||||
(int)($slide?->is_voting_open ?? 0),
|
||||
// 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' => $showResults ? $this->slidePayload($slide) : null,
|
||||
@@ -141,25 +141,19 @@ class PollStateService
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Word cloud slide
|
||||
* @param string $participantHash Participant hash
|
||||
* @return array{mine: list<string>, down: list<string>, max: int, remaining: int|null,
|
||||
* limitReached: bool, allowUpvotes: bool, allowDownvotes: bool}
|
||||
* `mine` (named/upvoted) and `down` are lower case word keys, `remaining` is null when unlimited
|
||||
* @return array{mine: list<string>, down: list<string>, allowUpvotes: bool, allowDownvotes: bool}
|
||||
* `mine` (named/upvoted) and `down` are lower case word keys
|
||||
*/
|
||||
public function wordState(Slide $slide, string $participantHash): array
|
||||
{
|
||||
$votes = $this->Responses->wordVotesOf($slide->id, $participantHash);
|
||||
$mine = array_values(array_unique(array_map(VoteService::wordKey(...), $votes['up'])));
|
||||
$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');
|
||||
|
||||
return [
|
||||
'mine' => $mine,
|
||||
'down' => $down,
|
||||
'max' => $max,
|
||||
'remaining' => $remaining,
|
||||
'limitReached' => $remaining === 0,
|
||||
'allowUpvotes' => $allowUpvotes,
|
||||
'allowDownvotes' => $allowUpvotes && (bool)$slide->setting('allow_downvotes'),
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user