From cfb445123ed9a8b6e0da44058beefd64f3656c63 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Sun, 8 Nov 2026 20:02:36 +0100 Subject: [PATCH] Keep results off participant devices Results belong on the stage. Participants only get results where they interact with them (word cloud with upvotes) and, once resolved, the solution of quiz and ordering slides with their own verdict, without counts or distribution. Removes the per-poll setting show_results_to_participants (column stays unused). Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 20 ++++++---- src/Controller/AdminController.php | 2 +- src/Model/Entity/Poll.php | 2 - src/Model/Table/PollsTable.php | 2 - src/Service/PollStateService.php | 38 ++++++++++--------- templates/Admin/index.php | 4 -- .../Controller/AdminControllerTest.php | 2 +- .../Controller/ParticipateControllerTest.php | 14 ++++--- .../Controller/PrivateFeedbackTest.php | 2 - .../TestCase/Controller/ScaleCommentsTest.php | 7 ++-- tests/TestCase/Service/OrderTest.php | 9 +++-- tests/TestCase/Service/QuizTest.php | 9 +++-- webroot/css/plenario.css | 7 ++++ webroot/js/plenario.js | 27 +++++++++++-- 14 files changed, 86 insertions(+), 59 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 975d772..af2e1b9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -81,7 +81,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures ### Datenmodell - `polls`: `title`, `email`, `admin_token_hash` (sha256), `admin_token_encrypted` (Security::encrypt), - `join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`, `show_results_to_participants`, + `join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`, `show_results_to_participants` (ungenutzt, Altlast), `embed_key` (Einbett-Schlüssel), `embed_seen_at` (letztes Lebenszeichen der eingebetteten Live-Folie), `paused_slide_id` (Folie vor der Pause) - `slides`: `type` (`choice|wordcloud|open|scale|content|quiz|youtube|qa|order`), `question`, `description`, `position`, @@ -107,10 +107,15 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures - Teilnehmende sind anonym: nur `VoteService::participantHash()` (HMAC, pro Poll) speichern. - 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. +- **Ergebnisse gehören auf die Bühne, nicht aufs Endgerät.** Teilnehmende bekommen `results` nur, wo sie damit + interagieren (Wortwolke mit Upvotes, solange offen) und als Auflösung ihrer eigenen Antwort (Quiz nach `finished`, + Reihenfolge nach dem Schließen) – dann nur die Lösung **ohne** Zählungen/Verteilung (`PollStateService::participantResults()` + entfernt `count`, `percent`, `placed`, `correctCount`; die JS-Renderer erkennen daran die Teilnehmeransicht). + Q&A nutzt eigenes `qa`. Es gibt keinen Schalter dafür pro Umfrage. - Ausnahme Wortwolke: Begriffe werden einzeln abgegeben (AJAX, `vote` liefert dann JSON `{ok, message, state}`), 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 - die Wolke live (auch ohne `show_results_to_participants`); Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`). + die Wolke live; 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), 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`. @@ -119,8 +124,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures `time_limit`, erneutes Öffnen eines laufenden Quiz startet den Timer nicht neu). „Offen“ heißt immer `Slide::isVotingOpen()` (inkl. Deadline), nicht nur `is_voting_open`. Abgelaufene Quizze schließt `SlidesTable::closeIfExpired()` beim State-Abruf. **Zählungen und `is_correct` dürfen vor `finished` nie im - JSON/HTML landen** (weder Presenter noch Teilnehmende); danach sehen Teilnehmende die Auflösung immer, - unabhängig von `show_results_to_participants`. Zurücksetzen setzt das Quiz wieder auf `ready`. + JSON/HTML landen** (weder Presenter noch Teilnehmende); danach sehen Teilnehmende die Lösung und ob sie + richtig lagen (ohne Verteilung). Zurücksetzen setzt das Quiz wieder auf `ready`. - `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 ``. - Ausgaben in Templates immer mit `h()` escapen. JS baut DOM mit `textContent`, nie `innerHTML` mit Nutzerdaten. @@ -151,8 +156,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures `Slide::shuffledOptions(participantHash)` gemischt (stabil, nie schon richtig), sortieren und senden `order[]` (alle ids genau einmal), einmal pro Person. Startet offen wie normale Folien; **aufgelöst wird beim Schließen der Abstimmung** (`Slide::isOrderRevealed()`). Vorher landen weder richtige Reihenfolge noch Zählungen im JSON (Presenter sieht die Einträge gemischt mit Seed `slide:{id}`); - danach sehen alle die Lösung inkl. „X von N komplett richtig“ und je Eintrag, wie oft er an der richtigen Stelle lag, Teilnehmende - zusätzlich `order.isCorrect` – unabhängig von `show_results_to_participants`. Tests: `OrderTest.php`, `OrderSlideTest.php`. + danach sieht der Presenter die Lösung inkl. „X von N komplett richtig“ und je Eintrag, wie oft er an der richtigen Stelle lag; + Teilnehmende nur die Lösung mit eigenen Platzierungen und `order.isCorrect`. Tests: `OrderTest.php`, `OrderSlideTest.php`. - **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne `paused_slide_id` = noch nicht gestartet. Immer über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` setzen, @@ -171,8 +176,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures Schalter „Ergebnisse verbergen“ (H) im Presenter/Embed. Das JSON enthält die vollständigen Ergebnisse plus `results.private = true`; `initPresenter` verbirgt sie beim Wechsel auf eine solche Folie und zeigt stattdessen nur die Anzahl (`Results.privateSummary`). Einblenden gilt nur für diese Folie, die globale Wahl für normale Folien (`hideAll`) - bleibt unberührt. Teilnehmende bekommen bei privaten Folien **nie** `results` (unabhängig von - `show_results_to_participants`). Die Fassung des PDF-Exports ohne interne Inhalte entfernt sie per + bleibt unberührt. Teilnehmende bekommen (wie bei allen Abstimmungsfolien) keine `results`. Die Fassung des PDF-Exports ohne interne Inhalte entfernt sie per `ResultsService::withoutContents()`. Volle Ansicht in der Verwaltung (`slides:answers` → „Auswertung“). - **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value` in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index a478c92..6ee334e 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -71,7 +71,7 @@ class AdminController extends AdminAppController { $this->request->allowMethod(['post']); $this->Polls->patchEntity($this->poll, (array)$this->request->getData(), [ - 'fields' => ['title', 'is_active', 'show_results_to_participants'], + 'fields' => ['title', 'is_active'], ]); if ($this->Polls->save($this->poll)) { $this->Flash->success(__('Einstellungen gespeichert.')); diff --git a/src/Model/Entity/Poll.php b/src/Model/Entity/Poll.php index 22d7236..675e61d 100644 --- a/src/Model/Entity/Poll.php +++ b/src/Model/Entity/Poll.php @@ -18,7 +18,6 @@ use Cake\ORM\Entity; * @property \Cake\I18n\DateTime|null $embed_seen_at * @property int|null $paused_slide_id * @property bool $is_active - * @property bool $show_results_to_participants * @property \Cake\I18n\DateTime|null $last_admin_access * @property \Cake\I18n\DateTime $created * @property \Cake\I18n\DateTime $modified @@ -36,7 +35,6 @@ class Poll extends Entity 'title' => true, 'email' => true, 'is_active' => true, - 'show_results_to_participants' => true, ]; /** diff --git a/src/Model/Table/PollsTable.php b/src/Model/Table/PollsTable.php index 4614459..f0fcc87 100644 --- a/src/Model/Table/PollsTable.php +++ b/src/Model/Table/PollsTable.php @@ -71,7 +71,6 @@ class PollsTable extends Table ->notEmptyString('email', __('Bitte gib deine E-Mail-Adresse ein.')); $validator->boolean('is_active'); - $validator->boolean('show_results_to_participants'); return $validator; } @@ -203,7 +202,6 @@ class PollsTable extends Table $token = $this->assignNewToken($poll); $poll->join_code = $this->generateJoinCode(); $poll->is_active = true; - $poll->show_results_to_participants = true; if (!$this->save($poll)) { return [$poll, null]; diff --git a/src/Service/PollStateService.php b/src/Service/PollStateService.php index 88f9e5d..8c81dde 100644 --- a/src/Service/PollStateService.php +++ b/src/Service/PollStateService.php @@ -14,16 +14,14 @@ use Cake\ORM\Locator\LocatorAwareTrait; * Builds the JSON state polled by the presenter screen (/admin/{token}/state) * and the participant page (/p/{code}/state). * - * The participant state never contains results unless the poll allows it and - * the participant has answered (or voting is closed). Exception: word clouds - * with upvotes enabled show the live cloud while voting is open, because - * participants upvote by clicking words in it. + * Results are shown on the presentation screen, not on participants' devices. The participant + * state only contains `results` where participants need them to interact: word clouds with + * upvotes show the live cloud while voting is open (participants upvote by clicking words). * - * Quiz slides reveal results (and the participant's own correctness) only - * once the quiz is finished – then always, independent of - * `show_results_to_participants`. Timed quizzes are closed lazily here - * when their deadline has passed. Ordering slides work the same way: solution, - * counts and the participant's correctness (`order`) only once voting is closed. + * Quiz slides reveal the solution (and the participant's own correctness) once the quiz is + * finished, without counts or distribution. Timed quizzes are closed lazily here when their + * deadline has passed. Ordering slides work the same way: solution and the participant's + * correctness (`order`) once voting is closed, without counts. * * Q&A slides have their own participant view (`qa`, see qaState()), never `results`. * Private slides (anonymous/internal feedback) never show results to participants, @@ -163,14 +161,13 @@ class PollStateService }; $isVotingOpen = $slide?->isVotingOpen() ?? false; + // Results reach the device only where participants act on them (upvoting words) + // or to resolve their own quiz/ordering answer. $showResults = $slide !== null - && $slide->isInteractive() - && $qa === null && !$slide->isPrivate() - && ($quiz !== null || $order !== null - ? ($quiz['phase'] ?? null) === Slide::QUIZ_FINISHED || ($order['revealed'] ?? false) - : ($poll->show_results_to_participants && ($hasResponded || !$isVotingOpen)) - || ($words !== null && $words['allowUpvotes'] && $isVotingOpen)); + && (($quiz['phase'] ?? null) === Slide::QUIZ_FINISHED + || ($order['revealed'] ?? false) + || ($words !== null && $words['allowUpvotes'] && $isVotingOpen)); return [ 'isActive' => $poll->is_active, @@ -197,7 +194,8 @@ class PollStateService } /** - * Results as participants see them: scale comments are for the presentation only. + * Results as participants see them: a resolved quiz/ordering slide only with the + * solution (no counts, no distribution - those are for the stage), a word cloud as is. * * @param \App\Model\Entity\Slide $slide Current slide * @return array @@ -205,8 +203,12 @@ class PollStateService protected function participantResults(Slide $slide): array { $results = $this->results->forSlide($slide); - if (isset($results['comments'])) { - $results['comments'] = []; + unset($results['correctCount']); + foreach (['options', 'items'] as $list) { + foreach ($results[$list] ?? [] as $i => $entry) { + unset($entry['count'], $entry['percent'], $entry['placed']); + $results[$list][$i] = $entry; + } } return $results; diff --git a/templates/Admin/index.php b/templates/Admin/index.php index 8e316bb..37ae761 100644 --- a/templates/Admin/index.php +++ b/templates/Admin/index.php @@ -224,10 +224,6 @@ $hasInternal = array_filter($slides, fn($slide) => $slide->isInteractive() && $s 'type' => 'checkbox', 'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'), ]) ?> - Form->control('show_results_to_participants', [ - 'type' => 'checkbox', - 'label' => __('Teilnehmende sehen Ergebnisse nach ihrer Antwort'), - ]) ?> Form->button(__('Speichern'), ['class' => 'button']) ?> Form->end() ?> diff --git a/tests/TestCase/Controller/AdminControllerTest.php b/tests/TestCase/Controller/AdminControllerTest.php index d940ea3..5bb126f 100644 --- a/tests/TestCase/Controller/AdminControllerTest.php +++ b/tests/TestCase/Controller/AdminControllerTest.php @@ -55,7 +55,7 @@ class AdminControllerTest extends TestCase $this->get("/admin/$token"); $this->assertResponseNotContains('name="_method" value="PUT"', 'settings form must not override method'); - $this->post("/admin/$token/settings", ['title' => 'Neu', 'is_active' => '1', 'show_results_to_participants' => '0']); + $this->post("/admin/$token/settings", ['title' => 'Neu', 'is_active' => '1']); $this->assertRedirect(['_name' => 'admin', 'token' => $token]); $this->assertSame('Neu', $this->pollsTable()->get($poll->id)->title); } diff --git a/tests/TestCase/Controller/ParticipateControllerTest.php b/tests/TestCase/Controller/ParticipateControllerTest.php index 7f1c556..366fdee 100644 --- a/tests/TestCase/Controller/ParticipateControllerTest.php +++ b/tests/TestCase/Controller/ParticipateControllerTest.php @@ -76,7 +76,7 @@ class ParticipateControllerTest extends TestCase $this->assertSame(0, TableRegistry::getTableLocator()->get('Responses')->find()->count()); } - public function testStateHidesResultsUntilAnswered(): void + public function testStateNeverContainsResults(): void { [$poll] = $this->createPoll(); $slide = $this->createSlide($poll, Slide::TYPE_SCALE); @@ -96,14 +96,18 @@ class ParticipateControllerTest extends TestCase $this->get("/p/{$poll->join_code}/state"); $state = json_decode((string)$this->_response->getBody(), true); $this->assertTrue($state['hasResponded']); - $this->assertEqualsWithDelta(4.0, $state['results']['average'], 0.001); + // Results are for the stage only, not even after answering or closing. + $this->assertNull($state['results']); + + $this->slidesTable()->updateAll(['is_voting_open' => false], ['id' => $slide->id]); + $this->cookie('plenario_pid', self::PID); + $this->get("/p/{$poll->join_code}/state"); + $this->assertNull(json_decode((string)$this->_response->getBody(), true)['results']); } public function testWordcloudAjaxVoteReturnsStateWithUpvoteCloud(): void { [$poll] = $this->createPoll(); - $poll->show_results_to_participants = false; - $this->pollsTable()->saveOrFail($poll); $slide = $this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['settings' => ['allow_upvotes' => true]]); $this->goLive($poll, $slide); @@ -114,7 +118,7 @@ class ParticipateControllerTest extends TestCase $body = json_decode((string)$this->_response->getBody(), true); $this->assertTrue($body['ok']); $this->assertSame(['kaffee'], $body['state']['words']['mine']); - // Cloud is visible despite show_results_to_participants=false, because upvotes are on. + // The cloud reaches the device because participants upvote in it. $this->assertSame('Kaffee', $body['state']['results']['words'][0]['text']); $this->cookie('plenario_pid', self::PID); diff --git a/tests/TestCase/Controller/PrivateFeedbackTest.php b/tests/TestCase/Controller/PrivateFeedbackTest.php index b08ae6a..2634b1a 100644 --- a/tests/TestCase/Controller/PrivateFeedbackTest.php +++ b/tests/TestCase/Controller/PrivateFeedbackTest.php @@ -95,7 +95,6 @@ class PrivateFeedbackTest extends TestCase public function testParticipantsNeverSeeAnswers(): void { [$poll] = $this->privateSlideWithAnswer(); - $this->assertTrue($poll->show_results_to_participants); $this->assertNull($this->participantState($poll)['results']); $this->get('/p/' . $poll->join_code); @@ -214,7 +213,6 @@ class PrivateFeedbackTest extends TestCase public function testParticipantsNeverSeeScaleResults(): void { [$poll] = $this->privateScaleWithRatings(); - $this->assertTrue($poll->show_results_to_participants); $this->assertNull($this->participantState($poll)['results']); $this->get('/p/' . $poll->join_code); diff --git a/tests/TestCase/Controller/ScaleCommentsTest.php b/tests/TestCase/Controller/ScaleCommentsTest.php index 2c2b651..41a47e7 100644 --- a/tests/TestCase/Controller/ScaleCommentsTest.php +++ b/tests/TestCase/Controller/ScaleCommentsTest.php @@ -157,14 +157,13 @@ class ScaleCommentsTest extends TestCase public function testParticipantsNeverSeeComments(): void { [$poll] = $this->scaleWithComments(); - $this->assertTrue($poll->show_results_to_participants); - // Participant "a" has already rated and sees the results – but not the comments. + // Participant "a" has already rated – results stay on the stage. $this->cookie('plenario_pid', str_repeat('a', 32)); $this->get('/p/' . $poll->join_code . '/state'); $state = json_decode((string)$this->_response->getBody(), true); - $this->assertNotEmpty($state['results']['buckets']); - $this->assertSame([], $state['results']['comments']); + $this->assertTrue($state['hasResponded']); + $this->assertNull($state['results']); $this->assertResponseNotContains('Zu lang'); $this->get('/p/' . $poll->join_code); diff --git a/tests/TestCase/Service/OrderTest.php b/tests/TestCase/Service/OrderTest.php index 6ce0555..1dbb004 100644 --- a/tests/TestCase/Service/OrderTest.php +++ b/tests/TestCase/Service/OrderTest.php @@ -149,14 +149,15 @@ class OrderTest extends TestCase $this->assertSame([1, 2, 3, 4], array_column($results['items'], 'position')); $this->assertSame([2, 2, 3, 3], array_column($results['items'], 'placed')); - // Revealed even without show_results_to_participants. - $poll->show_results_to_participants = false; - $this->pollsTable()->saveOrFail($poll); + // Participants get the solution and their own verdict, but no counts. $wrong = $this->participantState($poll, 'p2'); $this->assertTrue($wrong['order']['revealed']); $this->assertFalse($wrong['order']['isCorrect']); $this->assertSame($this->ids($slide, ['Antike', 'Steinzeit', 'Mittelalter', 'Neuzeit']), $wrong['order']['answer']); - $this->assertNotNull($wrong['results']); + $this->assertSame([1, 2, 3, 4], array_column($wrong['results']['items'], 'position')); + $this->assertArrayNotHasKey('correctCount', $wrong['results']); + $this->assertArrayNotHasKey('placed', $wrong['results']['items'][0]); + $this->assertArrayNotHasKey('percent', $wrong['results']['items'][0]); $this->assertTrue($this->participantState($poll, 'p1')['order']['isCorrect']); $this->assertNull($this->participantState($poll, 'nobody')['order']['isCorrect']); diff --git a/tests/TestCase/Service/QuizTest.php b/tests/TestCase/Service/QuizTest.php index 9518606..75eb26f 100644 --- a/tests/TestCase/Service/QuizTest.php +++ b/tests/TestCase/Service/QuizTest.php @@ -170,14 +170,15 @@ class QuizTest extends TestCase $this->assertSame(['Berlin', true, 2], [$results['options'][0]['label'], $results['options'][0]['correct'], $results['options'][0]['count']]); $this->assertFalse($results['options'][1]['correct']); - // Revealed to participants even without show_results_to_participants. - $poll->show_results_to_participants = false; - $this->pollsTable()->saveOrFail($poll); + // Participants get the solution and their own verdict, but no distribution. $state = $this->participantState($poll, 'p2'); $this->assertSame('finished', $state['quiz']['phase']); $this->assertFalse($state['quiz']['isCorrect']); $this->assertSame($this->optionId($slide, 'Hamburg'), $state['quiz']['answerId']); - $this->assertNotNull($state['results']); + $this->assertSame([true, false], array_slice(array_column($state['results']['options'], 'correct'), 0, 2)); + $this->assertArrayNotHasKey('correctCount', $state['results']); + $this->assertArrayNotHasKey('count', $state['results']['options'][0]); + $this->assertArrayNotHasKey('percent', $state['results']['options'][0]); $this->assertTrue($this->participantState($poll, 'p1')['quiz']['isCorrect']); $this->assertNull($this->participantState($poll, 'nobody')['quiz']['isCorrect']); } diff --git a/webroot/css/plenario.css b/webroot/css/plenario.css index 566bfa6..b5582ad 100644 --- a/webroot/css/plenario.css +++ b/webroot/css/plenario.css @@ -465,6 +465,13 @@ textarea { resize: vertical; } .bar--correct .bar__label { color: var(--ok); } .bar--wrong .bar__fill { background: var(--muted); opacity: .6; } .bar.is-mine .bar__label { text-decoration: underline; text-underline-offset: 3px; } +/* quiz solution on the participant device (no counts) */ +.quiz-solution { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } +.quiz-solution__item { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); } +.quiz-solution__item.is-correct { color: var(--ok); font-weight: 700; } +.quiz-solution__item.is-wrong { color: var(--muted); } +.quiz-solution__item.is-mine { outline: 2px solid currentColor; outline-offset: -2px; } +.quiz-solution__mine { font-weight: 400; } /* ordering results */ .order-solution { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; } diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 522cbba..bdb171f 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -626,6 +626,21 @@ return el('div', { class: 'quiz-results quiz-results--' + results.phase }, children); } + if (results.correctCount === undefined) { + // Participant device: the solution only, the distribution is for the stage. + return el('ul', { class: 'quiz-solution' }, results.options.map(function (option) { + var mine = answerId !== null && answerId !== undefined && option.id === answerId; + return el('li', { + class: 'quiz-solution__item ' + (option.correct ? 'is-correct' : 'is-wrong') + (mine ? ' is-mine' : '') + }, [ + el('span', { 'aria-hidden': 'true', text: option.correct ? '✓ ' : '✗ ' }), + document.createTextNode(option.label), + el('span', { class: 'sr-only', text: option.correct ? ' – richtig' : ' – falsch' }), + mine ? el('span', { class: 'quiz-solution__mine', text: ' (deine Antwort)' }) : null + ]); + })); + } + var max = Math.max.apply(null, results.options.map(function (o) { return o.count; }).concat([1])); var percent = results.participants > 0 ? Math.round(results.correctCount / results.participants * 100) : 0; var summary = el('p', { class: 'quiz-summary' }, [ @@ -663,13 +678,17 @@ } var children = []; - if (results.participants > 0) { + // Participant device (no correctCount): only the solution with the own placements, + // the verdict above it is part of the page. + var onStage = results.correctCount !== undefined; + var withCounts = onStage && results.participants > 0; + if (withCounts) { var percent = Math.round(results.correctCount / results.participants * 100); children.push(el('p', { class: 'quiz-summary' }, [ el('strong', { text: results.correctCount + ' von ' + results.participants }), el('span', { text: ' komplett richtig (' + percent + ' %)' }) ])); - } else { + } else if (onStage) { children.push(el('p', { class: 'results-empty', text: 'Keine Antworten – so wäre es richtig gewesen:' })); } children.push(el('ol', { class: 'order-solution' }, results.items.map(function (item, index) { @@ -684,10 +703,10 @@ text: mine ? ' – von dir richtig platziert' : ' – von dir an anderer Stelle' }) ]), - results.participants > 0 ? el('div', { class: 'bar__track' }, [ + withCounts ? el('div', { class: 'bar__track' }, [ el('div', { class: 'bar__fill', style: 'width:' + item.percent + '%' }) ]) : null, - results.participants > 0 ? el('div', { + withCounts ? el('div', { class: 'bar__value', text: formatNumber(item.percent) + ' % an dieser Stelle (' + item.placed + ')' }) : null -- 2.54.1