Make the poll reset only delete responses
The presentation (current slide, pause) and the open/closed state of slides are kept. Only quiz and Q&A slides go back to their start, as the per-slide reset already did before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1b327899f
commit
8644d4bc4a
7 files changed
+37
-54
No files matched your search
@@ -29,7 +29,7 @@ class PollResetTest extends TestCase
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
public function testResetDeletesAllResponsesAndStartsOver(): void
|
||||
public function testResetOnlyDeletesResponses(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
[$other] = $this->createPoll('Andere');
|
||||
@@ -60,22 +60,21 @@ class PollResetTest extends TestCase
|
||||
|
||||
$this->post("/admin/$token/reset");
|
||||
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
||||
$this->assertFlashMessage('Die Umfrage wurde zurückgesetzt: Alle Antworten sind gelöscht, die Präsentation beginnt wieder bei der ersten Folie.');
|
||||
$this->assertFlashMessage('Alle Antworten wurden gelöscht.');
|
||||
|
||||
$responses = TableRegistry::getTableLocator()->get('Responses');
|
||||
$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).
|
||||
$poll = $this->pollsTable()->get($poll->id);
|
||||
$this->assertNull($poll->current_slide_id);
|
||||
$this->assertNull($poll->paused_slide_id);
|
||||
$this->assertSame($foreign->id, $this->pollsTable()->get($other->id)->current_slide_id);
|
||||
$this->assertSame($choice->id, $poll->paused_slide_id);
|
||||
|
||||
$slides = $this->slidesTable();
|
||||
$this->assertSame(Slide::QUIZ_READY, $slides->get($quiz->id)->quizPhase());
|
||||
$this->assertNull($slides->get($quiz->id)->voting_started_at);
|
||||
$this->assertTrue($slides->get($order->id)->is_voting_open);
|
||||
$this->assertFalse($slides->get($order->id)->isOrderRevealed());
|
||||
$this->assertFalse($slides->get($order->id)->is_voting_open, 'open/closed is kept');
|
||||
$this->assertSame(Slide::QA_COLLECT, $slides->get($qa->id)->qaStage());
|
||||
$this->assertTrue($slides->get($qa->id)->is_voting_open);
|
||||
$this->assertTrue($slides->get($choice->id)->is_voting_open);
|
||||
@@ -83,7 +82,7 @@ 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->assertNull($this->pollsTable()->get($poll->id)->current_slide_id);
|
||||
$this->assertSame($choice->id, $this->pollsTable()->get($poll->id)->paused_slide_id);
|
||||
}
|
||||
|
||||
public function testResetRequiresPost(): void
|
||||
@@ -101,7 +100,10 @@ class PollResetTest extends TestCase
|
||||
$this->assertResponseNotContains("/admin/$token/reset\"");
|
||||
$this->assertResponseContains('Noch nichts zurückzusetzen');
|
||||
|
||||
$this->goLive($poll, $slide);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
(new VoteService())->submit($poll, $slide, VoteService::participantHash(str_repeat('a', 32), $poll->id), [
|
||||
'option_id' => $slide->slide_options[0]->id,
|
||||
]);
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/reset\"");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user