
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 13s
- 重构AppMainStruct、AssignmentQuestion、Question等实体模型 - 更新相关DTO以匹配新的数据结构 - 优化前端页面布局和组件 - 添加全局信息和笔记功能相关代码 - 更新数据库迁移和程序配置
114 lines
4.3 KiB
Plaintext
114 lines
4.3 KiB
Plaintext
@using Entities.DTO
|
|
@using Entities.Contracts
|
|
@using Newtonsoft.Json
|
|
@using TechHelper.Client.Exam
|
|
@using TechHelper.Client.Pages.Exam.QuestionCard
|
|
|
|
|
|
<MudPaper Elevation="0" Class="rounded-xl" Style="background-color: transparent">
|
|
@* <MudText>@AssignmentQuestion.Id</MudText> *@
|
|
<MudPaper Class="ma-4 pa-5 rounded-xl">
|
|
<MudText Class="mt-3" Typo="Typo.button"><b>包裹器属性</b></MudText>
|
|
<MudTextField @bind-Value="AssignmentQuestion.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
|
|
<MudTextField @bind-Value="AssignmentQuestion.Index" Label="Index" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
|
<MudTextField @bind-Value="AssignmentQuestion.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
|
<MudChipSet T="AssignmentStructType" SelectedValue="AssignmentQuestion.StructType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleSelectedValueChanged">
|
|
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Root">@AssignmentStructType.Root</MudChip>
|
|
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Struct">@AssignmentStructType.Struct</MudChip>
|
|
<MudChip Text="purple" Color="Color.Primary" Value="@AssignmentStructType.Group">@AssignmentStructType.Group</MudChip>
|
|
<MudChip Text="blue" Color="Color.Info" Value="@AssignmentStructType.Question">@AssignmentStructType.Question</MudChip>
|
|
<MudChip Text="green" Color="Color.Warning" Value="@AssignmentStructType.SubQuestion">@AssignmentStructType.SubQuestion</MudChip>
|
|
<MudChip Text="orange" Color="Color.Error" Value="@AssignmentStructType.Option">@AssignmentStructType.Option</MudChip>
|
|
</MudChipSet>
|
|
|
|
|
|
<MudChipSet T="string" SelectedValue="@AssignmentQuestion.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
|
|
|
|
@foreach (var item in QuestionTypes)
|
|
{
|
|
var qt = item;
|
|
@* Style = "@($"background - color:{ item.Value.Color} ")"*@
|
|
|
|
<MudChip Style="@(qt.Key == AssignmentQuestion.QType ?
|
|
$"background-color:#ffffff; color:{item.Value.Color}" :
|
|
$"background-color:{item.Value.Color}; color:#ffffff")"
|
|
Value="@item.Key">
|
|
@item.Value.DisplayName
|
|
</MudChip>
|
|
}
|
|
</MudChipSet>
|
|
</MudPaper>
|
|
@if (AssignmentQuestion.Question != null)
|
|
{
|
|
<QuestionEdit Question="AssignmentQuestion.Question" />
|
|
}
|
|
</MudPaper>
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
public AssignmentQuestionDto AssignmentQuestion { get; set; } = new AssignmentQuestionDto();
|
|
public QuestionDto TempQuesdto;
|
|
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
|
|
|
[Inject]
|
|
private ILocalStorageService LocalStorageService { get; set; }
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
if (AssignmentQuestion.Question != null)
|
|
{
|
|
TempQuesdto = AssignmentQuestion.Question;
|
|
}
|
|
|
|
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
|
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
|
if(GlobalInfo != null)
|
|
{
|
|
QuestionTypes = GlobalInfo;
|
|
}
|
|
}
|
|
|
|
private void HandleQTSelectedValueChanged(string type)
|
|
{
|
|
AssignmentQuestion.QType = type;
|
|
if (AssignmentQuestion.ChildrenAssignmentQuestion.Count > 0 && AssignmentQuestion.StructType == AssignmentStructType.Group)
|
|
{
|
|
foreach (var item in AssignmentQuestion.ChildrenAssignmentQuestion)
|
|
{
|
|
item.QType = type;
|
|
if (item.Question != null)
|
|
{
|
|
item.Question.QType = type;
|
|
}
|
|
}
|
|
}
|
|
StateHasChanged();
|
|
}
|
|
|
|
private void HandleSelectedValueChanged(AssignmentStructType type)
|
|
{
|
|
AssignmentQuestion.StructType = type;
|
|
if (type != AssignmentStructType.Question && AssignmentQuestion.Question != null)
|
|
{
|
|
AssignmentQuestion.Title = AssignmentQuestion.Question.Title;
|
|
AssignmentQuestion.Question = null;
|
|
}
|
|
|
|
if (type == AssignmentStructType.Question && AssignmentQuestion.Question == null)
|
|
{
|
|
if (TempQuesdto != null)
|
|
{
|
|
AssignmentQuestion.Question = TempQuesdto;
|
|
if (AssignmentQuestion.Title == AssignmentQuestion.Question.Title)
|
|
{
|
|
AssignmentQuestion.Title = "";
|
|
}
|
|
}
|
|
else
|
|
AssignmentQuestion.Question = new QuestionDto { };
|
|
}
|
|
StateHasChanged();
|
|
}
|
|
}
|