Gemeinsame Dokumentation für mehrere Beteiligte eines Vorgangs
CI / build-and-test (push) Canceled after 0s

Ein Dokumentationseintrag kann jetzt weitere Schüler*innen betreffen
(Documentation.AdditionalStudentIds, StudentId bleibt Hauptperson). Der
Eintrag existiert nur einmal, erscheint aber im Dokumentations-Tab jeder
beteiligten Person. Der Dokumentations-Dialog bietet in beiden
Vorgänge-Tabs "Betrifft außerdem" mit den Beteiligten des Vorgangs an.
Klassenlehrer-Listen, WebUntis-Abgleich, Löschfristen und
Referenzzählung berücksichtigen die weiteren Beteiligten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-28 08:43:24 +02:00
1 parent e091b5c8de
commit 9a84bbaa38
23 files changed
+396 -49

No files matched your search

@@ -104,6 +104,12 @@ public partial class DocumentationDialogViewModel : ObservableObject
[ObservableProperty] private StudentOption? _selectedStudent;
[ObservableProperty] private string _studentError = "";
// Weitere Beteiligte (Documentation.AdditionalStudentIds) — nur angeboten, wenn der Aufrufer
// Kandidaten mitgibt (z.B. die übrigen Schüler*innen eines Vorgangs). Die Hauptperson steht
// mit in der Liste, wird aber ausgeblendet (CoStudentChoice.IsPrimary).
public List<CoStudentChoice> CoStudents { get; }
public bool HasCoStudents => CoStudents.Any(c => !c.IsPrimary);
[ObservableProperty] private string _typeName = DocumentationTypeDisplay.Options[0];
[ObservableProperty] private string _dateText = DateOnly.FromDateTime(DateTime.Today).ToString("dd.MM.yyyy");
[ObservableProperty] private string _title = "";
@@ -163,8 +169,11 @@ public partial class DocumentationDialogViewModel : ObservableObject
public Documentation? Result { get; private set; }
/// <param name="coStudentOptions">Kandidaten für "Betrifft außerdem" — ohne Angabe bleiben
/// bestehende weitere Beteiligte eines bearbeiteten Eintrags unverändert erhalten.</param>
public DocumentationDialogViewModel(Guid studentId, Documentation? editing, IAttachmentStorage attachmentStorage,
List<StudentOption>? studentOptions = null, Guid? contextGroupId = null, bool isNewDraft = false)
List<StudentOption>? studentOptions = null, Guid? contextGroupId = null, bool isNewDraft = false,
List<StudentOption>? coStudentOptions = null)
{
_studentId = studentId;
_editing = editing;
@@ -174,8 +183,17 @@ public partial class DocumentationDialogViewModel : ObservableObject
_attachmentStorage = attachmentStorage;
_contextGroupId = contextGroupId;
StudentOptions = studentOptions ?? [];
CoStudents = (coStudentOptions ?? [])
.Where(o => o.Id != Guid.Empty)
.DistinctBy(o => o.Id)
.Select(o => new CoStudentChoice(o.Id, o.Name)
{
IsSelected = editing?.AdditionalStudentIds.Contains(o.Id) == true,
})
.ToList();
if (CanPickStudent)
SelectedStudent = StudentOptions.FirstOrDefault(s => s.Id == studentId);
UpdatePrimaryCoStudent();
if (editing is null) return;
TypeName = DocumentationTypeDisplay.Label(editing.Type);
@@ -212,6 +230,22 @@ public partial class DocumentationDialogViewModel : ObservableObject
foreach (var tag in editing.Tags) Tags.Add(tag);
}
// Beim Bearbeiten bleibt die Hauptperson die des bestehenden Eintrags (Save() übernimmt die
// Auswahl dann nicht), sonst folgt sie der Bezug-Auswahl.
private Guid PrimaryStudentId =>
_editing is not null && !_isNewDraft ? _editing.StudentId
: CanPickStudent ? SelectedStudent?.Id ?? Guid.Empty
: _editing?.StudentId ?? _studentId;
partial void OnSelectedStudentChanged(StudentOption? value) => UpdatePrimaryCoStudent();
private void UpdatePrimaryCoStudent()
{
var primary = PrimaryStudentId;
foreach (var c in CoStudents) c.IsPrimary = c.Id == primary;
OnPropertyChanged(nameof(HasCoStudents));
}
partial void OnTypeNameChanged(string value)
{
OnPropertyChanged(nameof(IsConversation));
@@ -348,6 +382,14 @@ public partial class DocumentationDialogViewModel : ObservableObject
var type = DocumentationTypeDisplay.FromLabel(TypeName);
var effectiveStudentId = CanPickStudent ? SelectedStudent!.Id : _studentId;
Result = _editing ?? new Documentation { StudentId = effectiveStudentId, GroupId = _contextGroupId };
// Nicht angebotene weitere Beteiligte bleiben erhalten (z.B. beim Bearbeiten aus dem Schülerdatensatz,
// wo keine Kandidaten bekannt sind), angebotene folgen der Auswahl.
var offered = CoStudents.Select(c => c.Id).ToHashSet();
Result.AdditionalStudentIds = Result.AdditionalStudentIds.Where(id => !offered.Contains(id))
.Concat(CoStudents.Where(c => c.IsSelected).Select(c => c.Id))
.Where(id => id != Result.StudentId && id != Guid.Empty)
.Distinct()
.ToList();
Result.Type = type;
Result.Date = date;
Result.Title = Title.Trim();
@@ -413,6 +455,14 @@ public partial class DocumentationDialogViewModel : ObservableObject
}
}
public partial class CoStudentChoice(Guid id, string name) : ObservableObject
{
public Guid Id { get; } = id;
public string Name { get; } = name;
[ObservableProperty] private bool _isSelected;
[ObservableProperty] private bool _isPrimary;
}
public class AttachmentItem(string storageId, string fileName, long sizeBytes, DateTime uploadedAt)
{
public const string HazardAssessmentSuffix = ".gbu.json";
@@ -458,6 +508,10 @@ public partial class DocumentationItem : ObservableObject
public string OtherGroupLabel { get; }
/// Dimmt Einträge aus anderen Lerngruppen im Gruppen-Tab, ohne sie zu verstecken.
public double ContentOpacity => IsOwnGroup ? 1.0 : 0.55;
/// Nur im Schülerdatensatz gefüllt: die übrigen Beteiligten eines gemeinsamen Eintrags
/// (Documentation.AdditionalStudentIds bzw. Hauptperson), damit er dort als geteilt erkennbar ist.
public string SharedWith { get; init; } = "";
public bool IsShared => SharedWith != "";
[ObservableProperty] private bool _isRevealed;