Offer reset when slides were touched, not only when answers exist #78
No files matched your search
@@ -209,6 +209,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
||||
Quiz `ready`, Q&A `collect`, alle anderen offen – bei Reihenfolge bleibt die Lösung so verdeckt); Einstellungen bleiben. Das Zurücksetzen der
|
||||
Umfrage setzt außerdem die Präsentation auf „nicht gestartet“ (`Poll::notStarted()`: weder live noch pausiert). Vorab eingetragene Q&A-Fragen bleiben standardmäßig erhalten (nur ihre Upvotes gehen weg):
|
||||
Folien-Reset behält sie immer, der Umfrage-Reset hat die Checkbox `keep_prepared` (nur sichtbar, wenn es welche gibt).
|
||||
Die Reset-Buttons (Dashboard, ↺ je Folie) erscheinen nicht nur bei Antworten, sondern auch, wenn eine Folie vom Ausgangszustand abweicht
|
||||
(`Slide::isFresh()`: Quiz gestartet, Folie geschlossen, Q&A-Phase) oder die Präsentation läuft/pausiert (`Poll::isStarted()`).
|
||||
Idempotent, in einer Transaktion. Tests: `PollResetTest.php`.
|
||||
- **Duplizieren** (`slides:duplicate`, POST): kopiert Fragetext (+ „(Kopie)“), Beschreibung, Einstellungen und Optionen
|
||||
inkl. `is_correct`, **nie Antworten**. Die Kopie landet direkt hinter dem Original und startet wie eine neue Folie
|
||||
|
||||
@@ -61,7 +61,12 @@ class AdminController extends AdminAppController
|
||||
|
||||
$hasPrepared = $this->Responses->hasPrepared($this->poll->id);
|
||||
|
||||
$this->set(compact('slides', 'responseCounts', 'hasPrepared', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
|
||||
// Answers are not the only thing a reset undoes: a started quiz, closed slides or a running presentation too.
|
||||
$canReset = $responseCounts !== []
|
||||
|| $this->poll->isStarted()
|
||||
|| array_filter($slides, fn(Slide $slide) => !$slide->isFresh()) !== [];
|
||||
|
||||
$this->set(compact('slides', 'responseCounts', 'canReset', 'hasPrepared', 'typeLabels', 'typeDescriptions', 'joinUrl', 'embedKey'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,14 @@ class Poll extends Entity
|
||||
$this->embed_seen_at = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Live or paused, i.e. not in the state notStarted() sets
|
||||
*/
|
||||
public function isStarted(): bool
|
||||
{
|
||||
return $this->current_slide_id !== null || $this->paused_slide_id !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Paused after a slide had been live (not: not started yet)
|
||||
*/
|
||||
|
||||
@@ -450,6 +450,21 @@ class Slide extends Entity
|
||||
$this->focus_response_id = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the slide is in the state startFresh() sets (nothing started, closed or discussed yet).
|
||||
* A reset has nothing to do for such a slide unless it has answers.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFresh(): bool
|
||||
{
|
||||
return $this->is_voting_open === !$this->isQuiz()
|
||||
&& $this->voting_started_at === null
|
||||
&& $this->voting_ends_at === null
|
||||
&& $this->stage === ($this->isQa() ? self::QA_COLLECT : null)
|
||||
&& $this->focus_response_id === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or closes voting. Opening a quiz that is not running (re)starts its
|
||||
* voting window and timer; opening a running quiz changes nothing.
|
||||
|
||||
@@ -174,12 +174,14 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
'data-confirm' => $isCurrent ? __('Diese Folie ist gerade live. Ausblenden und die Umfrage pausieren?') : null,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($count > 0) : ?>
|
||||
<?php if ($count > 0 || !$slide->isFresh()) : ?>
|
||||
<?= $this->Form->postButton('↺', $url('slides:reset', ['id' => $slide->id]), [
|
||||
'class' => 'button button--small button--icon',
|
||||
'title' => __('Zurücksetzen: alle Antworten dieser Folie löschen'),
|
||||
'aria-label' => __('Antworten der Folie „{0}“ zurücksetzen', $slide->question),
|
||||
'data-confirm' => __('Alle {0} Antworten dieser Folie löschen?', $count),
|
||||
'title' => __('Zurücksetzen: Antworten löschen und Folie wie neu starten'),
|
||||
'aria-label' => __('Folie „{0}“ zurücksetzen', $slide->question),
|
||||
'data-confirm' => $count > 0
|
||||
? __('Alle {0} Antworten dieser Folie löschen und die Folie zurücksetzen?', $count)
|
||||
: __('Folie zurücksetzen?'),
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->Form->postButton('🗑', $url('slides:delete', ['id' => $slide->id]), [
|
||||
@@ -291,8 +293,10 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
|
||||
<h3><?= __('Umfrage zurücksetzen') ?></h3>
|
||||
<p class="hint"><?= __('Löscht alle Antworten aller Folien und setzt die Präsentation auf „nicht gestartet“ zurück, z. B. für eine neue Gruppe. Folien und Einstellungen bleiben erhalten.') ?></p>
|
||||
<?php if ($responseCounts !== []) : ?>
|
||||
<p class="hint"><?= $this->Html->link(__('Ergebnisse vorher als PDF sichern'), '#export') ?></p>
|
||||
<?php if ($canReset) : ?>
|
||||
<?php if ($responseCounts !== []) : ?>
|
||||
<p class="hint"><?= $this->Html->link(__('Ergebnisse vorher als PDF sichern'), '#export') ?></p>
|
||||
<?php endif; ?>
|
||||
<?= $this->Form->create(null, ['url' => $url('admin:reset')]) ?>
|
||||
<?php if ($hasPrepared) : ?>
|
||||
<?= $this->Form->control('keep_prepared', [
|
||||
@@ -301,13 +305,15 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
'label' => __('Vorab eingetragene Fragen (Fragen & Antworten) behalten'),
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->Form->button(__('Alle Antworten löschen'), [
|
||||
<?= $this->Form->button($responseCounts !== [] ? __('Alle Antworten löschen') : __('Umfrage zurücksetzen'), [
|
||||
'class' => 'button button--small button--danger',
|
||||
'data-confirm' => __('Alle Antworten aller Folien unwiderruflich löschen?'),
|
||||
'data-confirm' => $responseCounts !== []
|
||||
? __('Alle Antworten aller Folien unwiderruflich löschen?')
|
||||
: __('Alle Folien zurücksetzen und die Präsentation auf „nicht gestartet“ stellen?'),
|
||||
]) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
<?php else : ?>
|
||||
<p class="hint"><em><?= __('Noch nichts zurückzusetzen: Es gibt keine Antworten.') ?></em></p>
|
||||
<p class="hint"><em><?= __('Noch nichts zurückzusetzen: keine Antworten, alle Folien im Ausgangszustand, Präsentation nicht gestartet.') ?></em></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3><?= __('Umfrage löschen') ?></h3>
|
||||
|
||||
@@ -149,4 +149,39 @@ class PollResetTest extends TestCase
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/reset\"");
|
||||
}
|
||||
|
||||
public function testDashboardOffersResetWithoutAnswersWhenSlidesWereTouched(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ);
|
||||
$quiz->startFresh();
|
||||
$this->slidesTable()->saveOrFail($quiz);
|
||||
$choice = $this->createSlide($poll, Slide::TYPE_CHOICE);
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains('Noch nichts zurückzusetzen');
|
||||
|
||||
// Quiz started, nobody answered yet.
|
||||
$quiz->setVotingOpen(true);
|
||||
$this->slidesTable()->saveOrFail($quiz);
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/reset\"");
|
||||
$this->assertResponseContains("/admin/$token/slides/{$quiz->id}/reset");
|
||||
$this->assertResponseNotContains("/admin/$token/slides/{$choice->id}/reset");
|
||||
|
||||
// Closed slide.
|
||||
$quiz->startFresh();
|
||||
$this->slidesTable()->saveOrFail($quiz);
|
||||
$choice->is_voting_open = false;
|
||||
$this->slidesTable()->saveOrFail($choice);
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/reset\"");
|
||||
$this->assertResponseContains("/admin/$token/slides/{$choice->id}/reset");
|
||||
|
||||
// Presentation running.
|
||||
$choice->startFresh();
|
||||
$this->slidesTable()->saveOrFail($choice);
|
||||
$this->goLive($poll, $choice);
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/reset\"");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user