diff --git a/AGENTS.md b/AGENTS.md
index 90fe1c2..1bee80f 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -145,6 +145,9 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
`SlidesTable::closeIfExpired()` beim State-Abruf. **Zählungen und `is_correct` dürfen vor `finished` nie im
JSON/HTML landen** (weder Presenter noch Teilnehmende); danach sehen Teilnehmende die Lösung und ob sie
richtig lagen (ohne Verteilung). Zurücksetzen setzt das Quiz wieder auf `ready`.
+ **Klicker/Presenter-Stick** (sendet nur →/← bzw. Bild↑/↓): `AdminController::control` behandelt `next` auf einem Quiz als
+ Schritt – `ready` → starten, `running` → beenden (Lösung), erst `finished` → nächste Folie. `prev` geht immer zur vorigen Folie
+ und startet nie ein Quiz. Tests: `QuizClickerTest.php`.
- `Poll`/`Response` haben `_hidden` für sensible Felder; mass assignment über `_accessible` restriktiv halten.
- Alle POST-Formulare laufen über CSRF (`CsrfProtectionMiddleware`). JS sendet `X-CSRF-Token` aus ``.
- Ausgaben in Templates immer mit `h()` escapen. JS baut DOM mit `textContent`, nie `innerHTML` mit Nutzerdaten.
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 990254f..af8b8c3 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -196,7 +196,8 @@ class AdminController extends AdminAppController
* SlideControlService (open, close, toggle, stage, question).
*
* On a Q&A slide that is being discussed, next/prev step through the questions
- * first (like builds in presentation software). While paused, next/prev resume
+ * first (like builds in presentation software); on a quiz, next starts it and then ends it
+ * before moving on, prev always goes to the previous slide. While paused, next/prev resume
* the slide that was live before.
*
* Answers with the new state as JSON for XHR requests, otherwise redirects back.
@@ -220,6 +221,15 @@ class AdminController extends AdminAppController
) {
$action = 'none';
}
+ // Forward on a quiz is a build step too: start it, then end it, only then the next slide.
+ // Back never touches the quiz, so a clicker can page through the slides afterwards.
+ if ($current !== null && $current->isQuiz() && $action === 'next') {
+ $phase = $current->quizPhase();
+ if ($phase !== Slide::QUIZ_FINISHED) {
+ (new SlideControlService())->apply($current, $phase === Slide::QUIZ_READY ? 'open' : 'close');
+ $action = 'none';
+ }
+ }
switch ($action) {
case 'none':
diff --git a/tests/TestCase/Controller/QuizClickerTest.php b/tests/TestCase/Controller/QuizClickerTest.php
new file mode 100644
index 0000000..13762f9
--- /dev/null
+++ b/tests/TestCase/Controller/QuizClickerTest.php
@@ -0,0 +1,95 @@
+
+ */
+ protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ $this->enableCsrfToken();
+ }
+
+ /**
+ * @return array
+ */
+ protected function control(string $token, string $action): array
+ {
+ $this->configRequest(['headers' => ['Accept' => 'application/json']]);
+ $this->post("/admin/$token/control", ['action' => $action]);
+ $this->assertResponseOk();
+
+ return json_decode((string)$this->_response->getBody(), true);
+ }
+
+ protected function createQuiz(Poll $poll, array $data = []): Slide
+ {
+ $quiz = $this->createSlide($poll, Slide::TYPE_QUIZ, $data);
+ $quiz->startFresh();
+
+ return $this->slidesTable()->saveOrFail($quiz);
+ }
+
+ public function testNextStartsAndEndsQuizBeforeMovingOn(): void
+ {
+ [$poll, $token] = $this->createPoll();
+ $intro = $this->createSlide($poll, Slide::TYPE_CONTENT);
+ $quiz = $this->createQuiz($poll, ['settings' => ['time_limit' => 0] + Slide::DEFAULT_SETTINGS[Slide::TYPE_QUIZ]]);
+ $outro = $this->createSlide($poll, Slide::TYPE_CONTENT);
+ $this->goLive($poll, $intro);
+
+ // Arriving at the quiz does not start it.
+ $state = $this->control($token, 'next');
+ $this->assertSame($quiz->id, $state['slide']['id']);
+ $this->assertSame(Slide::QUIZ_READY, $this->slidesTable()->get($quiz->id)->quizPhase());
+
+ // Next: start. Next: end. Next: next slide.
+ $state = $this->control($token, 'next');
+ $this->assertSame($quiz->id, $state['slide']['id']);
+ $this->assertSame(Slide::QUIZ_RUNNING, $this->slidesTable()->get($quiz->id)->quizPhase());
+
+ $state = $this->control($token, 'next');
+ $this->assertSame($quiz->id, $state['slide']['id']);
+ $this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($quiz->id)->quizPhase());
+
+ $state = $this->control($token, 'next');
+ $this->assertSame($outro->id, $state['slide']['id']);
+
+ // Back never restarts the quiz: it is passed through and stays finished.
+ $state = $this->control($token, 'prev');
+ $this->assertSame($quiz->id, $state['slide']['id']);
+ $this->assertSame(Slide::QUIZ_FINISHED, $this->slidesTable()->get($quiz->id)->quizPhase());
+ $state = $this->control($token, 'prev');
+ $this->assertSame($intro->id, $state['slide']['id']);
+ }
+
+ public function testPrevOnUnstartedQuizJustGoesBack(): void
+ {
+ [$poll, $token] = $this->createPoll();
+ $intro = $this->createSlide($poll, Slide::TYPE_CONTENT);
+ $quiz = $this->createQuiz($poll);
+ $this->goLive($poll, $quiz);
+
+ $state = $this->control($token, 'prev');
+ $this->assertSame($intro->id, $state['slide']['id']);
+ $this->assertSame(Slide::QUIZ_READY, $this->slidesTable()->get($quiz->id)->quizPhase());
+ }
+}