Merge pull request 'Let the presenter resume a paused poll with the pause button' (#38) from fix/presenter-resume into main
Reviewed-on: #38
This commit was merged in pull request #38.
This commit is contained in:
commit
e9e1159ad9
5 files changed
+52
-9
No files matched your search
@@ -190,7 +190,8 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
Idempotent, in einer Transaktion. Tests: `PollResetTest.php`.
|
Idempotent, in einer Transaktion. Tests: `PollResetTest.php`.
|
||||||
- **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne
|
- **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne
|
||||||
`paused_slide_id` = noch nicht gestartet. Immer über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` /
|
`paused_slide_id` = noch nicht gestartet. Immer über `Poll::showSlide()` / `showEmbeddedSlide()` / `pause()` /
|
||||||
`forgetSlide()` setzen, nie `current_slide_id` direkt. Presenter: P pausiert, ←/→ setzt bei der pausierten Folie fort.
|
`forgetSlide()` setzen, nie `current_slide_id` direkt. Presenter: P bzw. der Pause-Button schaltet um (Aktionen `stop`/`resume`, beide idempotent, kein Server-Toggle),
|
||||||
|
←/→ setzt ebenfalls bei der pausierten Folie fort.
|
||||||
Wird die Live- oder pausierte Folie gelöscht, pausiert die Umfrage und setzt mit der nachrückenden Folie fort
|
Wird die Live- oder pausierte Folie gelöscht, pausiert die Umfrage und setzt mit der nachrückenden Folie fort
|
||||||
(`forgetSlide()`, keine FKs auf `current_slide_id`/`paused_slide_id`, sie dürfen nie auf gelöschte Folien zeigen).
|
(`forgetSlide()`, keine FKs auf `current_slide_id`/`paused_slide_id`, sie dürfen nie auf gelöschte Folien zeigen).
|
||||||
- **Einbettung** (`/e/{key}/{id}`, `EmbedController`): eigener `embed_key` statt Admin-Token (darf nur diese Folie zeigen,
|
- **Einbettung** (`/e/{key}/{id}`, `EmbedController`): eigener `embed_key` statt Admin-Token (darf nur diese Folie zeigen,
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class AdminController extends AdminAppController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Presenter controls. Field `action`:
|
* Presenter controls. Field `action`:
|
||||||
* goto (+ slide_id), next, prev, stop (pause), and the slide actions of
|
* goto (+ slide_id), next, prev, stop (pause), resume (continue after a pause), and the slide actions of
|
||||||
* SlideControlService (open, close, toggle, stage, question).
|
* SlideControlService (open, close, toggle, stage, question).
|
||||||
*
|
*
|
||||||
* On a Q&A slide that is being discussed, next/prev step through the questions
|
* On a Q&A slide that is being discussed, next/prev step through the questions
|
||||||
@@ -241,6 +241,12 @@ class AdminController extends AdminAppController
|
|||||||
case 'stop':
|
case 'stop':
|
||||||
$this->poll->pause();
|
$this->poll->pause();
|
||||||
break;
|
break;
|
||||||
|
case 'resume':
|
||||||
|
// Explicit (not a toggle), so a repeated click never pauses again.
|
||||||
|
if ($index === false && in_array($this->poll->paused_slide_id, $ids, true)) {
|
||||||
|
$this->poll->showSlide((int)$this->poll->paused_slide_id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (!in_array($action, SlideControlService::ACTIONS, true)) {
|
if (!in_array($action, SlideControlService::ACTIONS, true)) {
|
||||||
throw new BadRequestException('Unknown action');
|
throw new BadRequestException('Unknown action');
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Presenter screen. Rendered empty and filled by webroot/js/plenario.js
|
* Presenter screen. Rendered empty and filled by webroot/js/plenario.js
|
||||||
* (Plenario.presenter) from /admin/{token}/state.
|
* (Plenario.presenter) from /admin/{token}/state.
|
||||||
*
|
*
|
||||||
* Keyboard: ←/→ slides, P pause (→ resumes), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark.
|
* Keyboard: ←/→ slides, P pause/resume (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark.
|
||||||
* Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first.
|
* Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first.
|
||||||
*
|
*
|
||||||
* @var \App\View\AppView $this
|
* @var \App\View\AppView $this
|
||||||
@@ -50,8 +50,10 @@ $host = preg_replace('#^https?://#', '', $joinBaseUrl);
|
|||||||
<button type="button" class="ctrl" data-action="next" aria-keyshortcuts="ArrowRight PageDown Space" title="<?= __('Nächste Folie (→ oder Leertaste)') ?>">
|
<button type="button" class="ctrl" data-action="next" aria-keyshortcuts="ArrowRight PageDown Space" title="<?= __('Nächste Folie (→ oder Leertaste)') ?>">
|
||||||
<span aria-hidden="true">→</span><span class="sr-only"><?= __('Nächste Folie') ?></span>
|
<span aria-hidden="true">→</span><span class="sr-only"><?= __('Nächste Folie') ?></span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="ctrl" data-action="stop" aria-keyshortcuts="P" title="<?= __('Pause: Teilnehmende sehen eine Pause-Seite (P)') ?>">
|
<button type="button" class="ctrl" data-action="stop" data-pause aria-keyshortcuts="P" title="<?= __('Pause: Teilnehmende sehen eine Pause-Seite (P)') ?>"
|
||||||
<span aria-hidden="true">⏸</span><span class="sr-only"><?= __('Pause') ?></span>
|
data-title-pause="<?= h(__('Pause: Teilnehmende sehen eine Pause-Seite (P)')) ?>"
|
||||||
|
data-title-resume="<?= h(__('Fortsetzen: pausierte Folie wieder zeigen (P)')) ?>">
|
||||||
|
<span aria-hidden="true" data-pause-icon>⏸</span><span class="sr-only" data-pause-label><?= __('Pause') ?></span>
|
||||||
<kbd class="ctrl__key" aria-hidden="true">[P]</kbd>
|
<kbd class="ctrl__key" aria-hidden="true">[P]</kbd>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="ctrl ctrl--wide" data-action="toggle" data-voting aria-keyshortcuts="V" title="<?= __('Abstimmung öffnen/schließen (V)') ?>">
|
<button type="button" class="ctrl ctrl--wide" data-action="toggle" data-voting aria-keyshortcuts="V" title="<?= __('Abstimmung öffnen/schließen (V)') ?>">
|
||||||
|
|||||||
@@ -289,6 +289,34 @@ class AdminControllerTest extends TestCase
|
|||||||
$this->assertSame($second->id, $this->pollsTable()->get($poll->id)->current_slide_id, 'stays on last slide');
|
$this->assertSame($second->id, $this->pollsTable()->get($poll->id)->current_slide_id, 'stays on last slide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPauseAndResumeAreIdempotent(): void
|
||||||
|
{
|
||||||
|
[$poll, $token] = $this->createPoll();
|
||||||
|
$this->createSlide($poll, Slide::TYPE_CHOICE);
|
||||||
|
$second = $this->createSlide($poll, Slide::TYPE_WORDCLOUD);
|
||||||
|
$this->get("/admin/$token/present");
|
||||||
|
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
|
||||||
|
$this->post("/admin/$token/control", ['action' => 'goto', 'slide_id' => $second->id]);
|
||||||
|
|
||||||
|
foreach ([1, 2] as $attempt) {
|
||||||
|
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
|
||||||
|
$this->post("/admin/$token/control", ['action' => 'stop']);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$state = json_decode((string)$this->_response->getBody(), true);
|
||||||
|
$this->assertNull($state['slide'], "paused after stop #$attempt");
|
||||||
|
$this->assertTrue($state['poll']['isPaused']);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ([1, 2] as $attempt) {
|
||||||
|
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
|
||||||
|
$this->post("/admin/$token/control", ['action' => 'resume']);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
$state = json_decode((string)$this->_response->getBody(), true);
|
||||||
|
$this->assertSame($second->id, $state['slide']['id'], "resumes the paused slide (#$attempt)");
|
||||||
|
$this->assertFalse($state['poll']['isPaused']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testControlRejectsSlideOfOtherPoll(): void
|
public function testControlRejectsSlideOfOtherPoll(): void
|
||||||
{
|
{
|
||||||
[, $token] = $this->createPoll('A');
|
[, $token] = $this->createPoll('A');
|
||||||
|
|||||||
+10
-4
@@ -1040,9 +1040,15 @@
|
|||||||
setText('[data-counter]', state.count === 0
|
setText('[data-counter]', state.count === 0
|
||||||
? '0 / 0'
|
? '0 / 0'
|
||||||
: (state.index === null ? (state.poll.isPaused ? '⏸' : '–') : state.index + 1) + ' / ' + state.count);
|
: (state.index === null ? (state.poll.isPaused ? '⏸' : '–') : state.index + 1) + ' / ' + state.count);
|
||||||
var pauseButton = q('[data-action="stop"]');
|
var pauseButton = q('[data-pause]');
|
||||||
if (pauseButton) {
|
if (pauseButton) {
|
||||||
pauseButton.hidden = !slide;
|
var paused = !slide && !!state.poll.isPaused;
|
||||||
|
pauseButton.hidden = !slide && !paused;
|
||||||
|
pauseButton.setAttribute('data-action', paused ? 'resume' : 'stop');
|
||||||
|
pauseButton.setAttribute('aria-pressed', paused ? 'true' : 'false');
|
||||||
|
pauseButton.title = pauseButton.getAttribute(paused ? 'data-title-resume' : 'data-title-pause') || '';
|
||||||
|
pauseButton.querySelector('[data-pause-icon]').textContent = paused ? '▶' : '⏸';
|
||||||
|
pauseButton.querySelector('[data-pause-label]').textContent = paused ? 'Fortsetzen' : 'Pause';
|
||||||
}
|
}
|
||||||
if (embedded) {
|
if (embedded) {
|
||||||
renderLive();
|
renderLive();
|
||||||
@@ -1056,7 +1062,7 @@
|
|||||||
q('[data-description]').textContent = state.count === 0
|
q('[data-description]').textContent = state.count === 0
|
||||||
? 'Lege in der Verwaltung Fragen an.'
|
? 'Lege in der Verwaltung Fragen an.'
|
||||||
: (state.poll.isPaused
|
: (state.poll.isPaused
|
||||||
? 'Teilnehmende sehen gerade eine Pause-Seite. Drücke → zum Fortsetzen.'
|
? 'Teilnehmende sehen gerade eine Pause-Seite. Drücke P oder → zum Fortsetzen.'
|
||||||
: 'Drücke → um zu starten.');
|
: 'Drücke → um zu starten.');
|
||||||
q('[data-results]').innerHTML = '';
|
q('[data-results]').innerHTML = '';
|
||||||
renderMedia(null);
|
renderMedia(null);
|
||||||
@@ -1254,7 +1260,7 @@
|
|||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'p':
|
case 'p':
|
||||||
case 'P':
|
case 'P':
|
||||||
control('stop');
|
control(state && !state.slide && state.poll.isPaused ? 'resume' : 'stop');
|
||||||
break;
|
break;
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
case 'PageDown':
|
case 'PageDown':
|
||||||
|
|||||||
Reference in new issue
Block a user