Let the dashboard follow the presenter
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

The live marker in the slide list stayed on the last known slide when the
presenter moved on in another window or with a clicker. The dashboard now
polls a cheap version fingerprint (admin:live) and reloads the lists when it
changes, but never under an open dialog, a pending request or a drag.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-13 12:19:12 +01:00
1 parent 9c6a19f0de
commit 8c7818ee40
7 files changed
+104 -1

No files matched your search

+12
View File
@@ -60,6 +60,7 @@ class AdminController extends AdminAppController
$embedKey = $this->Polls->ensureEmbedKey($this->poll);
$hasPrepared = $this->Responses->hasPrepared($this->poll->id);
$this->setPollInterval();
// Answers are not the only thing a reset undoes: a started quiz, closed slides or a running presentation too.
$canReset = $responseCounts !== []
@@ -195,6 +196,17 @@ class AdminController extends AdminAppController
return $this->json((new PollStateService())->forPresenter($this->poll));
}
/**
* Fingerprint of the dashboard content (JSON `{version}`), polled by the dashboard so the
* live marker follows the presenter. See PollStateService::dashboardVersion().
*
* @return \Cake\Http\Response
*/
public function live(): Response
{
return $this->json(['version' => (new PollStateService())->dashboardVersion($this->poll)]);
}
/**
* Presenter controls. Field `action`:
* goto (+ slide_id), next, prev, stop (pause), resume (continue after a pause), and the slide actions of
+27
View File
@@ -56,6 +56,33 @@ class PollStateService
$this->results = new ResultsService();
}
/**
* Cheap fingerprint of everything the admin dashboard shows (live/paused slide, slide settings
* and status, answer counts). The dashboard polls it and reloads its lists when it changes.
*
* @param \App\Model\Entity\Poll $poll Poll
* @return string
*/
public function dashboardVersion(Poll $poll): string
{
$slides = $this->Slides->find()
->select([
'n' => $this->Slides->find()->func()->count('*'),
'latest' => $this->Slides->find()->func()->max('modified'),
])
->where(['poll_id' => $poll->id])
->disableHydration()
->first();
return md5(json_encode([
(int)$poll->is_active,
$poll->current_slide_id,
$poll->paused_slide_id,
$slides,
$this->Responses->countParticipantsPerSlide($poll->id),
], JSON_THROW_ON_ERROR));
}
/**
* @param \App\Model\Entity\Poll $poll Poll
* @return \App\Model\Entity\Slide|null