Hide Q&A upvote counts until voting ends
CI / Deploy / test (push) Successful in 1m0s
CI / Deploy / deploy (push) Skipped

A live ranking on the stage swayed the vote. During the vote stage the
presenter now gets the questions in submission order without counts,
only the total of votes cast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 15:05:09 +01:00
1 parent 891e3cb174
commit 759e15390e
5 files changed
+21 -11

No files matched your search

+2 -1
View File
@@ -165,7 +165,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
wird es während `vote` auf 0 gesetzt, springt `SlidesController::saveSlide()` nach `discuss`. wird es während `vote` auf 0 gesetzt, springt `SlidesController::saveSlide()` nach `discuss`.
Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget Setting `allow_self_upvote` (Standard aus, für Themen-Priorisierung) erlaubt Stimmen auf eigene Fragen aus demselben Budget
(State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt; (State `qa.allowSelfUpvote`); bewusst aus, weil anonym sonst Selbstvermarktung die Rangfolge bestimmt;
Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung. `discuss`: Abstimmung zu, Fragen nach Upvotes Teilnehmende sehen alle Fragen in Eingangsreihenfolge **ohne** Zählung; auch die Bühne (Presenter/Embed, PDF) bekommt in `vote`
keine Zählungen je Frage und keine Rangfolge (`ResultsService::qa()`, nur die Summe `upvotes`), damit niemand beeinflusst wird. `discuss`: Abstimmung zu, Fragen nach Upvotes
sortiert (Gleichstand: älteste zuerst), `focus_response_id` = aktuelle Frage. In `discuss` blättern next/prev sortiert (Gleichstand: älteste zuerst), `focus_response_id` = aktuelle Frage. In `discuss` blättern next/prev
(→/←, Klicker) zuerst durch die Fragen, erst danach durch die Folien. Fokuswechsel per `updateAll` ohne `modified`, (→/←, Klicker) zuerst durch die Fragen, erst danach durch die Folien. Fokuswechsel per `updateAll` ohne `modified`,
damit Teilnehmerseiten nicht neu laden. Teilnehmende bekommen nie `results`, sondern `qa` aus `PollStateService::qaState()`. damit Teilnehmerseiten nicht neu laden. Teilnehmende bekommen nie `results`, sondern `qa` aus `PollStateService::qaState()`.
+9 -2
View File
@@ -40,7 +40,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* - qa: 'stage' (collect|vote|discuss), 'stages' (available stages in order, no 'vote' without upvotes), * - qa: 'stage' (collect|vote|discuss), 'stages' (available stages in order, no 'vote' without upvotes),
* 'maxUpvotes' (per participant, 0 = no upvotes), 'maxPerQuestion' (per participant and question), * 'maxUpvotes' (per participant, 0 = no upvotes), 'maxPerQuestion' (per participant and question),
* 'upvotes' (total), * 'upvotes' (total),
* 'questions' => [['id', 'text', 'votes']] most upvoted first (ties: oldest first), * 'questions' => [['id', 'text', 'votes']] most upvoted first (ties: oldest first);
* during 'vote' only [['id', 'text']] in submission order (no counts while voting is open),
* 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null). * 'focusId' (question being discussed|null), 'focusIndex' (0-based position in questions|null).
* Presenter only – participants get their own view, see PollStateService::qaState(). * Presenter only – participants get their own view, see PollStateService::qaState().
*/ */
@@ -215,6 +216,12 @@ class ResultsService
protected function qa(Slide $slide): array protected function qa(Slide $slide): array
{ {
$questions = (new QaService())->rankedQuestions($slide); $questions = (new QaService())->rankedQuestions($slide);
$upvotes = array_sum(array_column($questions, 'votes'));
if ($slide->qaStage() === Slide::QA_VOTE) {
// A live ranking on the stage would sway the vote: submission order, no counts until voting ends.
usort($questions, fn($a, $b) => $a['id'] <=> $b['id']);
$questions = array_map(fn($q) => ['id' => $q['id'], 'text' => $q['text']], $questions);
}
$focusIndex = null; $focusIndex = null;
foreach ($questions as $index => $question) { foreach ($questions as $index => $question) {
if ($question['id'] === $slide->focus_response_id) { if ($question['id'] === $slide->focus_response_id) {
@@ -227,7 +234,7 @@ class ResultsService
'stages' => $slide->qaStages(), 'stages' => $slide->qaStages(),
'maxUpvotes' => (int)$slide->setting('max_upvotes'), 'maxUpvotes' => (int)$slide->setting('max_upvotes'),
'maxPerQuestion' => $slide->qaUpvotesPerQuestion(), 'maxPerQuestion' => $slide->qaUpvotesPerQuestion(),
'upvotes' => array_sum(array_column($questions, 'votes')), 'upvotes' => $upvotes,
'questions' => $questions, 'questions' => $questions,
'focusId' => $focusIndex === null ? null : $slide->focus_response_id, 'focusId' => $focusIndex === null ? null : $slide->focus_response_id,
'focusIndex' => $focusIndex, 'focusIndex' => $focusIndex,
+1 -1
View File
@@ -213,7 +213,7 @@ $bar = function (float $percent, bool $ok = false): string {
<?php if ($r['questions'] === []) : ?> <?php if ($r['questions'] === []) : ?>
<p class="empty"><?= __('Keine Fragen eingereicht.') ?></p> <p class="empty"><?= __('Keine Fragen eingereicht.') ?></p>
<?php else : ?> <?php else : ?>
<?php $withUpvotes = $r['maxUpvotes'] > 0; ?> <?php $withUpvotes = $r['maxUpvotes'] > 0 && $r['stage'] !== 'vote'; ?>
<table> <table>
<thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><?php if ($withUpvotes) : ?><th class="num"><?= __('Upvotes') ?></th><?php endif; ?></tr></thead> <thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><?php if ($withUpvotes) : ?><th class="num"><?= __('Upvotes') ?></th><?php endif; ?></tr></thead>
<tbody> <tbody>
+6 -2
View File
@@ -203,12 +203,16 @@ class QaTest extends TestCase
$this->assertVoteFails('Du hast diese Frage nicht unterstützt.', fn() => $this->vote($poll, $slide, 'p3', $c, 'remove')); $this->assertVoteFails('Du hast diese Frage nicht unterstützt.', fn() => $this->vote($poll, $slide, 'p3', $c, 'remove'));
$this->vote($poll, $slide, 'p3', $a); $this->vote($poll, $slide, 'p3', $a);
// While voting is open, the stage only gets the total: no ranking, no counts per question.
$results = (new ResultsService())->forSlide($slide); $results = (new ResultsService())->forSlide($slide);
$this->assertSame([[$b, 3], [$a, 1], [$c, 0]], array_map(fn($q) => [$q['id'], $q['votes']], $results['questions'])); $this->assertSame([$a, $b, $c], array_column($results['questions'], 'id'));
$this->assertArrayNotHasKey('votes', $results['questions'][0]);
$this->assertSame(4, $results['upvotes']); $this->assertSame(4, $results['upvotes']);
$ranked = (new QaService())->rankedQuestions($slide);
$this->assertSame([[$b, 3], [$a, 1], [$c, 0]], array_map(fn($q) => [$q['id'], $q['votes']], $ranked));
$this->vote($poll, $slide, 'p3', $b, 'remove'); $this->vote($poll, $slide, 'p3', $b, 'remove');
$this->assertSame(2, (new ResultsService())->forSlide($slide)['questions'][0]['votes'], 'remove withdraws only one upvote'); $this->assertSame(2, (new QaService())->rankedQuestions($slide)[0]['votes'], 'remove withdraws only one upvote');
$this->vote($poll, $slide, 'p3', $b); $this->vote($poll, $slide, 'p3', $b);
// Voting view of participants: all questions, submission order, no counts. // Voting view of participants: all questions, submission order, no counts.
+3 -5
View File
@@ -1000,7 +1000,6 @@
var onStage = options && options.onStage; var onStage = options && options.onStage;
var onQuestion = options && options.onQuestion; var onQuestion = options && options.onQuestion;
var questions = results.questions; var questions = results.questions;
var maxVotes = Math.max.apply(null, questions.map(function (q) { return q.votes; }).concat([1]));
var children = [Qa.steps(results.stage, onStage, results.stages)]; var children = [Qa.steps(results.stage, onStage, results.stages)];
var withVotes = results.maxUpvotes > 0; var withVotes = results.maxUpvotes > 0;
@@ -1027,11 +1026,10 @@
+ results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen') + results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen')
+ (results.maxPerQuestion < results.maxUpvotes ? ' (höchstens ' + results.maxPerQuestion + ' pro Frage)' : '') + (results.maxPerQuestion < results.maxUpvotes ? ' (höchstens ' + results.maxPerQuestion + ' pro Frage)' : '')
+ ' · bisher ' + results.upvotes + ' vergeben' })); + ' · bisher ' + results.upvotes + ' vergeben' }));
children.push(el('ol', { class: 'qa-list' }, questions.map(function (question) { // No counts or ranking while voting is open (the server sends none), so the stage does not sway the vote.
children.push(el('ul', { class: 'qa-list' }, questions.map(function (question) {
return el('li', { class: 'qa-item' }, [ return el('li', { class: 'qa-item' }, [
el('span', { class: 'qa-item__text', text: question.text }), el('span', { class: 'qa-item__text', text: question.text })
votes(question),
el('span', { class: 'qa-item__bar', style: 'width:' + (question.votes / maxVotes * 100) + '%' })
]); ]);
}))); })));
} else if (questions.length === 0) { } else if (questions.length === 0) {