重构作业结构:优化实体模型、DTO映射和前端界面
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 13s
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 13s
- 重构AppMainStruct、AssignmentQuestion、Question等实体模型 - 更新相关DTO以匹配新的数据结构 - 优化前端页面布局和组件 - 添加全局信息和笔记功能相关代码 - 更新数据库迁移和程序配置
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
@using Entities.DTO
|
||||
@using Entities.Contracts
|
||||
@using Newtonsoft.Json
|
||||
@using TechHelper.Client.Exam
|
||||
@using TechHelper.Client.Pages.Exam.QuestionCard
|
||||
|
||||
@@ -12,12 +13,30 @@
|
||||
<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)
|
||||
{
|
||||
@@ -30,6 +49,10 @@
|
||||
[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();
|
||||
@@ -37,6 +60,30 @@
|
||||
{
|
||||
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)
|
||||
|
Reference in New Issue
Block a user