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
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user