publishElementVersion($content->createElement('film', 'film', $title), null, ['file' => $file]); } protected function sheet(string $title): ContentElementVersion { $content = app(ContentService::class); return $content->publishElementVersion($content->createElement('document', 'document', $title), null, ['file' => 'inhalte/'.str($title)->slug().'.pdf']); } protected function section(string $title, string $body): ContentElementVersion { $content = app(ContentService::class); return $content->publishElementVersion($content->createElement('text', 'text', $title), $body); } /** * Übung mit gemeinsamem Einstieg und zwei Varianten: A mit Film, B ohne Film (nur Arbeitsblatt). * * @return array{version: CompositionVersion, intro: ContentElementVersion, filmA: ContentElementVersion, sheetB: ContentElementVersion, textA: ContentElementVersion, textB: ContentElementVersion} */ protected function exercise(string $title = 'Stopp sagen', ?Composition $composition = null): array { $content = app(ContentService::class); $intro = $this->section($title.' · Einstieg', "Gemeinsamer Einstieg.\n\n- Sicher stehen\n- Deutlich sprechen"); $filmA = $this->film($title.' · Film A'); $sheetB = $this->sheet($title.' · Arbeitsblatt B'); $textA = $this->section($title.' · Durchführung A', 'Variante A: Der Film zeigt die Situation.'); $textB = $this->section($title.' · Durchführung B', 'Variante B: Ohne Film mit dem Arbeitsblatt.'); $composition ??= $this->exerciseComposition($title); $version = $content->publishComposition($composition, [ ['role' => 'Einstieg', 'target' => $intro], ['role' => 'Durchführung A', 'target' => $textA, 'variant' => 'a'], ['role' => 'Film A', 'target' => $filmA, 'variant' => 'a', 'requirement' => 'erforderlich'], ['role' => 'Durchführung B', 'target' => $textB, 'variant' => 'b'], ['role' => 'Arbeitsblatt B', 'target' => $sheetB, 'variant' => 'b', 'requirement' => 'ergaenzend'], ], null, null, ['learning_goal' => 'Nein sagen und Abstand halten', 'duration_minutes' => 15, 'duration_max' => 20, 'prerequisites' => 'Keine'], [ ['key' => 'a', 'name' => 'Mit Film', 'description' => 'Einstieg über den Film'], ['key' => 'b', 'name' => 'Ohne Film', 'description' => 'Nur mit Arbeitsblatt'], ]); return compact('version', 'intro', 'filmA', 'sheetB', 'textA', 'textB'); } protected function exerciseComposition(string $title): Composition { $composition = app(ContentService::class)->createComposition($title, CompositionKind::Exercise); $composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'uebung')->value('id'); $composition->save(); return $composition; } /** * @param list|null $selection */ protected function moduleWith(string $title, CompositionVersion $exercise, ?array $selection = null, CompositionKind $kind = CompositionKind::Uebung, ?ContentElementVersion $extra = null): CompositionVersion { $content = app(ContentService::class); $composition = $content->createComposition($title, $kind); $composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', $kind === CompositionKind::Kurs ? 'programm' : 'modul')->value('id'); $composition->save(); $members = [['role' => 'Übung', 'target' => $exercise, 'selection' => $selection]]; if ($extra !== null) { $members[] = ['role' => 'Zusatz', 'target' => $extra]; } return $content->publishComposition($composition, $members); } }