Add duplicating slides

Copies question, description, settings and options (incl. correct quiz
answers) directly behind the original, without responses. The copy starts
like a new slide (Slide::startFresh()) and opens in the edit form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 15:18:10 +01:00
1 parent 5b3fccde67
commit e2f24877dd
7 files changed
+214 -5

No files matched your search

+17 -4
View File
@@ -43,10 +43,8 @@ class SlidesController extends AdminAppController
'validate' => false,
]);
$slide->poll_id = $this->poll->id;
// A quiz is started by the presenter (that also starts its timer).
$slide->is_voting_open = $type !== Slide::TYPE_QUIZ;
// Q&A starts by collecting questions.
$slide->stage = $type === Slide::TYPE_QA ? Slide::QA_COLLECT : null;
// A quiz is started by the presenter (that also starts its timer), Q&A starts by collecting questions.
$slide->startFresh();
$optionsText = $type === Slide::TYPE_CHOICE ? "\n" : '';
$quizOptions = [];
$orderOptions = [];
@@ -126,6 +124,21 @@ class SlidesController extends AdminAppController
return $this->redirect($this->adminUrl());
}
/**
* Copies a slide (without responses) directly behind the original and opens the copy for editing.
*
* @param string $id Slide id
* @return \Cake\Http\Response|null
*/
public function duplicate(string $id): ?Response
{
$this->request->allowMethod(['post']);
$copy = $this->Slides->duplicate($this->loadSlide($id));
$this->Flash->success(__('Folie dupliziert. Du bearbeitest jetzt die Kopie.'));
return $this->redirect($this->adminUrl('slides:edit', ['id' => $copy->id]));
}
/**
* Saves a complete new slide order (drag & drop), expects `ids[]` and answers with JSON.
*