From f9ff57ff7250811e712bdc906f4c34add01477c7 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:05:13 +0800 Subject: [PATCH] Finishddd --- Entities/Contracts/AppMainStruct.cs | 4 +- Entities/DTO/AssignmentQuestionDto.cs | 2 +- .../AuthProviders/TestAuthStateProvider.cs | 23 - .../Content/AutoMapperProFile.cs | 21 + TechHelper.Client/Exam/Exam.cs | 241 ------ .../Exam/ExamPaperExtensions .cs | 251 +----- TechHelper.Client/Exam/ExamParse.cs | 802 ++++++------------ TechHelper.Client/Pages/Exam/ExamCreate.razor | 22 +- .../Pages/Exam/ParseRoleConfig.razor | 163 ++-- TechHelper.Client/Program.cs | 6 +- TechHelper.Client/Services/ExamService.cs | 2 +- ...ner.cs => 20250624103910_init.Designer.cs} | 8 +- ...4030547_init.cs => 20250624103910_init.cs} | 6 +- .../ApplicationContextModelSnapshot.cs | 6 +- .../Repositories/ExamRepository.cs | 1 + 15 files changed, 385 insertions(+), 1173 deletions(-) delete mode 100644 TechHelper.Client/AuthProviders/TestAuthStateProvider.cs create mode 100644 TechHelper.Client/Content/AutoMapperProFile.cs rename TechHelper.Server/Migrations/{20250624030547_init.Designer.cs => 20250624103910_init.Designer.cs} (99%) rename TechHelper.Server/Migrations/{20250624030547_init.cs => 20250624103910_init.cs} (99%) diff --git a/Entities/Contracts/AppMainStruct.cs b/Entities/Contracts/AppMainStruct.cs index 8fa68b5..5246b5c 100644 --- a/Entities/Contracts/AppMainStruct.cs +++ b/Entities/Contracts/AppMainStruct.cs @@ -70,8 +70,10 @@ namespace Entities.Contracts public enum AssignmentStructType : byte { Question, + Composite, Struct, - SubQuestion + SubQuestion, + Option } } diff --git a/Entities/DTO/AssignmentQuestionDto.cs b/Entities/DTO/AssignmentQuestionDto.cs index 5068f76..5cb66a9 100644 --- a/Entities/DTO/AssignmentQuestionDto.cs +++ b/Entities/DTO/AssignmentQuestionDto.cs @@ -20,7 +20,7 @@ namespace Entities.DTO public AssignmentStructType StructType { get; set; } = AssignmentStructType.Question; public AssignmentQuestionDto? ParentAssignmentQuestion { get; set; } - public ICollection ChildrenAssignmentQuestion { get; set; } = new List(); + public List ChildrenAssignmentQuestion { get; set; } = new List(); public QuestionDto? Question { get; set; } } diff --git a/TechHelper.Client/AuthProviders/TestAuthStateProvider.cs b/TechHelper.Client/AuthProviders/TestAuthStateProvider.cs deleted file mode 100644 index 219578e..0000000 --- a/TechHelper.Client/AuthProviders/TestAuthStateProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNetCore.Components.Authorization; -using System.Security.Claims; - -namespace TechHelper.Client.AuthProviders -{ - public class TestAuthStateProvider : AuthenticationStateProvider - { - - - public override async Task GetAuthenticationStateAsync() - { - var claims = new List - { - new Claim(ClaimTypes.Name, "John Doe"), - new Claim(ClaimTypes.Role, "Administrator") - }; - - var anonymous = new ClaimsIdentity(); - - return await Task.FromResult(new AuthenticationState(new ClaimsPrincipal(anonymous))); - } - } -} diff --git a/TechHelper.Client/Content/AutoMapperProFile.cs b/TechHelper.Client/Content/AutoMapperProFile.cs new file mode 100644 index 0000000..aff8517 --- /dev/null +++ b/TechHelper.Client/Content/AutoMapperProFile.cs @@ -0,0 +1,21 @@ +using AutoMapper; +using AutoMapper.Internal.Mappers; +using Entities.Contracts; +using Entities.DTO; +using TechHelper.Client.Exam; + +namespace TechHelper.Context +{ + public class AutoMapperProFile : Profile + { + public AutoMapperProFile() + { + CreateMap() + .ForMember(d => d.Options, o => o.MapFrom(s => string.Join(Environment.NewLine, s.Options.Select(op => op.Text)))); + CreateMap() + .ForMember(d=>d.Description, o=>o.Ignore()); + CreateMap(); + } + } + +} diff --git a/TechHelper.Client/Exam/Exam.cs b/TechHelper.Client/Exam/Exam.cs index 26f6e50..a0141a5 100644 --- a/TechHelper.Client/Exam/Exam.cs +++ b/TechHelper.Client/Exam/Exam.cs @@ -5,245 +5,4 @@ using System.IO; // 用于 XML 反序列化 namespace TechHelper.Client.Exam { - - //[XmlRoot("EP")] - //public class StringsList - //{ - - // [XmlElement("Q")] - // public List Items { get; set; } - //} - - //// XML 根元素 - //[XmlRoot("EP")] - //public class ExamPaper - //{ - // // XML 特性: 包含 列表 - // [XmlArray("QGs")] - // [XmlArrayItem("QG")] - // [JsonProperty("QuestionGroups")] - // public List QuestionGroups { get; set; } = new List(); - //} - - //[XmlRoot("QG")] - //public class QuestionGroup - //{ - // // JSON 特性 - // [JsonProperty("题号")] - // // XML 特性:作为 属性 - // [XmlAttribute("Id")] - // public byte Id { get; set; } - - // [JsonProperty("标题")] - // [XmlElement("T")] // T for Title - // public string Title { get; set; } - - // [JsonProperty("分值")] - // [XmlAttribute("S")] // S for Score - // public int Score { get; set; } - - // [JsonProperty("题目引用")] - // [XmlElement("QR")] // QR for QuestionReference,作为 元素 - // public string QuestionReference { get; set; } = ""; // 初始化为空字符串 - - // [JsonProperty("子题目")] - // [XmlArray("SQs")] // SQs 包含 列表 - // [XmlArrayItem("SQ")] - // public List SubQuestions { get; set; } = new List(); - - // [JsonProperty("子题组")] - // [XmlArray("SQGs")] // SQGs 包含 列表 (嵌套题组) - // [XmlArrayItem("QG")] - // public List SubQuestionGroups { get; set; } = new List(); - //} - - //// 子题目类 - //public class SubQuestion - //{ - - // [JsonProperty("子题号")] - // [XmlAttribute("Id")] // Id for SubId - // public byte SubId { get; set; } - - // [JsonProperty("题干")] - // [XmlElement("T")] // T for Text (Stem) - // public string Stem { get; set; } - - // [JsonProperty("分值")] - // [XmlAttribute("S")] // S for Score - // public int Score { get; set; } // 分值通常为整数 - - // [JsonProperty("选项")] - // [XmlArray("Os")] // Os 包含 列表 - // [XmlArrayItem("O")] - // public List