Files
TechHelper/TechHelper.Client/Pages/Exam/ExamView/ExamStructView.razor
SpecialX 6a65281850
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 13s
重构作业结构:优化实体模型、DTO映射和前端界面
- 重构AppMainStruct、AssignmentQuestion、Question等实体模型
- 更新相关DTO以匹配新的数据结构
- 优化前端页面布局和组件
- 添加全局信息和笔记功能相关代码
- 更新数据库迁移和程序配置
2025-09-04 15:43:33 +08:00

115 lines
4.4 KiB
Plaintext

@using Entities.Contracts
@using Entities.DTO
@using Newtonsoft.Json
@using TechHelper.Client.Exam
@using TechHelper.Client.Pages.Exam.QuestionCard
<MudPaper @onclick:stopPropagation Style="background-color:transparent" Elevation="0">
<MudPaper Elevation=@Elevation Class=@Class @onclick="HandleClick" Style="@Style">
<MudStack Row="true" Class="justify-content-between align-content-center" Style="background-color: transparent">
<MudText Class="justify-content-lg-start" Typo="Typo.h6">@ExamStruct.Title</MudText>
<MudStack Row="true" Class="align-content-center">
<MudText Class="ma-auto" Align="Align.Center" Typo="Typo.body2"> Num: @ExamStruct.ChildrenAssignmentQuestion.Count</MudText>
<MudText Class="ma-auto" Align="Align.Center" Typo="Typo.body2"><b>总分:</b> @ExamStruct.Score 分</MudText>
<MudToggleIconButton @bind-Toggled="ExamStruct.BCorrect"
Icon="@Icons.Material.Filled.Close"
Color="@Color.Error"
ToggledIcon="@Icons.Material.Filled.Check"
ToggledColor="@Color.Success"
title="@(ExamStruct.BCorrect ? "On" : "Off")" />
<MudIconButton Color="Color.Tertiary" Icon="@Icons.Material.Filled.ExpandLess" Size="Size.Small" />
<MudIconButton Color="Color.Tertiary" Icon="@Icons.Material.Filled.ExpandMore" Size="Size.Small" />
<MudIconButton Icon="@Icons.Material.Filled.Delete" aria-label="delete" Size="Size.Small" />
<MudChip T="string" Color="Color.Info" Class="justify-content-end">@ExamStruct.StructType</MudChip>
<MudChip T="string" Color="Color.Warning" Class="justify-content-end">@(ExamStruct.QType == string.Empty ? "" : QuestionTypes[ExamStruct.QType].DisplayName)</MudChip>
@if(ExamStruct.Question!=null)
{
<MudRating SelectedValue="@((int)ExamStruct.Question.DifficultyLevel)" ReadOnly="true" Size="Size.Small" />
}
</MudStack>
</MudStack>
@if (ExamStruct.Question != null)
{
<QuestionCard Question="ExamStruct.Question" Index="ExamStruct.Index" Elevation=0 Class="my-2 pa-1 rounded-xl" />
}
@foreach (var examStruct in ExamStruct.ChildrenAssignmentQuestion)
{
<ExamStructView ExamStruct="examStruct" ClickedStruct="HandleChildStructClick" Elevation=@(examStruct.Question != null
&& examStruct.ChildrenAssignmentQuestion.Count == 0 ? 0 : 0) Class="@($"my-2 pa-1 rounded-xl {(examStruct.StructType != AssignmentStructType.Question ? "my-5" : "my-1")}")"
Style=@(examStruct.StructType switch
{
AssignmentStructType.Question => "background-color: #ececec",
AssignmentStructType.Group => "background-color: #ffffff",
AssignmentStructType.Struct => "background-color: #cccccccc",
AssignmentStructType.SubQuestion => "background-color: #ffffff",
AssignmentStructType.Option => "background-color: #ffffff",
_ => "background-color: transparent"
}) />
}
</MudPaper>
</MudPaper>
@* Style=@(examStruct.StructType switch
{
AssignmentStructType.Question => "background-color: #ffffff",
AssignmentStructType.Composite => "background-color: #ececec",
AssignmentStructType.Struct => "background-color: #dcdcdc",
AssignmentStructType.SubQuestion => "background-color: #ffffff",
AssignmentStructType.Option => "background-color: #dddddd",
_ => "background-color: transparent"
}) *@
@code {
[Parameter]
public AssignmentQuestionDto ExamStruct { get; set; } = new AssignmentQuestionDto();
[Parameter]
public EventCallback<AssignmentQuestionDto> ClickedStruct { get; set; }
[Parameter]
public string Class { get; set; } = "my-2 pa-1";
[Parameter]
public int Elevation { get; set; } = 0;
[Parameter]
public string Style { get; set; } = "background-color : #eeeeee";
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
[Inject]
private ILocalStorageService LocalStorageService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
if (GlobalInfo != null)
{
QuestionTypes = GlobalInfo;
}
}
private async void HandleClick()
{
await ClickedStruct.InvokeAsync(ExamStruct);
}
private async void HandleChildStructClick(AssignmentQuestionDto clickedChildExamStruct)
{
await ClickedStruct.InvokeAsync(clickedChildExamStruct);
}
private void HandleSelected(int num)
{
ExamStruct.Question.DifficultyLevel = (DifficultyLevel)num;
}
}