Reset poll to "not started" and keep prepared Q&A questions
CI / Deploy / PHP 8.4 (push) Successful in 1m5s
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Resetting a poll now also clears the live/paused slide so the presentation
starts over. Questions entered beforehand on Q&A slides are kept by default
(only their upvotes are removed); the dashboard offers a checkbox to delete
them too. Resetting a single slide always keeps them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-13 09:52:26 +01:00
1 parent 19320f01c4
commit 97a60290b4
7 files changed
+119 -22

No files matched your search

+44 -3
View File
@@ -55,6 +55,7 @@ class PollResetTest extends TestCase
$qa->stage = Slide::QA_DISCUSS;
$qa->is_voting_open = false;
$this->slidesTable()->saveManyOrFail([$quiz, $order, $qa]);
$poll->showSlide($qa->id);
$poll->pause();
$this->pollsTable()->saveOrFail($poll);
@@ -66,10 +67,10 @@ class PollResetTest extends TestCase
$this->assertSame(0, $responses->find()->where(['slide_id IN' => [$choice->id, $quiz->id, $order->id, $qa->id]])->count());
$this->assertSame(1, $responses->find()->where(['slide_id' => $foreign->id])->count(), 'other polls stay untouched');
// The presentation stays where it is (paused on the choice slide).
// The presentation is back to "not started".
$poll = $this->pollsTable()->get($poll->id);
$this->assertNull($poll->current_slide_id);
$this->assertSame($choice->id, $poll->paused_slide_id);
$this->assertNull($poll->paused_slide_id);
$slides = $this->slidesTable();
$this->assertSame(Slide::QUIZ_READY, $slides->get($quiz->id)->quizPhase());
@@ -82,7 +83,47 @@ class PollResetTest extends TestCase
// Idempotent: a second reset changes nothing and does not fail.
$this->post("/admin/$token/reset");
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
$this->assertSame($choice->id, $this->pollsTable()->get($poll->id)->paused_slide_id);
$this->assertNull($this->pollsTable()->get($poll->id)->paused_slide_id);
}
public function testResetStopsLivePresentation(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll, Slide::TYPE_CHOICE);
$second = $this->createSlide($poll, Slide::TYPE_CHOICE);
$poll = $this->goLive($poll, $second);
(new VoteService())->submit($poll, $second, VoteService::participantHash(str_repeat('a', 32), $poll->id), [
'option_id' => $second->slide_options[0]->id,
]);
$this->post("/admin/$token/reset");
$reloaded = $this->pollsTable()->get($poll->id);
$this->assertNull($reloaded->current_slide_id);
$this->assertNull($reloaded->paused_slide_id);
}
public function testResetKeepsPreparedQuestionsUnlessAsked(): void
{
[$poll, $token] = $this->createPoll();
$qa = $this->createSlide($poll, Slide::TYPE_QA);
$responses = TableRegistry::getTableLocator()->get('Responses');
$question = $responses->saveOrFail($responses->newEntity([
'slide_id' => $qa->id,
'participant_hash' => VoteService::PREPARED_HASH,
'text_value' => 'Vorbereitet?',
], ['accessibleFields' => ['*' => true]]));
$responses->saveOrFail($responses->newEntity([
'slide_id' => $qa->id,
'participant_hash' => VoteService::participantHash(str_repeat('a', 32), $poll->id),
'parent_id' => $question->id,
], ['accessibleFields' => ['*' => true]]));
$this->post("/admin/$token/reset");
$this->assertSame(1, $responses->find()->where(['slide_id' => $qa->id])->count());
$this->assertSame(1, $responses->find()->where(['id' => $question->id])->count());
$this->post("/admin/$token/reset", ['keep_prepared' => '0']);
$this->assertSame(0, $responses->find()->where(['slide_id' => $qa->id])->count());
}
public function testResetRequiresPost(): void