Allow a comment without a rating on scales instead of "Keine Angabe"
With the comment field enabled, scales and star ratings accept a comment alone. It counts as taking part but not in the average or the distribution; the number is shown separately. The explicit skip button and its setting are removed again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6432911ed
commit
dbac9e93c7
14 files changed
+85
-105
No files matched your search
@@ -239,29 +239,22 @@ class ParticipateControllerTest extends TestCase
|
||||
$this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack']));
|
||||
}
|
||||
|
||||
public function testScaleSkipButtonOnlyWithSetting(): void
|
||||
public function testScaleCommentOnlyWithoutRating(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
|
||||
$this->goLive($poll, $slide);
|
||||
$this->cookie('plenario_pid', self::PID);
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseNotContains('Keine Angabe');
|
||||
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['allow_skip' => true, 'comments' => true]]);
|
||||
$this->goLive($poll, $slide);
|
||||
$this->cookie('plenario_pid', self::PID);
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseContains('name="skip"');
|
||||
$this->assertResponseContains('auch nur einen Kommentar');
|
||||
$this->assertResponseNotContains('required>');
|
||||
|
||||
$this->cookie('plenario_pid', self::PID);
|
||||
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'skip' => '1']);
|
||||
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'comment' => 'Keine Meinung dazu']);
|
||||
$this->assertFlashMessage('Danke für deine Antwort!');
|
||||
|
||||
// No rating, so no comment to add afterwards.
|
||||
$this->cookie('plenario_pid', self::PID);
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseContains('Deine Antwort ist angekommen.');
|
||||
$this->assertResponseNotContains('Kommentar hinzufügen');
|
||||
$this->assertResponseContains('Keine Meinung dazu');
|
||||
}
|
||||
}
|
||||
@@ -71,49 +71,60 @@ class VoteServiceTest extends TestCase
|
||||
(new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']);
|
||||
}
|
||||
|
||||
public function testScaleSkipCountsAsParticipantButNotInAverage(): void
|
||||
public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'allow_skip' => true]]);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'comments' => true]]);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
$service = new VoteService();
|
||||
$service->submit($poll, $slide, 'p1', ['value' => '4']);
|
||||
$service->submit($poll, $slide, 'p2', ['skip' => '1']);
|
||||
$service->submit($poll, $slide, 'p2', ['comment' => 'Kann ich nicht beurteilen']);
|
||||
|
||||
$results = (new ResultsService())->forSlide($slide);
|
||||
$this->assertSame(2, $results['participants']);
|
||||
$this->assertSame(1, $results['skipped']);
|
||||
$this->assertSame(1, $results['commentOnly']);
|
||||
$this->assertSame(4.0, (float)$results['average']);
|
||||
$this->assertSame(1, array_sum(array_column($results['buckets'], 'count')));
|
||||
$this->assertTrue($service->hasSkipped($slide, 'p2'));
|
||||
$this->assertFalse($service->hasSkipped($slide, 'p1'));
|
||||
$this->assertSame(['Kann ich nicht beurteilen'], array_column($results['comments'], 'text'));
|
||||
$this->assertSame([null], array_column((new ResultsService())->comments($slide), 'value'));
|
||||
|
||||
// Only once per person, like any answer.
|
||||
$this->expectExceptionMessage('bereits abgestimmt');
|
||||
$service->submit($poll, $slide, 'p2', ['value' => '2']);
|
||||
}
|
||||
|
||||
public function testScaleSkipNeedsTheSetting(): void
|
||||
public function testScaleWithoutRatingNeedsCommentField(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$this->expectExceptionMessage('nicht möglich');
|
||||
(new VoteService())->submit($poll, $slide, 'p1', ['skip' => '1']);
|
||||
$this->expectExceptionMessage('zwischen 1 und 5');
|
||||
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => 'Nur Kommentar']);
|
||||
}
|
||||
|
||||
public function testScaleSkipHasNoComment(): void
|
||||
public function testScaleNeedsRatingOrComment(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['allow_skip' => true, 'comments' => true]]);
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
|
||||
$this->expectExceptionMessage('oder schreibe einen Kommentar');
|
||||
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => ' ']);
|
||||
}
|
||||
|
||||
public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
$service = new VoteService();
|
||||
$service->submit($poll, $slide, 'p1', ['skip' => '1', 'comment' => 'Ignoriert']);
|
||||
$service->submit($poll, $slide, 'p1', ['comment' => 'Erst']);
|
||||
$service->editText($poll, $slide, 'p1', ['comment' => 'Dann']);
|
||||
$this->assertSame('Dann', $service->ownText($slide, 'p1'));
|
||||
|
||||
$this->assertNull($service->ownText($slide, 'p1'));
|
||||
$this->expectExceptionMessage('keinen Kommentar');
|
||||
$service->editText($poll, $slide, 'p1', ['comment' => 'Nachtrag']);
|
||||
$this->expectExceptionMessage('nicht leer sein');
|
||||
$service->editText($poll, $slide, 'p1', ['comment' => '']);
|
||||
}
|
||||
|
||||
public function testMultipleChoiceResults(): void
|
||||
|
||||
Reference in new issue
Block a user