exam_service
This commit is contained in:
127
TechHelper.Client/Pages/Exam/ParseRoleConfig.razor
Normal file
127
TechHelper.Client/Pages/Exam/ParseRoleConfig.razor
Normal file
@@ -0,0 +1,127 @@
|
||||
@using TechHelper.Client.Exam
|
||||
|
||||
<MudPaper Outlined="true" Class="mt-2">
|
||||
|
||||
<MudRadioGroup @bind-Value="_examParser">
|
||||
@foreach (ExamParserEnum item in Enum.GetValues(typeof(ExamParserEnum)))
|
||||
{
|
||||
<MudRadio T="ExamParserEnum" Value="@item">@item</MudRadio>
|
||||
}
|
||||
</MudRadioGroup>
|
||||
|
||||
<MudTextField @bind-Value="_ParserConfig" Label="正则表达式模式" Variant="Variant.Outlined" FullWidth="true" Class="mb-2" />
|
||||
<MudNumericField Label="优先级" @bind-Value="_Priority" Variant="Variant.Outlined" Min="1" Max="100" />
|
||||
<MudButton OnClick="AddPattern" Variant="Variant.Filled" Color="Color.Primary" Class="mt-2">添加模式</MudButton>
|
||||
|
||||
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">所有已配置模式:</MudText>
|
||||
|
||||
|
||||
@if (ExamParserConfig.MajorQuestionGroupPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="大题组模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.MajorQuestionGroupPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无大题组模式。</MudText>
|
||||
}
|
||||
|
||||
@* 题目模式详情 *@
|
||||
@if (ExamParserConfig.QuestionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="题目模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.QuestionPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无题目模式。</MudText>
|
||||
}
|
||||
|
||||
@if (ExamParserConfig.OptionPatterns.Any())
|
||||
{
|
||||
<MudExpansionPanel Text="选项模式详情" Class="mb-2">
|
||||
<MudStack>
|
||||
@foreach (var config in ExamParserConfig.OptionPatterns)
|
||||
{
|
||||
<MudChip T="string">
|
||||
**模式:** <code>@config.Pattern</code>, **优先级:** @config.Priority
|
||||
</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
</MudExpansionPanel>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mb-2">暂无选项模式。</MudText>
|
||||
}
|
||||
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" OnClick="ResetPatterns">重置默认规则</MudButton>
|
||||
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
public ExamParserEnum _examParser { get; set; } = ExamParserEnum.MajorQuestionGroupPatterns;
|
||||
private string _ParserConfig;
|
||||
private int _Priority = 1;
|
||||
|
||||
[Parameter]
|
||||
public ExamParserConfig ExamParserConfig { get; set; } = new ExamParserConfig();
|
||||
|
||||
[Inject]
|
||||
public ISnackbar Snackbar { get; set; }
|
||||
|
||||
private void AddPattern()
|
||||
{
|
||||
|
||||
switch ((ExamParserEnum)_examParser)
|
||||
{
|
||||
case ExamParserEnum.MajorQuestionGroupPatterns:
|
||||
ExamParserConfig.MajorQuestionGroupPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加大题组模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
case ExamParserEnum.QuestionPatterns:
|
||||
ExamParserConfig.QuestionPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加题目模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
case ExamParserEnum.OptionPatterns:
|
||||
ExamParserConfig.OptionPatterns.Add(new RegexPatternConfig(_ParserConfig, _Priority));
|
||||
Snackbar.Add($"已添加选项模式: {_ParserConfig}, 优先级: {_Priority}", Severity.Success);
|
||||
break;
|
||||
default:
|
||||
Snackbar.Add("请选择要添加的模式类型。");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ResetPatterns()
|
||||
{
|
||||
ExamParserConfig = new ExamParserConfig();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user