private repeticiónCarácter buscarCarácterConMásErrores(Hashtable listaErrores) { repeticiónCarácter result = new repeticiónCarácter(); result.carácter = '-'; result.repetición = 0; foreach (DictionaryEntry de in listaErrores) { string cadenaValor = (string)de.Value; if (int.Parse(cadenaValor) > result.repetición) //(int)de.Value > result.repetición) { result.repetición = int.Parse(cadenaValor); // (int)de.Value; result.carácter = (char)de.Key; } } return(result); }
public estadísticaLección() { idEstadística = 0; idUsuario = 0; idActividad = 0; idLección = 0; swlecciónTerminada = false; caracteresPorMinuto = 0; aciertos = 0; porcentajeAciertos = 0; duración = 0; errores = 0; porcentajeErrores = 0; repeticiónCarácter caracterAux = new repeticiónCarácter(); caracterAux.carácter = '-'; caracterAux.repetición = 0; caracterConMásErrores = caracterAux; caracterConMásErrores = caracterAux; caracterSegundoConMásErrores = caracterAux; caracterTerceroConMásErrores = caracterAux; }
public void cargarEstadística(int idUsuario, int idActividad, int idLección, int idEstadística) //se carga desde el id de la estadística { //XmlDocument xml = new XmlDocument(); if (File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Recursos\Estadísticas\" + idUsuario.ToString() + "\\" + idActividad.ToString() + "\\" + idLección.ToString() + "\\" + idEstadística.ToString() + ".xml")) { XDocument xml = XDocument.Load(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\Recursos\Estadísticas\" + idUsuario.ToString() + "\\" + idActividad.ToString() + "\\" + idLección.ToString() + "\\" + idEstadística.ToString() + ".xml"); //XElement elemento = xml.Element("fecha"); string fecha = xml.Element("estadísticas").Element("fecha").Value;// elemento.Value; //elemento = xml.Element("hora"); string hora = xml.Element("estadísticas").Element("hora").Value; int año, mes, día, hour, minutos; año = int.Parse(fecha.Substring(fecha.Length - 4)); mes = int.Parse(fecha.Substring(3, 2)); día = int.Parse(fecha.Substring(0, 2)); hour = int.Parse(hora.Substring(0, 2)); minutos = int.Parse(hora.Substring(3, hora.Length - 3)); estadística.fechaHora = new DateTime(año, mes, día, hour, minutos, 0); //corregir que cargue la fecha y la hora desde los string //elemento = xml.Element("caracteresPorMinuto"); estadística.caracteresPorMinuto = int.Parse(xml.Element("estadísticas").Element("caracteresPorMinuto").Value); //elemento = xml.Element("aciertos"); estadística.aciertos = int.Parse(xml.Element("estadísticas").Element("aciertos").Value); //elemento = xml.Element("porcentajeAciertos"); estadística.porcentajeAciertos = int.Parse(xml.Element("estadísticas").Element("porcentajeAciertos").Value); //elemento = xml.Element("duración"); estadística.duración = int.Parse(xml.Element("estadísticas").Element("duración").Value); //elemento = xml.Element("errores"); estadística.errores = int.Parse(xml.Element("estadísticas").Element("errores").Value); //elemento = xml.Element("porcentajeErrores"); estadística.porcentajeErrores = int.Parse(xml.Element("estadísticas").Element("porcentajeErrores").Value); //elemento = xml.Element("caracterConMásErrores_Letra"); repeticiónCarácter miCarácter = new repeticiónCarácter(); miCarácter.carácter = xml.Element("estadísticas").Element("caracterConMásErrores_Letra").Value.ToCharArray()[0]; //elemento = xml.Element("caracterConMásErrores_Repetición"); miCarácter.repetición = int.Parse(xml.Element("estadísticas").Element("caracterConMásErrores_Repetición").Value); estadística.caracterConMásErrores = miCarácter; //primero con más errores //elemento = xml.Element("carácterSegundoConMásErrores_Letra"); miCarácter.carácter = xml.Element("estadísticas").Element("carácterSegundoConMásErrores_Letra").Value.ToCharArray()[0]; //elemento = xml.Element("carácterSegundoConMásErrores_Repetición"); miCarácter.repetición = int.Parse(xml.Element("estadísticas").Element("carácterSegundoConMásErrores_Repetición").Value); estadística.caracterSegundoConMásErrores = miCarácter; //segundo con más errores //elemento = xml.Element("caracterTerceroConMásErrores_Letra"); miCarácter.carácter = xml.Element("estadísticas").Element("caracterTerceroConMásErrores_Letra").Value.ToCharArray()[0]; //elemento = xml.Element("caracterTerceroConMásErrores_Repetición"); miCarácter.repetición = int.Parse(xml.Element("estadísticas").Element("caracterTerceroConMásErrores_Repetición").Value); estadística.caracterTerceroConMásErrores = miCarácter; //tercero con más errores } // XmlNodeList preferencias = xml.GetElementsByTagName("preferencias"); // XmlNodeList pref = ((XmlElement)preferencias[0]).GetElementsByTagName("nombreUsuario"); // this.nombreUsuario = pref[0].InnerText; // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("tamañoLetra"); // this.tamañoLetra = Int32.Parse(pref[0].InnerText); // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("nivel"); // switch (pref[0].InnerText) // { // case "principiante": // this.nivel = nivelActividad.principiante; // break; // case "intermedio": // this.nivel = nivelActividad.intermedio; // break; // case "experto": // this.nivel = nivelActividad.experto; // break; // } // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("nombreSintetizador"); // this.nombreSintetizador = pref[0].InnerText; // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("velocidadSintetizador"); // this.velocidadSintetizador = Int32.Parse(pref[0].InnerText); // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("últimaActividad"); // this.últimaActividad = Int32.Parse(pref[0].InnerText); // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("últimaLección"); // this.últimaLección = Int32.Parse(pref[0].InnerText); // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("swPorTiempo"); // this.swPorTiempo = Boolean.Parse(pref[0].InnerText); // pref = ((XmlElement)preferencias[0]).GetElementsByTagName("cantSegundos"); // this.cantSegundosPorTiempo = Int32.Parse(pref[0].InnerText); }