public void AddStudentAns(ProblemType pt, Pid_Ans pa) { XmlNode xn; switch (pt) { case ProblemType.Choice: case ProblemType.Completion: case ProblemType.Judgment: case ProblemType.Word: case ProblemType.Excel: case ProblemType.PowerPoint: case ProblemType.CProgramCompletion: case ProblemType.CProgramModification: case ProblemType.CProgramFun: case ProblemType.CppProgramCompletion: case ProblemType.CppProgramModification: case ProblemType.CppProgramFun: case ProblemType.VbProgramCompletion: case ProblemType.VbProgramModification: case ProblemType.VbProgramFun: { xn = Find(xd.ChildNodes.Item(1).ChildNodes.Item(0), pt.ToString()); XmlElement xmlelem; xmlelem = xd.CreateElement("ProblemID"); xmlelem.AppendChild(xd.CreateTextNode(pa.id.ToString())); xn.AppendChild(xmlelem); xmlelem = xd.CreateElement("StudentAns"); xmlelem.AppendChild(xd.CreateTextNode(pa.ans)); xn.AppendChild(xmlelem); break; } default: { break; } } xd.Save(fileName); }
public void AddLog(ProblemType pt, Pid_Ans pa) { XmlNode xn; XmlElement xmlelem, xmlelem1; xmlelem = xd.CreateElement("Time"); XmlAttribute xa = xd.CreateAttribute("value"); xmlelem.Attributes.Append(xa); xmlelem.SetAttribute("value", DateTime.Now.ToLongTimeString()); xa = xd.CreateAttribute("type"); xmlelem.Attributes.Append(xa); xmlelem.SetAttribute("type", pt.ToString()); switch (pt) { case ProblemType.Choice: case ProblemType.Completion: case ProblemType.Judgment: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("StudentAns"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } case ProblemType.Word: case ProblemType.Excel: case ProblemType.PowerPoint: case ProblemType.CProgramCompletion: case ProblemType.CProgramModification: case ProblemType.CProgramFun: case ProblemType.CppProgramCompletion: case ProblemType.CppProgramModification: case ProblemType.CppProgramFun: case ProblemType.VbProgramCompletion: case ProblemType.VbProgramModification: case ProblemType.VbProgramFun: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("AnsPath"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } case ProblemType.Start: case ProblemType.Blank: { xmlelem1 = xd.CreateElement("ProblemID"); xmlelem1.AppendChild(xd.CreateTextNode(pa.id.ToString())); xmlelem.AppendChild(xmlelem1); xmlelem1 = xd.CreateElement("StudentAns"); xmlelem1.AppendChild(xd.CreateTextNode(pa.ans)); xmlelem.AppendChild(xmlelem1); break; } default: { break; } } xd.ChildNodes[1].AppendChild(xmlelem); xd.Save(fileName); }