Added a button which ends an exercise of the test situation of the BeyondFacts Lab

This commit is contained in:
Thorsten Sommer committed 2026-11-15 16:34:48 +01:00
1 parent 4fcc0c8727
commit c08e5d7fb0
8 files changed
+73 -1

No files matched your search

@@ -82,6 +82,10 @@ else
{
<AttachDocuments Name="File Attachments" DocumentPaths="@this.attachments" DocumentPathsChanged="@this.AttachmentsChanged" CatchAllDocuments="true" UseSmallForm="true" ShowMediaStatus="false" Provider="@this.Provider" AllowedFileTypes="@this.AllowedFileTypes" Disabled="@(!this.CanSend)"/>
}
@if (this.QuickMessage is { } quickMessage && this.conversation.HasAnswer)
{
<MudButton Variant="Variant.Outlined" Color="Color.Primary" StartIcon="@quickMessage.Icon" OnClick="@this.SendQuickMessageAsync" Disabled="@(!this.CanSend)">@quickMessage.Label</MudButton>
}
@if (this.IsRunning)
{
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@AppIcons.STOP" OnClick="@this.CancelAsync">@T("Stop")</MudButton>
@@ -91,5 +95,9 @@ else
<MudButton StartIcon="@AppIcons.RESET" OnClick="@this.ResetAsync" Disabled="@this.IsRunning">@T("Start over")</MudButton>
}
</MudStack>
@if (this.QuickMessage is { Hint.Length: > 0 } hintedMessage && this.conversation.HasAnswer)
{
<MudText Typo="Typo.caption" Class="d-block mt-1">@hintedMessage.Hint</MudText>
}
}
}
@@ -171,6 +171,13 @@ public partial class EmbeddedChat : MSGComponentBase
[Parameter]
public string ExportFileName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a message the user sends with one click once the model has answered, such as asking for the
/// evaluation at the end of an exercise; null for none.
/// </summary>
[Parameter]
public EmbeddedChatQuickMessage? QuickMessage { get; set; }
[Inject]
private EmbeddedChatService ChatService { get; init; } = null!;
@@ -425,6 +432,18 @@ public partial class EmbeddedChat : MSGComponentBase
await this.ChatService.SendAsync(this.ChatId, this.RequestOf(message));
}
/// <summary>
/// Sends the message of the button, see QuickMessage, as if the user had written it. What the user typed meanwhile
/// stays in the field.
/// </summary>
private async Task SendQuickMessageAsync()
{
if (this.QuickMessage is not { } quickMessage || !this.CanSend)
return;
await this.ChatService.SendAsync(this.ChatId, this.RequestOf(new ContentText { Text = quickMessage.Message }));
}
/// <summary>
/// Lets the model open the conversation, see StartRequest.
/// </summary>