CI Feature / test (push) Successful in 3m32s
Neuer kind 'exercise', Varianten je Fassung, Verwendung (erforderlich/ergänzend) und Variantenauswahl am einbindenden Mitglied; der Stand schreibt nur gewählte Varianten fest. Änderungsnachweis über structure_hash. Formatierte Anleitung im Mitgliederbereich und PDF (Fußzeile, Metadaten, Ausgabenachweis, keine gespeicherten Kopien); Sperre trifft nur das Medium. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
94 lines
4.3 KiB
PHP
94 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Support;
|
|
|
|
use App\Domain\Catalog\Composition;
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\CompositionVersion;
|
|
use App\Domain\Catalog\ContentElementVersion;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Domain\Catalog\EditorialContentKind;
|
|
|
|
/**
|
|
* Baut Übungen für Tests: Medien- und Textfassungen, die Übung mit Varianten und Module, die sie einbinden.
|
|
*/
|
|
trait BuildsExercises
|
|
{
|
|
protected function film(string $title, string $file = 'inhalte/film.mp4'): ContentElementVersion
|
|
{
|
|
$content = app(ContentService::class);
|
|
|
|
return $content->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<string>|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);
|
|
}
|
|
}
|