Let participants edit or delete their Q&A questions while collecting
CI / Deploy / test (push) Successful in 56s
CI / Deploy / deploy (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 12:02:59 +01:00
1 parent 51d1be8695
commit 3a8962976e
6 files changed
+272 -15

No files matched your search

+89
View File
@@ -297,4 +297,93 @@ class QaTest extends TestCase
$slide = $this->slidesTable()->get($slide->id);
$this->assertSame([Slide::QA_COLLECT, true, null], [$slide->qaStage(), $slide->is_voting_open, $slide->focus_response_id]);
}
public function testOwnQuestionCanBeEditedWhileCollecting(): void
{
[$poll, $slide] = $this->createQa();
$votes = new VoteService();
$mine = $this->ask($poll, $slide, 'p1', 'Wan gehts los?');
$other = $this->ask($poll, $slide, 'p2', 'Gibt es Kaffee?');
$votes->submit($poll, $slide, 'p1', ['vote' => 'edit', 'question_id' => $mine, 'question' => ' Wann geht es los? ']);
$responses = $this->fetchTable('Responses');
$this->assertSame('Wann geht es los?', $responses->get($mine)->get('text_value'));
// Repeating the same edit is harmless, case-only changes of the own question are fine.
$votes->submit($poll, $slide, 'p1', ['vote' => 'edit', 'question_id' => $mine, 'question' => 'WANN geht es los?']);
$this->assertSame(2, $responses->find()->where(['slide_id' => $slide->id])->count());
$this->assertVoteFails('Diese Frage wurde schon gestellt. Du kannst sie gleich beim Abstimmen unterstützen.', fn() => $votes->submit(
$poll,
$slide,
'p1',
['vote' => 'edit', 'question_id' => $mine, 'question' => 'gibt es kaffee?'],
));
$this->assertVoteFails('Bitte gib eine Frage ein.', fn() => $votes->submit(
$poll,
$slide,
'p1',
['vote' => 'edit', 'question_id' => $mine, 'question' => ' '],
));
$this->assertVoteFails('Diese Frage gibt es nicht mehr oder sie stammt nicht von dir.', fn() => $votes->submit(
$poll,
$slide,
'p1',
['vote' => 'edit', 'question_id' => $other, 'question' => 'Gekapert'],
));
$this->assertSame('Gibt es Kaffee?', $responses->get($other)->get('text_value'));
}
public function testOwnQuestionCanBeDeletedWhileCollecting(): void
{
[$poll, $slide] = $this->createQa();
$votes = new VoteService();
$mine = $this->ask($poll, $slide, 'p1', 'Weg damit');
$other = $this->ask($poll, $slide, 'p2', 'Bleibt');
$this->assertVoteFails('Diese Frage gibt es nicht mehr oder sie stammt nicht von dir.', fn() => $votes->submit(
$poll,
$slide,
'p1',
['vote' => 'delete', 'question_id' => $other],
));
// Upvotes left over from a voting stage the presenter stepped back from go with it.
$slide = $this->stage($slide, Slide::QA_VOTE);
$this->vote($poll, $slide, 'p2', $mine);
$slide = $this->stage($slide, Slide::QA_COLLECT);
$votes->submit($poll, $slide, 'p1', ['vote' => 'delete', 'question_id' => $mine]);
$responses = $this->fetchTable('Responses');
$this->assertSame([$other], $responses->find()->where(['slide_id' => $slide->id])->all()->extract('id')->toList());
$state = (new PollStateService())->qaState($slide, 'p1');
$this->assertSame([], $state['mine']);
// Deleting again is answered with a message, nothing else happens.
$this->assertVoteFails('Diese Frage gibt es nicht mehr oder sie stammt nicht von dir.', fn() => $votes->submit(
$poll,
$slide,
'p1',
['vote' => 'delete', 'question_id' => $mine],
));
}
public function testQuestionsAreFixedOnceVotingStarts(): void
{
[$poll, $slide] = $this->createQa();
$votes = new VoteService();
$mine = $this->ask($poll, $slide, 'p1', 'Feste Frage');
foreach ([Slide::QA_VOTE, Slide::QA_DISCUSS] as $stage) {
$slide = $this->stage($slide, $stage);
$poll = $this->fetchTable('Polls')->get($poll->id);
foreach (['edit', 'delete'] as $action) {
try {
$votes->submit($poll, $slide, 'p1', ['vote' => $action, 'question_id' => $mine, 'question' => 'Geändert']);
$this->fail('VoteException expected');
} catch (VoteException) {
}
}
}
$this->assertSame('Feste Frage', $this->fetchTable('Responses')->get($mine)->get('text_value'));
}
}