Exemplo n.º 1
0
        public static string ToDisplayName(this ProblemType self)
        {
            switch (self)
            {
            case ProblemType.Basic:
                return("基本");

            case ProblemType.Advanced:
                return("応用");
            }
            throw new ArgumentException($"self: {self.ToString()} は無効な値");
        }
Exemplo n.º 2
0
        private string ProblemDescription(ProblemType p, uint n)
        {
            switch (p)
            {
            case ProblemType.ExceptionThrown: return($"Exceptions thrown: {n}");

            case ProblemType.ExceptionTriggered: return($"Exceptions triggered: {n} incidents from {m_exceptionsTriggered.Count} locations");

            case ProblemType.GenericProblem: return($"Other problems: {n}");

            case ProblemType.ModConflict: return($"Mod Conflicts: {n}");

#if DEVELOPER
            case ProblemType.HelperNotLoadedFirst: return("Helper is not loaded first");
#endif
            }
            return(p.ToString());
        }
Exemplo n.º 3
0
        //[Conditional("SHOWLOGS")]
        public void Line(string Routine, ProblemType Problem, string Details, Loud myLoudness)
        {
            bool show = true;

            if (OnlyTime == true && Problem != ProblemType.TIMING)
            {
                show = false;
            }


            if ((this.Loudness == Loud.DOFF) || (this.Loudness < myLoudness))
            {
                //NewMessage.Show("Not loud enough!");
                //Console.WriteLine ("exiting log");
                // if this message is not loud enough we don't post it
                //return false;
                show = false;
            }

            if (true == show)
            {
                //NewMessage.Show("loud enough!");
                string log = (String.Format("{0}, {1}, {2}, {3}", Routine, Problem.ToString(), Details, myLoudness));

                // this happens if we try to close but the close does not happen for some reason
                if (null == LogLines)
                {
                    LogLines = new List <string>();
                }

                LogLines.Add(log);
                if (OutputToConstoleToo)
                {
                    ConsoleIt(log);
                }

                if (LogLines.Count >= bUFFER_LINES)
                {
                    WriteLog();
                }
            }
            //return true;
        }
Exemplo n.º 4
0
 public string Get(ProblemType pt)
 {
     string s = "";
     XmlNode xn = Find(xd.ChildNodes.Item(1).ChildNodes.Item(0), pt.ToString());
     if (xn != null)
     {
         foreach (XmlNode xnn in xn.ChildNodes)
         {
             if (xnn.Name == "StudentAns")
             {
                 s += xnn.ChildNodes.Item(0).Value + ",";
             }
             if (xnn.Name == "AnsPath")
             {
                 return xnn.ChildNodes.Item(0).Value;
             }
         }
         s = s.Remove(s.Length - 1);
     }
     return s;
 }
Exemplo n.º 5
0
 public string FindLogAns(ProblemType pt, int id)
 {
     string temp = "";
     foreach (XmlNode xn in xd.ChildNodes.Item(1).ChildNodes)
     {
         if (xn.Attributes[1].Value == pt.ToString() && xn.ChildNodes[0].LastChild.Value == id.ToString())
         {
             temp = xn.ChildNodes[1].LastChild.Value;
         }
     }
     return temp;
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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);
 }