CleanExamDto
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
@page "/exam/check/{ExamID}"
|
||||
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mb-4">试卷批改预览: @ExamDto.AssignmentTitle</MudText>
|
||||
<MudText Typo="Typo.h4" Class="mb-4">试卷批改预览: @Assignment.Title</MudText>
|
||||
<MudDivider Class="my-4" />
|
||||
|
||||
@if (_isLoading)
|
||||
@@ -74,36 +74,36 @@ else
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string ExamId { get; set; } // 从路由获取的试卷ID
|
||||
public string ExamId { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IExamService ExamService { get; set; } // 注入试卷服务
|
||||
public IExamService ExamService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private ISnackbar Snackbar { get; set; } // 注入 Snackbar 用于消息提示
|
||||
private ISnackbar Snackbar { get; set; }
|
||||
|
||||
[Inject]
|
||||
private NavigationManager Navigation { get; set; } // 注入导航管理器
|
||||
private NavigationManager Navigation { get; set; }
|
||||
|
||||
private MudTable<QuestionRowData> _table = new(); // MudTable 实例引用
|
||||
private ExamDto ExamDto { get; set; } = new ExamDto(); // 原始试卷数据
|
||||
private ExamStruct _examStruct = new ExamStruct(); // 处理后的试卷结构,包含带序号的题目
|
||||
private MudTable<QuestionRowData> _table = new();
|
||||
private AssignmentDto Assignment { get; set; } = new AssignmentDto();
|
||||
private ExamStruct _examStruct = new ExamStruct();
|
||||
|
||||
private List<Student> _students = new List<Student>(); // 临时生成的学生列表
|
||||
private List<QuestionRowData> _questionsForTable = new List<QuestionRowData>(); // 用于 MudTable 的数据源
|
||||
private List<Student> _students = new List<Student>();
|
||||
private List<QuestionRowData> _questionsForTable = new List<QuestionRowData>();
|
||||
|
||||
private bool _isLoading = true;
|
||||
|
||||
private bool _isLoading = true; // 加载状态
|
||||
|
||||
// 在组件初始化时加载数据
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isLoading = true;
|
||||
await LoadExamData();
|
||||
GenerateTemporaryStudentsAndAnswers(); // 生成学生和初始作答数据
|
||||
GenerateTemporaryStudentsAndAnswers();
|
||||
_isLoading = false;
|
||||
}
|
||||
|
||||
// 加载试卷数据的方法
|
||||
|
||||
private async Task LoadExamData()
|
||||
{
|
||||
if (Guid.TryParse(ExamId, out Guid parsedExamId))
|
||||
@@ -113,13 +113,13 @@ else
|
||||
var result = await ExamService.GetExam(parsedExamId);
|
||||
if (result.Status)
|
||||
{
|
||||
ExamDto = result.Result as ExamDto ?? new ExamDto();
|
||||
_examStruct = ExamDto.GetStruct(); // 将 ExamDto 转换为 ExamStruct
|
||||
Assignment = result.Result as AssignmentDto ?? new AssignmentDto();
|
||||
_examStruct = Assignment.GetStruct();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar?.Add($"获取试卷失败: {result.Message}", Severity.Error);
|
||||
Navigation.NavigateTo("/exam/manager"); // 导航回管理页
|
||||
Navigation.NavigateTo("/exam/manager");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Reference in New Issue
Block a user