Allow Q&A rounds without upvotes and limit upvotes per question
CI / Deploy / test (push) Successful in 57s
CI / Deploy / deploy (push) Skipped

- max_upvotes = 0 disables upvoting: the voting stage is skipped
  (collect -> discuss), questions are discussed in submission order
- new setting max_upvotes_per_question caps a participant's upvotes
  on a single question (0 = no limit besides max_upvotes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-09 08:36:02 +01:00
1 parent 3e44ded107
commit bc86ec2db6
16 files changed
+235 -38

No files matched your search

+16 -2
View File
@@ -31,7 +31,8 @@ use Cake\Utility\Security;
* at most MAX_QA_QUESTIONS per participant, the same question (case-insensitive)
* only once per slide. `vote=up|remove` + `question_id` only while voting: upvote
* questions of others (own ones too with setting `allow_self_upvote`), at most
* `max_upvotes` in total, freely distributed (several on one question are allowed);
* `max_upvotes` in total, freely distributed (several on one question are allowed,
* at most `max_upvotes_per_question` if set; `max_upvotes` = 0 means no voting stage);
* `remove` withdraws one own upvote of the question.
* - ordering: `order` = all option ids, each exactly once, in the participant's order.
* Stored as one row with the ids comma separated in `text_value` (see parseOrder()).
@@ -297,6 +298,9 @@ class VoteService
return [['text_value' => $text]];
}
if (!$slide->hasQaUpvotes()) {
throw new VoteException(__('Bei dieser Fragerunde wird nicht abgestimmt.'));
}
if ($stage !== Slide::QA_VOTE) {
throw new VoteException(__('Die Abstimmung über die Fragen hat noch nicht begonnen.'));
}
@@ -324,8 +328,18 @@ class VoteService
if (!$slide->setting('allow_self_upvote') && in_array($id, $own['questions'], true)) {
throw new VoteException(__('Deine eigene Frage kannst du nicht unterstützen.'));
}
// Several upvotes on the same question are allowed (push important questions).
// Several upvotes on the same question are allowed (push important questions),
// up to the limit per question.
$max = (int)$slide->setting('max_upvotes');
$perQuestion = $slide->qaUpvotesPerQuestion();
if ($perQuestion < $max && count(array_keys($own['upvotes'], $id, true)) >= $perQuestion) {
throw new VoteException(__n(
'Du kannst jeder Frage nur eine Stimme geben.',
'Du kannst jeder Frage höchstens {0} Stimmen geben.',
$perQuestion,
$perQuestion,
));
}
if (count($own['upvotes']) >= $max) {
throw new VoteException(__n(
'Du hast deine Stimme schon vergeben. Nimm sie zurück, um eine andere Frage zu unterstützen.',