Feature/private scale #18

Merged
gnilebein merged 5 commits from feature/private-scale into main 2026-11-08 18:38:01 +01:00
5 changed files with 42 additions and 12 deletions
Showing only changes of commit d6166bd9d9 - Show all commits

No files matched your search

+2 -1
View File
@@ -173,7 +173,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
`buckets: []` und `average: null` (nur `participants`), Teilnehmende bekommen keine `results`. Verteilung und `buckets: []` und `average: null` (nur `participants`), Teilnehmende bekommen keine `results`. Verteilung und
Durchschnitt nur in der Verwaltung (`slides:answers` → „Auswertung“, `ResultsService::scaleResults()`) und im CSV-Export. Durchschnitt nur in der Verwaltung (`slides:answers` → „Auswertung“, `ResultsService::scaleResults()`) und im CSV-Export.
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value` - **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 `results.comments` in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State
`results.comments` (Teilnehmende bekommen immer `[]`, `PollStateService::participantResults()`)
(älteste zuerst, je `id`, `text`, `value`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“, (älteste zuerst, je `id`, `text`, `value`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“,
vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback bleibt `comments` leer, vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback bleibt `comments` leer,
lesbar nur in der Auswertung (`ResultsService::comments()`) und im CSV-Export. lesbar nur in der Auswertung (`ResultsService::comments()`) und im CSV-Export.
+17 -1
View File
@@ -187,7 +187,7 @@ class PollStateService
$slide?->modified?->toUnixString() ?? 0, $slide?->modified?->toUnixString() ?? 0,
]), ]),
'slide' => $showResults ? $this->slidePayload($slide) : null, 'slide' => $showResults ? $this->slidePayload($slide) : null,
'results' => $showResults ? $this->results->forSlide($slide) : null, 'results' => $showResults ? $this->participantResults($slide) : null,
'words' => $words, 'words' => $words,
'quiz' => $quiz, 'quiz' => $quiz,
'qa' => $qa, 'qa' => $qa,
@@ -195,6 +195,22 @@ class PollStateService
]; ];
} }
/**
* Results as participants see them: scale comments are for the presentation only.
*
* @param \App\Model\Entity\Slide $slide Current slide
* @return array<string, mixed>
*/
protected function participantResults(Slide $slide): array
{
$results = $this->results->forSlide($slide);
if (isset($results['comments'])) {
$results['comments'] = [];
}
return $results;
}
/** /**
* Ordering progress of one participant. Own answer and correctness only once * Ordering progress of one participant. Own answer and correctness only once
* revealed (voting closed); before that the state must not hint at the solution. * revealed (voting closed); before that the state must not hint at the solution.
+2 -1
View File
@@ -20,7 +20,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* private (anonymous feedback): 'answers' is always empty, texts only via answers() * private (anonymous feedback): 'answers' is always empty, texts only via answers()
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null, * - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool); * 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool);
* 'comments' => [['id', 'text', 'value']] oldest first (only with the comment field, else []); * 'comments' => [['id', 'text', 'value']] oldest first (only with the comment field, else [];
* presentation only, emptied for participants in PollStateService);
* private (internal feedback): 'buckets' and 'comments' are always empty and 'average' null, * private (internal feedback): 'buckets' and 'comments' are always empty and 'average' null,
* ratings and comments only via scaleResults() / comments() * ratings and comments only via scaleResults() / comments()
* - quiz: 'phase' (ready|running|finished), 'timeLimit' (s, 0 = manual), 'remaining' (s|null), * - quiz: 'phase' (ready|running|finished), 'timeLimit' (s, 0 = manual), 'remaining' (s|null),
+1 -1
View File
@@ -171,7 +171,7 @@ $optionsError = $slide->getError('options_text');
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'), 'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
'checked' => (bool)$settings['comments'], 'checked' => (bool)$settings['comments'],
]) ?> ]) ?>
<p class="hint"><?= __('Die Kommentare laufen bei den Ergebnissen nacheinander durch – außer bei internem Feedback, dann siehst du sie nur in der Auswertung.') ?></p> <p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden). Bei internem Feedback siehst du sie nur in der Auswertung.') ?></p>
<?= $this->Form->control('settings.private', [ <?= $this->Form->control('settings.private', [
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __('Internes Feedback: Ergebnis nicht öffentlich anzeigen'), 'label' => __('Internes Feedback: Ergebnis nicht öffentlich anzeigen'),
@@ -13,7 +13,7 @@ use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
/** /**
* Scale slides with an optional comment field: comments rotate on the results unless the scale is private. * Scale slides with an optional comment field: comments rotate in the presentation unless the scale is private.
*/ */
class ScaleCommentsTest extends TestCase class ScaleCommentsTest extends TestCase
{ {
@@ -144,20 +144,32 @@ class ScaleCommentsTest extends TestCase
$this->assertSame([4, 3], array_column($results['comments'], 'value')); $this->assertSame([4, 3], array_column($results['comments'], 'value'));
} }
public function testParticipantsSeeCommentsOnlyWithPublicResults(): void public function testParticipantsNeverSeeComments(): void
{ {
[$poll] = $this->scaleWithComments(); [$poll] = $this->scaleWithComments();
// Participant "a" has already rated. $this->assertTrue($poll->show_results_to_participants);
// Participant "a" has already rated and sees the results – but not the comments.
$this->cookie('plenario_pid', str_repeat('a', 32)); $this->cookie('plenario_pid', str_repeat('a', 32));
$this->get('/p/' . $poll->join_code . '/state'); $this->get('/p/' . $poll->join_code . '/state');
$state = json_decode((string)$this->_response->getBody(), true); $state = json_decode((string)$this->_response->getBody(), true);
$this->assertCount(2, $state['results']['comments']); $this->assertNotEmpty($state['results']['buckets']);
$this->assertSame([], $state['results']['comments']);
$this->assertResponseNotContains('Zu lang');
$poll->show_results_to_participants = false; $this->get('/p/' . $poll->join_code);
$this->pollsTable()->saveOrFail($poll); $this->assertResponseNotContains('Zu lang');
$this->get('/p/' . $poll->join_code . '/state'); }
$this->assertNull(json_decode((string)$this->_response->getBody(), true)['results']);
public function testEmbedShowsComments(): void
{
[$poll, , $slide] = $this->scaleWithComments();
$key = $this->pollsTable()->ensureEmbedKey($poll);
$this->get("/e/$key/{$slide->id}/state");
$state = json_decode((string)$this->_response->getBody(), true);
$this->assertCount(2, $state['results']['comments']);
} }
public function testPrivateScaleNeverShowsComments(): void public function testPrivateScaleNeverShowsComments(): void