From c11c5640c2afa679338e0e8852a0882353d8f125 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 15 Nov 2026 16:36:23 +0100 Subject: [PATCH] Added the simulation of the test situation to the sessions shared from the BeyondFacts Lab --- .../BeyondFactsLab/BflShareDialog.razor.cs | 6 +++-- .../BeyondFactsLab/BflShareInput.cs | 3 ++- .../BeyondFactsLab/BflShareModelBuilder.cs | 14 ++++++++++- .../BflShareModelBuilderTests.cs | 23 +++++++++++++++++-- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareDialog.razor.cs b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareDialog.razor.cs index a26ef3735..8672e3ee5 100644 --- a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareDialog.razor.cs +++ b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareDialog.razor.cs @@ -144,8 +144,10 @@ public partial class BflShareDialog : MSGComponentBase } var researchTopics = research.Where(entry => !string.IsNullOrWhiteSpace(entry.Value.Text)).Select(entry => entry.Key).ToList(); - var researchedPeople = BflStepResearch.Of(research, await this.Store.LoadAllPersonResearchAsync(this.ProjectId)).People.Count(person => person.Stages.Count > 0); - this.source = new BflShareInput(forms, workStates, results, conversations, materials, researchTopics, researchedPeople, false, APP_VERSION, DateTimeOffset.UtcNow, Culture, await this.LoadValueDeckAsync()); + var people = await this.Store.LoadAllPersonResearchAsync(this.ProjectId); + var researchedPeople = BflStepResearch.Of(research, people).People.Count(person => person.Stages.Count > 0); + var simulation = BflEffectiveSimulation.Of(forms.GetValueOrDefault(BflStep.TEST_SITUATION)?.Simulation, BflSimulationCandidates.Of(forms, research, people)); + this.source = new BflShareInput(forms, workStates, results, conversations, materials, researchTopics, researchedPeople, false, APP_VERSION, DateTimeOffset.UtcNow, Culture, await this.LoadValueDeckAsync(), simulation); this.otherNames = string.Join('\n', BflShareNames.Suggest(forms, workStates, research.GetValueOrDefault(BflResearchTopic.PARTICIPANTS))); } catch (Exception exception) when (exception is IOException or UnauthorizedAccessException or InvalidDataException) diff --git a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareInput.cs b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareInput.cs index 8b65a4141..977c5c615 100644 --- a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareInput.cs +++ b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareInput.cs @@ -17,4 +17,5 @@ namespace AIStudio.Assistants.BeyondFactsLab; /// When the person shares the session. /// The culture for dates and numbers, the one of the language of the app. /// The value deck in the language of the app, with which the session shows the card sort of the person; null leaves the card sort out. -public sealed record BflShareInput(IReadOnlyDictionary Forms, IReadOnlyDictionary WorkStates, IReadOnlyDictionary Results, IReadOnlyDictionary> Conversations, IReadOnlyList Materials, IReadOnlyCollection ResearchTopics, int ResearchedPeople, bool IncludePersonalDisclosures, string AppVersion, DateTimeOffset SharedAtUtc, CultureInfo Culture, BflValueDeck? ValueDeck); \ No newline at end of file +/// Whom the conversation of the step "Test situation" plays right now; only its mode and how many people it plays go into the session, never their names. Null counts as generic counterparts. +public sealed record BflShareInput(IReadOnlyDictionary Forms, IReadOnlyDictionary WorkStates, IReadOnlyDictionary Results, IReadOnlyDictionary> Conversations, IReadOnlyList Materials, IReadOnlyCollection ResearchTopics, int ResearchedPeople, bool IncludePersonalDisclosures, string AppVersion, DateTimeOffset SharedAtUtc, CultureInfo Culture, BflValueDeck? ValueDeck, BflEffectiveSimulation? Simulation = null); \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareModelBuilder.cs b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareModelBuilder.cs index 4ed6f281a..218c92f11 100644 --- a/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareModelBuilder.cs +++ b/app/MindWork AI Studio/Assistants/BeyondFactsLab/BflShareModelBuilder.cs @@ -45,7 +45,8 @@ public static class BflShareModelBuilder /// /// Appends what the research team needs to read the session: the version of AI Studio, the date, how much material - /// the person added, on which topics the lab researched, and how many people it researched in depth. + /// the person added, on which topics the lab researched, how many people it researched in depth, and whom the test + /// situation simulates. /// /// The session so far. /// What the session is put together from. @@ -62,9 +63,20 @@ public static class BflShareModelBuilder AppendItem(text, TB("Material"), string.Format(input.Culture, TB("{0} documents, {1} recordings, {2} images"), documents, recordings, images)); AppendItem(text, TB("Research on the web"), topics.Count > 0 ? string.Join(", ", topics) : TB("none")); AppendItem(text, TB("People researched in depth"), input.ResearchedPeople.ToString(input.Culture)); + AppendItem(text, TB("Simulation in the test situation"), Simulation(input)); AppendItem(text, TB("Personal disclosures"), input.IncludePersonalDisclosures ? TB("included") : TB("left out")); } + /// + /// Describes whom the test situation simulates: the mode and how many people, without their names. + /// + /// What the session is put together from. + private static string Simulation(BflShareInput input) + { + var simulation = input.Simulation ?? BflEffectiveSimulation.GENERIC; + return simulation.People.Count is 0 ? simulation.Mode.Title : string.Format(input.Culture, TB("{0} ({1} simulated)"), simulation.Mode.Title, simulation.People.Count); + } + /// /// Appends a step: its details, its confirmed work state, its conversation, and for the last step the confirmed /// materials. diff --git a/app/Tests/BeyondFactsLab/BflShareModelBuilderTests.cs b/app/Tests/BeyondFactsLab/BflShareModelBuilderTests.cs index 11c7364a1..5a22383a7 100644 --- a/app/Tests/BeyondFactsLab/BflShareModelBuilderTests.cs +++ b/app/Tests/BeyondFactsLab/BflShareModelBuilderTests.cs @@ -179,6 +179,24 @@ public sealed class BflShareModelBuilderTests } } + [Test] + public void TheSimulationAppearsWithItsModeAndTheNumberOfPeopleButNoNames() + { + var research = new BflPersonResearch { Name = "Eva Klein" }; + research.Set(BflPersonResearchStage.POSITIONS, new BflResearch { Text = "Positionen", CreatedAtUtc = NOW }); + var simulation = new BflEffectiveSimulation(BflSimulationMode.PANEL_DISCUSSION, [new BflSimulatedPerson(new() { Name = "Eva Klein" }, research)]); + + var withPeople = Build(simulation: simulation); + var generic = Build(); + + using (Assert.EnterMultipleScope()) + { + Assert.That(withPeople, Does.Contain($"- **Simulation in the test situation:** {BflSimulationMode.PANEL_DISCUSSION.Title} (1 simulated)\n")); + Assert.That(withPeople, Does.Not.Contain("Eva Klein")); + Assert.That(generic, Does.Contain($"- **Simulation in the test situation:** {BflSimulationMode.GENERIC.Title}\n")); + } + } + [Test] public void EveryStepAppearsInItsOrder() { @@ -237,7 +255,7 @@ public sealed class BflShareModelBuilderTests Assert.That(Build(forms: forms, valueDeck: deck), Does.Not.Contain("Card sort")); } - private static string Build(Dictionary? forms = null, IReadOnlyDictionary? workStates = null, IReadOnlyDictionary? results = null, IReadOnlyDictionary>? conversations = null, IReadOnlyList? materials = null, IReadOnlyCollection? researchTopics = null, int researchedPeople = 0, bool includePersonalDisclosures = false, BflValueDeck? valueDeck = null) => BflShareModelBuilder.Build(new BflShareInput( + private static string Build(Dictionary? forms = null, IReadOnlyDictionary? workStates = null, IReadOnlyDictionary? results = null, IReadOnlyDictionary>? conversations = null, IReadOnlyList? materials = null, IReadOnlyCollection? researchTopics = null, int researchedPeople = 0, bool includePersonalDisclosures = false, BflValueDeck? valueDeck = null, BflEffectiveSimulation? simulation = null) => BflShareModelBuilder.Build(new BflShareInput( forms ?? Forms(), workStates ?? new Dictionary(), results ?? new Dictionary(), @@ -249,7 +267,8 @@ public sealed class BflShareModelBuilderTests "26.11.2", NOW, CultureInfo.InvariantCulture, - valueDeck)); + valueDeck, + simulation)); private static Dictionary Forms() => BflStep.All.ToDictionary(step => step, _ => new BflStepFormData());