添加项目文件。
This commit is contained in:
73
TechHelper.Client/Pages/Exam/QuestionGroupDisplay.razor
Normal file
73
TechHelper.Client/Pages/Exam/QuestionGroupDisplay.razor
Normal file
@@ -0,0 +1,73 @@
|
||||
@using TechHelper.Client.Exam
|
||||
|
||||
<MudCard Class="@(IsNested ? "mb-3 pa-2" : "my-4")" Outlined="@IsNested">
|
||||
@* 嵌套时添加边框和内边距 *@
|
||||
<MudCardHeader>
|
||||
<MudStack>
|
||||
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="@(IsNested ? Typo.h6 : Typo.h5)">@QuestionGroup.Id. </MudText> @* 嵌套时字号稍小 *@
|
||||
<MudText Typo="@(IsNested ? Typo.h6 : Typo.h5)">@QuestionGroup.Title</MudText>
|
||||
@if (!string.IsNullOrEmpty(QuestionGroup.ScoreProblemMarker))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">( @QuestionGroup.ScoreProblemMarker )</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
@if (!string.IsNullOrEmpty(QuestionGroup.QuestionReference))
|
||||
{
|
||||
<MudText Class="mt-2" Style="white-space: pre-wrap;">@QuestionGroup.QuestionReference</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
</MudCardHeader>
|
||||
<MudCardContent>
|
||||
@* 渲染直接子题目 *@
|
||||
@if (QuestionGroup.SubQuestions != null && QuestionGroup.SubQuestions.Any())
|
||||
{
|
||||
@if (!IsNested) // 只有顶级大题才显示“子题目”标题
|
||||
{
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">题目详情:</MudText>
|
||||
}
|
||||
@foreach (var qitem in QuestionGroup.SubQuestions)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Baseline" Class="mb-2">
|
||||
<MudText Typo="Typo.body1">@qitem.SubId. </MudText>
|
||||
<MudText Typo="Typo.body1">@qitem.Stem</MudText>
|
||||
@if (!string.IsNullOrEmpty(qitem.ScoreProblemMarker))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-1">( @qitem.ScoreProblemMarker )</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
@if (!string.IsNullOrEmpty(qitem.SampleAnswer))
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Tertiary" Class="ml-6 mb-2">示例答案: @qitem.SampleAnswer</MudText>
|
||||
}
|
||||
@if (qitem.Options != null && qitem.Options.Any())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@* 递归渲染子题组 *@
|
||||
@if (QuestionGroup.SubQuestionGroups != null && QuestionGroup.SubQuestionGroups.Any())
|
||||
{
|
||||
<MudDivider Class="my-4" />
|
||||
@if (!IsNested) // 只有顶级大题才显示“嵌套题组”标题
|
||||
{
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">相关题组:</MudText>
|
||||
}
|
||||
@foreach (var subGroup in QuestionGroup.SubQuestionGroups)
|
||||
{
|
||||
<QuestionGroupDisplay QuestionGroup="subGroup" IsNested="true" /> @* 递归调用自身 *@
|
||||
}
|
||||
}
|
||||
</MudCardContent>
|
||||
|
||||
</MudCard>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public TechHelper.Client.Exam.QuestionGroup QuestionGroup { get; set; } = new TechHelper.Client.Exam.QuestionGroup();
|
||||
|
||||
[Parameter]
|
||||
public bool IsNested { get; set; } = false; // 判断是否是嵌套的题组,用于调整样式和显示标题
|
||||
}
|
Reference in New Issue
Block a user