using Newtonsoft.Json; using System.Xml.Serialization; // 确保引用此命名空间 using System.Collections.Generic; 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 string Id { get; set; } [JsonProperty("标题")] [XmlAttribute("T")] // T for Title public string Title { get; set; } [JsonProperty("分值")] [XmlAttribute("S")] // S for Score public int Score { get; set; } [JsonProperty("分值问题标记")] [XmlAttribute("SPM")] // SPM for ScoreProblemMarker public string ScoreProblemMarker { get; set; } = ""; // 初始化为空字符串,避免 null [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 string SubId { get; set; } [JsonProperty("题干")] [XmlAttribute("T")] // T for Text (Stem) public string Stem { get; set; } [JsonProperty("分值")] [XmlAttribute("S")] // S for Score public int Score { get; set; } // 分值通常为整数 [JsonProperty("分值问题标记")] [XmlAttribute("SPM")] // SPM for ScoreProblemMarker public string ScoreProblemMarker { get; set; } = ""; // 注意:这里的 Options 需要适配 XML 结构 // 因此它不再是 List,而是 List