重构项目结构,移除Assignment相关功能,优化Submission模块
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s

This commit is contained in:
SpecialX
2025-10-09 18:57:28 +08:00
parent 403b34a098
commit ac900159ba
289 changed files with 11948 additions and 20150 deletions

View File

@@ -2,6 +2,9 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<p>Authorizing...</p>
</Authorizing>
<NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{

View File

@@ -1,5 +1,4 @@
using AutoMapper;
using AutoMapper.Internal.Mappers;
using Entities.Contracts;
using Entities.DTO;
using TechHelper.Client.Exam;
@@ -12,11 +11,8 @@ namespace TechHelper.Context
{
CreateMap<QuestionEx, QuestionDto>()
.ForMember(d => d.Options, o => o.MapFrom(s => string.Join(Environment.NewLine, s.Options.Select(op => op.Text))));
CreateMap<AssignmentQuestionEx, AssignmentQuestionDto>()
.ForMember(d=>d.Description, o=>o.Ignore());
CreateMap<AssignmentEx, AssignmentDto>();
CreateMap<ExamQuestionEx, ExamQuestionDto>();
CreateMap<ExamEx, ExamDto>();
CreateMap<AssignmentCheckData, Submission>();
}
}

View File

@@ -14,7 +14,7 @@ namespace TechHelper.Client.Exam
public class AssignmentCheckQuestion
{
public string Sequence { get; set; } = string.Empty;
public AssignmentQuestionDto AssignmentQuestionDto { get; set; } = new AssignmentQuestionDto();
public ExamQuestionDto ExamQuestionDto { get; set; } = new ExamQuestionDto();
public float Score { get; set; }
}
@@ -42,7 +42,7 @@ namespace TechHelper.Client.Exam
public static class ExamStructExtensions
{
public static AssignmentCheckData GetStruct(this AssignmentDto dto)
public static AssignmentCheckData GetStruct(this ExamDto dto)
{
if (dto == null)
{
@@ -66,7 +66,7 @@ namespace TechHelper.Client.Exam
/// <param name="parentSequence">当前题目组的父级序号(例如:"1", "2.1")。如果为空,则表示顶级题目组。</param>
/// <param name="allQuestions">用于收集所有生成题目项的列表。</param>
private static void GetSeqRecursive(
AssignmentQuestionDto currentGroup,
ExamQuestionDto currentGroup,
string? parentSequence,
List<AssignmentCheckQuestion> allQuestions)
{
@@ -74,7 +74,7 @@ namespace TechHelper.Client.Exam
? $"{parentSequence}.{currentGroup.Index}"
: currentGroup.Index.ToString();
foreach (var subGroup in currentGroup.ChildrenAssignmentQuestion)
foreach (var subGroup in currentGroup.ChildExamQuestions)
{
GetSeqRecursive(subGroup, currentGroupSequence, allQuestions);
}
@@ -83,7 +83,7 @@ namespace TechHelper.Client.Exam
allQuestions.Add(new AssignmentCheckQuestion
{
AssignmentQuestionDto = currentGroup,
ExamQuestionDto = currentGroup,
//Sequence = currentGroupSequence,
Sequence = currentGroup.Sequence,
Score = currentGroup.Score,

View File

@@ -16,18 +16,18 @@ namespace TechHelper.Client.Exam
.Where(line => !string.IsNullOrWhiteSpace(line)).ToList();
}
public static void SeqIndex(this AssignmentDto dto)
public static void SeqIndex(this ExamDto dto)
{
dto.ExamStruct.SeqQGroupIndex();
}
public static void SeqQGroupIndex(this AssignmentQuestionDto dto)
public static void SeqQGroupIndex(this ExamQuestionDto dto)
{
foreach (var sqg in dto.ChildrenAssignmentQuestion)
foreach (var sqg in dto.ChildExamQuestions)
{
sqg.Index = (byte)(dto.ChildrenAssignmentQuestion.IndexOf(sqg) + 1);
sqg.Index = (byte)(dto.ChildExamQuestions.ToList().IndexOf(sqg) + 1);
sqg.SeqQGroupIndex();
}

View File

@@ -1,6 +1,8 @@
using Entities.Contracts; // 假设这些实体合约仍然是必需的
using System.Text.RegularExpressions;
using System.Text;
using Entities.DTO;
using TechHelper.Client.Services;
namespace TechHelper.Client.Exam
{
@@ -41,17 +43,17 @@ namespace TechHelper.Client.Exam
}
}
public class AssignmentEx
public class ExamEx
{
public string Title { get; set; } = "Title";
public string Description { get; set; } = "Description";
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
public AssignmentQuestionEx ExamStruct { get; set; } = new AssignmentQuestionEx();
public TypeCommonDto Subject { get; set; }
public ExamQuestionEx ExamStruct { get; set; } = new ExamQuestionEx();
public List<ParseError> Errors { get; set; } = new List<ParseError>();
}
// 试题的包裹器, 或者 单独作为一个试题结构存在
public class AssignmentQuestionEx
public class ExamQuestionEx
{
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
@@ -59,8 +61,8 @@ namespace TechHelper.Client.Exam
public float Score { get; set; }
public string Sequence { get; set; } = string.Empty;
public QuestionEx? Question { get; set; }
public AssignmentStructType Type { get; set; }
public List<AssignmentQuestionEx> ChildrenAssignmentQuestion { get; set; } = new List<AssignmentQuestionEx>();
public TypeCommonDto Type { get; set; }
public List<ExamQuestionEx> ChildrenAssignmentQuestion { get; set; } = new List<ExamQuestionEx>();
public int Priority { get; set; }
}
@@ -85,10 +87,10 @@ namespace TechHelper.Client.Exam
{
public string Pattern { get; set; }
public int Priority { get; set; }
public AssignmentStructType Type { get; set; }
public ExamStructType Type { get; set; }
public Regex Regex { get; private set; }
public RegexPatternConfig(string pattern, int priority, AssignmentStructType type = AssignmentStructType.Question)
public RegexPatternConfig(string pattern, int priority, ExamStructType type = ExamStructType.Question)
{
Pattern = pattern;
Priority = priority;
@@ -113,26 +115,26 @@ namespace TechHelper.Client.Exam
// Group 2: 题目/题组标题内容
// 例如:一. 这是大题一
QuestionPatterns.Add(new RegexPatternConfig(@"^([一二三四五六七八九十]+)[.\、]\s*(.+)", 1, AssignmentStructType.Struct));
QuestionPatterns.Add(new RegexPatternConfig(@"^([一二三四五六七八九十]+)[.\、]\s*(.+)", 1, ExamStructType.Struct));
// 例如:(一) 这是第一子题组
QuestionPatterns.Add(new RegexPatternConfig(@"^\(([一二三四五六七八九十]{1,2}|十[一二三四五六七八九])\)\s*(.+)", 2, AssignmentStructType.Group));
QuestionPatterns.Add(new RegexPatternConfig(@"^\(([一二三四五六七八九十]{1,2}|十[一二三四五六七八九])\)\s*(.+)", 2, ExamStructType.Group));
// 例如1. 这是第一道题目 或 1 这是第一道题目
QuestionPatterns.Add(new RegexPatternConfig(@"^(\d+)\.?\s*(.+)", 3, AssignmentStructType.Question));
QuestionPatterns.Add(new RegexPatternConfig(@"^(\d+)\.?\s*(.+)", 3, ExamStructType.Question));
// 例如:(1). 这是小问一 或 (1) 这是小问一
QuestionPatterns.Add(new RegexPatternConfig(@"^\((\d+)\)\.?\s*(.+)", 4, AssignmentStructType.Question));
QuestionPatterns.Add(new RegexPatternConfig(@"^\((\d+)\)\.?\s*(.+)", 4, ExamStructType.Question));
// 例如:① 这是另一种小问 或 ①. 这是另一种小问 (如果 ① 后面会跟点,这个更通用)
// 如果 ① 后面通常没有点,但您希望它也能匹配,则保留原样或根据实际情况调整
QuestionPatterns.Add(new RegexPatternConfig(@"^[①②③④⑤⑥⑦⑧⑨⑩]+\.?\s*(.+)", 5, AssignmentStructType.Question));
QuestionPatterns.Add(new RegexPatternConfig(@"^[①②③④⑤⑥⑦⑧⑨⑩]+\.?\s*(.+)", 5, ExamStructType.Question));
// 选项模式 (保持不变,使用 AssignmentStructType.Option 区分)
OptionPatterns.Add(new RegexPatternConfig(@"([A-Z]\.)\s*(.*?)(?=[A-Z]\.|$)", 1, AssignmentStructType.Option));
OptionPatterns.Add(new RegexPatternConfig(@"([a-z]\.)\s*(.*?)(?=[a-z]\.|$)", 2, AssignmentStructType.Option));
// 选项模式 (保持不变,使用 ExamStructType.Option 区分)
OptionPatterns.Add(new RegexPatternConfig(@"([A-Z]\.)\s*(.*?)(?=[A-Z]\.|$)", 1, ExamStructType.Option));
OptionPatterns.Add(new RegexPatternConfig(@"([a-z]\.)\s*(.*?)(?=[a-z]\.|$)", 2, ExamStructType.Option));
// 独立的得分正则表达式:匹配行末尾的 "(X分)" 格式
// Group 1: 捕获分数(如 "10" 或 "0.5"
@@ -206,7 +208,7 @@ namespace TechHelper.Client.Exam
_config = config ?? throw new ArgumentNullException(nameof(config), "ExamParserConfig cannot be null.");
}
public AssignmentEx BuildExam(string fullExamText, List<PotentialMatch> allPotentialMatches)
public ExamEx BuildExam(string fullExamText, List<PotentialMatch> allPotentialMatches)
{
if (string.IsNullOrWhiteSpace(fullExamText))
{
@@ -217,7 +219,7 @@ namespace TechHelper.Client.Exam
throw new ArgumentNullException(nameof(allPotentialMatches), "Potential matches list cannot be null.");
}
var assignment = new AssignmentEx();
var assignment = new ExamEx();
try
{
assignment.Title = GetExamTitle(fullExamText);
@@ -228,8 +230,8 @@ namespace TechHelper.Client.Exam
assignment.Title = "未识别试卷标题";
}
var assignmentQuestionStack = new Stack<AssignmentQuestionEx>();
var rootAssignmentQuestion = new AssignmentQuestionEx { Type = AssignmentStructType.Struct, Priority = 0, Title = "Root Exam Structure" };
var assignmentQuestionStack = new Stack<ExamQuestionEx>();
var rootAssignmentQuestion = new ExamQuestionEx { Priority = 0, Title = "Root Exam Structure" };
assignmentQuestionStack.Push(rootAssignmentQuestion);
assignment.ExamStruct = rootAssignmentQuestion;
@@ -270,7 +272,7 @@ namespace TechHelper.Client.Exam
}
}
if (pm.PatternConfig.Type == AssignmentStructType.Option)
if (pm.PatternConfig.Type == ExamStructType.Option)
{
HandleOptionMatch(pm, i, assignmentQuestionStack.Peek(), assignment.Errors);
}
@@ -337,7 +339,7 @@ namespace TechHelper.Client.Exam
return true;
}
private void HandleQuestionGroupMatch(PotentialMatch pm, int index, Stack<AssignmentQuestionEx> assignmentQuestionStack, List<ParseError> errors)
private void HandleQuestionGroupMatch(PotentialMatch pm, int index, Stack<ExamQuestionEx> assignmentQuestionStack, List<ParseError> errors)
{
try
{
@@ -379,24 +381,22 @@ namespace TechHelper.Client.Exam
string seq = pm.RegexMatch.Groups[1].Value.Trim();
seq = string.IsNullOrEmpty(seq) || string.IsNullOrEmpty(sequence) ? seq : " ." + seq;
AssignmentQuestionEx newAssignmentQuestion;
if (pm.PatternConfig.Type == AssignmentStructType.Struct)
ExamQuestionEx newAssignmentQuestion;
if (pm.PatternConfig.Type == ExamStructType.Struct)
{
newAssignmentQuestion = new AssignmentQuestionEx
newAssignmentQuestion = new ExamQuestionEx
{
Title = title,
Score = score,
Sequence = sequence + seq,
Priority = pm.PatternConfig.Priority,
Type = pm.PatternConfig.Type
};
}
else // AssignmentStructType.Question 类型
else // ExamStructType.Question 类型
{
newAssignmentQuestion = new AssignmentQuestionEx
newAssignmentQuestion = new ExamQuestionEx
{
Priority = pm.PatternConfig.Priority,
Type = pm.PatternConfig.Type,
Sequence = sequence + seq,
Score = score,
Question = new QuestionEx
@@ -417,7 +417,7 @@ namespace TechHelper.Client.Exam
}
}
private void HandleOptionMatch(PotentialMatch pm, int index, AssignmentQuestionEx currentAssignmentQuestion, List<ParseError> errors)
private void HandleOptionMatch(PotentialMatch pm, int index, ExamQuestionEx currentAssignmentQuestion, List<ParseError> errors)
{
try
{
@@ -452,7 +452,7 @@ namespace TechHelper.Client.Exam
}
}
private void ProcessQuestionContent(AssignmentQuestionEx question, string contentText, List<ParseError> errors)
private void ProcessQuestionContent(ExamQuestionEx question, string contentText, List<ParseError> errors)
{
if (question?.Question == null)
{
@@ -479,12 +479,14 @@ namespace TechHelper.Client.Exam
public class ExamParser
{
private readonly ExamParserConfig _config;
private readonly ICommonService _commonService;
private readonly ExamDocumentScanner _scanner;
private readonly ExamStructureBuilder _builder;
public ExamParser(ExamParserConfig config)
public ExamParser(ExamParserConfig config, ICommonService commonService)
{
_config = config ?? throw new ArgumentNullException(nameof(config));
_commonService = commonService;
_scanner = new ExamDocumentScanner(_config);
_builder = new ExamStructureBuilder(_config);
}
@@ -494,9 +496,9 @@ namespace TechHelper.Client.Exam
/// </summary>
/// <param name="examPaperText">完整的试卷文本</param>
/// <returns>解析后的 AssignmentEx 对象</returns>
public AssignmentEx ParseExamPaper(string examPaperText)
public ExamEx ParseExamPaper(string examPaperText)
{
var assignment = new AssignmentEx();
var assignment = new ExamEx();
List<PotentialMatch> allPotentialMatches = _scanner.Scan(examPaperText, assignment.Errors);
assignment = _builder.BuildExam(examPaperText, allPotentialMatches);
return assignment;

View File

@@ -92,8 +92,8 @@ namespace TechHelper.Client.HttpRepository
public async Task<ResponseDto> RegisterUserAsync(UserForRegistrationDto userForRegistrationDto)
{
userForRegistrationDto.ClientURI = Path.Combine(
_navigationManager.BaseUri, "emailconfirmation");
//userForRegistrationDto.ClientURI = Path.Combine(
// _navigationManager.BaseUri, "emailconfirmation");
var reponse = await _client.PostAsJsonAsync("account/register",
userForRegistrationDto);

View File

@@ -5,22 +5,22 @@
<MudPopoverProvider />
<MudLayout>
<MudAppBar Elevation="0" Class="rounded-xl" Style="background-color: transparent; border:none">
<MudAppBar Elevation="0" Class="" Style="background-color: white; border:none">
<MudBreakpointProvider>
<MudHidden Breakpoint="Breakpoint.SmAndDown" Invert=true>
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Primary" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
</MudHidden>
<MudHidden Breakpoint="Breakpoint.SmAndDown">
<SearchBar></SearchBar>
<MudButton Class="mt-1">application</MudButton>
</MudHidden>
</MudBreakpointProvider>
<MudSpacer />
<MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Primary" Edge="Edge.End" />
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" Height="100%" Elevation="0" Style="background-color:#f5f6fb">
<MudDrawerHeader Class="h-100 d-flex flex-grow-1" Style="background-color:#f5f6fb">
<MudPaper Width="250px" Class="d-flex py-3 flex-column justify-content-between rounded-xl" Elevation="3">
<MudDrawer @bind-Open="_drawerOpen" Height="100%" Elevation="0" Style="background-color:white">
<MudDrawerHeader Class="h-100 d-flex flex-grow-1" Style="background-color:white">
<MudPaper Width="250px" Class="d-flex py-3 flex-column justify-content-between rounded-xl" Elevation="0">
<MudNavMenu Bordered="true" Dense="true" Rounded="true" Color="Color.Error" Margin="Margin.Dense">
<ApplicationMainIconCard></ApplicationMainIconCard>
<MudDivider Class="my-2" />
@@ -42,7 +42,7 @@
<MudMainContent Style="background: #f5f6fb">
<SnackErrorBoundary @ref="errorBoundary">
<MudPaper Height="calc(100vh - 64px)" Style="background-color:transparent" Class="overflow-hidden px-1 py-2" Elevation="0">
<MudPaper Style="background-color:transparent" Elevation="0" Class="d-flex w-100 h-100 overflow-hidden pa-2 rounded-xl">
<MudPaper Style="background-color:gray; color:white; font-size:1.2rem; font-weight:bold; text-align:center; padding:1rem;" Elevation="0" Class="d-flex w-100 h-100 overflow-hidden pa-2 rounded-xl">
@Body
</MudPaper>
</MudPaper>

View File

@@ -1,7 +1,7 @@
using TechHelper.Client.HttpRepository;
using Entities.DTO;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.WebUtilities;
using Entities.DTO;
namespace TechHelper.Client.Pages.Author
{

View File

@@ -33,7 +33,7 @@
<MudPaper Class="d-flex flex-column flex-grow-1 rounded-xl px-5 justify-content-center pt-15 w-100 " Elevation="0" Outlined="false">
<MudText Typo="Typo.h5"> <b>注册账户</b> </MudText>
<MudTextField Label="Name" HelperText="Max. 8 characters"
@bind-Value="_userForRegistration.Name" For="@(() => _userForRegistration.Email)" />
@bind-Value="_userForRegistration.DisplayName" For="@(() => _userForRegistration.Email)" />
<MudTextField Label="Email" Class="mt-3"
@bind-Value="_userForRegistration.Email" For="@(() => _userForRegistration.Email)" />
<MudTextField Label="Password" HelperText="Choose a strong password" Class="mt-3"

View File

@@ -1,11 +1,11 @@
using TechHelper.Client.HttpRepository;
using Entities.DTO;
using Microsoft.AspNetCore.Components;
using MudBlazor;
using System.Text.RegularExpressions;
using TechHelper.Features;
using Entities.Contracts;
using TechHelper.Client.Services;
using Entities.DTO;
namespace TechHelper.Client.Pages.Author
{

View File

@@ -22,7 +22,7 @@
private IMudDialogInstance MudDialog { get; set; }
[Parameter]
public AssignmentDto Assignment { get; set; } = new AssignmentDto();
public ExamDto Assignment { get; set; } = new ExamDto();
private void Cancel() => MudDialog.Cancel();

View File

@@ -3,10 +3,10 @@
@using Helper
<MudPaper Elevation=5 Class="w-100 pa-5 rounded-xl" Height="@Height" Style="@Style">
<MudTextField Value="@AssignmentDto.Title"></MudTextField>
<MudTextField Value="@AssignmentDto.Score">SCORE</MudTextField>
<MudTextField Value="@AssignmentDto.TotalQuestions">NUMQUESTION</MudTextField>
<MudChipSet T="SubjectAreaEnum" SelectedValue="@AssignmentDto.SubjectArea" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
<MudTextField Value="@ExamDto.Title"></MudTextField>
<MudTextField Value="@ExamDto.Score">SCORE</MudTextField>
<MudTextField Value="@ExamDto.TotalQuestions">NUMQUESTION</MudTextField>
@* <MudChipSet T="SubjectAreaEnum" SelectedValue="@ExamDto.SubjectId" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
@foreach (SubjectAreaEnum item in Enum.GetValues(typeof(SubjectAreaEnum)))
{
@@ -15,7 +15,7 @@
Value="@item">
</MudChip>
}
</MudChipSet>
</MudChipSet> *@
<MudText>DUETIME</MudText>
<MudText>EXAMTYPE</MudText>
</MudPaper>
@@ -24,7 +24,7 @@
@code {
[Parameter]
public AssignmentDto AssignmentDto { get; set; }
public ExamDto ExamDto { get; set; }
[Parameter]
public string Style { get; set; }
[Parameter]
@@ -32,6 +32,6 @@
public void HandleQTSelectedValueChanged(SubjectAreaEnum subject)
{
AssignmentDto.SubjectArea = subject;
// ExamDto.SubjectArea = subject;
}
}

View File

@@ -12,7 +12,7 @@
</MudText>
</TitleContent>
<DialogContent>
<MudPaper Elevation="0" Class="rounded-xl pa-1 " Style="background-color: transparent">
@* <MudPaper Elevation="0" Class="rounded-xl pa-1 " Style="background-color: transparent">
<MudPaper Elevation="0" Class="rounded-xl pa-2 ma-2">
<MudTextField @bind-Value="Exam.Name" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
<MudTextField @bind-Value="Exam.TotalQuestions" Label="TotalQuestions" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
@@ -40,7 +40,7 @@
<MudChip Text="@ExamType.AITest.ToString()" Color="Color.Error" Value="@ExamType.AITest"> @ExamType.AITest</MudChip>
</MudChipSet>
</MudPaper>
</MudPaper>
</MudPaper> *@
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
@@ -53,7 +53,7 @@
private IMudDialogInstance MudDialog { get; set; }
[Parameter]
public AssignmentDto Exam { get; set; } = new AssignmentDto();
public ExamDto Exam { get; set; } = new ExamDto();
public SubjectAreaEnum SubjectArea { get; set; }

View File

@@ -0,0 +1,31 @@
@using TechHelper.Client.Services
@using Entities.DTO
@using Entities.Contracts
<MudChipSet T="TypeCommonDto" @bind-SelectedValue="@SelectedValue">
@foreach (var item in QuestionTypes)
{
<MudChip Color="Color.Primary" Value="@item"> @item.Name</MudChip>
}
</MudChipSet>
@code {
private TypeCommonDto SelectedValue;
private List<TypeCommonDto> QuestionTypes;
[Parameter]
public TypeNameType Type { get; set; }
[Parameter]
public Guid? SubjectID { get; set; } = null;
[Inject]
public ICommonService CommonService { get; set; }
protected async override Task OnInitializedAsync()
{
var QuestionServices = await CommonService.GetCommonTypesAsync(Type, SubjectID);
}
}

View File

@@ -9,7 +9,7 @@
</MudText>
</TitleContent>
<DialogContent>
<TechHelper.Client.Pages.Exam.AssignmentQuestionEdit AssignmentQuestion="Questions"/>
<TechHelper.Client.Pages.Exam.ExamQuestionEdit ExamQuestion="Questions"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
@@ -22,7 +22,7 @@
private IMudDialogInstance MudDialog { get; set; }
[Parameter]
public AssignmentQuestionDto Questions { get; set; } = new AssignmentQuestionDto();
public ExamQuestionDto Questions { get; set; } = new ExamQuestionDto();
private void Cancel() => MudDialog.Cancel();

View File

@@ -1,113 +0,0 @@
@using Entities.DTO
@using Entities.Contracts
@using Newtonsoft.Json
@using TechHelper.Client.Exam
@using TechHelper.Client.Pages.Exam.QuestionCard
<MudPaper Elevation="0" Class="rounded-xl" Style="background-color: transparent">
@* <MudText>@AssignmentQuestion.Id</MudText> *@
<MudPaper Class="ma-4 pa-5 rounded-xl">
<MudText Class="mt-3" Typo="Typo.button"><b>包裹器属性</b></MudText>
<MudTextField @bind-Value="AssignmentQuestion.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
<MudTextField @bind-Value="AssignmentQuestion.Index" Label="Index" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
<MudTextField @bind-Value="AssignmentQuestion.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
<MudChipSet T="AssignmentStructType" SelectedValue="AssignmentQuestion.StructType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleSelectedValueChanged">
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Root">@AssignmentStructType.Root</MudChip>
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Struct">@AssignmentStructType.Struct</MudChip>
<MudChip Text="purple" Color="Color.Primary" Value="@AssignmentStructType.Group">@AssignmentStructType.Group</MudChip>
<MudChip Text="blue" Color="Color.Info" Value="@AssignmentStructType.Question">@AssignmentStructType.Question</MudChip>
<MudChip Text="green" Color="Color.Warning" Value="@AssignmentStructType.SubQuestion">@AssignmentStructType.SubQuestion</MudChip>
<MudChip Text="orange" Color="Color.Error" Value="@AssignmentStructType.Option">@AssignmentStructType.Option</MudChip>
</MudChipSet>
<MudChipSet T="string" SelectedValue="@AssignmentQuestion.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
@foreach (var item in QuestionTypes)
{
var qt = item;
@* Style = "@($"background - color:{ item.Value.Color} ")"*@
<MudChip Style="@(qt.Key == AssignmentQuestion.QType ?
$"background-color:#ffffff; color:{item.Value.Color}" :
$"background-color:{item.Value.Color}; color:#ffffff")"
Value="@item.Key">
@item.Value.DisplayName
</MudChip>
}
</MudChipSet>
</MudPaper>
@if (AssignmentQuestion.Question != null)
{
<QuestionEdit Question="AssignmentQuestion.Question" />
}
</MudPaper>
@code {
[Parameter]
public AssignmentQuestionDto AssignmentQuestion { get; set; } = new AssignmentQuestionDto();
public QuestionDto TempQuesdto;
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
[Inject]
private ILocalStorageService LocalStorageService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
if (AssignmentQuestion.Question != null)
{
TempQuesdto = AssignmentQuestion.Question;
}
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
if(GlobalInfo != null)
{
QuestionTypes = GlobalInfo;
}
}
private void HandleQTSelectedValueChanged(string type)
{
AssignmentQuestion.QType = type;
if (AssignmentQuestion.ChildrenAssignmentQuestion.Count > 0 && AssignmentQuestion.StructType == AssignmentStructType.Group)
{
foreach (var item in AssignmentQuestion.ChildrenAssignmentQuestion)
{
item.QType = type;
if (item.Question != null)
{
item.Question.QType = type;
}
}
}
StateHasChanged();
}
private void HandleSelectedValueChanged(AssignmentStructType type)
{
AssignmentQuestion.StructType = type;
if (type != AssignmentStructType.Question && AssignmentQuestion.Question != null)
{
AssignmentQuestion.Title = AssignmentQuestion.Question.Title;
AssignmentQuestion.Question = null;
}
if (type == AssignmentStructType.Question && AssignmentQuestion.Question == null)
{
if (TempQuesdto != null)
{
AssignmentQuestion.Question = TempQuesdto;
if (AssignmentQuestion.Title == AssignmentQuestion.Question.Title)
{
AssignmentQuestion.Title = "";
}
}
else
AssignmentQuestion.Question = new QuestionDto { };
}
StateHasChanged();
}
}

View File

@@ -59,9 +59,9 @@ else if (_questionsForTable.Any() && _students.Any())
@student.DisplayName: <MudText Typo="Typo.h5" Color="Color.Primary" Class="d-inline-block ml-2">@GetStudentTotalScore(student.Id)</MudText>
</MudText>
}
<MudButton Variant="Variant.Filled" Color="Color.Success" Class="mt-4" @onclick="SubmitGrading">
@* <MudButton Variant="Variant.Filled" Color="Color.Success" Class="mt-4" @onclick="SubmitGrading">
提交批改结果 (模拟)
</MudButton>
</MudButton> *@
</MudPaper>
}
@@ -86,10 +86,10 @@ else
private NavigationManager Navigation { get; set; }
private MudTable<QuestionRowData> _table = new();
private AssignmentDto Assignment { get; set; } = new AssignmentDto();
private ExamDto Assignment { get; set; } = new ExamDto();
private AssignmentCheckData _examStruct = new AssignmentCheckData();
private List<StudentDto> _students = new List<StudentDto>();
private List<UserListDto> _students = new List<UserListDto>();
private List<QuestionRowData> _questionsForTable = new List<QuestionRowData>();
private bool _isLoading = true;
@@ -99,14 +99,14 @@ else
protected override async Task OnInitializedAsync()
{
_isLoading = true;
await LoadExamData();
// _isLoading = true;
// await LoadExamData();
var result = await ClassServices.GetClassStudents();
if (!result.Status) Snackbar.Add($"获取学生失败, {result.Message}", Severity.Error);
_students = result.Result as List<StudentDto> ?? new List<StudentDto>();
BuildTable();
_isLoading = false;
// var result = await ClassServices.GetClassStudents();
// if (!result.Status) Snackbar.Add($"获取学生失败, {result.Message}", Severity.Error);
// _students = result.Result as List<StudentDto> ?? new List<StudentDto>();
// BuildTable();
// _isLoading = false;
}
private void BuildTable()
@@ -135,7 +135,7 @@ else
var result = await ExamService.GetExam(parsedExamId);
if (result.Status)
{
Assignment = result.Result as AssignmentDto ?? new AssignmentDto();
Assignment = result.Result as ExamDto ?? new ExamDto();
_examStruct = Assignment.GetStruct();
}
else
@@ -188,52 +188,52 @@ else
StateHasChanged();
}
private void SubmitGrading()
{
// private void SubmitGrading()
// {
List<SubmissionDto> submissionDto = new List<SubmissionDto>();
// List<SubmissionDto> submissionDto = new List<SubmissionDto>();
foreach (var student in _students)
{
var newSubmission = new SubmissionDto();
newSubmission.StudentId = student.Id;
newSubmission.AssignmentId = Assignment.Id;
newSubmission.SubmissionTime = DateTime.Now;
newSubmission.Status = Entities.Contracts.SubmissionStatus.Graded;
// foreach (var student in _students)
// {
// var newSubmission = new SubmissionDto();
// newSubmission.StudentId = student.Id;
// newSubmission.AssignmentId = Assignment.Id;
// newSubmission.SubmissionTime = DateTime.Now;
// newSubmission.Status = Entities.Contracts.SubmissionStatus.Graded;
foreach (var row in _questionsForTable)
{
if (row.QuestionItem.AssignmentQuestionDto.StructType == Entities.Contracts.AssignmentStructType.Struct) continue;
if (row.StudentAnswers.TryGetValue(student.Id, out bool isCorrect))
{
newSubmission.SubmissionDetails.Add(new SubmissionDetailDto
{
IsCorrect = isCorrect,
StudentId = student.Id,
AssignmentQuestionId = row.QuestionItem.AssignmentQuestionDto.Id,
PointsAwarded = isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0
});
// foreach (var row in _questionsForTable)
// {
// if (row.QuestionItem.AssignmentQuestionDto.StructType == Entities.Contracts.AssignmentStructType.Struct) continue;
// if (row.StudentAnswers.TryGetValue(student.Id, out bool isCorrect))
// {
// newSubmission.SubmissionDetails.Add(new SubmissionDetailDto
// {
// IsCorrect = isCorrect,
// StudentId = student.Id,
// AssignmentQuestionId = row.QuestionItem.AssignmentQuestionDto.Id,
// PointsAwarded = isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0
// });
newSubmission.OverallGrade += isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0;
}
}
submissionDto.Add(newSubmission);
}
// newSubmission.OverallGrade += isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0;
// }
// }
// submissionDto.Add(newSubmission);
// }
submissionDto.ForEach(async s =>
{
Snackbar?.Add($"正在提交: {_students.FirstOrDefault(std => std.Id == s.StudentId)?.DisplayName} 的试卷", Severity.Info);
var submidResult = await ExamService.SubmissionAssignment(s);
if (submidResult.Status)
Snackbar?.Add($"批改结果已提交 {_students.FirstOrDefault(st => st.Id == s.StudentId)?.DisplayName}", Severity.Success);
else
Snackbar?.Add("批改结果提交失败", Severity.Error);
// submissionDto.ForEach(async s =>
// {
// Snackbar?.Add($"正在提交: {_students.FirstOrDefault(std => std.Id == s.StudentId)?.DisplayName} 的试卷", Severity.Info);
// var submidResult = await ExamService.SubmissionAssignment(s);
// if (submidResult.Status)
// Snackbar?.Add($"批改结果已提交 {_students.FirstOrDefault(st => st.Id == s.StudentId)?.DisplayName}", Severity.Success);
// else
// Snackbar?.Add("批改结果提交失败", Severity.Error);
});
// });
}
// }
}

View File

@@ -16,54 +16,34 @@
@inject IDialogService DialogService
<MudPaper Elevation="5" Class="d-flex overflow-hidden flex-grow-1 pa-1 rounded-xl " Style="overflow:hidden; position:relative;height:100%">
<MudDrawerContainer Class="mud-height-full flex-grow-1" Style="height:100%">
<MudDrawer @bind-Open="@_open" Elevation="0" Variant="@DrawerVariant.Persistent" Color="Color.Primary" Anchor="Anchor.End" OverlayAutoClose="true">
@if (_edit)
<MudStack Class="flex-grow-1 h-100">
<MudPaper Class="rounded-xl ma-1 pa-2" Style="background-color:#fefefefe">
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenEditor">文本编辑器</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="ParseExam">载入</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">发布</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">指派</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenTest">Test</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="HandleGlobalInfo">GlobalExamInfo</MudButton>
</MudPaper>
<ExamView Class="overflow-auto ma-1 pa-2 rounded-xl" ClickedStruct="HandleClickedStruct" ParsedExam="ExamContent"></ExamView>
<MudPaper MaxWidth="300">
@if (_parsedExam.Errors.Any())
{
<AssignmentQuestionEdit AssignmentQuestion="selectedAssignmentQuestion" />
}
else
{
<MudDrawerHeader>
<MudText Typo="Typo.h6"> 配置 </MudText>
</MudDrawerHeader>
<MudStack Class="overflow-auto">
<ParseRoleConfig />
<MudButton Color="Color.Success"> ParseExam </MudButton>
</MudStack>
}
</MudDrawer>
<MudStack Class="flex-grow-1 h-100">
<MudPaper Class="rounded-xl ma-1 pa-2" Style="background-color:#fefefefe">
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenEditor">文本编辑器</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="ParseExam">载入</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">发布</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">指派</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenTest">Test</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="HandleGlobalInfo">GlobalExamInfo</MudButton>
</MudPaper>
<ExamView Class="overflow-auto ma-1 pa-2 rounded-xl" ClickedStruct="HandleClickedStruct" ParsedExam="ExamContent"></ExamView>
<MudPaper MaxWidth="300">
@if (_parsedExam.Errors.Any())
foreach (var item in _parsedExam.Errors)
{
foreach (var item in _parsedExam.Errors)
{
<MudText> @item.Message </MudText>
}
<MudText> @item.Message </MudText>
}
</MudPaper>
</MudStack>
</MudDrawerContainer>
}
</MudPaper>
</MudStack>
</MudPaper>
@code {
@@ -71,19 +51,11 @@
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
private AssignmentQuestionDto selectedAssignmentQuestion = new AssignmentQuestionDto();
private IReadOnlyCollection<string> _selected;
private bool _open = false;
private bool _edit = false;
private ExamQuestionDto selectedAssignmentQuestion = new ExamQuestionDto();
private void ToggleDrawer()
{
_open = !_open;
_edit = false;
}
private BlazoredTextEditor _textEditor = new BlazoredTextEditor();
private AssignmentEx _parsedExam = new AssignmentEx();
private AssignmentDto ExamContent = new AssignmentDto();
private ExamEx _parsedExam = new ExamEx();
private ExamDto ExamContent = new ExamDto();
private ExamParserConfig _examParserConfig { get; set; } = new ExamParserConfig();
private string EditorText = "";
@@ -98,20 +70,6 @@
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
var response = await NoteService.GetNote((byte)SubjectAreaEnum.Literature);
if (response.Status)
{
try
{
LocalStorageService.SetItem("GlobalInfo", response.Result);
}
catch (Exception ex)
{
}
}
}
private async void OpenEditor()
@@ -141,12 +99,8 @@
StateHasChanged();
}
private async void HandleClickedStruct(AssignmentQuestionDto dto)
private async void HandleClickedStruct(ExamQuestionDto dto)
{
// _open = true;
// _edit = true;
// StateHasChanged();
var parameters = new DialogParameters<QuestionCardDialog> { { x => x.Questions, dto } };
var dialog = await DialogService.ShowAsync<QuestionCardDialog>("Edit_Question", parameters);
@@ -157,6 +111,9 @@
StateHasChanged();
}
[Inject]
public ICommonService commonService { get; set; }
private async Task ParseExam()
{
@@ -167,12 +124,12 @@
{
try
{
var exampar = new ExamParser(_examParserConfig);
var exampar = new ExamParser(_examParserConfig, commonService);
_parsedExam = exampar.ParseExamPaper(plainText);
Snackbar.Add("试卷解析成功。", Severity.Success);
Snackbar.Add($"{_parsedExam.Errors}。", Severity.Success);
StateHasChanged();
ExamContent = Mapper.Map<AssignmentDto>(_parsedExam);
ExamContent = Mapper.Map<ExamDto>(_parsedExam);
ExamContent.SeqIndex();
}
catch (Exception ex)
@@ -194,8 +151,6 @@
[Inject]
public IExamService examService { get; set; }
[Inject]
public INoteService NoteService { get; set; }
public async Task Publish()
@@ -207,7 +162,6 @@
{
Dictionary<string, (Color, string)> Note = new Dictionary<string, (Color, string)> { { "Hello", (Color.Surface, "World") }, { "My", (Color.Surface, "App") }, };
var json = JsonConvert.SerializeObject(Note);
var result = await NoteService.AddNote(new GlobalDto { SubjectArea = Entities.Contracts.SubjectAreaEnum.Physics, Data = json });
@@ -218,9 +172,6 @@
private async void HandleGlobalInfo()
{
// _open = true;
// _edit = true;
// StateHasChanged();
var parameters = new DialogParameters<ExamGlobalInfoDialog> { { x => x.Assignment, ExamContent } };
@@ -232,53 +183,3 @@
StateHasChanged();
}
}
<!-- #region name -->
@* <MudButtonGroup Vertical="true" Color="Color.Primary" Variant="Variant.Filled">
<MudIconButton Icon="@Icons.Material.Filled.Settings" OnClick="@ToggleDrawer" Color="Color.Secondary" />
<MudIconButton Icon="@Icons.Material.Filled.TransitEnterexit" OnClick="@ParseExam" Color="Color.Secondary" />
<MudIconButton Icon="@Icons.Material.Filled.Save" OnClick="@ToggleDrawer" Color="Color.Secondary" />
<MudIconButton Icon="@Icons.Material.Filled.Publish" OnClick="@Publish" Color="Color.Secondary" />
</MudButtonGroup> *@
@* <MudPaper Class="ma-2 h-100">
<MudPaper Elevation="0" Style="height:calc(100% - 80px)">
<BlazoredTextEditor @ref="@_textEditor">
<ToolbarContent>
<select class="ql-header">
<option selected=""></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
<option value="4"></option>
<option value="5"></option>
</select>
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
<select class="ql-background"></select>
</span>
<span class="ql-formats">
<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>
</span>
<span class="ql-formats">
<button class="ql-link"></button>
</span>
</ToolbarContent>
<EditorContent>
</EditorContent>
</BlazoredTextEditor>
</MudPaper>
</MudPaper> *@
<!-- #endregion -->

View File

@@ -2,7 +2,6 @@
@using Entities.DTO
@using TechHelper.Client.Pages.Exam.ExamView
@using TechHelper.Client.Services
@using Entities.DTO
@using TechHelper.Client.Exam
<ExamView ParsedExam="@ExamDto"/>
@@ -20,7 +19,7 @@
[Inject]
private ISnackbar Snackbar { get; set; }
private AssignmentDto ExamDto { get; set; }
private ExamDto ExamDto { get; set; }
protected override async Task OnInitializedAsync()
{
@@ -31,7 +30,7 @@
try
{
var result = await ExamService.GetExam(parsedExamId);
if (result.Status) ExamDto = result.Result as AssignmentDto ?? new AssignmentDto();
if (result.Status) ExamDto = result.Result as ExamDto ?? new ExamDto();
}
catch (Exception ex)
{

View File

@@ -4,7 +4,6 @@
@using TechHelper.Client.Pages.Common.Exam
@page "/exam/manage"
@using Entities.DTO
@using TechHelper.Client.Services
@attribute [Authorize]
@@ -34,7 +33,7 @@ else
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
private List<AssignmentDto> examDtos = new List<AssignmentDto>();
private List<ExamDto> examDtos = new List<ExamDto>();
private bool isloding = true;
@@ -51,7 +50,7 @@ else
var result = await ExamService.GetAllExam();
if (result.Status)
{
examDtos = result.Result as List<AssignmentDto> ?? new List<AssignmentDto>();
examDtos = result.Result as List<ExamDto> ?? new List<ExamDto>();
Snackbar.Add("加载成功", Severity.Info);
}
else

View File

@@ -3,7 +3,7 @@
<MudPaper Class="overflow-hidden " Style="background-color:pink" Width="@Width" Height="@Height" MaxHeight="@MaxHeight" MaxWidth="@MaxWidth">
<MudPaper Class="d-flex flex-column flex-grow-1 justify-content-between" Height="100%" Style="background-color:green">
<MudText Typo="Typo.body2"> @AssignmentDto.Title </MudText>
<MudText Typo="Typo.body2"> @ExamDto.Title </MudText>
<MudPaper>
@@ -34,7 +34,7 @@
public NavigationManager navigationManager { get; set; }
[Parameter]
public AssignmentDto AssignmentDto { get; set; }
public ExamDto ExamDto { get; set; }
[Parameter]
@@ -61,11 +61,11 @@
private void ExamClick()
{
navigationManager.NavigateTo($"exam/edit/{AssignmentDto.Id}");
navigationManager.NavigateTo($"exam/edit/{ExamDto.Id}");
}
private void CheckExam()
{
navigationManager.NavigateTo($"exam/check/{AssignmentDto.Id}");
navigationManager.NavigateTo($"exam/check/{ExamDto.Id}");
}
}

View File

@@ -0,0 +1,112 @@
@using Entities.Contracts
@using Entities.DTO
@using Newtonsoft.Json
@using TechHelper.Client.Exam
@using TechHelper.Client.Pages.Exam.QuestionCard
<MudPaper Elevation="0" Class="rounded-xl" Style="background-color: transparent">
@* <MudText>@AssignmentQuestion.Id</MudText> *@
<MudPaper Class="ma-4 pa-5 rounded-xl">
<MudText Class="mt-3" Typo="Typo.button"><b>包裹器属性</b></MudText>
<MudTextField @bind-Value="ExamQuestion.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
<MudTextField @bind-Value="ExamQuestion.Index" Label="Index" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
<MudTextField @bind-Value="ExamQuestion.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
@* <MudChipSet T="AssignmentStructType" SelectedValue="AssignmentQuestion.StructType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleSelectedValueChanged">
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Root">@AssignmentStructType.Root</MudChip>
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Struct">@AssignmentStructType.Struct</MudChip>
<MudChip Text="purple" Color="Color.Primary" Value="@AssignmentStructType.Group">@AssignmentStructType.Group</MudChip>
<MudChip Text="blue" Color="Color.Info" Value="@AssignmentStructType.Question">@AssignmentStructType.Question</MudChip>
<MudChip Text="green" Color="Color.Warning" Value="@AssignmentStructType.SubQuestion">@AssignmentStructType.SubQuestion</MudChip>
<MudChip Text="orange" Color="Color.Error" Value="@AssignmentStructType.Option">@AssignmentStructType.Option</MudChip>
</MudChipSet> *@
@* <MudChipSet T="string" SelectedValue="@AssignmentQuestion.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
@foreach (var item in QuestionTypes)
{
var qt = item;
<MudChip Style="@(qt.Key == AssignmentQuestion.QType ?
$"background-color:#ffffff; color:{item.Value.Color}" :
$"background-color:{item.Value.Color}; color:#ffffff")"
Value="@item.Key">
@item.Value.DisplayName
</MudChip>
}
</MudChipSet> *@
</MudPaper>
@if (ExamQuestion.Question != null)
{
<QuestionEdit Question="ExamQuestion.Question" />
}
</MudPaper>
@code {
[Parameter]
public ExamQuestionDto ExamQuestion { get; set; } = new ExamQuestionDto();
public QuestionDto TempQuesdto;
// Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
[Inject]
private ILocalStorageService LocalStorageService { get; set; }
// protected override void OnInitialized()
// {
// base.OnInitialized();
// if (AssignmentQuestion.Question != null)
// {
// TempQuesdto = AssignmentQuestion.Question;
// }
// var cs = LocalStorageService.GetItem<string>("GlobalInfo");
// var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
// if(GlobalInfo != null)
// {
// QuestionTypes = GlobalInfo;
// }
// }
// private void HandleQTSelectedValueChanged(string type)
// {
// AssignmentQuestion.QType = type;
// if (AssignmentQuestion.ChildrenAssignmentQuestion.Count > 0 && AssignmentQuestion.StructType == AssignmentStructType.Group)
// {
// foreach (var item in AssignmentQuestion.ChildrenAssignmentQuestion)
// {
// item.QType = type;
// if (item.Question != null)
// {
// item.Question.QType = type;
// }
// }
// }
// StateHasChanged();
// }
// private void HandleSelectedValueChanged(AssignmentStructType type)
// {
// AssignmentQuestion.StructType = type;
// if (type != AssignmentStructType.Question && AssignmentQuestion.Question != null)
// {
// AssignmentQuestion.Title = AssignmentQuestion.Question.Title;
// AssignmentQuestion.Question = null;
// }
// if (type == AssignmentStructType.Question && AssignmentQuestion.Question == null)
// {
// if (TempQuesdto != null)
// {
// AssignmentQuestion.Question = TempQuesdto;
// if (AssignmentQuestion.Title == AssignmentQuestion.Question.Title)
// {
// AssignmentQuestion.Title = "";
// }
// }
// else
// AssignmentQuestion.Question = new QuestionDto { };
// }
// StateHasChanged();
// }
}

View File

@@ -10,23 +10,15 @@
<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"> Num: @ExamStruct.ChildExamQuestions.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>
@* <MudChip T="string" Color="Color.Info" Class="justify-content-end">@ExamStruct.Type.Name</MudChip> *@
@if(ExamStruct.Question!=null)
{
<MudRating SelectedValue="@((int)ExamStruct.Question.DifficultyLevel)" ReadOnly="true" Size="Size.Small" />
@* <MudRating SelectedValue="@((int)ExamStruct.Question.DifficultyLevel)" ReadOnly="true" Size="Size.Small" /> *@
}
</MudStack>
</MudStack>
@@ -36,41 +28,16 @@
<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();
public ExamQuestionDto ExamStruct { get; set; } = new ExamQuestionDto();
[Parameter]
public EventCallback<AssignmentQuestionDto> ClickedStruct { get; set; }
public EventCallback<ExamQuestionDto> ClickedStruct { get; set; }
[Parameter]
public string Class { get; set; } = "my-2 pa-1";
@@ -81,20 +48,11 @@
[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()
@@ -102,14 +60,14 @@
await ClickedStruct.InvokeAsync(ExamStruct);
}
private async void HandleChildStructClick(AssignmentQuestionDto clickedChildExamStruct)
private async void HandleChildStructClick(ExamQuestionDto clickedChildExamStruct)
{
await ClickedStruct.InvokeAsync(clickedChildExamStruct);
}
private void HandleSelected(int num)
{
ExamStruct.Question.DifficultyLevel = (DifficultyLevel)num;
// ExamStruct.Question.DifficultyLevel = (DifficultyLevel)num;
}
}

View File

@@ -24,10 +24,10 @@ else
@code {
[Parameter]
public AssignmentDto ParsedExam { get; set; } = new AssignmentDto();
public ExamDto ParsedExam { get; set; } = new ExamDto();
[Parameter]
public EventCallback<AssignmentQuestionDto> ClickedStruct { get; set; }
public EventCallback<ExamQuestionDto> ClickedStruct { get; set; }
[Parameter]
public string Height { get; set; } = "100%";
@@ -39,7 +39,7 @@ else
public string Style { get; set; } = "";
private void HandleClickedStruct(AssignmentQuestionDto dto)
private void HandleClickedStruct(ExamQuestionDto dto)
{
ClickedStruct.InvokeAsync(dto);
}

View File

@@ -30,7 +30,7 @@
public QuestionDto Question { get; set; } = new QuestionDto();
[Parameter]
public AssignmentStructType Type { get; set; } = AssignmentStructType.Question;
public ExamStructType Type { get; set; } = ExamStructType.Question;
[Parameter]
public byte Index { get; set; } = 0;

View File

@@ -1,5 +1,5 @@
@using Entities.DTO
@using Entities.Contracts
@using Entities.Contracts
@using Entities.DTO
@using Newtonsoft.Json
@using TechHelper.Client.Exam
@@ -8,13 +8,10 @@
@* <MudText>@Question.Id</MudText> *@
<MudText Class="mt-3" Typo="Typo.button"><b>问题属性</b></MudText>
<MudChipSet T="string" SelectedValue="@Question.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
@* <MudChipSet T="string" SelectedValue="@Question.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
@foreach (var item in QuestionTypes)
{
var qt = item;
@* Style = "@($"background - color:{ item.Value.Color} ")"*@
<MudChip Style="@(qt.Key == Question.QType ?
$"background-color:#ffffff; color:{item.Value.Color}" :
$"background-color:{item.Value.Color}; color:#ffffff")"
@@ -22,7 +19,9 @@
@item.Value.DisplayName
</MudChip>
}
</MudChipSet>
</MudChipSet> *@
<MudRating SelectedValue="@(diffi)" SelectedValueChanged="HandleSelected" Size="Size.Small" />
<MudTextField @bind-Value="Question.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoGrow="true" />
<MudTextField @bind-Value="Question.Answer" Label="Answer" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoGrow="true" />
@@ -35,7 +34,7 @@
[Parameter]
public QuestionDto Question { get; set; } = new QuestionDto();
public int diffi = 0;
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
// Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
[Inject]
private ILocalStorageService LocalStorageService { get; set; }
@@ -43,26 +42,23 @@
{
base.OnInitialized();
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
if (GlobalInfo != null)
{
QuestionTypes = GlobalInfo;
}
// var cs = LocalStorageService.GetItem<string>("GlobalInfo");
// var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
// if (GlobalInfo != null)
// {
// }
}
private void HandleSelectedValueChanged(QuestionType type)
{
Question.Type = type;
}
private void HandleSelected(int num)
{
Question.DifficultyLevel = (DifficultyLevel)num;
// Question.DifficultyLevel = (DifficultyLevel)num;
}
private void HandleQTSelectedValueChanged(string type)
{
Question.QType = type;
StateHasChanged();
}
}

View File

@@ -1,12 +1,17 @@
@page "/"
@using Microsoft.AspNetCore.Authorization
@using TechHelper.Client.Pages.Common.Exam
@*
<AuthorizeView Roles="Student">
<Authorizing>
<p>Loading...</p>
</Authorizing>
<Authorized>
<TechHelper.Client.Pages.Student.HomePage />
</Authorized>
</AuthorizeView>
</AuthorizeView> *@
<MudText>Hello</MudText>
@code {
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
@@ -14,6 +19,5 @@
protected override Task OnInitializedAsync()
{
return base.OnInitializedAsync();
Console.WriteLine(authenticationStateTask.Result.User.IsInRole("Student"));
}
}

View File

@@ -18,7 +18,7 @@
<MudRadioGroup T="UserRoles" Label="Roles" @bind-Value="_userRegistrationToClassDto.Roles">
@foreach (UserRoles item in Enum.GetValues(typeof(UserRoles)))
{
if (item != UserRoles.Administrator)
if (item != UserRoles.Admin)
{
<MudRadio Value="@item">@item.ToString()</MudRadio>
}

View File

@@ -1,5 +1,6 @@
@using TechHelper.Client.Services
@inject IStudentSubmissionService StudentSubmissionService
@using Entities.DTO
<MudPaper Class="ma-2 pa-2 rounded-xl d-flex flex-column flex-grow-1 overflow-auto" MaxHeight="100%">
@@ -60,7 +61,7 @@
if (result.Status && result.Result != null)
{
// 从服务器获取的数据映射到我们的模型
var submissions = result.Result as List<Entities.DTO.StudentSubmissionSummaryDto>;
var submissions = result.Result as List<StudentSubmissionSummaryDto>;
if (submissions != null)
{

View File

@@ -3,7 +3,7 @@
@code {
[Parameter]
public StudentDto StudentDto{ get; set; }
public StudentExamDetailDto StudentDto{ get; set; }

View File

@@ -16,7 +16,7 @@
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
private List<StudentDto> ClassStudents { get; set; } = new List<StudentDto>();
private List<StudentExamDetailDto> ClassStudents { get; set; } = new List<StudentExamDetailDto>();
[Inject]
public IClassServices ClassServices { get; set; }
@@ -24,7 +24,7 @@
protected override async Task OnInitializedAsync()
{
var result = await ClassServices.GetClassStudents();
ClassStudents = result.Result as List<StudentDto> ?? new List<StudentDto>();
ClassStudents = result.Result as List<StudentExamDetailDto> ?? new List<StudentExamDetailDto>();
StateHasChanged();
}
}

View File

@@ -47,7 +47,6 @@ builder.Services.AddScoped<IClassServices, ClasssServices>();
builder.Services.AddScoped<IEmailSender, QEmailSender>();
builder.Services.AddScoped<HttpInterceptorHandlerService>();
builder.Services.AddScoped<IAIService, AiService>();
builder.Services.AddScoped<INoteService, NoteService>();
builder.Services.AddScoped<IUserServices, UserServices>();
builder.Services.AddHttpClient("WebApiClient", client =>
{

View File

@@ -1,9 +1,7 @@
using Entities.Contracts;
using Entities.DTO;
using Entities.DTO;
using Newtonsoft.Json;
using System.Net.Http.Json;
using TechHelper.Client.HttpRepository;
using TechHelper.Services;
namespace TechHelper.Client.Services
{
@@ -38,7 +36,7 @@ namespace TechHelper.Client.Services
{
var result = await _client.PostAsJsonAsync("class/getClassStudents","");
var content = await result.Content.ReadAsStringAsync();
var users = JsonConvert.DeserializeObject<List<StudentDto>>(content);
var users = JsonConvert.DeserializeObject<List<StudentExamDetailDto>>(content);
return ApiResponse.Success(result: users);
}
catch(Exception ex)
@@ -63,7 +61,7 @@ namespace TechHelper.Client.Services
}
}
public StudentDto GetStudents(byte Class)
public StudentExamDetailDto GetStudents(byte Class)
{
try
{
@@ -71,18 +69,18 @@ namespace TechHelper.Client.Services
var content = result.Result.Content.ReadAsStringAsync();
if (content.Result != null)
{
var users = JsonConvert.DeserializeObject<StudentDto>(content.Result);
var users = JsonConvert.DeserializeObject<StudentExamDetailDto>(content.Result);
return users;
}
else
{
return new StudentDto();
return new StudentExamDetailDto();
}
}
catch (Exception ex)
{
Console.WriteLine($"获取失败,{ex.Message}, InnerException: {ex.InnerException}");
return new StudentDto();
return new StudentExamDetailDto();
}
}

View File

@@ -0,0 +1,47 @@
using Entities.Contracts;
using Entities.DTO;
using System.Net.Http.Json;
using TechHelper.Client.HttpRepository;
namespace TechHelper.Client.Services
{
public class CommonService : ICommonService
{
private readonly HttpClient _client;
private readonly IAuthenticationClientService _authenticationClientService;
public CommonService(HttpClient client, IAuthenticationClientService authenticationClientService)
{
_client = client;
_authenticationClientService = authenticationClientService;
}
public async Task<List<TypeCommonDto>> GetCommonTypesAsync(TypeNameType typeNameType, Guid? SubjectId = null)
{
switch (typeNameType)
{
case TypeNameType.Subject:
{
var response = await _client.GetAsync("subject");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
case TypeNameType.ExamType:
{
var response = await _client.GetAsync("exam-type");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
case TypeNameType.QuestionType:
{
var response = await _client.GetAsync("question-type");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
}
throw new NotImplementedException();
}
}
}

View File

@@ -1,6 +1,5 @@
using System.Xml.Serialization; // 用于 XML 序列化/反序列化
using TechHelper.Client.AI;
using TechHelper.Services;
using Entities.DTO;
using System.Net.Http.Json; // 用于 PostAsJsonAsync
using Newtonsoft.Json;
@@ -93,7 +92,7 @@ namespace TechHelper.Client.Services
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<List<AssignmentDto>>(content);
var result = JsonConvert.DeserializeObject<List<ExamDto>>(content);
return ApiResponse.Success(result: result);
}
else
@@ -112,7 +111,7 @@ namespace TechHelper.Client.Services
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var exam = JsonConvert.DeserializeObject<AssignmentDto>(content);
var exam = JsonConvert.DeserializeObject<ExamDto>(content);
return ApiResponse.Success();
}
return ApiResponse.Error(message: "获取失败");
@@ -130,7 +129,7 @@ namespace TechHelper.Client.Services
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var exam = JsonConvert.DeserializeObject<AssignmentDto>(content);
var exam = JsonConvert.DeserializeObject<ExamDto>(content);
return ApiResponse.Success(result: exam);
}
else
@@ -162,7 +161,7 @@ namespace TechHelper.Client.Services
}
}
public async Task<ApiResponse> SaveParsedExam(AssignmentDto assiDto)
public async Task<ApiResponse> SaveParsedExam(ExamDto assiDto)
{
// 直接使用注入的 _client 实例
var response = await _client.PostAsJsonAsync("exam/add", assiDto);

View File

@@ -1,6 +1,5 @@
using Entities.DTO;
using System.Net;
using TechHelper.Services;
namespace TechHelper.Client.Services
{
@@ -10,6 +9,6 @@ namespace TechHelper.Client.Services
public Task<ResponseDto> CreateClass(UserRegistrationToClassDto userClass);
public Task<ApiResponse> GetClassStudents();
public Task<ApiResponse> GetGradeClasses(byte grade);
public StudentDto GetStudents(byte Class);
public StudentExamDetailDto GetStudents(byte Class);
}
}

View File

@@ -0,0 +1,10 @@
using Entities.Contracts;
using Entities.DTO;
namespace TechHelper.Client.Services
{
public interface ICommonService
{
public Task<List<TypeCommonDto>> GetCommonTypesAsync(TypeNameType typeNameType, Guid? SubjectId = null);
}
}

View File

@@ -1,5 +1,4 @@
using Entities.DTO;
using TechHelper.Services;
namespace TechHelper.Client.Services
{
@@ -7,7 +6,7 @@ namespace TechHelper.Client.Services
{
public Task<ApiResponse> FormatExam(string examContent);
public Task<ApiResponse> DividExam(string examContent);
public Task<ApiResponse> SaveParsedExam(AssignmentDto assiDto);
public Task<ApiResponse> SaveParsedExam(ExamDto assiDto);
public Task<ApiResponse> ParseSingleQuestionGroup(string examContent);
public ApiResponse ConvertToXML<T>(string xmlContent);

View File

@@ -1,14 +0,0 @@
using Entities.DTO;
using TechHelper.Services;
namespace TechHelper.Client.Services
{
public interface INoteService
{
public Task<ApiResponse> AddNote(GlobalDto dto);
public Task<ApiResponse> DeleteNote(byte id);
public Task<ApiResponse> GetAllNotes();
public Task<ApiResponse> GetNote(byte id);
public Task<ApiResponse> UpdateNote(GlobalDto dto);
}
}

View File

@@ -1,5 +1,4 @@
using Entities.DTO;
using TechHelper.Services;
namespace TechHelper.Client.Services
{

View File

@@ -1,4 +1,4 @@
using TechHelper.Services;
using Entities.DTO;
namespace TechHelper.Client.Services
{

View File

@@ -1,151 +0,0 @@
using Entities.DTO;
using System.Net.Http.Json;
using TechHelper.Client.AI;
using TechHelper.Services;
namespace TechHelper.Client.Services
{
public class NoteService : INoteService
{
private readonly HttpClient _client;
public NoteService(HttpClient client)
{
_client = client;
}
/// <summary>
/// 添加一个新笔记
/// </summary>
/// <param name="dto">包含笔记数据的数据传输对象</param>
/// <returns>操作结果</returns>
public async Task<ApiResponse> AddNote(GlobalDto dto)
{
try
{
var response = await _client.PostAsJsonAsync("note", dto);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
return result ?? ApiResponse.Success("操作成功。");
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
return ApiResponse.Error($"添加失败。状态码: {response.StatusCode}。详情: {errorContent}");
}
}
catch (HttpRequestException ex)
{
return ApiResponse.Error($"网络请求错误: {ex.Message}");
}
}
/// <summary>
/// 根据 ID 删除一个笔记
/// </summary>
/// <param name="id">要删除的笔记的 ID</param>
/// <returns>操作结果</returns>
public async Task<ApiResponse> DeleteNote(byte id)
{
try
{
var response = await _client.DeleteAsync($"note/{id}");
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
return result ?? ApiResponse.Success("删除成功。");
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
return ApiResponse.Error($"删除失败。状态码: {response.StatusCode}。详情: {errorContent}");
}
}
catch (HttpRequestException ex)
{
return ApiResponse.Error($"网络请求错误: {ex.Message}");
}
}
/// <summary>
/// 获取所有笔记
/// </summary>
/// <returns>包含所有笔记列表的操作结果</returns>
public async Task<ApiResponse> GetAllNotes()
{
try
{
var response = await _client.GetAsync("note");
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
return result ?? ApiResponse.Success("获取成功。");
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
return ApiResponse.Error($"获取失败。状态码: {response.StatusCode}。详情: {errorContent}");
}
}
catch (HttpRequestException ex)
{
return ApiResponse.Error($"网络请求错误: {ex.Message}");
}
}
/// <summary>
/// 根据 ID 获取单个笔记
/// </summary>
/// <param name="id">要获取的笔记的 ID</param>
/// <returns>包含单个笔记数据的操作结果</returns>
public async Task<ApiResponse> GetNote(byte id)
{
try
{
var response = await _client.GetAsync($"note/{id}");
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
return result ?? ApiResponse.Success("获取成功。");
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
return ApiResponse.Error($"获取失败。状态码: {response.StatusCode}。详情: {errorContent}");
}
}
catch (HttpRequestException ex)
{
return ApiResponse.Error($"网络请求错误: {ex.Message}");
}
}
public async Task<ApiResponse> UpdateNote(GlobalDto dto)
{
try
{
var response = await _client.PutAsJsonAsync("note", dto);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
return result ?? ApiResponse.Success("更新成功。");
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
return ApiResponse.Error($"更新失败。状态码: {response.StatusCode}。详情: {errorContent}");
}
}
catch (HttpRequestException ex)
{
return ApiResponse.Error($"网络请求错误: {ex.Message}");
}
}
}
}

View File

@@ -1,5 +1,4 @@
using Entities.DTO;
using TechHelper.Client.HttpRepository;
using System.Net.Http.Json;
namespace TechHelper.Client.Services

View File

@@ -1,7 +1,5 @@
using Entities.DTO;
using TechHelper.Services;
using System.Net.Http.Json;
using Newtonsoft.Json;
using Entities.DTO;
namespace TechHelper.Client.Services
{

View File

@@ -1,4 +1,4 @@
using TechHelper.Services;
using Entities.DTO;
namespace TechHelper.Client.Services
{

View File

@@ -36,10 +36,10 @@
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js"></script>
<script src="_content/Blazored.TextEditor/quill-blot-formatter.min.js"></script>
<script src="_content/Blazored.TextEditor/Blazored-BlazorQuill.js"></script>
<script async
<!--<script async
defer
src="https://maxkb.eazygame.cn/chat/api/embed?protocol=https&host=maxkb.eazygame.cn&token=be77837293de870e">
</script>
</script>-->
</body>