Add hiding slides from the presentation
Hidden slides stay prepared in the dashboard but are skipped when presenting (start, next/prev, goto), can not go live via embed and are left out of the PDF export. Hiding the live or paused slide pauses the poll like deleting it and resumes with the next visible slide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2f24877dd
commit
3c978e6f22
15 files changed
+333
-35
No files matched your search
@@ -110,10 +110,11 @@ class Poll extends Entity
|
||||
}
|
||||
|
||||
/**
|
||||
* A slide is being deleted. If it was live or is the one a pause resumes, the poll pauses
|
||||
* and resumes with $resumeSlideId instead (null: no slides left = not started). Idempotent.
|
||||
* A slide leaves the presentation (deleted or hidden). If it was live or is the one a pause
|
||||
* resumes, the poll pauses and resumes with $resumeSlideId instead (null: no slides left =
|
||||
* not started). Idempotent.
|
||||
*
|
||||
* @param int $slideId Deleted slide
|
||||
* @param int $slideId Deleted or hidden slide
|
||||
* @param int|null $resumeSlideId Slide that takes its place (must belong to this poll)
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@ use Cake\ORM\Entity;
|
||||
* @property string $question
|
||||
* @property string|null $description
|
||||
* @property int $position
|
||||
* @property bool $is_hidden Prepared, but skipped in the presentation (never live)
|
||||
* @property array<string, mixed>|null $settings
|
||||
* @property bool $is_voting_open
|
||||
* @property \Cake\I18n\DateTime|null $voting_started_at Quiz: start of the voting window
|
||||
|
||||
@@ -423,18 +423,51 @@ class SlidesTable extends Table
|
||||
* Ordered slides of a poll including options.
|
||||
*
|
||||
* @param int $pollId Poll id
|
||||
* @param bool $visibleOnly Only slides that are part of the presentation (not hidden)
|
||||
* @return list<\App\Model\Entity\Slide>
|
||||
*/
|
||||
public function listForPoll(int $pollId): array
|
||||
public function listForPoll(int $pollId, bool $visibleOnly = false): array
|
||||
{
|
||||
/** @var list<\App\Model\Entity\Slide> $slides */
|
||||
$slides = $this->find()
|
||||
$query = $this->find()
|
||||
->where(['Slides.poll_id' => $pollId])
|
||||
->contain(['SlideOptions'])
|
||||
->orderBy(['Slides.position' => 'ASC', 'Slides.id' => 'ASC'])
|
||||
->all()
|
||||
->toList();
|
||||
->orderBy(['Slides.position' => 'ASC', 'Slides.id' => 'ASC']);
|
||||
if ($visibleOnly) {
|
||||
$query->where(['Slides.is_hidden' => false]);
|
||||
}
|
||||
/** @var list<\App\Model\Entity\Slide> $slides */
|
||||
$slides = $query->all()->toList();
|
||||
|
||||
return $slides;
|
||||
}
|
||||
|
||||
/**
|
||||
* The visible slide that takes the place of a slide leaving the presentation
|
||||
* (deleted or hidden): the next visible one behind it, otherwise the one before.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Slide leaving the presentation
|
||||
* @return int|null Slide id, null if no other visible slide is left
|
||||
*/
|
||||
public function replacementFor(Slide $slide): ?int
|
||||
{
|
||||
$rows = $this->find()
|
||||
->select(['id', 'is_hidden'])
|
||||
->where(['poll_id' => $slide->poll_id])
|
||||
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
|
||||
->disableHydration()
|
||||
->all()
|
||||
->toList();
|
||||
$index = array_search($slide->id, array_column($rows, 'id'), true);
|
||||
if ($index === false) {
|
||||
return null;
|
||||
}
|
||||
$candidates = array_merge(array_slice($rows, $index + 1), array_reverse(array_slice($rows, 0, $index)));
|
||||
foreach ($candidates as $row) {
|
||||
if (!$row['is_hidden']) {
|
||||
return (int)$row['id'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user