public static async Task <ResumenEstadisitcas> getStatic(string token) { ResumenEstadisitcas rest = new ResumenEstadisitcas(); List <TestStat> estadisticas = new List <TestStat>(); Uri_Get url = new Uri_Get(baseURL + getEstadisticas); url.GetData(parametro_getStatis_token, token); //Evitar cache unixTimestamp = (int)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + ""; url.GetData(unixTime, unixTimestamp); var result = await client.GetStringAsync(url.getUri()); JObject json = JObject.Parse(result); if ((string)json.SelectToken("error") == "200") { JObject jo = (JObject)json["data"]; JArray jArray = (JArray)jo["tests"]; for (int i = 0; i < jArray.Count; i++) { estadisticas.Add(new TestStat((long)jArray[i]["fecha"], (int)jArray[i]["not_answered"], (int)jArray[i]["answers"], (int)jArray[i]["mark"], (long)jArray[i]["time"], (int)jArray[i]["correct"], (int)jArray[i]["failed"])); } rest = new ResumenEstadisitcas(estadisticas, (long)jo["avg_time"], (double)jo["avg_mark"], (double)jo["per_correct"], (double)jo["per_failed"], (double)jo["per_not_answered"]); } return(rest); }
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { ////Pie Chart Data Source //ObservableCollection<PieData> PieDataCollection = new ObservableCollection<PieData>() //{ // new PieData() { Title = "Correctas", Value = 60 }, // new PieData() { Title = "Falladas", Value = 25 }, // new PieData() { Title = "Sin Contestar", Value = 5 } //}; //PieChart.DataSource = PieDataCollection; ////Line Chart Data Source //ObservableCollection<LineData> LineDataCollection = new ObservableCollection<LineData>() //{ // new LineData { Category = "E1", Line1 = 80, Line2 = 40, Line3 = 50 }, // new LineData { Category = "E2", Line1 = 50, Line2 = 70, Line3 = 40 }, // new LineData { Category = "E3", Line1 = 60, Line2 = 50, Line3 = 20 }, // new LineData { Category = "E4", Line1 = 10, Line2 = 30, Line3 = 50 }, // new LineData { Category = "E5", Line1 = 40, Line2 = 10, Line3 = 70 } //}; //LineChart.DataSource = LineDataCollection; estadisticas = await Comunicacion.getStatic(AplicationSettings.getToken()); if (estadisticas.test != null) { ObservableCollection <PieData> PieDataCollection = new ObservableCollection <PieData>(); PieDataCollection.Add(new PieData("Correctas", estadisticas.per_correcta)); PieDataCollection.Add(new PieData("Incorrectas", estadisticas.per_incorrecta)); PieDataCollection.Add(new PieData("No Respondidas", estadisticas.per_noRespondida)); PieChart.DataSource = PieDataCollection; ObservableCollection <LineData> LineDataCollection = new ObservableCollection <LineData>(); int i = 1; foreach (var a in estadisticas.test) { LineDataCollection.Add(new LineData { Category = "Test" + i, Line1 = a.correctasSobreCien(), Line2 = a.falladasSobreCien(), Line3 = a.sinResponderSobreCien() }); i++; } LineChart.DataSource = LineDataCollection; NotaMedia.Text = (double)(estadisticas.per_correcta / 10) + ""; TiempoMedio.Text = (double)(estadisticas.avg_tiempo / 1000) + " s"; } }