Pflege Übungen im Aufbauarbeitsplatz und weise Verwendung und Sperrfolgen nach
CI Feature / test (push) Successful in 2m34s
CI Feature / test (push) Successful in 2m34s
Eigener Eintrag Übungen unter Inhalte (Bestand, Anlegen, gemeinsamer Aufbau mit Varianten, Verwendung und Variantenauswahl im Modul und Programm), Verwendungsnachweis über verschachtelte und ältere Stände, Auswirkungsbericht einer Mediensperre, gesperrte Bestandteile verhindern die Angebotsaktivierung, Vorschaubilder gesperrter Medien werden nicht mehr ausgeliefert, Rückfalltest gegen die Daten des neuen Stands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1f97a351a
commit
bbee288e69
22 files changed
+1104
-26
No files matched your search
@@ -54,6 +54,7 @@ public function publish(
|
||||
?string $note,
|
||||
array $didactic,
|
||||
bool $consent,
|
||||
array $variants = [],
|
||||
): CompositionVersion {
|
||||
$review = $this->review($host, $members);
|
||||
|
||||
@@ -67,8 +68,8 @@ public function publish(
|
||||
|
||||
$this->publishedDrafts = [];
|
||||
|
||||
return DB::transaction(function () use ($host, $members, $actor, $note, $didactic): CompositionVersion {
|
||||
return $this->materialize($host, $members, $didactic, $actor, $note, []);
|
||||
return DB::transaction(function () use ($host, $members, $actor, $note, $didactic, $variants): CompositionVersion {
|
||||
return $this->materialize($host, $members, $didactic, $actor, $note, [], $variants);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -330,6 +331,7 @@ private function materialize(
|
||||
?User $actor,
|
||||
?string $note,
|
||||
array $stack,
|
||||
array $variants = [],
|
||||
): CompositionVersion {
|
||||
if (isset($this->publishedDrafts[$composition->id])) {
|
||||
return $this->publishedDrafts[$composition->id];
|
||||
@@ -347,6 +349,9 @@ private function materialize(
|
||||
'role' => trim((string) ($member['role'] ?? '')),
|
||||
'note' => trim((string) ($member['note'] ?? '')),
|
||||
'target' => $this->resolveTarget((string) ($member['target'] ?? ''), $actor, $stack),
|
||||
'variant' => isset($member['variant']) && $member['variant'] !== '' ? (string) $member['variant'] : null,
|
||||
'requirement' => $member['requirement'] ?? 'erforderlich',
|
||||
'selection' => is_array($member['selection'] ?? null) && $member['selection'] !== [] ? array_values($member['selection']) : null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -358,8 +363,11 @@ private function materialize(
|
||||
[
|
||||
'learning_goal' => $didactic['learning_goal'] ?? null,
|
||||
'duration_minutes' => $didactic['duration_minutes'] ?? null,
|
||||
'duration_max' => $didactic['duration_max'] ?? null,
|
||||
'material_note' => $didactic['material_note'] ?? null,
|
||||
'prerequisites' => $didactic['prerequisites'] ?? null,
|
||||
],
|
||||
$variants,
|
||||
);
|
||||
$this->publishedDrafts[$composition->id] = $version;
|
||||
|
||||
@@ -420,11 +428,14 @@ private function resolveTarget(string $target, ?User $actor, array $stack): Cont
|
||||
[
|
||||
'learning_goal' => $draft['learning_goal'] ?? null,
|
||||
'duration_minutes' => $draft['duration_minutes'] ?? null,
|
||||
'duration_max' => $draft['duration_max'] ?? null,
|
||||
'material_note' => $draft['material_note'] ?? null,
|
||||
'prerequisites' => $draft['prerequisites'] ?? null,
|
||||
],
|
||||
$actor,
|
||||
is_string($draft['revision_note'] ?? null) ? $draft['revision_note'] : null,
|
||||
$stack,
|
||||
is_array($draft['variants'] ?? null) ? $draft['variants'] : [],
|
||||
);
|
||||
app(EditorialWorkingDraft::class)->clear($composition);
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
/**
|
||||
* Verwendungsnachweis: Wo wird eine Übungsfassung tatsächlich verwendet, und was trifft eine Sperre? Der Nachweis steigt
|
||||
* über die Verschachtelung bis zu den Wurzeln der Artikel-Stände auf und erfasst damit auch ältere, abgelöste und
|
||||
* gesperrte Stände. Er liest nur und ändert keinen Stand.
|
||||
*/
|
||||
class ExerciseUsage
|
||||
{
|
||||
/**
|
||||
* Je Fassung der Komposition: die einbindenden Fassungen (mit Rolle, Position und Variantenauswahl) und die
|
||||
* Artikel-Stände, deren Wurzel die Fassung selbst oder eine einbindende Fassung ist.
|
||||
*
|
||||
* @return list<array{version: CompositionVersion, hosts: list<array<string, mixed>>, releases: list<array<string, mixed>>}>
|
||||
*/
|
||||
public function forComposition(Composition $composition): array
|
||||
{
|
||||
$guide = app(ExerciseGuide::class);
|
||||
$result = [];
|
||||
|
||||
foreach ($composition->versions()->orderBy('number')->get() as $version) {
|
||||
$hosts = [];
|
||||
$roots = [$version->id => $version];
|
||||
$queue = [$version->id];
|
||||
$seen = [$version->id];
|
||||
|
||||
while ($queue !== []) {
|
||||
$current = array_shift($queue);
|
||||
|
||||
foreach (CompositionMember::query()->where('nested_composition_version_id', $current)->with('compositionVersion.composition')->orderBy('id')->get() as $member) {
|
||||
$host = $member->compositionVersion;
|
||||
|
||||
if ($host === null || $host->composition === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hosts[] = [
|
||||
'composition' => $host->composition,
|
||||
'version' => $host,
|
||||
'role' => $member->role,
|
||||
'position' => $member->position,
|
||||
'selection' => $member->variant_selection,
|
||||
'direct' => $current === $version->id,
|
||||
];
|
||||
|
||||
if (! in_array($host->id, $seen, true)) {
|
||||
$seen[] = $host->id;
|
||||
$roots[$host->id] = $host;
|
||||
$queue[] = $host->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$releases = [];
|
||||
|
||||
foreach (ArticleRelease::query()->whereIn('root_composition_version_id', array_keys($roots))->with('article')->orderBy('license_article_id')->orderBy('number')->get() as $release) {
|
||||
$root = $roots[$release->root_composition_version_id];
|
||||
$releases[] = [
|
||||
'article' => $release->article,
|
||||
'release' => $release,
|
||||
'status' => $release->status,
|
||||
'path' => $root->id === $version->id ? null : $guide->pathTo($root, $version->id),
|
||||
'root' => $root,
|
||||
];
|
||||
}
|
||||
|
||||
$result[] = ['version' => $version, 'hosts' => $hosts, 'releases' => $releases];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Folgen einer Sperre dieser Medienfassung je Artikel-Stand. Die Festschreibung bleibt unverändert; gesperrt wird
|
||||
* nur die Ausgabe des Mediums.
|
||||
*
|
||||
* @return list<array{article: LicenseArticle, release: ArticleRelease, status: ReleaseStatus, variant: string|null, requirement: string|null, path: string, effect: string}>
|
||||
*/
|
||||
public function blockImpact(ContentElementVersion $version): array
|
||||
{
|
||||
$impact = [];
|
||||
|
||||
foreach (ReleaseContent::query()->where('content_element_version_id', $version->id)->with('release.article')->orderBy('id')->get() as $content) {
|
||||
$release = $content->release;
|
||||
$required = ($content->requirement ?? CompositionMember::REQUIRED) === CompositionMember::REQUIRED;
|
||||
$effect = match (true) {
|
||||
! $required => 'Nur dieses ergänzende Medium entfällt. Die Übung bleibt vollständig durchführbar.',
|
||||
$content->variant_key !== null => 'Die Variante „'.$content->variant_key.'“ ist nicht mehr vollständig durchführbar. Andere Varianten bleiben nutzbar.',
|
||||
default => 'Ein erforderlicher Bestandteil entfällt. Die Anleitung bleibt lesbar.',
|
||||
};
|
||||
$impact[] = [
|
||||
'article' => $release->article,
|
||||
'release' => $release,
|
||||
'status' => $release->status,
|
||||
'variant' => $content->variant_key,
|
||||
'requirement' => $content->requirement,
|
||||
'path' => $content->path,
|
||||
'effect' => $effect,
|
||||
];
|
||||
}
|
||||
|
||||
return $impact;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,27 @@ class OfferCoverage
|
||||
{
|
||||
public function __construct(private readonly ContentResolver $resolver) {}
|
||||
|
||||
/**
|
||||
* Bestandteile der Fassung, deren Medienfassung gesperrt ist. Ein Angebot soll nicht aktiviert werden, solange sein
|
||||
* Umfang gesperrte Bestandteile enthält; die Prüfung nennt sie vorab.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function blockedLeaves(CompositionVersion $version): array
|
||||
{
|
||||
$rows = $this->resolver->expand($version);
|
||||
$blocked = ContentElementVersion::query()
|
||||
->whereIn('id', array_column($rows, 'version_id'))
|
||||
->where('status', ContentVersionStatus::Gesperrt->value)
|
||||
->pluck('id')
|
||||
->all();
|
||||
|
||||
return array_values(array_map(
|
||||
fn (array $row): string => $row['path'],
|
||||
array_filter($rows, fn (array $row): bool => in_array($row['version_id'], $blocked, true)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<LicenseArticle> $articles
|
||||
* @return list<string>
|
||||
|
||||
@@ -289,6 +289,12 @@ private function assertCoverage(array $lines, array $attributes): void
|
||||
}
|
||||
}
|
||||
|
||||
$blocked = app(OfferCoverage::class)->blockedLeaves($version);
|
||||
|
||||
if ($blocked !== []) {
|
||||
throw new DomainRuleException('Das Angebot enthält gesperrte Bestandteile: '.implode(', ', $blocked));
|
||||
}
|
||||
|
||||
$missing = app(OfferCoverage::class)->missingLeaves($version, $articles);
|
||||
|
||||
if ($missing !== []) {
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
@@ -69,6 +70,15 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public string $materialNote = '';
|
||||
|
||||
/** @var list<array{key: string, name: string, description: string}> Durchführungsvarianten einer Übung */
|
||||
public array $variants = [];
|
||||
|
||||
public string $durationMax = '';
|
||||
|
||||
public string $prerequisites = '';
|
||||
|
||||
public string $newVariantName = '';
|
||||
|
||||
public string $revisionNote = '';
|
||||
|
||||
public string $search = '';
|
||||
@@ -490,6 +500,138 @@ public function cancelText(): void
|
||||
$this->newTextBody = '';
|
||||
}
|
||||
|
||||
public function isExercise(): bool
|
||||
{
|
||||
return $this->hostKind() === CompositionKind::Exercise;
|
||||
}
|
||||
|
||||
public function addVariant(): void
|
||||
{
|
||||
$name = trim($this->newVariantName);
|
||||
|
||||
if ($name === '') {
|
||||
$this->feedback = 'Eine Variante braucht einen Namen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$base = Str::slug($name) ?: 'variante';
|
||||
$key = $base;
|
||||
$n = 2;
|
||||
|
||||
while (in_array($key, array_column($this->variants, 'key'), true)) {
|
||||
$key = $base.'-'.$n++;
|
||||
}
|
||||
|
||||
$this->variants[] = ['key' => $key, 'name' => $name, 'description' => ''];
|
||||
$this->newVariantName = '';
|
||||
$this->feedback = 'Variante „'.$name.'“ ist angelegt. Ordne ihr Bestandteile zu. Gespeichert wird mit „Entwurf speichern“.';
|
||||
}
|
||||
|
||||
public function removeVariant(string $key): void
|
||||
{
|
||||
foreach ($this->members as $member) {
|
||||
if (($member['variant'] ?? null) === $key) {
|
||||
$this->feedback = 'Diese Variante hat noch Bestandteile. Ordne sie zuerst einer anderen Variante oder dem gemeinsamen Teil zu.';
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->variants = array_values(array_filter($this->variants, fn (array $variant): bool => $variant['key'] !== $key));
|
||||
$this->feedback = 'Die Variante ist aus diesem Entwurf genommen. Eine freigegebene Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
public function setMemberVariant(int $index, string $key): void
|
||||
{
|
||||
if (! isset($this->members[$index])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->members[$index]['variant'] = $key === '' ? null : $key;
|
||||
}
|
||||
|
||||
public function setMemberRequirement(int $index, string $requirement): void
|
||||
{
|
||||
if (! isset($this->members[$index]) || ! in_array($requirement, ['erforderlich', 'ergaenzend'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->members[$index]['requirement'] = $requirement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Angebotene Varianten der eingebundenen Übungsfassung. Ohne Auswahl werden alle angeboten.
|
||||
*/
|
||||
public function toggleVariantSelection(int $index, string $key): void
|
||||
{
|
||||
if (! isset($this->members[$index])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all = array_column($this->offeredVariants((string) ($this->members[$index]['target'] ?? '')), 'key');
|
||||
$current = $this->members[$index]['selection'] ?? null;
|
||||
$current = is_array($current) ? $current : $all;
|
||||
$current = in_array($key, $current, true) ? array_values(array_diff($current, [$key])) : [...$current, $key];
|
||||
|
||||
if ($current === []) {
|
||||
$this->feedback = 'Mindestens eine Variante muss angeboten werden.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->members[$index]['selection'] = count($current) === count($all) ? null : array_values($current);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, name: string}>
|
||||
*/
|
||||
public function offeredVariants(string $target): array
|
||||
{
|
||||
if (preg_match('/^composition:(\d+)$/', $target, $match) !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CompositionVersion::query()->find((int) $match[1])?->variants
|
||||
->map(fn ($variant): array => ['key' => $variant->key, 'name' => $variant->name])
|
||||
->all() ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $member
|
||||
* @return array{variant: string|null, requirement: string, selection: list<string>|null}
|
||||
*/
|
||||
private function memberExtras(array $member): array
|
||||
{
|
||||
$selection = $member['selection'] ?? null;
|
||||
|
||||
return [
|
||||
'variant' => isset($member['variant']) && $member['variant'] !== '' ? (string) $member['variant'] : null,
|
||||
'requirement' => ($member['requirement'] ?? 'erforderlich') === 'ergaenzend' ? 'ergaenzend' : 'erforderlich',
|
||||
'selection' => is_array($selection) && $selection !== [] ? array_values(array_map('strval', $selection)) : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, name: string, description: string}>
|
||||
*/
|
||||
private function normalizeVariants(mixed $variants): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach (is_array($variants) ? $variants : [] as $variant) {
|
||||
if (is_array($variant) && trim((string) ($variant['key'] ?? '')) !== '') {
|
||||
$result[] = [
|
||||
'key' => trim((string) $variant['key']),
|
||||
'name' => trim((string) ($variant['name'] ?? '')),
|
||||
'description' => trim((string) ($variant['description'] ?? '')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -969,7 +1111,7 @@ private function includePart(string $target, bool $allowDraft): bool
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->members as $index => $member) {
|
||||
foreach ($this->isExercise() ? [] : $this->members as $index => $member) {
|
||||
if (($member['target'] ?? '') === $target) {
|
||||
$this->selected = $index;
|
||||
$this->panel = 'bestandteil';
|
||||
@@ -989,6 +1131,7 @@ private function includePart(string $target, bool $allowDraft): bool
|
||||
|
||||
$row['role'] = app(EditorialCatalog::class)->defaultRole((string) $row['kind']);
|
||||
$row['note'] = '';
|
||||
$row = [...$row, ...$this->memberExtras([])];
|
||||
$this->members[] = $row;
|
||||
$this->members = array_values($this->members);
|
||||
$this->selected = array_key_last($this->members);
|
||||
@@ -1079,6 +1222,7 @@ public function useVersion(int $index, string $target): void
|
||||
$this->commitRoleDraft();
|
||||
$row['role'] = $this->members[$index]['role'] ?? $row['kind'];
|
||||
$row['note'] = $this->members[$index]['note'] ?? '';
|
||||
$row = [...$row, ...$this->memberExtras($this->members[$index])];
|
||||
$this->members[$index] = $row;
|
||||
$this->syncRoleDraft();
|
||||
$this->feedback = $row['version_label'].' ist für diese Stelle ausgewählt. Der Entwurf speichert das. Eine freigegebene Fassung bleibt unverändert.';
|
||||
@@ -1611,9 +1755,12 @@ public function publishRevision(): bool
|
||||
[
|
||||
'learning_goal' => $this->blank($this->learningGoal),
|
||||
'duration_minutes' => $minutes,
|
||||
'duration_max' => $this->blank($this->durationMax),
|
||||
'material_note' => $this->blank($this->materialNote),
|
||||
'prerequisites' => $this->blank($this->prerequisites),
|
||||
],
|
||||
$this->releaseConsent,
|
||||
$this->normalizeVariants($this->variants),
|
||||
);
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->feedback = $exception->getMessage();
|
||||
@@ -1730,7 +1877,8 @@ protected function loadAufbau(): void
|
||||
$this->imageCaptionText = $this->captionFor($composition->thumbnail_source);
|
||||
$this->catalogScope = match ($this->hostKind()) {
|
||||
CompositionKind::Kurs => 'module',
|
||||
CompositionKind::Uebung => 'medien',
|
||||
CompositionKind::Uebung => 'uebungen',
|
||||
CompositionKind::Exercise => 'medien',
|
||||
default => 'alles',
|
||||
};
|
||||
|
||||
@@ -1744,6 +1892,9 @@ protected function loadAufbau(): void
|
||||
|
||||
if ($version === null) {
|
||||
$this->members = [];
|
||||
$this->variants = [];
|
||||
$this->durationMax = '';
|
||||
$this->prerequisites = '';
|
||||
$this->learningGoal = '';
|
||||
$this->durationMinutes = '';
|
||||
$this->materialNote = '';
|
||||
@@ -1777,10 +1928,14 @@ protected function applyDraft(array $draft): void
|
||||
|
||||
$row['role'] = (string) ($member['role'] ?? $row['kind']);
|
||||
$row['note'] = trim((string) ($member['note'] ?? ''));
|
||||
$row = [...$row, ...$this->memberExtras($member)];
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$this->members = $rows;
|
||||
$this->variants = $this->normalizeVariants($draft['variants'] ?? []);
|
||||
$this->durationMax = ($draft['duration_max'] ?? null) === null ? '' : (string) $draft['duration_max'];
|
||||
$this->prerequisites = (string) ($draft['prerequisites'] ?? '');
|
||||
$this->learningGoal = (string) ($draft['learning_goal'] ?? '');
|
||||
$this->durationMinutes = ($draft['duration_minutes'] ?? null) === null ? '' : (string) $draft['duration_minutes'];
|
||||
$this->materialNote = (string) ($draft['material_note'] ?? '');
|
||||
@@ -1798,6 +1953,11 @@ protected function applyDraft(array $draft): void
|
||||
protected function applyVersion(CompositionVersion $version): void
|
||||
{
|
||||
$this->members = app(EditorialCatalog::class)->rows($version, (int) $this->getRecord()->getKey());
|
||||
$this->variants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [
|
||||
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description,
|
||||
])->all());
|
||||
$this->durationMax = $version->duration_max === null ? '' : (string) $version->duration_max;
|
||||
$this->prerequisites = (string) ($version->prerequisites ?? '');
|
||||
$this->learningGoal = (string) ($version->learning_goal ?? '');
|
||||
$this->durationMinutes = $version->duration_minutes === null ? '' : (string) $version->duration_minutes;
|
||||
$this->materialNote = (string) ($version->material_note ?? '');
|
||||
@@ -1884,18 +2044,21 @@ protected function needsRevision(): bool
|
||||
|
||||
protected function sameMembers(CompositionVersion $version): bool
|
||||
{
|
||||
$version->loadMissing('members');
|
||||
$version->loadMissing('members.variant');
|
||||
$current = $version->members->map(function ($member): string {
|
||||
$target = $member->content_element_version_id
|
||||
? 'element:'.$member->content_element_version_id
|
||||
: 'composition:'.$member->nested_composition_version_id;
|
||||
|
||||
return $member->role.'|'.$target.'|'.trim((string) ($member->placement_note ?? ''));
|
||||
return $member->role.'|'.$target.'|'.trim((string) ($member->placement_note ?? ''))
|
||||
.'|'.($member->variant?->key ?? '').'|'.($member->requirement ?: 'erforderlich').'|'.json_encode($member->variant_selection);
|
||||
})->all();
|
||||
$next = array_values(array_map(
|
||||
fn (array $member): string => trim((string) ($member['role'] ?? '')).'|'.($member['target'] ?? '').'|'.trim((string) ($member['note'] ?? '')),
|
||||
$this->members,
|
||||
));
|
||||
$next = array_values(array_map(function (array $member): string {
|
||||
$extras = $this->memberExtras($member);
|
||||
|
||||
return trim((string) ($member['role'] ?? '')).'|'.($member['target'] ?? '').'|'.trim((string) ($member['note'] ?? ''))
|
||||
.'|'.($extras['variant'] ?? '').'|'.$extras['requirement'].'|'.json_encode($extras['selection']);
|
||||
}, $this->members));
|
||||
|
||||
return $current === $next;
|
||||
}
|
||||
@@ -1910,8 +2073,15 @@ protected function didacticChanged(CompositionVersion $version): bool
|
||||
|
||||
$storedMinutes = $version->duration_minutes === null ? null : (int) $version->duration_minutes;
|
||||
|
||||
$storedVariants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [
|
||||
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description,
|
||||
])->all());
|
||||
|
||||
return $version->learning_goal !== $this->blank($this->learningGoal)
|
||||
|| $version->material_note !== $this->blank($this->materialNote)
|
||||
|| $version->prerequisites !== $this->blank($this->prerequisites)
|
||||
|| ($version->duration_max === null ? null : (string) $version->duration_max) !== $this->blank($this->durationMax)
|
||||
|| $storedVariants !== $this->normalizeVariants($this->variants)
|
||||
|| $storedMinutes !== $minutes;
|
||||
}
|
||||
|
||||
@@ -2122,12 +2292,16 @@ protected function payload(): array
|
||||
'learning_goal' => $this->blank($this->learningGoal),
|
||||
'duration_minutes' => $minutes === false ? $this->durationMinutes : $minutes,
|
||||
'material_note' => $this->blank($this->materialNote),
|
||||
'duration_max' => $this->blank($this->durationMax),
|
||||
'prerequisites' => $this->blank($this->prerequisites),
|
||||
'variants' => $this->normalizeVariants($this->variants),
|
||||
'revision_note' => $this->blank($this->revisionNote),
|
||||
'members' => array_values(array_map(
|
||||
fn (array $member): array => [
|
||||
'role' => trim((string) ($member['role'] ?? '')),
|
||||
'target' => (string) ($member['target'] ?? ''),
|
||||
'note' => trim((string) ($member['note'] ?? '')),
|
||||
...$this->memberExtras($member),
|
||||
],
|
||||
$members,
|
||||
)),
|
||||
@@ -2162,6 +2336,9 @@ protected function readyPayload(): array
|
||||
'learning_goal' => null,
|
||||
'duration_minutes' => null,
|
||||
'material_note' => null,
|
||||
'duration_max' => null,
|
||||
'prerequisites' => null,
|
||||
'variants' => [],
|
||||
'revision_note' => null,
|
||||
'members' => [],
|
||||
];
|
||||
@@ -2173,12 +2350,18 @@ protected function readyPayload(): array
|
||||
'learning_goal' => $version->learning_goal,
|
||||
'duration_minutes' => $version->duration_minutes === null ? null : (int) $version->duration_minutes,
|
||||
'material_note' => $version->material_note,
|
||||
'duration_max' => $version->duration_max === null ? null : (string) $version->duration_max,
|
||||
'prerequisites' => $version->prerequisites,
|
||||
'variants' => $this->normalizeVariants($version->variants->map(fn ($variant): array => [
|
||||
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description,
|
||||
])->all()),
|
||||
'revision_note' => null,
|
||||
'members' => array_values(array_map(
|
||||
fn (array $row): array => [
|
||||
'role' => trim((string) ($row['role'] ?? '')),
|
||||
'target' => (string) ($row['target'] ?? ''),
|
||||
'note' => trim((string) ($row['note'] ?? '')),
|
||||
...$this->memberExtras($row),
|
||||
],
|
||||
$rows,
|
||||
)),
|
||||
@@ -2202,6 +2385,7 @@ protected function normalizePayload(array $payload): array
|
||||
'role' => trim((string) ($member['role'] ?? '')),
|
||||
'target' => (string) ($member['target'] ?? ''),
|
||||
'note' => trim((string) ($member['note'] ?? '')),
|
||||
...$this->memberExtras($member),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2209,6 +2393,9 @@ protected function normalizePayload(array $payload): array
|
||||
'learning_goal' => $payload['learning_goal'] ?? null,
|
||||
'duration_minutes' => $payload['duration_minutes'] ?? null,
|
||||
'material_note' => $payload['material_note'] ?? null,
|
||||
'duration_max' => isset($payload['duration_max']) && $payload['duration_max'] !== '' ? (string) $payload['duration_max'] : null,
|
||||
'prerequisites' => $payload['prerequisites'] ?? null,
|
||||
'variants' => $this->normalizeVariants($payload['variants'] ?? []),
|
||||
'revision_note' => $payload['revision_note'] ?? null,
|
||||
'members' => $members,
|
||||
];
|
||||
|
||||
@@ -33,12 +33,12 @@ protected function fixedKind(): ?CompositionKind
|
||||
|
||||
private function onDesk(): bool
|
||||
{
|
||||
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
|
||||
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung, CompositionKind::Exercise], true);
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
$desk = $this->onDesk() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
|
||||
$desk = $this->onDesk() && $this->kind() !== CompositionKind::Exercise ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
|
||||
|
||||
return $this->kind()->deskExplanation().$desk;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Practices\Pages;
|
||||
|
||||
use App\Filament\Resources\Compositions\Pages\EditComposition;
|
||||
use App\Filament\Resources\Practices\PracticeResource;
|
||||
|
||||
class EditPractice extends EditComposition
|
||||
{
|
||||
protected static string $resource = PracticeResource::class;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Practices\Pages;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Filament\Resources\Compositions\Pages\ListCompositionKind;
|
||||
use App\Filament\Resources\Practices\PracticeResource;
|
||||
|
||||
class ListPractices extends ListCompositionKind
|
||||
{
|
||||
protected static string $resource = PracticeResource::class;
|
||||
|
||||
protected function kind(): CompositionKind
|
||||
{
|
||||
return CompositionKind::Exercise;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Practices;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Filament\Resources\Compositions\CompositionKindResource;
|
||||
use App\Filament\Resources\Practices\Pages\EditPractice;
|
||||
use App\Filament\Resources\Practices\Pages\ListPractices;
|
||||
|
||||
/**
|
||||
* Die fachliche Übung. Der ältere Eintrag „Module“ (`ExerciseResource`, Adresse `uebungen`) bleibt unverändert und
|
||||
* zeigt die Zusammenstellungen der Art `uebung`; hier stehen die Übungen mit Varianten.
|
||||
*/
|
||||
class PracticeResource extends CompositionKindResource
|
||||
{
|
||||
protected static ?string $slug = 'fachuebungen';
|
||||
|
||||
protected static ?string $navigationLabel = 'Übungen';
|
||||
|
||||
protected static ?string $modelLabel = 'Übung';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Übungen';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function kind(): CompositionKind
|
||||
{
|
||||
return CompositionKind::Exercise;
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPractices::route('/'),
|
||||
'edit' => EditPractice::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,9 @@ public function elementUsage(ContentElement $element): array
|
||||
foreach ($contents as $content) {
|
||||
$lines[] = 'Lizenzartikel '.$content->release->article->code
|
||||
.' · Stand '.$content->release->number
|
||||
.' · '.$content->path;
|
||||
.' · '.$content->path
|
||||
.($content->variant_key !== null ? ' · Variante '.$content->variant_key : '')
|
||||
.($content->requirement === CompositionMember::SUPPLEMENTARY ? ' · ergänzend' : '');
|
||||
}
|
||||
|
||||
return $lines === []
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
use App\Filament\Resources\Practices\PracticeResource;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -33,6 +34,7 @@ class EditorialCatalog
|
||||
public function rows(CompositionVersion $version, int $exceptCompositionId): array
|
||||
{
|
||||
$version->loadMissing([
|
||||
'members.variant',
|
||||
'members.contentElementVersion.element.editorialContentKind',
|
||||
'members.nestedCompositionVersion.composition.editorialContentKind',
|
||||
]);
|
||||
@@ -50,6 +52,9 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr
|
||||
|
||||
$row['role'] = $member->role;
|
||||
$row['note'] = trim((string) ($member->placement_note ?? ''));
|
||||
$row['variant'] = $member->variant?->key;
|
||||
$row['requirement'] = $member->requirement ?: 'erforderlich';
|
||||
$row['selection'] = is_array($member->variant_selection) ? $member->variant_selection : null;
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
@@ -244,7 +249,11 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
->with('composition.editorialContentKind')
|
||||
->whereHas('composition', function ($builder) use ($scope, $query, $like): void {
|
||||
if ($scope === 'module') {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
$builder->whereIn('kind', [CompositionKind::Uebung, CompositionKind::Exercise]);
|
||||
}
|
||||
|
||||
if ($scope === 'uebungen') {
|
||||
$builder->where('kind', CompositionKind::Exercise);
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
@@ -317,7 +326,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
->where('composition_id', '!=', $exceptCompositionId)
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
if ($kind === 'modul') {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
$builder->whereIn('kind', [CompositionKind::Uebung, CompositionKind::Exercise]);
|
||||
}
|
||||
|
||||
if ($dimensionId > 0) {
|
||||
@@ -363,7 +372,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$builder->where('status', ContentVersionStatus::Bereit);
|
||||
})
|
||||
->when($kind === 'modul', function ($builder): void {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
$builder->whereIn('kind', [CompositionKind::Uebung, CompositionKind::Exercise]);
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
@@ -1073,6 +1082,7 @@ public function create(string $designation, CompositionKind $kind): Composition
|
||||
$slug = match ($kind) {
|
||||
CompositionKind::Kurs => 'programm',
|
||||
CompositionKind::Uebung => 'modul',
|
||||
CompositionKind::Exercise => 'uebung',
|
||||
default => null,
|
||||
};
|
||||
$editorial = $slug === null ? null : EditorialContentKind::query()->where('slug', $slug)->first();
|
||||
@@ -1094,6 +1104,7 @@ public static function editUrl(Composition $composition): string
|
||||
CompositionKind::Kurs => CourseResource::class,
|
||||
CompositionKind::Kombination => CombinationResource::class,
|
||||
CompositionKind::Uebung => ExerciseResource::class,
|
||||
CompositionKind::Exercise => PracticeResource::class,
|
||||
};
|
||||
|
||||
return $resource::getUrl('edit', ['record' => $composition]);
|
||||
|
||||
@@ -74,6 +74,7 @@ public function bestand(): array
|
||||
$einheit = match ($fixed) {
|
||||
CompositionKind::Kurs => ['Programm', 'Programme'],
|
||||
CompositionKind::Uebung => ['Modul', 'Module'],
|
||||
CompositionKind::Exercise => ['Übung', 'Übungen'],
|
||||
CompositionKind::Kombination => ['Fachliche Kombination', 'Fachliche Kombinationen'],
|
||||
default => ['Programm oder Modul', 'Programme und Module'],
|
||||
};
|
||||
@@ -188,7 +189,7 @@ public function entries(): array
|
||||
$rows[] = [
|
||||
'schluessel' => 'c'.$composition->id,
|
||||
'titel' => $title,
|
||||
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : ''),
|
||||
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : '').($kind === CompositionKind::Exercise ? ' · Herkunft: lokal' : ''),
|
||||
'text' => $summary,
|
||||
'bild' => $cover['url'],
|
||||
'bildFehlt' => 'Kein Titelbild',
|
||||
@@ -219,11 +220,19 @@ public function entries(): array
|
||||
*/
|
||||
protected function createCompositionAction(CompositionKind $kind): Action
|
||||
{
|
||||
$label = $kind === CompositionKind::Kurs ? 'Programm' : 'Modul';
|
||||
$label = match ($kind) {
|
||||
CompositionKind::Kurs => 'Programm',
|
||||
CompositionKind::Exercise => 'Übung',
|
||||
default => 'Modul',
|
||||
};
|
||||
|
||||
return Action::make($kind === CompositionKind::Kurs ? 'createProgram' : 'createModule')
|
||||
return Action::make(match ($kind) {
|
||||
CompositionKind::Kurs => 'createProgram',
|
||||
CompositionKind::Exercise => 'createExercise',
|
||||
default => 'createModule',
|
||||
})
|
||||
->label($label.' anlegen')
|
||||
->modalHeading('Neues '.$label)
|
||||
->modalHeading(($kind === CompositionKind::Exercise ? 'Neue ' : 'Neues ').$label)
|
||||
->modalDescription('Der Name genügt. Danach öffnet sich der Aufbau; Texte, Bilder und Einordnung folgen dort und in der Redaktion.')
|
||||
->modalSubmitActionLabel($label.' anlegen')
|
||||
->modalWidth('lg')
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
@@ -501,8 +502,10 @@ private function maySeeThumbnail(Request $request, string $kind, int $subject):
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ein gesperrtes Medium zeigt auch kein Vorschaubild mehr (Sperre gilt für Ausgaben und Ableitungen).
|
||||
if ($kind === 'element' && $release->contents->contains(
|
||||
fn ($content): bool => $content->elementVersion?->content_element_id === $subject,
|
||||
fn ($content): bool => $content->elementVersion?->content_element_id === $subject
|
||||
&& $content->elementVersion->status !== ContentVersionStatus::Gesperrt,
|
||||
)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\ExerciseGuide;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Entitlement\DecideAccess;
|
||||
@@ -389,7 +391,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
||||
'view_url' => $view,
|
||||
'poster_url' => $poster,
|
||||
'download_url' => $download,
|
||||
'program_url' => $this->programUrl($node),
|
||||
'program_url' => $this->exerciseUrl($user, $rootId, $node) ?? $this->programUrl($node),
|
||||
'composition_id' => $node->compositionId,
|
||||
'element_id' => $node->contentElementId,
|
||||
'version_id' => $node->contentElementVersionId,
|
||||
@@ -491,6 +493,46 @@ private function element(int $id): ?ContentElement
|
||||
return $this->elements[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Übung im Zusammenhang des erworbenen Moduls oder Programms: die im Stand gebundene Fassung und ihre Varianten,
|
||||
* nicht die jeweils neueste Fassung der Übung. Gefunden wird der jüngste auslieferbare Stand des Kontos, dessen
|
||||
* festgeschriebene Wurzel diese Fassung an einer Stelle einbindet.
|
||||
*/
|
||||
private function exerciseUrl(User $user, int $rootId, StructureNode $node): ?string
|
||||
{
|
||||
if ($node->compositionVersionId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$nested = CompositionVersion::query()->with('composition')->find($node->compositionVersionId);
|
||||
|
||||
if ($nested?->composition?->kind !== CompositionKind::Exercise) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$guide = app(ExerciseGuide::class);
|
||||
|
||||
foreach ($this->grants($user) as $grant) {
|
||||
$releases = ArticleRelease::query()
|
||||
->where('license_article_id', $grant->license_article_id)
|
||||
->whereIn('status', [ReleaseStatus::Veroeffentlicht, ReleaseStatus::AbgeloestVerfuegbar])
|
||||
->whereHas('rootCompositionVersion', fn ($query) => $query->where('composition_id', $rootId))
|
||||
->with('rootCompositionVersion')
|
||||
->orderByDesc('number')
|
||||
->get();
|
||||
|
||||
foreach ($releases as $release) {
|
||||
$path = $guide->pathTo($release->rootCompositionVersion, $nested->id);
|
||||
|
||||
if ($path !== null) {
|
||||
return route('member.exercise', ['article' => $grant->license_article_id, 'release' => $release->id, 'path' => $path]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function programUrl(StructureNode $node): ?string
|
||||
{
|
||||
if ($node->compositionId === null || $node->compositionVersionId === null) {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="vw vw-aufbauseite" x-data x-on:keydown.window.ctrl.s.prevent="$wire.saveDraft()">
|
||||
@include('filament.verwaltung.kopf', [
|
||||
'zurueck' => ['label' => 'Zum Arbeitsplatz', 'href' => \App\Filament\Pages\EditorialDesk::getUrl()],
|
||||
'brot' => [['label' => $this->isProgram() ? 'Programme' : 'Module', 'href' => $this::getResource()::getUrl('index')], $titel],
|
||||
'brot' => [['label' => $this->hostKind()->plural() === 'Kurse' ? 'Programme' : $this->hostKind()->plural(), 'href' => $this::getResource()::getUrl('index')], $titel],
|
||||
'titel' => $titel,
|
||||
'typ' => $this->hostLabel().' · '.$typ,
|
||||
'status' => [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@php
|
||||
$cover = $this->coverPicture();
|
||||
$filme = $this->frameFilms();
|
||||
$ort = $this->isProgram() ? 'dieses Programms' : 'dieses Moduls';
|
||||
$ort = $this->isProgram() ? 'dieses Programms' : ($this->isExercise() ? 'dieser Übung' : 'dieses Moduls');
|
||||
@endphp
|
||||
<div class="vw-medien-raster">
|
||||
<section class="vw-medien-haupt" aria-labelledby="didaktik-titel">
|
||||
@@ -19,9 +19,40 @@
|
||||
<input class="vw-eingabe" type="text" wire:model.live.blur="revisionNote">
|
||||
</label>
|
||||
</div>
|
||||
<label class="vw-feldlabel">Materialbedarf
|
||||
<label class="vw-feldlabel">{{ $this->isExercise() ? 'Ausstattung' : 'Materialbedarf' }}
|
||||
<textarea class="vw-eingabe" rows="3" wire:model.live.blur="materialNote"></textarea>
|
||||
</label>
|
||||
@if ($this->isExercise())
|
||||
<div class="vw-raster-2">
|
||||
<label class="vw-feldlabel">Zeitbedarf bis (Minuten)
|
||||
<input class="vw-eingabe" type="text" inputmode="numeric" wire:model.live.blur="durationMax">
|
||||
</label>
|
||||
<label class="vw-feldlabel">Voraussetzungen
|
||||
<input class="vw-eingabe" type="text" wire:model.live.blur="prerequisites">
|
||||
</label>
|
||||
</div>
|
||||
<h2 id="varianten-titel" class="vw-abschnitt-titel">Varianten</h2>
|
||||
<p class="vw-feld-hilfe">Eine Übung kann mehrere Durchführungsvarianten haben. Gemeinsame Bestandteile gelten für alle; jedem Bestandteil ordnest du im Aufbau eine Variante zu.</p>
|
||||
<ul class="vw-liste" aria-labelledby="varianten-titel">
|
||||
@foreach ($this->variants as $i => $variant)
|
||||
<li class="vw-raster-2">
|
||||
<label class="vw-feldlabel">Name der Variante
|
||||
<input class="vw-eingabe" type="text" wire:model.live.blur="variants.{{ $i }}.name">
|
||||
</label>
|
||||
<label class="vw-feldlabel">Beschreibung
|
||||
<input class="vw-eingabe" type="text" wire:model.live.blur="variants.{{ $i }}.description">
|
||||
</label>
|
||||
<button type="button" class="vw-link" wire:click="removeVariant('{{ $variant['key'] }}')">Variante entfernen</button>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<div class="vw-raster-2">
|
||||
<label class="vw-feldlabel">Neue Variante
|
||||
<input class="vw-eingabe" type="text" wire:model="newVariantName" wire:keydown.enter="addVariant" placeholder="z. B. Mit Film">
|
||||
</label>
|
||||
<button type="button" class="button button-secondary" wire:click="addVariant">Variante anlegen</button>
|
||||
</div>
|
||||
@endif
|
||||
<p class="vw-feld-hilfe">Name, Texte, Präsentationsmedien und Einordnung bearbeitest du in der Redaktion.
|
||||
<button type="button" class="vw-link" wire:click="openRedaktion('texte')">Redaktion öffnen</button></p>
|
||||
</section>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
$gewaehlt = $auswahl !== null ? $members[$auswahl] : null;
|
||||
$symbol = fn (?string $tone): string => match ($tone) { 'film' => 'film', 'audio' => 'audio', 'dokument' => 'dokument', 'modul', 'programm' => 'modul', default => 'dokument' };
|
||||
$istKomposition = fn (array $m): bool => (bool) preg_match('/^composition(-draft)?:/', (string) ($m['target'] ?? ''));
|
||||
$ort = ($this->isProgram() ? 'im Programm' : 'im Modul');
|
||||
$ort = ($this->isProgram() ? 'im Programm' : ($this->isExercise() ? 'in der Übung' : 'im Modul'));
|
||||
@endphp
|
||||
<div class="vw-aufbau">
|
||||
<section class="vw-struktur" aria-labelledby="struktur-titel">
|
||||
@@ -196,6 +196,38 @@
|
||||
<label class="vw-feldlabel">Hinweis an dieser Stelle
|
||||
<textarea class="vw-eingabe" rows="4" wire:model.live.blur="noteDraft" placeholder="Was Trainer an dieser Stelle beachten sollen"></textarea>
|
||||
</label>
|
||||
@if ($this->isExercise())
|
||||
<label class="vw-feldlabel">Variante
|
||||
<select class="vw-eingabe" wire:change="setMemberVariant({{ $auswahl }}, $event.target.value)">
|
||||
<option value="" @selected(($gewaehlt['variant'] ?? null) === null)>Gemeinsam (gilt für alle Varianten)</option>
|
||||
@foreach ($this->variants as $variant)
|
||||
<option value="{{ $variant['key'] }}" @selected(($gewaehlt['variant'] ?? null) === $variant['key'])>{{ $variant['name'] ?: $variant['key'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
<label class="vw-feldlabel">Verwendung
|
||||
<select class="vw-eingabe" wire:change="setMemberRequirement({{ $auswahl }}, $event.target.value)">
|
||||
<option value="erforderlich" @selected(($gewaehlt['requirement'] ?? 'erforderlich') === 'erforderlich')>Erforderlich</option>
|
||||
<option value="ergaenzend" @selected(($gewaehlt['requirement'] ?? 'erforderlich') === 'ergaenzend')>Ergänzend</option>
|
||||
</select>
|
||||
<span class="vw-feld-hilfe">Fehlt ein erforderlicher Bestandteil, gilt die Variante als nicht vollständig durchführbar. Ein ergänzender entfällt mit Hinweis.</span>
|
||||
</label>
|
||||
@endif
|
||||
@php($angeboten = $this->offeredVariants((string) ($gewaehlt['target'] ?? '')))
|
||||
@if ($angeboten !== [])
|
||||
<fieldset class="vw-chipgruppe">
|
||||
<legend>Angebotene Varianten</legend>
|
||||
<div class="vw-chips">
|
||||
@foreach ($angeboten as $variante)
|
||||
<label>
|
||||
<input type="checkbox" @checked(! is_array($gewaehlt['selection'] ?? null) || in_array($variante['key'], $gewaehlt['selection'], true)) wire:click="toggleVariantSelection({{ $auswahl }}, '{{ $variante['key'] }}')">
|
||||
<span>{{ $variante['name'] }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
<span class="vw-feld-hilfe">Gilt nur in diesem Aufbau. Nur die angebotenen Varianten werden im Stand festgeschrieben.</span>
|
||||
</fieldset>
|
||||
@endif
|
||||
@if (count($alternativen) > 1)
|
||||
<fieldset class="vw-chipgruppe">
|
||||
<legend>Verwendete Fassung</legend>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Http\SignedLink;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Rückfalltest: Dieser Test läuft im VORHERIGEN Programmstand (Teil 0) gegen eine Datenbank, die der NEUE Stand erzeugt
|
||||
* hat (Übung mit zwei Varianten, Modul mit Variante A, Programm mit Variante B, verkauft). Der Rückfall setzt nur den
|
||||
* Code zurück; die Daten bleiben. Der alte Stand darf nicht abstürzen, keine ungewählte Variante und keine Übung
|
||||
* offenlegen und beim Bearbeiten nichts verlieren.
|
||||
*/
|
||||
class RueckfallGegenNeueDatenTest extends TestCase
|
||||
{
|
||||
/** @var array<string, int> */
|
||||
private array $ids;
|
||||
|
||||
private string $file;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->file = sys_get_temp_dir().'/rueckfall-'.uniqid().'.sqlite';
|
||||
copy((string) getenv('RUECKFALL_DB'), $this->file);
|
||||
config(['database.connections.sqlite.database' => $this->file]);
|
||||
DB::purge('sqlite');
|
||||
$this->ids = json_decode((string) file_get_contents((string) getenv('RUECKFALL_JSON')), true, 512, JSON_THROW_ON_ERROR);
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
DB::purge('sqlite');
|
||||
@unlink($this->file);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_the_stored_exercise_is_a_kind_the_previous_state_does_not_know(): void
|
||||
{
|
||||
$this->assertSame(1, DB::table('compositions')->where('kind', 'exercise')->count());
|
||||
$this->assertNull(Composition::query()->find($this->ids['exercise_composition']));
|
||||
}
|
||||
|
||||
public function test_the_member_area_neither_crashes_nor_leaks(): void
|
||||
{
|
||||
$member = User::query()->findOrFail($this->ids['member']);
|
||||
|
||||
$this->actingAs($member)->get(route('member.library'))->assertOk()->assertSee('Modul Stopp')->assertSee('Programm Stopp');
|
||||
|
||||
foreach (['module_composition', 'program_composition'] as $key) {
|
||||
$this->actingAs($member)
|
||||
->get(route('member.program', $this->ids[$key]))
|
||||
->assertOk()
|
||||
->assertDontSee('Stopp sagen')
|
||||
->assertDontSee('Variante')
|
||||
->assertDontSee('Film A')
|
||||
->assertDontSee('Durchführung');
|
||||
}
|
||||
|
||||
$this->actingAs($member)->get(route('member.program', $this->ids['exercise_composition']))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_only_the_chosen_variant_of_each_stand_is_delivered(): void
|
||||
{
|
||||
$member = User::query()->findOrFail($this->ids['member']);
|
||||
|
||||
$this->actingAs($member)
|
||||
->get(route('member.article', $this->ids['module_article']))
|
||||
->assertOk()
|
||||
->assertSee('Film A')
|
||||
->assertSee('Durchführung A')
|
||||
->assertDontSee('Durchführung B')
|
||||
->assertDontSee('Arbeitsblatt B');
|
||||
|
||||
$this->actingAs($member)
|
||||
->get(route('member.article', $this->ids['program_article']))
|
||||
->assertOk()
|
||||
->assertSee('Durchführung B')
|
||||
->assertDontSee('Film A')
|
||||
->assertDontSee('Durchführung A');
|
||||
|
||||
$unchosen = SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $this->ids['module_article'],
|
||||
'release' => $this->ids['module_release'],
|
||||
'version' => $this->ids['film_b_text'],
|
||||
'action' => 'ansehen',
|
||||
'reader' => $member->id,
|
||||
]);
|
||||
$this->actingAs($member)->get($unchosen)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_the_previous_editors_are_read_only_and_lose_nothing(): void
|
||||
{
|
||||
$staff = User::factory()->redakteur()->create();
|
||||
$staff->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$membersBefore = DB::table('composition_members')->count();
|
||||
$versionsBefore = DB::table('composition_versions')->count();
|
||||
|
||||
foreach ([[EditExercise::class, 'module_composition'], [EditCourse::class, 'program_composition']] as [$page, $key]) {
|
||||
$component = Livewire::actingAs($staff, 'staff')
|
||||
->test($page, ['record' => $this->ids[$key]])
|
||||
->assertOk()
|
||||
->assertSee('neueren Programmversion');
|
||||
|
||||
$this->assertNotNull($component->instance()->schreibschutz());
|
||||
$component->call('saveDraft')->call('armRelease')->call('discardDraft');
|
||||
$this->assertFalse($component->instance()->publishRevision());
|
||||
}
|
||||
|
||||
$this->assertSame($membersBefore, DB::table('composition_members')->count());
|
||||
$this->assertSame($versionsBefore, DB::table('composition_versions')->count());
|
||||
$this->assertSame(0, DB::table('compositions')->whereNotNull('working_draft')->count());
|
||||
}
|
||||
|
||||
public function test_the_previous_state_refuses_a_new_stand_that_would_drop_the_exercise(): void
|
||||
{
|
||||
$article = LicenseArticle::query()->findOrFail($this->ids['module_article']);
|
||||
$release = ArticleRelease::query()->findOrFail($this->ids['module_release']);
|
||||
$releases = $article->releases()->count();
|
||||
|
||||
try {
|
||||
app(ArticleService::class)->publishRelease($article, $release->rootCompositionVersion, 'Neuer Stand im alten Programmstand.');
|
||||
$this->fail('Der alte Stand darf keinen Stand mit Übung veröffentlichen.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('Programmstand', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame($releases, $article->releases()->count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Tests\Support\BuildsExercises;
|
||||
|
||||
/**
|
||||
* Erzeugt mit dem NEUEN Programmstand eine SQLite-Datei mit Übungsdaten (Übung mit zwei Varianten, ein Modul mit Variante
|
||||
* A, ein Programm mit Variante B, verkauft und freigeschaltet) und schreibt die Kennungen als JSON. Der vorherige
|
||||
* Programmstand prüft anschließend gegen genau diese Datei (Rückfalltest).
|
||||
*
|
||||
* Aufruf: php build_rueckfall.php <worktree> <sqlite-datei> <json-datei>
|
||||
*/
|
||||
[$script, $root, $db, $out] = $argv;
|
||||
|
||||
chdir($root);
|
||||
require $root.'/vendor/autoload.php';
|
||||
|
||||
foreach (['DB_CONNECTION' => 'sqlite', 'DB_DATABASE' => $db, 'DB_URL' => '', 'APP_ENV' => 'testing', 'CACHE_STORE' => 'array', 'SESSION_DRIVER' => 'array', 'QUEUE_CONNECTION' => 'sync'] as $key => $value) {
|
||||
putenv($key.'='.$value);
|
||||
$_ENV[$key] = $value;
|
||||
$_SERVER[$key] = $value;
|
||||
}
|
||||
|
||||
@unlink($db);
|
||||
touch($db);
|
||||
|
||||
$app = require $root.'/bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
Artisan::call('migrate:fresh', ['--force' => true]);
|
||||
|
||||
$builder = new class
|
||||
{
|
||||
use BuildsExercises;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function run(): array
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$module = $this->moduleWith('Modul Stopp', $exercise['version'], ['a']);
|
||||
$program = $this->moduleWith('Programm Stopp', $exercise['version'], ['b'], CompositionKind::Kurs);
|
||||
$articles = app(ArticleService::class);
|
||||
$moduleArticle = $articles->create('modul-stopp');
|
||||
$moduleRelease = $articles->publishRelease($moduleArticle, $module, 'Modul.');
|
||||
$programArticle = $articles->create('programm-stopp');
|
||||
$programRelease = $articles->publishRelease($programArticle, $program, 'Programm.');
|
||||
|
||||
$offers = app(OfferService::class);
|
||||
$rights = $offers->createRightsProfile('Voll', 'ehrenamtlich', ['film' => ['streamen', 'laden'], 'text' => ['ansehen', 'laden'], 'document' => ['ansehen', 'laden']]);
|
||||
$offer = $offers->create('Angebot');
|
||||
$offers->activate($offer, [
|
||||
['target' => $moduleArticle->fresh(), 'rights' => $rights],
|
||||
['target' => $programArticle->fresh(), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf']);
|
||||
$member = User::factory()->create(['name' => 'Kursleitung Probe']);
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
$display = app(CompositionDisplayRelease::class);
|
||||
$display->release($module, $member);
|
||||
$display->release($program, $member);
|
||||
|
||||
return [
|
||||
'member' => $member->id,
|
||||
'module_composition' => $module->composition_id,
|
||||
'program_composition' => $program->composition_id,
|
||||
'exercise_composition' => $exercise['version']->composition_id,
|
||||
'module_article' => $moduleArticle->id,
|
||||
'module_release' => $moduleRelease->id,
|
||||
'program_article' => $programArticle->id,
|
||||
'program_release' => $programRelease->id,
|
||||
'film_a' => $exercise['filmA']->id,
|
||||
'film_b_text' => $exercise['textB']->id,
|
||||
'sheet_b' => $exercise['sheetB']->id,
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
file_put_contents($out, json_encode($builder->run(), JSON_PRETTY_PRINT));
|
||||
echo "ok\n";
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ExerciseGuide;
|
||||
@@ -75,6 +76,23 @@ public function test_the_trainer_reads_the_bound_version_with_the_offered_varian
|
||||
->assertDontSee('Variante A: Der Film zeigt die Situation.');
|
||||
}
|
||||
|
||||
public function test_the_module_page_leads_to_the_bound_exercise_not_to_the_newest_one(): void
|
||||
{
|
||||
$display = app(CompositionDisplayRelease::class);
|
||||
$display->release($this->moduleRelease->rootCompositionVersion, $this->member);
|
||||
$display->release($this->programRelease->rootCompositionVersion, $this->member);
|
||||
|
||||
$this->actingAs($this->member)
|
||||
->get(route('member.program', $this->moduleRelease->rootCompositionVersion->composition_id))
|
||||
->assertOk()
|
||||
->assertSee(route('member.exercise', ['article' => $this->moduleArticle, 'release' => $this->moduleRelease, 'path' => '1']), false);
|
||||
|
||||
$this->actingAs($this->member)
|
||||
->get(route('member.program', $this->programRelease->rootCompositionVersion->composition_id))
|
||||
->assertOk()
|
||||
->assertSee(route('member.exercise', ['article' => $this->programArticle, 'release' => $this->programRelease, 'path' => '1']), false);
|
||||
}
|
||||
|
||||
public function test_the_pdf_carries_the_same_version_the_marking_and_the_delivery_record(): void
|
||||
{
|
||||
$response = $this->actingAs($this->member)->get($this->pdf($this->moduleArticle, $this->moduleRelease, 'a'));
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Filament\Resources\Practices\Pages\EditPractice;
|
||||
use App\Filament\Resources\Practices\Pages\ListPractices;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsExercises;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Die Redaktion legt eine Übung im gemeinsamen Aufbauarbeitsplatz an, pflegt Varianten und Verwendung und baut sie in
|
||||
* ein Modul und ein Programm ein.
|
||||
*/
|
||||
class UebungEditorTest extends TestCase
|
||||
{
|
||||
use BuildsExercises;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
public function test_the_exercise_list_offers_creating_an_exercise_with_its_editorial_kind(): void
|
||||
{
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListPractices::class)
|
||||
->assertOk()
|
||||
->assertSee('Übung anlegen')
|
||||
->mountAction('createExercise')
|
||||
->setActionData(['designation' => 'Stopp sagen'])
|
||||
->callMountedAction();
|
||||
|
||||
$practice = Composition::query()->where('designation', 'Stopp sagen')->firstOrFail();
|
||||
$this->assertSame(CompositionKind::Exercise, $practice->kind);
|
||||
$this->assertSame('uebung', $practice->editorialContentKind->slug);
|
||||
}
|
||||
|
||||
public function test_an_exercise_with_variants_is_built_released_and_kept_in_the_draft_across_a_context_switch(): void
|
||||
{
|
||||
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
|
||||
$film = $this->film('Demonstration');
|
||||
$sheet = $this->sheet('Arbeitsblatt');
|
||||
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(EditPractice::class, ['record' => $practice->getKey()])
|
||||
->assertOk()
|
||||
->set('learningGoal', 'Nein sagen üben')
|
||||
->set('durationMinutes', '10')
|
||||
->set('durationMax', '15')
|
||||
->set('prerequisites', 'Keine')
|
||||
->set('newVariantName', 'Mit Film')
|
||||
->call('addVariant')
|
||||
->set('newVariantName', 'Ohne Film')
|
||||
->call('addVariant')
|
||||
->set('newTextTitle', 'Einstieg')
|
||||
->set('newTextBody', "Gemeinsamer Einstieg.\n\n- Sicher stehen")
|
||||
->call('addText')
|
||||
->call('addPart', 'element:'.$film->id)
|
||||
->call('addPart', 'element:'.$film->id)
|
||||
->call('addPart', 'element:'.$sheet->id);
|
||||
|
||||
$this->assertSame(['mit-film', 'ohne-film'], array_column($component->get('variants'), 'key'));
|
||||
$this->assertCount(4, $component->get('members'), 'Dasselbe Medium darf in zwei Varianten vorkommen.');
|
||||
|
||||
$component
|
||||
->call('setMemberVariant', 1, 'mit-film')
|
||||
->call('setMemberVariant', 2, 'ohne-film')
|
||||
->call('setMemberVariant', 3, 'ohne-film')
|
||||
->call('setMemberRequirement', 3, 'ergaenzend')
|
||||
->call('saveDraft')
|
||||
->assertSee('Mit Film');
|
||||
|
||||
// Kontextwechsel: Der Entwurf lädt die Zuordnungen wieder.
|
||||
$again = Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(EditPractice::class, ['record' => $practice->getKey()]);
|
||||
$this->assertSame(['mit-film', 'ohne-film'], array_column($again->get('variants'), 'key'));
|
||||
$this->assertSame([null, 'mit-film', 'ohne-film', 'ohne-film'], array_column($again->get('members'), 'variant'));
|
||||
$this->assertSame('ergaenzend', $again->get('members')[3]['requirement']);
|
||||
|
||||
$again->call('armRelease')->set('releaseConsent', true)->call('publishRevision');
|
||||
|
||||
$version = $practice->fresh()->versions()->firstOrFail()->load('variants', 'members.variant');
|
||||
$this->assertSame(['mit-film', 'ohne-film'], $version->variants->pluck('key')->all());
|
||||
$this->assertSame(15, $version->duration_max);
|
||||
$this->assertSame('Keine', $version->prerequisites);
|
||||
$this->assertSame([null, 'mit-film', 'ohne-film', 'ohne-film'], $version->members->map(fn ($m) => $m->variant?->key)->all());
|
||||
$this->assertSame('ergaenzend', $version->members[3]->requirement);
|
||||
$this->assertNotNull($version->structure_hash);
|
||||
}
|
||||
|
||||
public function test_a_changed_variant_or_usage_counts_as_a_change_even_when_the_media_stay_the_same(): void
|
||||
{
|
||||
$exercise = $this->exercise('Wechsel');
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(EditPractice::class, ['record' => $exercise['version']->composition_id]);
|
||||
|
||||
$this->assertSame('Die freigegebene Fassung ist unverändert. Es entsteht keine neue Fassung.', $component->call('publishRevision')->get('feedback'));
|
||||
|
||||
$component->call('setMemberRequirement', 2, 'ergaenzend')->call('armRelease')->assertSet('releaseArmed', true);
|
||||
$component->call('publishRevision');
|
||||
$this->assertSame(2, $exercise['version']->composition->versions()->count());
|
||||
$this->assertNotSame($exercise['version']->fresh()->structure_hash, $exercise['version']->composition->versions()->orderByDesc('number')->first()->structure_hash);
|
||||
}
|
||||
|
||||
public function test_a_module_and_a_program_take_the_exercise_with_a_chosen_variant_and_remember_it(): void
|
||||
{
|
||||
$exercise = $this->exercise('Einbau');
|
||||
|
||||
foreach ([[CompositionKind::Uebung, EditExercise::class], [CompositionKind::Kurs, EditCourse::class]] as [$kind, $page]) {
|
||||
$host = app(EditorialCatalog::class)->create('Produkt '.$kind->value, $kind);
|
||||
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')
|
||||
->test($page, ['record' => $host->getKey()])
|
||||
->call('addPart', 'composition:'.$exercise['version']->id);
|
||||
|
||||
$this->assertSame([['key' => 'a', 'name' => 'Mit Film'], ['key' => 'b', 'name' => 'Ohne Film']], $component->instance()->offeredVariants('composition:'.$exercise['version']->id));
|
||||
|
||||
$component
|
||||
->call('toggleVariantSelection', 0, 'a')
|
||||
->call('saveDraft');
|
||||
|
||||
$reloaded = Livewire::actingAs($this->editor(), 'staff')->test($page, ['record' => $host->getKey()]);
|
||||
$this->assertSame(['b'], $reloaded->get('members')[0]['selection'], 'Die Auswahl bleibt beim erneuten Öffnen erhalten.');
|
||||
|
||||
$reloaded->call('armRelease')->call('publishRevision');
|
||||
$member = $host->fresh()->versions()->firstOrFail()->members()->firstOrFail();
|
||||
$this->assertSame(['b'], $member->variant_selection);
|
||||
$this->assertInstanceOf(CompositionVersion::class, $member->nestedCompositionVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\ExerciseUsage;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Support\BuildsExercises;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Parallele Fassungen und gezielte Mediensperre: Der Verwendungsnachweis steigt bis zu den Ständen auf (auch älteren und
|
||||
* verschachtelten), die Sperre wirkt bei der Ausgabe, und der Auswirkungsbericht benennt Variante und Verwendung.
|
||||
*/
|
||||
class UebungSperreTest extends TestCase
|
||||
{
|
||||
use BuildsExercises;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_the_usage_reaches_nested_and_older_stands(): void
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$inner = $this->moduleWith('Modul innen', $exercise['version'], ['a']);
|
||||
$outer = $this->moduleWith('Programm außen', $inner, null, CompositionKind::Kurs);
|
||||
$articles = app(ArticleService::class);
|
||||
$article = $articles->create('programm-aussen');
|
||||
$first = $articles->publishRelease($article, $outer, 'Erster Stand.');
|
||||
$second = $articles->publishRelease($article->fresh(), $outer, 'Zweiter Stand.');
|
||||
$direct = $articles->publishRelease($articles->create('modul-innen'), $inner, 'Modul allein.');
|
||||
|
||||
$usage = app(ExerciseUsage::class)->forComposition($exercise['version']->composition);
|
||||
|
||||
$this->assertCount(1, $usage);
|
||||
$this->assertSame(['Modul innen', 'Programm außen'], array_map(fn (array $host): string => $host['composition']->designation, $usage[0]['hosts']));
|
||||
$this->assertSame([['a'], null], array_map(fn (array $host) => $host['selection'], $usage[0]['hosts']));
|
||||
|
||||
$stands = collect($usage[0]['releases']);
|
||||
$this->assertEqualsCanonicalizing([$first->id, $second->id, $direct->id], $stands->map(fn (array $row): int => $row['release']->id)->all());
|
||||
$this->assertSame('1-1', $stands->first(fn (array $row): bool => $row['release']->id === $first->id)['path'], 'Zwei Ebenen tief.');
|
||||
$this->assertSame('1', $stands->first(fn (array $row): bool => $row['release']->id === $direct->id)['path']);
|
||||
$this->assertSame('abgeloest_verfuegbar', $first->fresh()->status->value);
|
||||
}
|
||||
|
||||
public function test_the_impact_of_a_block_names_stand_variant_and_usage(): void
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$withFilm = $this->moduleWith('Mit Film', $exercise['version'], ['a']);
|
||||
$withoutFilm = $this->moduleWith('Ohne Film', $exercise['version'], ['b']);
|
||||
$articles = app(ArticleService::class);
|
||||
$articles->publishRelease($articles->create('mit-film'), $withFilm, 'Film.');
|
||||
$articles->publishRelease($articles->create('ohne-film'), $withoutFilm, 'Ohne Film.');
|
||||
|
||||
$film = app(ExerciseUsage::class)->blockImpact($exercise['filmA']);
|
||||
$this->assertCount(1, $film);
|
||||
$this->assertSame('mit-film', $film[0]['article']->code);
|
||||
$this->assertSame('a', $film[0]['variant']);
|
||||
$this->assertStringContainsString('nicht mehr vollständig durchführbar', $film[0]['effect']);
|
||||
|
||||
$sheet = app(ExerciseUsage::class)->blockImpact($exercise['sheetB']);
|
||||
$this->assertSame('ergaenzend', $sheet[0]['requirement']);
|
||||
$this->assertStringContainsString('Nur dieses ergänzende Medium entfällt', $sheet[0]['effect']);
|
||||
$this->assertSame([], app(ExerciseUsage::class)->blockImpact($this->film('Unbenutzt')));
|
||||
}
|
||||
|
||||
public function test_a_block_changes_neither_the_frozen_stand_nor_the_usage(): void
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$module = $this->moduleWith('Modul', $exercise['version'], ['a']);
|
||||
$articles = app(ArticleService::class);
|
||||
$release = $articles->publishRelease($articles->create('modul'), $module, 'Modul.');
|
||||
$before = $release->contents->pluck('content_element_version_id')->all();
|
||||
|
||||
app(ContentService::class)->block($exercise['filmA'], 'Rechte zurückgezogen.');
|
||||
|
||||
$this->assertSame($before, $release->fresh()->contents->pluck('content_element_version_id')->all());
|
||||
$this->assertSame('veroeffentlicht', $release->fresh()->status->value);
|
||||
$this->assertCount(1, app(ExerciseUsage::class)->blockImpact($exercise['filmA']));
|
||||
}
|
||||
|
||||
public function test_an_offer_with_a_blocked_part_is_not_activated_and_names_it(): void
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$module = $this->moduleWith('Modul', $exercise['version'], ['a']);
|
||||
$articles = app(ArticleService::class);
|
||||
$article = $articles->create('modul-angebot');
|
||||
$articles->publishRelease($article, $module, 'Modul.');
|
||||
app(ContentService::class)->block($exercise['filmA'], 'Rechte zurückgezogen.');
|
||||
|
||||
$offers = app(OfferService::class);
|
||||
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen'], 'text' => ['ansehen']]);
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
$this->expectExceptionMessage('gesperrte Bestandteile');
|
||||
$offers->activate($offers->create('Angebot'), [['target' => $article->fresh(), 'rights' => $rights]], [
|
||||
'grant_kind' => 'auf_abruf',
|
||||
'composition_version_id' => $module->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_the_preview_picture_of_a_blocked_medium_is_not_served_any_more(): void
|
||||
{
|
||||
$exercise = $this->exercise();
|
||||
$element = $exercise['filmA']->element;
|
||||
$element->thumbnail_path = 'vorschau/film-a.jpg';
|
||||
$element->save();
|
||||
$module = $this->moduleWith('Modul', $exercise['version'], ['a']);
|
||||
$articles = app(ArticleService::class);
|
||||
$article = $articles->create('modul-bild');
|
||||
$articles->publishRelease($article, $module, 'Modul.');
|
||||
$offers = app(OfferService::class);
|
||||
$offer = $offers->create('Bild');
|
||||
$offers->activate($offer, [['target' => $article->fresh(), 'rights' => $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']])]], ['grant_kind' => 'auf_abruf']);
|
||||
$member = User::factory()->create();
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
|
||||
$url = route('member.thumbnail', ['kind' => 'element', 'subject' => $element->id]);
|
||||
// Erlaubt, aber die Datei fehlt in diesem Test.
|
||||
$this->actingAs($member)->get($url)->assertNotFound();
|
||||
|
||||
app(ContentService::class)->block($exercise['filmA'], 'Rechte zurückgezogen.');
|
||||
|
||||
$this->actingAs($member)->get($url)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_two_versions_of_an_exercise_run_in_parallel_stands(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$exercise = $this->exercise();
|
||||
$first = $this->moduleWith('Modul alt', $exercise['version'], ['a']);
|
||||
$revised = $content->publishElementVersion($exercise['textA']->element, 'Neuer Wortlaut.');
|
||||
$second = $content->publishComposition($exercise['version']->composition, [
|
||||
['role' => 'Durchführung A', 'target' => $revised, 'variant' => 'a'],
|
||||
['role' => 'Film A', 'target' => $exercise['filmA'], 'variant' => 'a'],
|
||||
], null, null, [], [['key' => 'a', 'name' => 'Mit Film']]);
|
||||
$newer = $this->moduleWith('Modul neu', $second, ['a']);
|
||||
$articles = app(ArticleService::class);
|
||||
$articles->publishRelease($articles->create('alt'), $first, 'Alt.');
|
||||
$articles->publishRelease($articles->create('neu'), $newer, 'Neu.');
|
||||
|
||||
$usage = app(ExerciseUsage::class)->forComposition($exercise['version']->composition);
|
||||
|
||||
$this->assertCount(2, $usage);
|
||||
$this->assertSame(['alt'], collect($usage[0]['releases'])->map(fn (array $row) => $row['article']->code)->all());
|
||||
$this->assertSame(['neu'], collect($usage[1]['releases'])->map(fn (array $row) => $row['article']->code)->all());
|
||||
$this->assertInstanceOf(ArticleRelease::class, $usage[0]['releases'][0]['release']);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user