Schütze den vorherigen Programmstand vor Kompositionen unbekannter Art
CI Feature / test (push) Successful in 2m14s
Deploy Test / test (push) Successful in 2m13s
Deploy Test / deploy (push) Successful in 24s

Eine Komposition mit einem kind-Wert, den erst ein neuerer Stand schreibt, gilt als nicht vorhanden
(globaler Bereichsfilter statt Absturz im Enum-Cast). Aufbauten mit solchen Bestandteilen werden hier
weder veröffentlicht noch als Angebot aktiviert, der Editor bleibt schreibgeschützt, die Mitgliederansicht
zeigt den Bestandteil nicht. Grundlage für die Übungsverwaltung, damit ein Rückfall nichts verliert oder offenlegt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-23 16:39:31 +01:00
1 parent da02e0bbda
commit ef56befc0e
16 files changed
+513 -5

No files matched your search

+4
View File
@@ -141,6 +141,10 @@ private function checkedRows(ContentElementVersion|CompositionVersion $root): ar
{
$root->refresh();
if (app(ForeignCompositions::class)->reaches($root)) {
throw new DomainRuleException('Der Aufbau enthält einen Bestandteil, den dieser Programmstand nicht kennt. Er wird hier nicht veröffentlicht, damit nichts fehlt oder zu viel ausgegeben wird.');
}
if ($root->status !== ContentVersionStatus::Bereit) {
throw new DomainRuleException('Ein Artikel-Stand kann nur eine bereitgestellte Fassung festschreiben.');
}
+5
View File
@@ -36,6 +36,11 @@ protected function casts(): array
];
}
protected static function booted(): void
{
static::addGlobalScope(new SupportedKindScope);
}
public function editorialContentKind(): BelongsTo
{
return $this->belongsTo(EditorialContentKind::class);
+8
View File
@@ -8,6 +8,14 @@ enum CompositionKind: string
case Uebung = 'uebung';
case Kurs = 'kurs';
/**
* @return list<string>
*/
public static function values(): array
{
return array_map(fn (self $case): string => $case->value, self::cases());
}
public function label(): string
{
return match ($this) {
@@ -220,6 +220,12 @@ private function inspectReleasedComposition(
): void {
$version = CompositionVersion::query()->with('composition', 'members')->find($id);
if ($version instanceof CompositionVersion && $version->composition === null && app(ForeignCompositions::class)->isForeignVersion($version->id)) {
$blocked[] = $this->block('Bestandteil', 'Dieser Bestandteil stammt aus einer neueren Programmversion und kann hier nicht freigegeben werden.', $depth, null);
return;
}
if (! $version instanceof CompositionVersion || $version->composition === null) {
$blocked[] = $this->block('Modul', 'Ein Bestandteil ist nicht mehr vorhanden.', $depth, null);
@@ -60,6 +60,11 @@ private function members(CompositionVersion $version, array $stack = []): array
$nested->loadMissing('composition.editorialContentKind', 'composition');
$composition = $nested->composition;
// Bestandteil einer Art, die dieser Programmstand nicht kennt: nicht anzeigen (Rückfallschutz).
if ($composition === null) {
continue;
}
$nodes[] = new StructureNode(
role: $member->role,
position: $member->position,
+8
View File
@@ -45,6 +45,14 @@ public function expand(ContentElementVersion|CompositionVersion $node, string $p
throw new DomainRuleException('Ein Kompositionsmitglied braucht genau ein Ziel.');
}
// Bestandteil einer Art, die dieser Programmstand nicht kennt: nicht auflösen (Rückfallschutz).
// Veröffentlichen verweigern die aufrufenden Stellen über ForeignCompositions.
$nested->loadMissing('composition');
if ($nested->composition === null) {
continue;
}
$rows = array_merge($rows, $this->expand($nested, $segment, $stack));
}
+4
View File
@@ -345,6 +345,10 @@ private function assertAcyclic(int $compositionId, array $members, array $stack
private function assertReadyMember(ContentElementVersion|CompositionVersion $target): void
{
if (app(ForeignCompositions::class)->reaches($target)) {
throw new DomainRuleException('Dieser Bestandteil stammt aus einer neueren Programmversion und wird hier nicht in eine Fassung aufgenommen.');
}
if ($target->status !== ContentVersionStatus::Bereit) {
throw new DomainRuleException('Eine Komposition darf nur bereitgestellte Fassungen enthalten.');
}
@@ -0,0 +1,93 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Support\Facades\DB;
/**
* Erkennt Kompositionen, deren Art dieser Programmstand nicht kennt (siehe {@see SupportedKindScope}), und Aufbauten, die
* solche Bestandteile enthalten. Gelesen wird am Modell vorbei, weil der Bereichsfilter diese Zeilen ausblendet.
*
* Wozu: Eine ältere Programmversion darf eine Fassung mit unbekanntem Bestandteil weder neu veröffentlichen noch
* überarbeiten. Sie würde den Bestandteil auslassen oder ohne seine Variantenwahl auflösen und damit Inhalt verlieren
* oder zu viel ausgeben.
*/
class ForeignCompositions
{
public function isForeignVersion(int $compositionVersionId): bool
{
return DB::table('composition_versions as v')
->join('compositions as c', 'c.id', '=', 'v.composition_id')
->where('v.id', $compositionVersionId)
->whereNotIn('c.kind', CompositionKind::values())
->exists();
}
/**
* @param string $target „composition:ID“ (Fassung) oder „composition-draft:ID“ (Komposition)
*/
public function isForeignTarget(string $target): bool
{
if (preg_match('/^composition:(\d+)$/', $target, $match) === 1) {
return $this->isForeignVersion((int) $match[1]);
}
if (preg_match('/^composition-draft:(\d+)$/', $target, $match) === 1) {
return DB::table('compositions')
->where('id', (int) $match[1])
->whereNotIn('kind', CompositionKind::values())
->exists();
}
return false;
}
/**
* Ist die Fassung selbst unbekannt oder erreicht sie, auch verschachtelt, einen unbekannten Bestandteil?
*/
public function reaches(ContentElementVersion|CompositionVersion $node): bool
{
return $node instanceof CompositionVersion && $this->reachesVersion($node->id, []);
}
/**
* Enthält irgendeine Fassung dieser Komposition einen unbekannten Bestandteil?
*/
public function compositionHasForeignMembers(int $compositionId): bool
{
return DB::table('composition_members as m')
->join('composition_versions as host', 'host.id', '=', 'm.composition_version_id')
->join('composition_versions as nested', 'nested.id', '=', 'm.nested_composition_version_id')
->join('compositions as c', 'c.id', '=', 'nested.composition_id')
->where('host.composition_id', $compositionId)
->whereNotIn('c.kind', CompositionKind::values())
->exists();
}
/**
* @param list<int> $seen
*/
private function reachesVersion(int $versionId, array $seen): bool
{
if (in_array($versionId, $seen, true)) {
return false;
}
if ($this->isForeignVersion($versionId)) {
return true;
}
$seen[] = $versionId;
foreach (DB::table('composition_members')
->where('composition_version_id', $versionId)
->whereNotNull('nested_composition_version_id')
->pluck('nested_composition_version_id') as $nestedId) {
if ($this->reachesVersion((int) $nestedId, $seen)) {
return true;
}
}
return false;
}
}
+4
View File
@@ -277,6 +277,10 @@ private function assertCoverage(array $lines, array $attributes): void
}
$version = CompositionVersion::query()->findOrFail($versionId);
if (app(ForeignCompositions::class)->reaches($version)) {
throw new DomainRuleException('Der Aufbau enthält einen Bestandteil, den dieser Programmstand nicht kennt. Das Angebot wird hier nicht aktiviert.');
}
$articles = [];
foreach ($lines as $line) {
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
/**
* Rückfallschutz: Dieser Code kennt nur die Kompositionsarten aus {@see CompositionKind}. Eine Komposition mit einem
* Wert, den erst eine neuere Programmversion einführt, gilt hier als nicht vorhanden. Sie wird weder geladen (der
* Enum-Zugriff würde sonst abstürzen) noch angezeigt, bearbeitet oder veröffentlicht. Eine neuere Programmversion
* kennt den Wert und sieht die Zeile wieder.
*/
class SupportedKindScope implements Scope
{
public function apply(Builder $builder, Model $model): void
{
$builder->whereIn($model->qualifyColumn('kind'), CompositionKind::values());
}
}
@@ -15,6 +15,7 @@
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\EditorialWorkingDraft;
use App\Domain\Catalog\ForeignCompositions;
use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\IdentityProfile;
@@ -489,8 +490,39 @@ public function cancelText(): void
$this->newTextBody = '';
}
/**
* Rückfallschutz: Enthält dieser Aufbau (in einer Fassung oder im Entwurf) einen Bestandteil, den dieser Programmstand
* nicht kennt, bleibt er schreibgeschützt. Der Editor könnte den Bestandteil sonst nicht laden und würde ihn beim
* Speichern oder Freigeben still weglassen.
*/
public function schreibschutz(): ?string
{
$foreign = app(ForeignCompositions::class);
$reason = 'Dieser Aufbau enthält einen Bestandteil aus einer neueren Programmversion. Er kann hier nur angesehen werden, damit nichts verloren geht.';
if ($foreign->compositionHasForeignMembers((int) $this->getRecord()->getKey())) {
return $reason;
}
$draft = app(EditorialWorkingDraft::class)->read($this->getRecord());
foreach (is_array($draft['members'] ?? null) ? $draft['members'] : [] as $member) {
if (is_array($member) && $foreign->isForeignTarget((string) ($member['target'] ?? ''))) {
return $reason;
}
}
return null;
}
public function saveDraft(): void
{
if (($reason = $this->schreibschutz()) !== null) {
$this->feedback = $reason;
return;
}
$this->commitRoleDraft();
$minutes = $this->minutes($this->durationMinutes);
@@ -508,6 +540,13 @@ public function saveDraft(): void
public function armRelease(): void
{
if (($reason = $this->schreibschutz()) !== null) {
$this->releaseArmed = false;
$this->feedback = $reason;
return;
}
$this->commitRoleDraft();
if ($this->members === []) {
@@ -585,6 +624,12 @@ protected function selectFirstPart(): void
public function discardDraft(): void
{
if (($reason = $this->schreibschutz()) !== null) {
$this->feedback = $reason;
return;
}
/** @var Composition $record */
$record = $this->getRecord();
app(EditorialWorkingDraft::class)->clear($record);
@@ -1521,6 +1566,12 @@ public function presentationChips(): array
public function publishRevision(): bool
{
if (($reason = $this->schreibschutz()) !== null) {
$this->feedback = $reason;
return false;
}
$this->commitRoleDraft();
if ($this->members === []) {
@@ -1929,6 +1980,12 @@ protected function persistRedaktion(): bool
protected function persistDraft(): bool
{
if (($reason = $this->schreibschutz()) !== null) {
$this->feedback = $reason;
return false;
}
if ($this->minutes($this->durationMinutes) === false) {
$this->feedback = 'Der Zeitbedarf ist eine Zahl von Minuten oder bleibt leer.';
+2 -2
View File
@@ -37,7 +37,7 @@ public static function assignmentTargets(?int $exceptCompositionId = null): arra
$media['element:'.$version->id] = self::elementLabel($version);
}
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->whereHas('composition')->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
if ($exceptCompositionId !== null && (int) $version->composition_id === $exceptCompositionId) {
continue;
}
@@ -94,7 +94,7 @@ public static function readyTargets(): array
$options['element:'.$version->id] = self::elementLabel($version);
}
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->whereHas('composition')->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
$options['composition:'.$version->id] = self::compositionLabel($version);
}
+13 -3
View File
@@ -266,7 +266,7 @@ public function elementUsage(ContentElement $element): array
->get();
foreach ($members as $member) {
$lines[] = self::compositionLabel($member->compositionVersion->composition)
$lines[] = self::compositionLabelOf($member->compositionVersion->composition)
.' · Fassung '.$member->compositionVersion->number
.' · Rolle '.$member->role;
}
@@ -313,7 +313,7 @@ public function compositionMembers(Composition $composition): array
}
$nested = $member->nestedCompositionVersion;
$lines[] = $member->role.' — '.($nested === null ? 'fehlt' : self::compositionLabel($nested->composition));
$lines[] = $member->role.' — '.($nested === null ? 'fehlt' : self::compositionLabelOf($nested->composition));
}
return $lines;
@@ -365,7 +365,7 @@ public function compositionUsage(Composition $composition): array
->get();
foreach ($parents as $member) {
$lines[] = self::compositionLabel($member->compositionVersion->composition)
$lines[] = self::compositionLabelOf($member->compositionVersion->composition)
.' · Fassung '.$member->compositionVersion->number
.' · Rolle '.$member->role;
}
@@ -448,6 +448,16 @@ private function purpose(string $purpose): string
};
}
/**
* Eine Zusammenstellung, die dieser Programmstand nicht kennt, erscheint nur als Hinweis ohne Namen und Inhalt.
*/
private static function compositionLabelOf(?Composition $composition): string
{
return $composition === null
? 'Zusammenstellung einer neueren Programmversion'
: self::compositionLabel($composition);
}
private static function compositionLabel(Composition $composition): string
{
$kind = $composition->kind;
+10
View File
@@ -140,6 +140,12 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
}
$composition = $version->composition;
// Art, die dieser Programmstand nicht kennt: nicht anbieten und nicht laden (Rückfallschutz).
if ($composition === null) {
return null;
}
$kind = $composition->editorialContentKind?->label
?: ($composition->kind instanceof CompositionKind ? $composition->kind->deskLabel() : 'Zusammenstellung');
@@ -1028,6 +1034,10 @@ private function suggestPicture(array $members, array $seen = []): ?array
$nested = $version->composition;
if ($nested === null) {
continue;
}
if ($this->cardUrl('komposition', $nested->id, $nested->thumbnail_path) !== null) {
return [
'kind' => 'komposition',
@@ -34,6 +34,7 @@
'titel' => $titel,
'typ' => $this->hostLabel().' · '.$typ,
'status' => [
($schutz = $this->schreibschutz()) !== null ? ['text' => $schutz, 'ton' => 'offen'] : null,
['text' => $aufbauOffen ? 'Änderungen am Aufbau nicht gespeichert' : $statusSatz, 'ton' => $aufbauOffen ? 'offen' : ($bereit !== null ? 'gut' : 'neutral')],
$redaktionOffen ? ['text' => 'Die Redaktion hat ungespeicherte Änderungen.', 'ton' => 'offen', 'aktion' => ['label' => 'Zur Redaktion', 'wire' => "openRedaktion('".$this->redaktionTab."')"]] : null,
],
+272
View File
@@ -0,0 +1,272 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\ArticleRelease;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\CompositionVersion;
use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferService;
use App\Domain\Entitlement\GrantIssuer;
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
use App\Filament\Resources\Exercises\Pages\EditExercise;
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
use App\Http\SignedLink;
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Livewire\Livewire;
use Tests\TestCase;
/**
* Rückfallschutz für den neuen Objekttyp „Übung“: Wird nach einem Deploy auf den vorherigen Programmstand zurückgesetzt,
* kennt dieser den neuen `kind`-Wert nicht. Die Zeilen werden hier mit dem Wert „exercise“ nachgestellt, den der neue
* Stand schreiben wird. Der vorherige Stand darf nicht abstürzen, nichts offenlegen, was er nicht darstellen kann, und
* beim Bearbeiten nichts verlieren.
*/
class RueckfallschutzTest extends TestCase
{
use RefreshDatabase;
private const FOREIGN = 'exercise';
private ContentElementVersion $filmA;
private ContentElementVersion $filmB;
private ContentElementVersion $text;
private CompositionVersion $exercise;
private CompositionVersion $module;
private LicenseArticle $article;
private ArticleRelease $release;
private User $member;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
$this->buildProduct();
}
public function test_the_kind_values_are_the_ones_this_program_state_knows(): void
{
$this->assertSame(['kombination', 'uebung', 'kurs'], CompositionKind::values());
}
public function test_a_composition_of_an_unknown_kind_does_not_crash_loading_and_stays_hidden(): void
{
$this->assertSame(
['Modul mit Übung'],
Composition::query()->orderBy('designation')->pluck('designation')->all(),
);
$this->assertNull(CompositionVersion::query()->with('composition')->findOrFail($this->exercise->id)->composition);
$this->assertNull(Composition::query()->find($this->exercise->composition_id));
$this->assertSame(1, DB::table('compositions')->where('kind', self::FOREIGN)->count(), 'Die Zeile bleibt unverändert erhalten.');
}
public function test_the_member_area_neither_crashes_nor_shows_what_it_cannot_present(): void
{
$this->actingAs($this->member)
->get(route('member.library'))
->assertOk()
->assertSee('Modul mit Übung');
$this->actingAs($this->member)
->get(route('member.program', $this->module->composition_id))
->assertOk()
->assertSee('Modul mit Übung')
->assertDontSee('Übung neuerer Stand')
->assertDontSee('Einstiegsfilm')
->assertDontSee('Alternativfilm')
->assertDontSee('Durchführungstext');
$this->actingAs($this->member)
->get(route('member.program', $this->exercise->composition_id))
->assertNotFound();
}
public function test_only_the_selected_variant_is_delivered_from_the_frozen_stand(): void
{
$this->actingAs($this->member)
->get(route('member.article', $this->article))
->assertOk()
->assertSee('Einstiegsfilm')
->assertDontSee('Alternativfilm');
$link = fn (ContentElementVersion $version): string => SignedLink::temporary('member.media', now()->addMinutes(10), [
'article' => $this->article->id,
'release' => $this->release->id,
'version' => $version->id,
'action' => 'ansehen',
'reader' => $this->member->id,
]);
$this->actingAs($this->member)->get($link($this->filmB))->assertForbidden();
}
public function test_the_previous_state_refuses_to_publish_what_it_cannot_resolve(): void
{
try {
app(ArticleService::class)->publishRelease($this->article->fresh(), $this->module, 'Neuer Stand im alten Programmstand.');
$this->fail('Ein Stand mit unbekanntem Bestandteil darf hier nicht entstehen.');
} catch (DomainRuleException $exception) {
$this->assertStringContainsString('Programmstand', $exception->getMessage());
}
$this->assertSame(1, $this->article->releases()->count());
$other = app(ContentService::class)->createComposition('Anderes Modul', CompositionKind::Uebung);
$this->expectException(DomainRuleException::class);
app(ContentService::class)->publishComposition($other, [['role' => 'Übung', 'target' => $this->exercise]]);
}
public function test_an_offer_is_not_activated_for_a_structure_with_an_unknown_part(): void
{
$offers = app(OfferService::class);
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']]);
$offer = $offers->create('Angebot mit Übung');
$this->expectException(DomainRuleException::class);
$this->expectExceptionMessage('Programmstand');
$offers->activate($offer, [['target' => $this->article->fresh(), 'rights' => $rights]], [
'grant_kind' => 'auf_abruf',
'composition_version_id' => $this->module->id,
]);
}
public function test_the_editor_of_a_structure_with_an_unknown_part_is_read_only_and_loses_nothing(): void
{
$module = Composition::query()->findOrFail($this->module->composition_id);
$versions = $module->versions()->count();
$members = DB::table('composition_members')->where('composition_version_id', $this->module->id)->count();
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditExercise::class, ['record' => $module->getKey()])
->assertOk()
->assertSee('neueren Programmversion');
$this->assertNotNull($component->instance()->schreibschutz());
$component->call('saveDraft');
$this->assertNull($module->fresh()->working_draft, 'Es wird kein Entwurf geschrieben, der den Bestandteil auslässt.');
$component->call('armRelease')->assertSet('releaseArmed', false);
$this->assertFalse($component->instance()->publishRevision());
$component->call('discardDraft');
$this->assertSame($versions, $module->versions()->count());
$this->assertSame($members, DB::table('composition_members')->where('composition_version_id', $this->module->id)->count());
}
public function test_an_editor_with_only_known_parts_still_saves(): void
{
$content = app(ContentService::class);
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Kurzfilm'), null, ['file' => 'inhalte/kurz.mp4']);
$plain = $content->createComposition('Normales Modul', CompositionKind::Uebung);
$content->publishComposition($plain, [['role' => 'Film', 'target' => $film]]);
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditExercise::class, ['record' => $plain->getKey()])
->assertOk();
$this->assertNull($component->instance()->schreibschutz());
$component->call('saveDraft');
$this->assertNotNull($plain->fresh()->working_draft);
}
public function test_the_staff_pages_around_the_structure_render_without_naming_the_unknown_part(): void
{
Livewire::actingAs($this->editor(), 'staff')
->test(ViewContentElement::class, ['record' => $this->filmA->content_element_id])
->assertOk()
->assertDontSee('Übung neuerer Stand');
$keeper = User::factory()->katalogverwalter()->create();
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
Livewire::actingAs($keeper, 'staff')
->test(ViewLicenseArticle::class, ['record' => $this->article->getKey()])
->assertOk()
->assertDontSee('Übung neuerer Stand');
}
public function test_the_public_site_does_not_know_the_unknown_composition(): void
{
$this->get(route('public.program', $this->exercise->composition_id))->assertNotFound();
$this->get(route('public.programs'))->assertOk()->assertDontSee('Übung neuerer Stand');
}
/**
* Ein Modul mit einer verschachtelten Übung, deren Fassung zwei Filmvarianten und einen Text enthält. Veröffentlicht
* wird nur die Variante A samt Text. Danach bekommt die Übung den Wert, den erst der neue Stand schreibt.
*/
private function buildProduct(): void
{
$content = app(ContentService::class);
$this->filmA = $content->publishElementVersion($content->createElement('film', 'film', 'Einstiegsfilm'), null, ['file' => 'inhalte/a.mp4']);
$this->filmB = $content->publishElementVersion($content->createElement('film', 'film', 'Alternativfilm'), null, ['file' => 'inhalte/b.mp4']);
$this->text = $content->publishElementVersion($content->createElement('text', 'text', 'Durchführungstext'), 'Erst aufwärmen, dann üben.');
$this->exercise = $content->publishComposition(
$content->createComposition('Übung neuerer Stand', CompositionKind::Kombination),
[
['role' => 'Einstieg Variante A', 'target' => $this->filmA],
['role' => 'Einstieg Variante B', 'target' => $this->filmB],
['role' => 'Durchführung', 'target' => $this->text],
],
null,
null,
['learning_goal' => 'Nein sagen üben'],
);
$kind = EditorialContentKind::query()->where('slug', 'modul')->firstOrFail();
$module = $content->createComposition('Modul mit Übung', CompositionKind::Uebung);
$module->editorial_content_kind_id = $kind->id;
$module->save();
$this->module = $content->publishComposition($module, [['role' => 'Übung', 'target' => $this->exercise]]);
$articles = app(ArticleService::class);
$this->article = $articles->create('modul-mit-uebung');
$this->release = $articles->publishRelease($this->article, $this->module, 'Modul mit Übung.');
// Gewählt ist nur Variante A: Der Stand schreibt Film B nicht fest.
DB::table('release_contents')
->where('article_release_id', $this->release->id)
->where('content_element_version_id', $this->filmB->id)
->delete();
$offers = app(OfferService::class);
$rights = $offers->createRightsProfile('Film und Text', 'ehrenamtlich', ['film' => ['streamen', 'laden'], 'text' => ['ansehen']]);
$offer = $offers->create('Zugang');
$offers->activate($offer, [['target' => $this->article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
$this->member = User::factory()->create();
app(GrantIssuer::class)->claim($this->member, $offer);
app(CompositionDisplayRelease::class)->release($this->module, $this->member);
DB::table('compositions')->where('id', $this->exercise->composition_id)->update(['kind' => self::FOREIGN]);
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $editor;
}
}