Zeige Nutzbarkeit, Didaktik und oeffentliche Programmfassung
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5e763d15ec
commit
c99a957e6f
17 files changed
+307
-6
No files matched your search
@@ -86,6 +86,7 @@ public function publishComposition(
|
||||
array $members,
|
||||
?User $confirmedBy = null,
|
||||
?string $note = null,
|
||||
array $didactic = [],
|
||||
): CompositionVersion {
|
||||
if ($members === []) {
|
||||
throw new DomainRuleException('Eine Komposition braucht mindestens ein Mitglied.');
|
||||
@@ -97,13 +98,16 @@ public function publishComposition(
|
||||
$this->assertReadyMember($member['target']);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($composition, $members, $confirmedBy, $note): CompositionVersion {
|
||||
return DB::transaction(function () use ($composition, $members, $confirmedBy, $note, $didactic): CompositionVersion {
|
||||
$number = ((int) $composition->versions()->max('number')) + 1;
|
||||
$version = $composition->versions()->create([
|
||||
'number' => $number,
|
||||
'status' => ContentVersionStatus::Entwurf,
|
||||
'members_hash' => $this->membersHash($members),
|
||||
'resolved_hash' => 'pending',
|
||||
'learning_goal' => $this->optionalText($didactic['learning_goal'] ?? null),
|
||||
'duration_minutes' => isset($didactic['duration_minutes']) ? (int) $didactic['duration_minutes'] : null,
|
||||
'material_note' => $this->optionalText($didactic['material_note'] ?? null),
|
||||
]);
|
||||
|
||||
foreach (array_values($members) as $index => $member) {
|
||||
@@ -219,6 +223,17 @@ private function membersHash(array $members): string
|
||||
return hash('sha256', json_encode($list, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
private function optionalText(mixed $value): ?string
|
||||
{
|
||||
if (! is_string($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
private function required(string $value, string $message): string
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
Reference in new issue
Block a user