From e824c081bfde5b542cd4d435fc9124b07db73683 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Fri, 30 May 2025 12:46:55 +0800 Subject: [PATCH] change --- Entities/Contracts/Assignment.cs | 5 +- Entities/Contracts/AssignmentQuestion.cs | 5 +- Entities/Contracts/Submission.cs | 3 +- Entities/Contracts/SubmissionDetail.cs | 3 +- Entities/DTO/ApiResponse.cs | 4 + Entities/DTO/ExamDto.cs | 55 ++ TechHelper.Client/AI/AIConfiguration.cs | 4 +- TechHelper.Client/AI/AiService.cs | 5 +- TechHelper.Client/Exam/Exam.cs | 5 +- TechHelper.Client/Exam/ExamParse.cs | 429 +++++++++++ TechHelper.Client/Exam/ExamService.cs | 171 +++++ TechHelper.Client/Exam/IExamService.cs | 14 + TechHelper.Client/Layout/MainLayout.razor | 35 +- TechHelper.Client/Layout/NavBar.razor | 18 +- TechHelper.Client/Pages/AccountView.razor | 2 +- TechHelper.Client/Pages/AuthLinks.razor | 32 +- .../Pages/Editor/EditorMain.razor | 188 +++-- .../Pages/Editor/EditorMain.razor.cs | 665 +++++++++++++----- .../Pages/Exam/QuestionGroupDisplay.razor | 42 +- TechHelper.Client/Program.cs | 2 + TechHelper.Client/wwwroot/ref/background.jpg | Bin 0 -> 61740 bytes TechHelper.Client/wwwroot/ref/bg.jpg | Bin 0 -> 8489 bytes TechHelper.Client/wwwroot/ref/bg2.jpg | Bin 0 -> 236964 bytes TechHelper.Client/wwwroot/ref/bg3.jpg | Bin 0 -> 40211 bytes TechHelper.Client/wwwroot/ref/bg4.jpg | Bin 0 -> 13628 bytes TechHelper.Client/wwwroot/ref/bg5.jpg | Bin 0 -> 291996 bytes .../Context/AutoMapperProFile.cs | 22 + .../AssignmentQuestionConfiguration.cs | 3 + ...ner.cs => 20250528090233_init.Designer.cs} | 33 +- ...0094348_init.cs => 20250528090233_init.cs} | 17 +- .../ApplicationContextModelSnapshot.cs | 31 +- TechHelper.Server/Services/ApiResponse.cs | 44 +- TechHelper.Server/Services/ExamService.cs | 306 ++++++++ TechHelper.Server/Services/IBaseService.cs | 10 +- TechHelper.Server/Services/IExamService.cs | 10 + 35 files changed, 1800 insertions(+), 363 deletions(-) create mode 100644 Entities/DTO/ExamDto.cs create mode 100644 TechHelper.Client/Exam/ExamParse.cs create mode 100644 TechHelper.Client/Exam/ExamService.cs create mode 100644 TechHelper.Client/Exam/IExamService.cs create mode 100644 TechHelper.Client/wwwroot/ref/background.jpg create mode 100644 TechHelper.Client/wwwroot/ref/bg.jpg create mode 100644 TechHelper.Client/wwwroot/ref/bg2.jpg create mode 100644 TechHelper.Client/wwwroot/ref/bg3.jpg create mode 100644 TechHelper.Client/wwwroot/ref/bg4.jpg create mode 100644 TechHelper.Client/wwwroot/ref/bg5.jpg rename TechHelper.Server/Migrations/{20250520094348_init.Designer.cs => 20250528090233_init.Designer.cs} (97%) rename TechHelper.Server/Migrations/{20250520094348_init.cs => 20250528090233_init.cs} (97%) create mode 100644 TechHelper.Server/Services/ExamService.cs create mode 100644 TechHelper.Server/Services/IExamService.cs diff --git a/Entities/Contracts/Assignment.cs b/Entities/Contracts/Assignment.cs index e4b4611..7e7d8a2 100644 --- a/Entities/Contracts/Assignment.cs +++ b/Entities/Contracts/Assignment.cs @@ -23,12 +23,15 @@ namespace Entities.Contracts [Column("description")] public string Description { get; set; } + [Column("subject_area")] + public string SubjectArea { get; set; } + [Required] [Column("due_date")] public DateTime DueDate { get; set; } [Column("total_points")] - public decimal? TotalPoints { get; set; } + public float? TotalPoints { get; set; } [Column("created_by")] [ForeignKey("Creator")] diff --git a/Entities/Contracts/AssignmentQuestion.cs b/Entities/Contracts/AssignmentQuestion.cs index adb19a5..2e0ca0e 100644 --- a/Entities/Contracts/AssignmentQuestion.cs +++ b/Entities/Contracts/AssignmentQuestion.cs @@ -23,11 +23,14 @@ namespace Entities.Contracts [Required] [Column("question_number")] - public uint QuestionNumber { get; set; } + public byte QuestionNumber { get; set; } [Column("created_at")] public DateTime CreatedAt { get; set; } + [Column("score")] + public float? Score { get; set; } + [Required] [Column("detail_id")] [ForeignKey("AssignmentGroup")] diff --git a/Entities/Contracts/Submission.cs b/Entities/Contracts/Submission.cs index 2009f91..30affba 100644 --- a/Entities/Contracts/Submission.cs +++ b/Entities/Contracts/Submission.cs @@ -34,8 +34,7 @@ namespace Entities.Contracts public DateTime SubmissionTime { get; set; } [Column("overall_grade")] - [Precision(5, 2)] - public decimal? OverallGrade { get; set; } + public float? OverallGrade { get; set; } [Column("overall_feedback")] public string OverallFeedback { get; set; } diff --git a/Entities/Contracts/SubmissionDetail.cs b/Entities/Contracts/SubmissionDetail.cs index 45670b7..a68d5eb 100644 --- a/Entities/Contracts/SubmissionDetail.cs +++ b/Entities/Contracts/SubmissionDetail.cs @@ -38,8 +38,7 @@ namespace Entities.Contracts public bool? IsCorrect { get; set; } [Column("points_awarded")] - [Precision(5, 2)] - public decimal? PointsAwarded { get; set; } + public float? PointsAwarded { get; set; } [Column("teacher_feedback")] public string TeacherFeedback { get; set; } diff --git a/Entities/DTO/ApiResponse.cs b/Entities/DTO/ApiResponse.cs index f8d9748..cb05d8b 100644 --- a/Entities/DTO/ApiResponse.cs +++ b/Entities/DTO/ApiResponse.cs @@ -14,6 +14,10 @@ this.Result = result; } + public ApiResponse() + { + } + public string Message { get; set; } public bool Status { get; set; } diff --git a/Entities/DTO/ExamDto.cs b/Entities/DTO/ExamDto.cs new file mode 100644 index 0000000..0a95e1a --- /dev/null +++ b/Entities/DTO/ExamDto.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entities.DTO +{ + public class ExamDto + { + public Guid? AssignmentId { get; set; } + public string AssignmentTitle { get; set; } = string.Empty; + public string Description { get; set; } + public string SubjectArea { get; set; } + public List QuestionGroups { get; set; } = new List(); + } + + public class QuestionGroupDto + { + public int Index { get; set; } + + public string Title { get; set; } + + public int Score { get; set; } + + public string QuestionReference { get; set; } + + public List SubQuestions { get; set; } = new List(); + + public List SubQuestionGroups { get; set; } = new List(); + } + + public class SubQuestionDto + { + + public byte Index { get; set; } + + public string Stem { get; set; } + + public float Score { get; set; } + + public List Options { get; set; } = new List(); + + public string SampleAnswer { get; set; } + + public string QuestionType { get; set; } + public string DifficultyLevel { get; set; } + + } + + public class OptionDto + { + public string Value { get; set; } + } +} diff --git a/TechHelper.Client/AI/AIConfiguration.cs b/TechHelper.Client/AI/AIConfiguration.cs index 7714e86..39bc771 100644 --- a/TechHelper.Client/AI/AIConfiguration.cs +++ b/TechHelper.Client/AI/AIConfiguration.cs @@ -166,8 +166,6 @@ "; - - - + public static string Format { get; internal set; } } } diff --git a/TechHelper.Client/AI/AiService.cs b/TechHelper.Client/AI/AiService.cs index e8ed922..ce22ad3 100644 --- a/TechHelper.Client/AI/AiService.cs +++ b/TechHelper.Client/AI/AiService.cs @@ -33,7 +33,6 @@ namespace TechHelper.Client.AI string content = response.Choices[0].Message?.Content; if (!string.IsNullOrEmpty(content)) { - // 移除 ... 标签及其内容 int startIndex = content.IndexOf(""); int endIndex = content.IndexOf(""); if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) @@ -46,11 +45,11 @@ namespace TechHelper.Client.AI } catch (HttpRequestException ex) { - Console.WriteLine($"API 请求错误:{ex.Message}"); + throw; } catch (Exception ex) { - Console.WriteLine($"发生未知错误:{ex.Message}"); + throw; } return null; } diff --git a/TechHelper.Client/Exam/Exam.cs b/TechHelper.Client/Exam/Exam.cs index 015c4b1..0737646 100644 --- a/TechHelper.Client/Exam/Exam.cs +++ b/TechHelper.Client/Exam/Exam.cs @@ -32,7 +32,7 @@ namespace TechHelper.Client.Exam [JsonProperty("题号")] // XML 特性:作为 属性 [XmlAttribute("Id")] - public string Id { get; set; } + public byte Id { get; set; } [JsonProperty("标题")] [XmlElement("T")] // T for Title @@ -60,9 +60,10 @@ namespace TechHelper.Client.Exam // 子题目类 public class SubQuestion { + [JsonProperty("子题号")] [XmlAttribute("Id")] // Id for SubId - public string SubId { get; set; } + public byte SubId { get; set; } [JsonProperty("题干")] [XmlElement("T")] // T for Text (Stem) diff --git a/TechHelper.Client/Exam/ExamParse.cs b/TechHelper.Client/Exam/ExamParse.cs new file mode 100644 index 0000000..6b1e012 --- /dev/null +++ b/TechHelper.Client/Exam/ExamParse.cs @@ -0,0 +1,429 @@ +using System.Text.RegularExpressions; + +namespace TechHelper.Client.Exam.Parse +{ + public class ExamPaper + { + public string Title { get; set; } = "未识别试卷标题"; + public string Descript { get; set; } = "未识别试卷描述"; + public string SubjectArea { get; set; } = "试卷类别"; + public List MajorQuestionGroups { get; set; } = new List(); + public List TopLevelQuestions { get; set; } = new List(); + } + + public class MajorQuestionGroup + { + public string Title { get; set; } = string.Empty; + public string Descript { get; set; } = string.Empty; + public float Score { get; set; } + public List SubMajorQuestionGroups { get; set; } = new List(); + public List Questions { get; set; } = new List(); + public int Priority { get; set; } + } + + public class Question + { + public string Number { get; set; } = string.Empty; + public string Text { get; set; } = string.Empty; + public float Score { get; set; } + public List