/// <summary> /// Считывание полей из XmlNode. /// </summary> /// <param name="xmlNode"></param> /// <returns></returns> public static ExerciseSerie CreateFromXml(XmlNode xmlNode) { ExerciseSerie result = new ExerciseSerie(); result.type = ExerciseType.CreateFromXml(xmlNode); foreach (XmlNode item in xmlNode.ChildNodes) { result.attempts.Add(ExerciseAttempt.CreateFromXml(item)); } return(result); }
/// <summary> /// Создание экземпляра попытки по XmlNode. /// </summary> /// <param name="xmlNode"></param> /// <returns></returns> public static ExerciseAttempt CreateFromXml(XmlNode xmlNode) { ExerciseAttempt result = new ExerciseAttempt(); XmlAttribute attr; attr = xmlNode.Attributes[xmlFieldTrainType]; if (attr != null && !string.IsNullOrEmpty(attr.Value)) { TrainType type = (TrainType)Enum.Parse(typeof(TrainType), attr.Value); switch (type) { case TrainType.Date: result = new ExerciseAttemptDate(); break; case TrainType.NetTrain: result = new ExerciseAttemptNetTrain(); break; case TrainType.ConsecutiveAssociations: result = new ExerciseAttemptAssociationsСonsecutive(); break; case TrainType.NumberAssociations: result = new ExerciseAttemptAssociationsNumber(); break; case TrainType.AssociationsPair: result = new ExerciseAttemptAssociationsPair(); break; default: result = new ExerciseAttempt(); break; } } result.LoadAttributesFromXml(xmlNode); return(result); }
public string GetDescription(bool withErrorsList) { StringBuilder sb = new StringBuilder(); sb.AppendLine(this.type.GetDescription()); DateTime d = new DateTime(); d = d.AddSeconds(this.GetTimeTotal); int errorCount = this.GetErrorsCount; double procent = 100 - (double)errorCount * 100 / (double)this.GetAttemptsCount; string tmp = string.Format("Всего попыток: {0}. Ошибок: {1}. Процент правильных ответов: {2}%.\r\n", this.GetAttemptsCount.ToString(), this.GetErrorsCount.ToString(), procent.ToString("F2")); tmp += string.Format("Всего потрачено времени {0}.\r\n", d.ToLongTimeString()); tmp += string.Format("Среднее время {0} c. Минимальное время {1} c. Максимальное время {2} c.", this.GetTimeAverange.ToString("F2"), this.GetTimeMinimum.ToString("F2"), this.GetTimeMaximum.ToString("F2")); sb.Append(tmp); if (withErrorsList && errorCount > 0) { sb.AppendLine(); sb.AppendLine(); sb.AppendLine("Ошибки:"); Collection <ExerciseAttempt> errors = this.GerErrors(); for (int i = 0; i < errors.Count; i++) { ExerciseAttempt item = errors[i]; sb.AppendFormat(item.GetErrorDesctiption()); if (i != errorCount - 1) { sb.AppendLine(); } } } return(sb.ToString()); }
public void SortAttempts() { ExerciseAttempt[] items = new ExerciseAttempt[this.attempts.Count]; DateTime?[] keys = new DateTime?[this.attempts.Count]; for (int i = 0; i < this.attempts.Count; i++) { items[i] = this.attempts[i]; keys[i] = this.attempts[i].DateStart; } // Сортируем свойства. Array.Sort(keys, items); attempts.Clear(); foreach (ExerciseAttempt item in items) { attempts.Add(item); } }