Merge pull request 'Reset poll to "not started" and keep prepared Q&A questions' (#75) from feature/reset-not-started into main
Reviewed-on: #75
This commit was merged in pull request #75.
This commit is contained in:
commit
3c66597696
7 files changed
+119
-22
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user