@using TechHelper.Client.Exam @if (QuestionGroup.Title != string.Empty) { @QuestionGroup.Id. @* 嵌套时字号稍小 *@ @QuestionGroup.Title @if (!string.IsNullOrEmpty(QuestionGroup.QuestionReference)) { @QuestionGroup.QuestionReference } } @* 渲染直接子题目 *@ @if (QuestionGroup.SubQuestions != null && QuestionGroup.SubQuestions.Any()) { @foreach (var qitem in QuestionGroup.SubQuestions) { @qitem.SubId. @qitem.Stem @if (qitem.Options != null && qitem.Options.Any()) { @foreach (var oitem in qitem.Options) { @oitem.Value } } @if (!string.IsNullOrEmpty(qitem.SampleAnswer)) { 示例答案: @qitem.SampleAnswer } } } @* 递归渲染子题组 *@ @if (QuestionGroup.SubQuestionGroups != null && QuestionGroup.SubQuestionGroups.Any()) { @if (!IsNested) // 只有顶级大题才显示“嵌套题组”标题 { 相关题组: } @foreach (var subGroup in QuestionGroup.SubQuestionGroups) { @* 递归调用自身 *@ } } @code { [Parameter] public TechHelper.Client.Exam.QuestionGroup QuestionGroup { get; set; } = new TechHelper.Client.Exam.QuestionGroup(); [Parameter] public bool IsNested { get; set; } = false; // 判断是否是嵌套的题组,用于调整样式和显示标题 }