Compare commits
2
Commits
845cc5fc4c
...
455f7765e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
455f7765e4 | ||
|
|
51e55e1464 |
No files matched your search
@@ -17,7 +17,8 @@ public sealed class McpToolsTests
|
||||
{
|
||||
"download_lesson_attachment", "get_competency_catalog", "get_competency_plan_versions",
|
||||
"get_exams", "get_grades",
|
||||
"get_groups", "get_lesson_plans", "get_named_untis_absence_pattern", "get_schedule",
|
||||
"get_groups", "get_lesson_plans", "get_named_untis_absence_pattern",
|
||||
"get_participation_sessions", "get_schedule",
|
||||
"get_students", "get_subjects", "get_time_entries", "get_untis_absence_rows",
|
||||
"get_untis_hub_status", "list_letter_templates", "render_letter",
|
||||
},
|
||||
@@ -31,10 +32,12 @@ public sealed class McpToolsTests
|
||||
new[]
|
||||
{
|
||||
"add_competency_item", "add_lesson_attachment", "add_lesson_competency", "add_lesson_phase",
|
||||
"add_session_competency",
|
||||
"apply_untis_absence_status", "create_competency_domain", "create_competency_plan_version",
|
||||
"create_grade_entry", "create_lesson",
|
||||
"create_subject", "create_time_entry", "create_unit", "move_lesson", "remove_competency_item",
|
||||
"remove_lesson_competency", "remove_lesson_phase", "update_competency_domain",
|
||||
"remove_lesson_competency", "remove_lesson_phase", "remove_session_competency",
|
||||
"update_competency_domain",
|
||||
"update_competency_item", "update_competency_plan_version", "update_group_competency_version",
|
||||
"update_lesson", "update_lesson_phase", "update_student_group_assignment",
|
||||
"update_subject", "update_unit",
|
||||
@@ -1026,4 +1029,91 @@ public sealed class McpToolsTests
|
||||
Assert.False(result.Applied);
|
||||
Assert.Equal(0, confirmation.CallCount);
|
||||
}
|
||||
|
||||
// ── ParticipationTools ───────────────────────────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void GetParticipationSessions_LiefertDatumKommentarUndKompetenzenDerGruppe()
|
||||
{
|
||||
var groupId = Guid.NewGuid();
|
||||
var item = new CompetencyItem { Code = "K1", Description = "Kompetenz" };
|
||||
var session = new ParticipationSession
|
||||
{
|
||||
GroupId = groupId, Date = new DateOnly(2026, 1, 12), Comment = "Sitzplan",
|
||||
Competencies = [new CompetencyReference { ItemId = item.Id, Code = item.Code, Description = item.Description }],
|
||||
};
|
||||
var sessions = new FakeSessions([session]);
|
||||
var tool = new ParticipationTools(sessions, new FakeCompetencyDomains(), new FakeMcpConfirmation());
|
||||
|
||||
var result = Assert.Single(tool.GetParticipationSessions(groupId));
|
||||
|
||||
Assert.Equal(session.Id, result.Id);
|
||||
Assert.Equal("Sitzplan", result.Comment);
|
||||
var competency = Assert.Single(result.Competencies);
|
||||
Assert.Equal(item.Id, competency.ItemId);
|
||||
Assert.Equal("K1", competency.Code);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddSessionCompetency_NutzerBestaetigt_OrdnetKompetenzZu()
|
||||
{
|
||||
var session = new ParticipationSession { Date = new DateOnly(2026, 1, 12) };
|
||||
var sessions = new FakeSessions([session]);
|
||||
var domains = new FakeCompetencyDomains();
|
||||
var item = new CompetencyItem { Code = "K1", Description = "Kompetenz" };
|
||||
domains.Add(new CompetencyDomain { Name = "Bereich", Items = [item] });
|
||||
var tool = new ParticipationTools(sessions, domains, new FakeMcpConfirmation());
|
||||
|
||||
var result = await tool.AddSessionCompetency(session.Id, item.Id);
|
||||
|
||||
Assert.True(result.Applied);
|
||||
var stored = Assert.Single(sessions.GetById(session.Id)!.Competencies);
|
||||
Assert.Equal(item.Id, stored.ItemId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddSessionCompetency_UnbekannteId_LiefertFehlerOhneNachfrage()
|
||||
{
|
||||
var session = new ParticipationSession { Date = new DateOnly(2026, 1, 12) };
|
||||
var sessions = new FakeSessions([session]);
|
||||
var confirmation = new FakeMcpConfirmation();
|
||||
var tool = new ParticipationTools(sessions, new FakeCompetencyDomains(), confirmation);
|
||||
|
||||
var result = await tool.AddSessionCompetency(session.Id, Guid.NewGuid());
|
||||
|
||||
Assert.False(result.Applied);
|
||||
Assert.Equal(0, confirmation.CallCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveSessionCompetency_NutzerBestaetigt_EntferntKompetenz()
|
||||
{
|
||||
var item = new CompetencyItem { Code = "K1", Description = "Kompetenz" };
|
||||
var session = new ParticipationSession
|
||||
{
|
||||
Date = new DateOnly(2026, 1, 12),
|
||||
Competencies = [new CompetencyReference { ItemId = item.Id, Code = item.Code, Description = item.Description }],
|
||||
};
|
||||
var sessions = new FakeSessions([session]);
|
||||
var tool = new ParticipationTools(sessions, new FakeCompetencyDomains(), new FakeMcpConfirmation());
|
||||
|
||||
var result = await tool.RemoveSessionCompetency(session.Id, item.Id);
|
||||
|
||||
Assert.True(result.Applied);
|
||||
Assert.Empty(sessions.GetById(session.Id)!.Competencies);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveSessionCompetency_NichtZugeordnet_LiefertFehlerOhneNachfrage()
|
||||
{
|
||||
var session = new ParticipationSession { Date = new DateOnly(2026, 1, 12) };
|
||||
var sessions = new FakeSessions([session]);
|
||||
var confirmation = new FakeMcpConfirmation();
|
||||
var tool = new ParticipationTools(sessions, new FakeCompetencyDomains(), confirmation);
|
||||
|
||||
var result = await tool.RemoveSessionCompetency(session.Id, Guid.NewGuid());
|
||||
|
||||
Assert.False(result.Applied);
|
||||
Assert.Equal(0, confirmation.CallCount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Desktop.Tests;
|
||||
|
||||
/// Nutzer-Feedback: Kompetenzen je Sitzung von Hand zu bewerten ist zu aufwendig - eine Schätzung
|
||||
/// aus dem allgemeinen Mitarbeit-Durchschnitt ersetzt die manuelle Erfassung im Regelfall.
|
||||
public sealed class ParticipationCompetencyEstimateTests
|
||||
{
|
||||
private static readonly AspectColumnDef Quality = new(new ParticipationAspect { Key = "quality", ValueType = AspectValueType.Scale5 });
|
||||
private static readonly AspectColumnDef Quantity = new(new ParticipationAspect { Key = "quantity", ValueType = AspectValueType.Scale5 });
|
||||
private static readonly AspectColumnDef Points = new(new ParticipationAspect { Key = "points", ValueType = AspectValueType.Points, MaxPoints = 4 });
|
||||
|
||||
[Fact]
|
||||
public void Estimate_OhneBewertungen_LiefertNull()
|
||||
{
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate([], [Quality], null);
|
||||
|
||||
Assert.Null(estimate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_MittelwertMehrererAspekte_RundetAufNaechstenSchritt()
|
||||
{
|
||||
var ratings = new List<AspectRating>
|
||||
{
|
||||
new() { Key = "quality", Value = 1 },
|
||||
new() { Key = "quantity", Value = 2 },
|
||||
};
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality, Quantity], null);
|
||||
|
||||
Assert.Equal(2, estimate); // Mittelwert 1.5 -> AwayFromZero gerundet auf 2
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_Spitzentag_HebtDieSchaetzungAn()
|
||||
{
|
||||
var ratings = new List<AspectRating> { new() { Key = "quality", Value = 0 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality], DayHighlightKind.Standout);
|
||||
|
||||
Assert.Equal(1, estimate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_Schlaftag_SenktDieSchaetzung()
|
||||
{
|
||||
var ratings = new List<AspectRating> { new() { Key = "quality", Value = 0 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality], DayHighlightKind.Sleepy);
|
||||
|
||||
Assert.Equal(-1, estimate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_SchlechterTag_SenktDieSchaetzungGleichWieSchlaftag()
|
||||
{
|
||||
var ratings = new List<AspectRating> { new() { Key = "quality", Value = 0 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality], DayHighlightKind.Rough);
|
||||
|
||||
Assert.Equal(-1, estimate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_KapptAufDenGueltigenBereich()
|
||||
{
|
||||
var ratings = new List<AspectRating> { new() { Key = "quality", Value = 2 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality], DayHighlightKind.Standout);
|
||||
|
||||
Assert.Equal(2, estimate); // 2 + 1 würde 3 ergeben, wird auf 2 gekappt
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_BeruecksichtigtNurBewerteteAspekte()
|
||||
{
|
||||
// "quantity" wurde nie bewertet - fließt nicht als 0 in den Mittelwert ein.
|
||||
var ratings = new List<AspectRating> { new() { Key = "quality", Value = 2 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Quality, Quantity], null);
|
||||
|
||||
Assert.Equal(2, estimate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Estimate_PunkteAspekt_WirdAufDieMinus2Bis2AchseNormiert()
|
||||
{
|
||||
// 4 von 4 Punkten -> oberes Ende der Achse (+2).
|
||||
var ratings = new List<AspectRating> { new() { Key = "points", Value = 4 } };
|
||||
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(ratings, [Points], null);
|
||||
|
||||
Assert.Equal(2, estimate);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,49 @@ public sealed class ParticipationSessionEditingTests
|
||||
Assert.Null(sessions.GetById(session.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Sitzung_MitBewertetenAspektenAberOhneKompetenzbewertung_ZeigtGeschaetztenWert()
|
||||
{
|
||||
var subjectId = Guid.NewGuid();
|
||||
var group = new LearningGroup { Name = "8a", SchoolYear = "2026/27", SubjectId = subjectId, GradeLevel = 8 };
|
||||
var student = new Student { FirstName = "Ada", LastName = "Lovelace" };
|
||||
var item = new CompetencyItem { Code = "K1", Description = "Kompetenz" };
|
||||
var session = new ParticipationSession
|
||||
{
|
||||
GroupId = group.Id, Date = new DateOnly(2026, 8, 19),
|
||||
Competencies = [new CompetencyReference { ItemId = item.Id, Code = item.Code, Description = item.Description }],
|
||||
};
|
||||
var sessions = new FakeSessions([session]);
|
||||
var entries = new FakeEntries();
|
||||
entries.Add(new ParticipationEntry
|
||||
{
|
||||
SessionId = session.Id, StudentId = student.Id,
|
||||
Ratings = [new AspectRating { Key = "quality", Value = 2 }],
|
||||
});
|
||||
var aspects = new FakeAspects();
|
||||
aspects.Save(new ParticipationAspect
|
||||
{
|
||||
Key = "quality", Label = "Qualität", ValueType = AspectValueType.Scale5, IsActive = true,
|
||||
});
|
||||
var versions = new FakeCompetencyCatalogVersions();
|
||||
var version = versions.GetOrCreateDefault(subjectId);
|
||||
var domains = new FakeCompetencyDomains();
|
||||
domains.Add(new CompetencyDomain
|
||||
{
|
||||
SubjectId = subjectId, GradeLevel = 8, VersionId = version.Id, Name = "Bereich", Items = [item],
|
||||
});
|
||||
var vm = new ParticipationTabViewModel(sessions, entries, aspects, new FakeStudents([student]),
|
||||
new FakeMemberships([]), new FakeGroups([group]), domains, versions);
|
||||
vm.Initialize(group.Id, group.SchoolYear);
|
||||
|
||||
vm.SelectedSession = vm.Sessions.Single(s => s.Id == session.Id);
|
||||
|
||||
var row = Assert.Single(vm.StudentRows);
|
||||
var cell = Assert.Single(row.CompetencyCells);
|
||||
Assert.True(cell.IsEstimated);
|
||||
Assert.Equal(2, cell.Value); // einziger bewerteter Aspekt "quality" = 2, kein Tageshighlight
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LoeschenBefehl_BrichtBeiAbgelehnterBestaetigungAb()
|
||||
{
|
||||
|
||||
@@ -78,4 +78,16 @@ public sealed class RatingCellTests
|
||||
var cell = new RatingCell(Guid.NewGuid(), "k", 2);
|
||||
Assert.Equal("++", cell.DisplayLabel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetValue_AufGeschaetzterZelle_MarkiertSieAlsBestaetigt()
|
||||
{
|
||||
var cell = new RatingCell(Guid.NewGuid(), "k", 1, isEstimated: true);
|
||||
Assert.True(cell.IsEstimated);
|
||||
|
||||
cell.SetValue(1); // bestätigt zufällig denselben Wert wie die Schätzung
|
||||
|
||||
Assert.False(cell.IsEstimated);
|
||||
Assert.Equal(1, cell.Value);
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,7 @@ public static class AppBootstrapper
|
||||
services.AddSingleton<StudentAttendanceCalendarService>();
|
||||
services.AddSingleton<CompetencyTools>();
|
||||
services.AddSingleton<GroupTools>();
|
||||
services.AddSingleton<ParticipationTools>();
|
||||
services.AddSingleton<UntisComparisonTools>();
|
||||
services.AddSingleton<McpServerHostedService>();
|
||||
services.AddSingleton<McpClientRegistrationService>();
|
||||
|
||||
@@ -32,13 +32,15 @@ public sealed class McpServerHostedService : IAsyncDisposable
|
||||
StudentTools studentTools, ExamTools examTools, GradeTools gradeTools,
|
||||
ScheduleTools scheduleTools, TimeEntryTools timeEntryTools, LessonPlanTools lessonPlanTools,
|
||||
GroupMembershipTools groupMembershipTools, LetterTemplateTools letterTemplateTools,
|
||||
CompetencyTools competencyTools, UntisComparisonTools untisComparisonTools, GroupTools groupTools)
|
||||
CompetencyTools competencyTools, UntisComparisonTools untisComparisonTools, GroupTools groupTools,
|
||||
ParticipationTools participationTools)
|
||||
{
|
||||
_settings = settings;
|
||||
_logger = logger;
|
||||
_serverOptions = BuildServerOptions(
|
||||
studentTools, examTools, gradeTools, scheduleTools, timeEntryTools, lessonPlanTools,
|
||||
groupMembershipTools, letterTemplateTools, competencyTools, untisComparisonTools, groupTools);
|
||||
groupMembershipTools, letterTemplateTools, competencyTools, untisComparisonTools, groupTools,
|
||||
participationTools);
|
||||
}
|
||||
|
||||
/// <summary>Setzt die Pipe-Server-Accept-Loop auf, falls aktiviert. Ohne Wirkung, falls
|
||||
@@ -115,7 +117,8 @@ public sealed class McpServerHostedService : IAsyncDisposable
|
||||
StudentTools studentTools, ExamTools examTools, GradeTools gradeTools,
|
||||
ScheduleTools scheduleTools, TimeEntryTools timeEntryTools, LessonPlanTools lessonPlanTools,
|
||||
GroupMembershipTools groupMembershipTools, LetterTemplateTools letterTemplateTools,
|
||||
CompetencyTools competencyTools, UntisComparisonTools untisComparisonTools, GroupTools groupTools)
|
||||
CompetencyTools competencyTools, UntisComparisonTools untisComparisonTools, GroupTools groupTools,
|
||||
ParticipationTools participationTools)
|
||||
{
|
||||
var toolCollection = new McpServerPrimitiveCollection<McpServerTool>();
|
||||
|
||||
@@ -187,6 +190,8 @@ public sealed class McpServerHostedService : IAsyncDisposable
|
||||
"Listet anonymisierte Fehlzeiten-Diskrepanzen einer Lerngruppe gegenüber WebUntis (keine Schülernamen, nur eine row-id je Zeile).");
|
||||
AddReadTool(untisComparisonTools.GetNamedUntisAbsencePattern, "get_named_untis_absence_pattern",
|
||||
"Liefert Fehlzeiten MIT Schülername für explizit angegebene Schüler-IDs - Ausnahme von der sonstigen Anonymisierung, erfordert jedes Mal eine gesonderte Nutzerbestätigung.");
|
||||
AddReadTool(participationTools.GetParticipationSessions, "get_participation_sessions",
|
||||
"Listet Mitarbeit-Sitzungen einer Lerngruppe (Datum, Kommentar, zugeordnete Kompetenzen), ohne die einzelnen Schülerbewertungen.");
|
||||
|
||||
AddWriteTool(timeEntryTools.CreateTimeEntry, "create_time_entry",
|
||||
"Schlägt einen neuen Zeiterfassungs-Eintrag vor (Bestätigung durch den Nutzer nötig).");
|
||||
@@ -236,6 +241,10 @@ public sealed class McpServerHostedService : IAsyncDisposable
|
||||
"Ändert Name/Standardstatus einer Bildungsplan-Version (Bestätigung durch den Nutzer nötig).");
|
||||
AddWriteTool(groupTools.UpdateGroupCompetencyVersion, "update_group_competency_version",
|
||||
"Setzt oder löscht die Bildungsplan-Version eines Kurses/einer Klasse (Bestätigung durch den Nutzer nötig).");
|
||||
AddWriteTool(participationTools.AddSessionCompetency, "add_session_competency",
|
||||
"Ordnet einer Mitarbeit-Sitzung eine Kompetenz zu (Bestätigung durch den Nutzer nötig).");
|
||||
AddWriteTool(participationTools.RemoveSessionCompetency, "remove_session_competency",
|
||||
"Entfernt eine Kompetenz von einer Mitarbeit-Sitzung (Bestätigung durch den Nutzer nötig).");
|
||||
AddWriteTool(untisComparisonTools.ApplyUntisAbsenceStatus, "apply_untis_absence_status",
|
||||
"Übernimmt einen Statusvorschlag für eine über get_untis_absence_rows gelieferte row-id (Bestätigung durch den Nutzer nötig, nennt keinen Schülernamen).");
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public static class McpToolScope
|
||||
"get_untis_hub_status",
|
||||
"get_untis_absence_rows",
|
||||
"get_named_untis_absence_pattern",
|
||||
"get_participation_sessions",
|
||||
];
|
||||
|
||||
/// <summary>Write-Tools (Phase 2+3) — jeder Aufruf läuft über <see cref="IMcpConfirmationService"/>,
|
||||
@@ -67,6 +68,8 @@ public static class McpToolScope
|
||||
"create_competency_plan_version",
|
||||
"update_competency_plan_version",
|
||||
"update_group_competency_version",
|
||||
"add_session_competency",
|
||||
"remove_session_competency",
|
||||
"apply_untis_absence_status",
|
||||
];
|
||||
|
||||
|
||||
@@ -39,6 +39,12 @@ public record LessonAttachmentDto(string StorageId, string FileName, long SizeBy
|
||||
/// Zusatzabfrage lesen kann, auch wenn das Katalog-Item inzwischen gelöscht wurde.</summary>
|
||||
public record CompetencyReferenceDto(Guid ItemId, string Code, string Description);
|
||||
|
||||
/// <summary>Mitarbeit-Sitzung (siehe ParticipationTools) - bewusst ohne die einzelnen
|
||||
/// Schülerbewertungen (personenbezogen, nicht über MCP erreichbar, siehe Klassenkommentar).</summary>
|
||||
public record ParticipationSessionDto(
|
||||
Guid Id, Guid GroupId, DateOnly Date, Guid? LessonId, string? Comment,
|
||||
List<CompetencyReferenceDto> Competencies);
|
||||
|
||||
public record LessonDto(
|
||||
Guid Id, Guid UnitId, Guid GroupId, DateOnly Date, int? LessonNumber, string Topic,
|
||||
string? Homework, string? PlanningIdeas, LessonStatus Status, List<CompetencyReferenceDto> Competencies,
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.ComponentModel;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
|
||||
namespace LehrerApp.Desktop.Services.Mcp.Tools;
|
||||
|
||||
/// <summary>MCP-Tools für Mitarbeit-Sitzungen (<see cref="ParticipationSession"/>) - Nutzer-Nachtrag.
|
||||
/// Bewusst nur die Sitzung selbst (Datum, Kommentar, Kompetenzzuordnung), NICHT die einzelnen
|
||||
/// Schülerbewertungen (<see cref="ParticipationEntry"/>/<see cref="AspectRating"/>): das wären
|
||||
/// personenbezogene Bewertungsdaten je Schüler, analog zu Documentation/Vorgang bewusst nicht über
|
||||
/// MCP erreichbar (siehe McpToolScope). "add_session_competency"/"remove_session_competency" folgen
|
||||
/// demselben Muster wie LessonPlanTools.AddLessonCompetency/RemoveLessonCompetency: einzelne
|
||||
/// Kompetenz statt ganze Liste ersetzen, um kein "letzter Schreiber gewinnt" zu riskieren, und mit
|
||||
/// Katalog-Validierung der übergebenen itemId.</summary>
|
||||
public class ParticipationTools(
|
||||
IParticipationSessionRepository sessions, ICompetencyDomainRepository competencyDomains,
|
||||
IMcpConfirmationService confirmation)
|
||||
{
|
||||
[Description("Listet Mitarbeit-Sitzungen einer Lerngruppe (Datum, Kommentar, zugeordnete Kompetenzen) - ohne die einzelnen Schülerbewertungen.")]
|
||||
public List<ParticipationSessionDto> GetParticipationSessions(
|
||||
[Description("Lerngruppen-ID, aus get_groups.")] Guid groupId) =>
|
||||
sessions.GetByGroup(groupId).Select(ToDto).ToList();
|
||||
|
||||
[Description("Ordnet einer Mitarbeit-Sitzung eine Kompetenz aus dem Katalog zu (siehe get_competency_catalog). Muss der Nutzer erst bestätigen.")]
|
||||
public async Task<WriteResultDto> AddSessionCompetency(
|
||||
[Description("ID der Mitarbeit-Sitzung, aus get_participation_sessions.")] Guid sessionId,
|
||||
[Description("ID der Einzelkompetenz, aus get_competency_catalog.")] Guid itemId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var session = sessions.GetById(sessionId);
|
||||
if (session is null) return new WriteResultDto(false, null, "Unbekannte Sitzungs-ID.");
|
||||
var item = FindCompetencyItem(itemId);
|
||||
if (item is null) return new WriteResultDto(false, null, "Unbekannte Kompetenz-ID.");
|
||||
if (session.Competencies.Any(c => c.ItemId == itemId))
|
||||
return new WriteResultDto(true, session.Id, "Kompetenz ist bereits zugeordnet.");
|
||||
|
||||
var message = $"Kompetenz „{item.Code}“ zur Mitarbeit-Sitzung vom {session.Date:dd.MM.yyyy} hinzufügen?";
|
||||
if (!await confirmation.ConfirmAsync("Kompetenz zuordnen?", message, ct))
|
||||
return new WriteResultDto(false, null, "Vom Nutzer abgelehnt oder nicht bestätigt.");
|
||||
|
||||
session.Competencies.Add(new CompetencyReference { ItemId = item.Id, Code = item.Code, Description = item.Description });
|
||||
sessions.Save(session);
|
||||
return new WriteResultDto(true, session.Id, "Kompetenz zugeordnet.");
|
||||
}
|
||||
|
||||
[Description("Entfernt eine Kompetenz von einer Mitarbeit-Sitzung. Muss der Nutzer erst bestätigen.")]
|
||||
public async Task<WriteResultDto> RemoveSessionCompetency(
|
||||
[Description("ID der Mitarbeit-Sitzung.")] Guid sessionId,
|
||||
[Description("ID der Einzelkompetenz, wie in get_participation_sessions hinterlegt.")] Guid itemId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var session = sessions.GetById(sessionId);
|
||||
if (session is null) return new WriteResultDto(false, null, "Unbekannte Sitzungs-ID.");
|
||||
var existing = session.Competencies.FirstOrDefault(c => c.ItemId == itemId);
|
||||
if (existing is null) return new WriteResultDto(false, null, "Diese Kompetenz ist dieser Sitzung nicht zugeordnet.");
|
||||
|
||||
var message = $"Kompetenz „{existing.Code}“ von der Mitarbeit-Sitzung vom {session.Date:dd.MM.yyyy} entfernen?";
|
||||
if (!await confirmation.ConfirmAsync("Kompetenz entfernen?", message, ct))
|
||||
return new WriteResultDto(false, null, "Vom Nutzer abgelehnt oder nicht bestätigt.");
|
||||
|
||||
session.Competencies.Remove(existing);
|
||||
sessions.Save(session);
|
||||
return new WriteResultDto(true, session.Id, "Kompetenz entfernt.");
|
||||
}
|
||||
|
||||
private CompetencyItem? FindCompetencyItem(Guid itemId) =>
|
||||
competencyDomains.GetAll().SelectMany(d => d.Items).FirstOrDefault(i => i.Id == itemId);
|
||||
|
||||
private static ParticipationSessionDto ToDto(ParticipationSession s) => new(
|
||||
s.Id, s.GroupId, s.Date, s.LessonId, s.Comment,
|
||||
s.Competencies.Select(c => new CompetencyReferenceDto(c.ItemId, c.Code, c.Description)).ToList());
|
||||
}
|
||||
@@ -443,10 +443,16 @@ public partial class ParticipationStudentRow : ObservableObject
|
||||
|
||||
// AspectKey trägt hier den Kompetenz-ItemId als String - reiner In-Memory-Transport
|
||||
// zwischen Zelle und Save-Callback (siehe SaveCompetencyRating), nie persistiert.
|
||||
// Ohne eigene Bewertung wird aus dem Mitarbeit-Durchschnitt der Sitzung geschätzt
|
||||
// (Nutzer-Feedback: manuelle Einzelerfassung je Kompetenz ist im Alltag zu aufwendig) -
|
||||
// die Schätzung wird NIE automatisch gespeichert, nur angezeigt (siehe RatingCell.IsEstimated);
|
||||
// ein Klick auf die Zelle setzt den Wert bewusst und persistiert ihn wie gehabt.
|
||||
var estimate = ParticipationCompetencyEstimate.Estimate(entry.Ratings, aspects, entry.DayHighlight);
|
||||
foreach (var competency in competencies)
|
||||
{
|
||||
var existing = entry.CompetencyRatings.FirstOrDefault(r => r.ItemId == competency.ItemId);
|
||||
var cell = new RatingCell(id, competency.ItemId.ToString("D"), existing?.Value);
|
||||
var cell = new RatingCell(id, competency.ItemId.ToString("D"), existing?.Value ?? estimate,
|
||||
isEstimated: existing is null && estimate is not null);
|
||||
cell.OnChanged = (sid, key, val) => OnCompetencyRatingChanged?.Invoke(sid, key, val);
|
||||
CompetencyCells.Add(cell);
|
||||
}
|
||||
@@ -672,22 +678,33 @@ public partial class RatingCell : ObservableObject
|
||||
|
||||
[ObservableProperty] private int? _value;
|
||||
[ObservableProperty] private string _displayLabel = "";
|
||||
/// <summary>true, solange Value aus ParticipationCompetencyEstimate geschätzt und noch nie
|
||||
/// explizit vom Nutzer gesetzt wurde (siehe ParticipationStudentRow) - steuert nur die Anzeige
|
||||
/// (reduzierte Deckkraft), nichts davon ist in ParticipationEntry.CompetencyRatings persistiert.
|
||||
/// Wird bei jedem SetValue-Aufruf unwiderruflich auf false gesetzt, auch wenn der Nutzer
|
||||
/// zufällig genau den geschätzten Wert bestätigt - ab dann zählt es als bewusste Entscheidung.</summary>
|
||||
[ObservableProperty] private bool _isEstimated;
|
||||
|
||||
public Action<Guid, string, int?>? OnChanged { get; set; }
|
||||
|
||||
public RatingCell(Guid studentId, string key, int? value,
|
||||
AspectValueType type = AspectValueType.Scale5, int maxPoints = 5)
|
||||
AspectValueType type = AspectValueType.Scale5, int maxPoints = 5, bool isEstimated = false)
|
||||
{
|
||||
StudentId = studentId;
|
||||
AspectKey = key;
|
||||
Type = type;
|
||||
MaxPoints = maxPoints;
|
||||
_value = type == AspectValueType.Points && value is { } v ? Math.Clamp(v, 0, maxPoints) : value;
|
||||
_isEstimated = isEstimated;
|
||||
UpdateLabel();
|
||||
}
|
||||
|
||||
public void SetValue(int? value)
|
||||
{
|
||||
// Reihenfolge wichtig: IsEstimated zuerst, damit ein auf Value lauschender Zellen-Renderer
|
||||
// (siehe ParticipationTabView.axaml.cs) beim Auswerten von Value bereits den korrekten
|
||||
// "bestätigt statt geschätzt"-Zustand sieht.
|
||||
IsEstimated = false;
|
||||
Value = Type == AspectValueType.Points && value is { } v ? Math.Clamp(v, 0, MaxPoints) : value;
|
||||
UpdateLabel();
|
||||
OnChanged?.Invoke(StudentId, AspectKey, Value);
|
||||
@@ -741,6 +758,37 @@ public class AspectColumnDef
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Nutzer-Feedback: Kompetenzen je Sitzung einzeln von Hand zu bewerten ist im Alltag zu
|
||||
/// aufwendig - eine Schätzung aus dem allgemeinen Mitarbeit-Durchschnitt der Sitzung (auf derselben
|
||||
/// -2..+2-Achse wie die Kompetenz-Bewertung selbst, siehe ParticipationRatingScale.Normalize) ersetzt
|
||||
/// die manuelle Erfassung im Regelfall; die Lehrkraft korrigiert nur noch die Ausnahmen von Hand.
|
||||
/// Die Tagesflagge wirkt bewusst symmetrisch (Nutzer-Entscheidung): Spitzentag hebt, Schlaftag und
|
||||
/// Schlechter Tag senken die Schätzung gleichermaßen, obwohl "Schlaftag" strenggenommen eher die
|
||||
/// Tagesform als die fachliche Kompetenz beschreibt.</summary>
|
||||
public static class ParticipationCompetencyEstimate
|
||||
{
|
||||
private const double DayHighlightAdjustment = 1.0;
|
||||
|
||||
public static int? Estimate(List<AspectRating> ratings, IReadOnlyList<AspectColumnDef> aspects, DayHighlightKind? dayHighlight)
|
||||
{
|
||||
var normalized = ratings
|
||||
.Select(r => (Rating: r, Def: aspects.FirstOrDefault(a => a.Key == r.Key)))
|
||||
.Where(x => x.Def is not null)
|
||||
.Select(x => ParticipationRatingScale.Normalize(x.Def!.ValueType, x.Rating.Value, x.Def.MaxPoints))
|
||||
.ToList();
|
||||
if (normalized.Count == 0) return null;
|
||||
|
||||
var adjustment = dayHighlight switch
|
||||
{
|
||||
DayHighlightKind.Standout => DayHighlightAdjustment,
|
||||
DayHighlightKind.Sleepy or DayHighlightKind.Rough => -DayHighlightAdjustment,
|
||||
_ => 0,
|
||||
};
|
||||
var estimate = (int)Math.Round(normalized.Average() + adjustment, MidpointRounding.AwayFromZero);
|
||||
return Math.Clamp(estimate, -2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public class ParticipationSessionItem
|
||||
{
|
||||
public Guid Id { get; }
|
||||
|
||||
@@ -133,15 +133,22 @@ public partial class ParticipationTabView : UserControl
|
||||
Content = label,
|
||||
Padding = new Avalonia.Thickness(5, 1),
|
||||
FontSize = 11,
|
||||
Opacity = cell.Value == val ? 1.0 : 0.3,
|
||||
Opacity = StepOpacity(cell, val),
|
||||
IsEnabled = !isReadOnly,
|
||||
};
|
||||
var capturedVal = val;
|
||||
void UpdateTip() => ToolTip.SetTip(btn, cell.IsEstimated && cell.Value == capturedVal
|
||||
? "Geschätzt aus dem Mitarbeit-Durchschnitt der Sitzung - anklicken, um zu bestätigen/ändern."
|
||||
: null);
|
||||
UpdateTip();
|
||||
btn.Click += (_, _) => cell.SetValue(capturedVal);
|
||||
cell.PropertyChanged += (_, pe) =>
|
||||
{
|
||||
if (pe.PropertyName == nameof(RatingCell.Value))
|
||||
btn.Opacity = cell.Value == capturedVal ? 1.0 : 0.3;
|
||||
if (pe.PropertyName is nameof(RatingCell.Value) or nameof(RatingCell.IsEstimated))
|
||||
{
|
||||
btn.Opacity = StepOpacity(cell, capturedVal);
|
||||
UpdateTip();
|
||||
}
|
||||
};
|
||||
panel.Children.Add(btn);
|
||||
}
|
||||
@@ -149,6 +156,12 @@ public partial class ParticipationTabView : UserControl
|
||||
return panel;
|
||||
}
|
||||
|
||||
// Geschätzte (noch nicht bestätigte) Werte werden abgeschwächt dargestellt (siehe
|
||||
// ParticipationCompetencyEstimate) - deutlich sichtbar genug, um nicht wie eine bewusste
|
||||
// Bewertung zu wirken, aber klar erkennbar heller als "nicht ausgewählt".
|
||||
private static double StepOpacity(RatingCell cell, int val) =>
|
||||
cell.Value != val ? 0.3 : cell.IsEstimated ? 0.6 : 1.0;
|
||||
|
||||
private static Control BuildPointsCell(RatingCell cell, bool isReadOnly)
|
||||
{
|
||||
var updown = new NumericUpDown
|
||||
|
||||
@@ -424,6 +424,21 @@ Mitarbeit-Note für denselben Zeitraum statt sie zu duplizieren (erkannt über d
|
||||
die bestehende Notenentwicklung (2.5) zeigt ausschließlich Klausur-/Einzelnoten-Einträge,
|
||||
keine Mitarbeit-Sitzungen — eine visuelle Markierung "im Diagramm" ist erst mit der
|
||||
geplanten Schüler-Überblicksansicht sinnvoll umsetzbar.
|
||||
- [x] **3.3.7** Kompetenz-Bewertung je Schüler/Sitzung automatisch aus dem Mitarbeit-Durchschnitt
|
||||
schätzen (Nutzer-Feedback: manuelle Einzelerfassung je Kompetenz war im Alltag zu aufwendig).
|
||||
Neue Klasse `ParticipationCompetencyEstimate` (Desktop) mittelt die bereits erfassten
|
||||
`AspectRating`-Werte der Sitzung (normiert auf dieselbe -2..+2-Achse wie die Kompetenz-
|
||||
Bewertung selbst, `ParticipationRatingScale.Normalize`) und rundet auf den nächsten Schritt;
|
||||
die Tagesflagge (3.3.6) wirkt bewusst **symmetrisch** (Nutzer-Entscheidung): Spitzentag hebt,
|
||||
Schlaftag und Schlechter Tag senken die Schätzung gleichermaßen, obwohl "Schlaftag"
|
||||
streng genommen eher die Tagesform als die fachliche Kompetenz beschreibt. Die Schätzung wird
|
||||
**nie automatisch gespeichert** — `ParticipationStudentRow` zeigt sie nur als Zellenwert an
|
||||
(`RatingCell.IsEstimated`, im Raster abgeschwächt dargestellt), solange keine explizite
|
||||
`CompetencyRating` existiert; ein Klick setzt den Wert bewusst und persistiert ihn wie bisher
|
||||
über `SaveCompetencyRating`. Bekannte Einschränkung: "Löschen" auf einer geschätzten Zelle
|
||||
zeigt sie bis zum nächsten Neuladen leer, danach erscheint wieder die (neu berechnete)
|
||||
Schätzung — es gibt keinen persistierten "bewusst leer"-Zustand, da das eine eigene
|
||||
Tombstone-Markierung bräuchte.
|
||||
|
||||
### Abschnittsnoten & Mitarbeits-Assistent (nicht aus dieser Liste, eigener Workflow-Bedarf)
|
||||
|
||||
@@ -3628,7 +3643,15 @@ alter und neuer Plan parallel, je nachdem, wann ein Kurs/eine Klasse eingeschult
|
||||
`update_group_competency_version` zum Setzen der Version eines Kurses.
|
||||
|
||||
Bewusst nicht Teil dieses Nachtrags: TODO 16.5 (Kompetenz-Referenzen in Unit/Lesson/ExamTask von
|
||||
Freitext-`Code` auf stabile `CompetencyItem.Id` umstellen) — unabhängiges, vorbestehendes Thema.
|
||||
Freitext-`Code` auf stabile `CompetencyItem.Id` umstellen) — unabhängiges, vorbestehendes Thema,
|
||||
mittlerweile eigenständig umgesetzt (siehe dort).
|
||||
|
||||
- [x] **8.4.5** MCP-Nachtrag: neue `ParticipationTools`-Klasse exponiert Mitarbeit-Sitzungen
|
||||
(`get_participation_sessions` — Datum, Kommentar, zugeordnete Kompetenzen, bewusst OHNE die
|
||||
einzelnen Schülerbewertungen, die bleiben personenbezogen und MCP-unerreichbar) sowie
|
||||
`add_session_competency`/`remove_session_competency` nach demselben Einzel-Zuordnung-statt-
|
||||
Listen-Ersetzen-Muster wie `LessonPlanTools`. Vorher gab es für Mitarbeit-Sitzungen gar kein
|
||||
MCP-Tool.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user