private List <GraficoOrdem> CriaGraficosConsolidados(RelatorioConsolidadoCapacidadeLeituraDTO relatorio) { var listaGraficos = new List <GraficoOrdem>(); relatorio.RelatorioPorOrdem.ForEach(o => { var graficoOrdem = new GraficoOrdem(); graficoOrdem.Ordem = o.Ordem; graficoOrdem.perguntasGrafico = new List <Grafico>(); o.Perguntas.ForEach(p => { var grafico = new Grafico(); grafico.NomeGrafico = p.Nome; p.Respostas.ForEach(r => { var barra = new GraficoBarra(); barra.Label = r.Nome; barra.Value = r.quantidade; grafico.Barras.Add(barra); }); graficoOrdem.perguntasGrafico.Add(grafico); }); listaGraficos.Add(graficoOrdem); }); return(listaGraficos); }
private static async Task CriaGraficosRelatorio(RelatorioCapacidadeLeituraPorTurma relatorio, SMEManagementContextData contexto) { var perguntasBanco = await contexto.PerguntaResposta.Include(x => x.Pergunta).Include(y => y.Resposta).Where(pr => relatorio.Perguntas.Any(p => p.Id == pr.Pergunta.Id)).ToListAsync(); relatorio.Graficos = new List <GraficoOrdem>(); relatorio.Ordens.ForEach(o => { var graficoOrdem = new GraficoOrdem(); graficoOrdem.Ordem = o.Nome; graficoOrdem.perguntasGrafico = new List <Grafico>(); relatorio.Perguntas.ForEach(p => { var grafico = new Grafico(); grafico.NomeGrafico = p.Nome; var listaRespostas = perguntasBanco.Where(x => x.Pergunta.Id == p.Id); listaRespostas.ForEach(r => { var barra = new GraficoBarra(); barra.Label = r.Resposta.Descricao; barra.Value = relatorio.Alunos.Count(x => x.Ordens.Any(ordem => ordem.Id == o.Id && ordem.Perguntas.Any(pr => pr.Id == p.Id && pr.Valor == r.Resposta.Descricao))); grafico.Barras.Add(barra); }); var barraAlunosSemPreenchimento = new GraficoBarra(); barraAlunosSemPreenchimento.Label = "Sem Preenchimento"; barraAlunosSemPreenchimento.Value = relatorio.Alunos.Count() - grafico.Barras.Sum(x => x.Value); grafico.Barras.Add(barraAlunosSemPreenchimento); graficoOrdem.perguntasGrafico.Add(grafico); }); relatorio.Graficos.Add(graficoOrdem); }); }