diff --git a/AGENTS.md b/AGENTS.md index 88cd67d..4c6d062 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -165,7 +165,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures 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 (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 (→/←, 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()`. diff --git a/src/Service/ResultsService.php b/src/Service/ResultsService.php index 61ceee9..f383458 100644 --- a/src/Service/ResultsService.php +++ b/src/Service/ResultsService.php @@ -40,7 +40,8 @@ use Cake\ORM\Locator\LocatorAwareTrait; * - 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), * '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). * Presenter only – participants get their own view, see PollStateService::qaState(). */ @@ -215,6 +216,12 @@ class ResultsService protected function qa(Slide $slide): array { $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; foreach ($questions as $index => $question) { if ($question['id'] === $slide->focus_response_id) { @@ -227,7 +234,7 @@ class ResultsService 'stages' => $slide->qaStages(), 'maxUpvotes' => (int)$slide->setting('max_upvotes'), 'maxPerQuestion' => $slide->qaUpvotesPerQuestion(), - 'upvotes' => array_sum(array_column($questions, 'votes')), + 'upvotes' => $upvotes, 'questions' => $questions, 'focusId' => $focusIndex === null ? null : $slide->focus_response_id, 'focusIndex' => $focusIndex, diff --git a/templates/Admin/export.php b/templates/Admin/export.php index 020e1a1..bd8aefa 100644 --- a/templates/Admin/export.php +++ b/templates/Admin/export.php @@ -213,7 +213,7 @@ $bar = function (float $percent, bool $ok = false): string {

- 0; ?> + 0 && $r['stage'] !== 'vote'; ?> diff --git a/tests/TestCase/Service/QaTest.php b/tests/TestCase/Service/QaTest.php index 10f2f1a..e805027 100644 --- a/tests/TestCase/Service/QaTest.php +++ b/tests/TestCase/Service/QaTest.php @@ -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->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); - $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']); + $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->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); // Voting view of participants: all questions, submission order, no counts. diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 97ad447..5b9caa9 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -1000,7 +1000,6 @@ var onStage = options && options.onStage; var onQuestion = options && options.onQuestion; 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 withVotes = results.maxUpvotes > 0; @@ -1027,11 +1026,10 @@ + results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen') + (results.maxPerQuestion < results.maxUpvotes ? ' (höchstens ' + results.maxPerQuestion + ' pro Frage)' : '') + ' · 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' }, [ - el('span', { class: 'qa-item__text', text: question.text }), - votes(question), - el('span', { class: 'qa-item__bar', style: 'width:' + (question.votes / maxVotes * 100) + '%' }) + el('span', { class: 'qa-item__text', text: question.text }) ]); }))); } else if (questions.length === 0) {
#