Lege einen wiederholbaren Pruefbestand fuer die Bibliothek an
Deploy Test / test (push) Successful in 17s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 08:36:06 +01:00
1 parent c99a957e6f
commit abcdc6908e
3 files changed
+97 -1

No files matched your search

@@ -0,0 +1,81 @@
<?php
namespace App\Console\Commands;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\OfferService;
use App\Models\User;
use Illuminate\Console\Command;
class SeedLibraryReview extends Command
{
protected $signature = 'library:review-fixture {--actor=}';
protected $description = 'Legt einmalig einen gekennzeichneten Prüfbestand für die Bibliothek an';
public function handle(
ContentService $content,
ArticleService $articles,
OfferService $offers,
CompositionDisplayRelease $display,
): int {
$existing = Composition::query()->where('designation', 'Prüfprogramm Abstand')->first();
if ($existing !== null) {
$this->info('Prüfbestand ist bereits vorhanden.');
return self::SUCCESS;
}
$actor = User::query()->find($this->option('actor')) ?? User::query()->orderBy('id')->first();
if ($actor === null) {
$this->error('Es gibt kein Konto, das die Anzeigefreigabe zeichnen kann.');
return self::FAILURE;
}
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
if ($kind === null) {
$this->error('Die Inhaltsart Programm fehlt.');
return self::FAILURE;
}
$sheet = $content->publishElementVersion(
$content->createElement('text', 'document', 'Prüfblatt Abstand'),
'Gekennzeichneter Prüftext. Kein Veröffentlichungstext.',
);
$composition = $content->createComposition('Prüfprogramm Abstand');
$composition->editorial_content_kind_id = $kind->id;
$composition->display_title = 'Prüfprogramm Abstand';
$composition->summary = 'Gekennzeichneter Prüfbestand für die Testinstanz.';
$composition->thumbnail_error = 'Prüfhinweis: kein Vorschaubild.';
$composition->save();
$version = $content->publishComposition($composition, [
['role' => 'Blatt', 'target' => $sheet],
], $actor, 'Prüfbestand', [
'learning_goal' => 'Den Prüfaufbau in der Bibliothek sehen.',
'duration_minutes' => 5,
'material_note' => 'Nur der Prüftext.',
]);
$article = $articles->create('pruef-abstand');
$articles->publishRelease($article, $version, 'Prüffassung.');
$rights = $offers->createRightsProfile('Prüfblatt ansehen', 'ehrenamtlich', [
'document' => ['ansehen', 'laden'],
]);
$offer = $offers->create('Prüfprogramm Abstand');
$offers->activate($offer, [
['target' => $article->fresh(), 'rights' => $rights],
], ['grant_kind' => 'auf_abruf', 'composition_version_id' => $version->id]);
$display->release($version, $actor, 'Prüffreigabe');
$this->info('Prüfbestand angelegt. Angebot: Prüfprogramm Abstand.');
return self::SUCCESS;
}
}
+5 -1
View File
@@ -51,7 +51,11 @@ public function index(User $user): array
continue;
}
$materials[$article->id] = [
$elementId = $release?->rootElementVersion?->element_id;
$key = $composition !== null
? 'komposition-'.$composition->id
: ($elementId !== null ? 'element-'.$elementId : 'artikel-'.$article->id);
$materials[$key] = [
'article' => $article,
'title' => app(CourseOutline::class)->title($article),
'kind' => app(CourseOutline::class)->kindLabel($article),
+11
View File
@@ -3,6 +3,7 @@
namespace Tests\Feature;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
@@ -62,4 +63,14 @@ public function test_didactic_fields_partial_coverage_and_public_page_follow_the
$this->get('/medien/bibliothek/geheim.jpg')->assertNotFound();
}
public function test_review_fixture_can_be_repeated(): void
{
$actor = User::factory()->create();
$this->artisan('library:review-fixture', ['--actor' => $actor->id])->assertSuccessful();
$this->artisan('library:review-fixture', ['--actor' => $actor->id])->assertSuccessful();
$this->assertSame(1, Composition::query()->where('designation', 'Prüfprogramm Abstand')->count());
}
}