Ordne Übungsabschnitte im Medienbestand ein und filtere Materialarten mehrfach
- Medium anlegen: Pflichtfeld Fachliche Materialart (serverseitig geprüft) - Materialart Übungsabschnitt (automatisch) für Abschnitte im Übungseditor und aus Shinkan, mit Verweis auf die Übung - Medienmanager: Checkboxen statt Dropdown, Start ohne Übungsabschnitte, persönlicher Standard je Konto - Zuordnung des Bestands nur bei belegter Herkunft; Übungsabschnitte nie öffentlich Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
99122ddfee
commit
ad581cb545
29 files changed
+1321
-25
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Catalog\ExerciseSections;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Übungsabschnitte im gemeinsamen Medienbestand (Auftrag Übungsverwaltung, Abschnitt 9), rein additiv:
|
||||
*
|
||||
* - `content_elements.origin_composition_id` hält fest, für welche Übung ein Textabschnitt angelegt wurde.
|
||||
* - Die fachliche Materialart `uebungsabschnitt` entsteht als System-Art ohne wählbaren Kontext: Sie wird nur
|
||||
* automatisch gesetzt.
|
||||
* - `user_view_defaults` hält den persönlichen Standard der Filter je Konto und Ansicht.
|
||||
*
|
||||
* Der Rückfall auf den vorherigen Programmstand setzt nur den Code zurück. Dieser kennt die Spalte und die Tabelle nicht
|
||||
* und behandelt die neue Materialart wie jede andere Zeile der redaktionellen Stammdaten. Texte bleiben lesbar,
|
||||
* auslieferbar und bearbeitbar; es geht nichts verloren.
|
||||
*
|
||||
* Bestehende Texte werden nur zugeordnet, wenn ihre Herkunft belegt ist (siehe ExerciseSections::backfill()).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->foreignId('origin_composition_id')->nullable()->constrained('compositions')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::create('user_view_defaults', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('view');
|
||||
$table->json('filters');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'view']);
|
||||
});
|
||||
|
||||
$now = now();
|
||||
DB::table('editorial_content_kinds')->insertOrIgnore([
|
||||
'slug' => 'uebungsabschnitt',
|
||||
'label' => 'Übungsabschnitt',
|
||||
'sort_order' => 26,
|
||||
'is_active' => true,
|
||||
'contexts' => json_encode([]),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
app(ExerciseSections::class)->backfill();
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('content_elements')
|
||||
->whereIn('editorial_content_kind_id', DB::table('editorial_content_kinds')->where('slug', 'uebungsabschnitt')->select('id'))
|
||||
->update(['editorial_content_kind_id' => null]);
|
||||
DB::table('editorial_content_kinds')->where('slug', 'uebungsabschnitt')->delete();
|
||||
|
||||
Schema::dropIfExists('user_view_defaults');
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('origin_composition_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user