public bool PontuarAluno(string id, double pontuacao) { var respsotas = _repoResposta.GetAll().Result; var index = respsotas.Count(); var ponteiro = index + 1; var estudanteBanco = _repoEstudante.GetAll().Result.Where(x => x.EstudanteSessao == id).FirstOrDefault(); if (estudanteBanco != null) { estudanteBanco.Pontuacao = estudanteBanco.Pontuacao + (decimal)pontuacao; _repoEstudante.Update(estudanteBanco); return(true); } else { var estudante = new Estudante(); estudante.EstudanteSessao = id; estudante.Pontuacao = (decimal)pontuacao; _repoEstudante.Add(estudante); return(true); } }
public RelatorioFinalObjectDTO GerarDadosRelatorio(int quizzId, int alunoId, string sessaoNome) { var perguntas = (from A in _repositoryQuizz.GetAll().Result join B in _repositoryPergunta.GetAll().Result on A.QuizzId equals B.QuizzId where A.QuizzId == quizzId select B ).Distinct().ToList(); var respostas = (from B in perguntas join C in _repositoyResposta.GetAll().Result on B.PerguntaId equals C.PerguntaId join D in _repositoryEstudanteResposta.GetAll().Result on C.RespostaId equals D.RespostaId join E in _repositoryEstudante.GetAll().Result on D.EstudanteId equals E.EstudanteId where C.EstudanteId == alunoId && B.QuizzId == quizzId select C).Distinct().ToList(); var nomeAluno = (from B in perguntas join C in _repositoyResposta.GetAll().Result on B.PerguntaId equals C.PerguntaId join D in _repositoryEstudanteResposta.GetAll().Result on C.RespostaId equals D.RespostaId join E in _repositoryEstudante.GetAll().Result on D.EstudanteId equals E.EstudanteId select E.Nome).Distinct().FirstOrDefault(); var nomeQuizz = (from A in _repositoryQuizz.GetAll().Result join B in _repositoryPergunta.GetAll().Result on A.QuizzId equals B.QuizzId where A.QuizzId == quizzId select A.Descricao ).Distinct().FirstOrDefault(); var retorno = new RelatorioFinalObjectDTO { Perguntas = _mapper.Map <List <PerguntaDTO> >(perguntas), Resposta = _mapper.Map <List <RespostaDTO> >(respostas), NomeAluno = nomeAluno, NomeQuizz = nomeQuizz }; return(retorno); }
public Pergunta buscarPerguntaParaIniciarQuizz(int id, int estudanteId) { var resposta = respostaRepository.GetAll() .Result .Where(x => x.EstudanteId == estudanteId).Select(x => x.PerguntaId); if (resposta != null && resposta.Count() > 0) { //perguntas var perguntas = repoPergunta.GetAll() .Result.Where(x => x.QuizzId == id && !resposta.Contains(x.PerguntaId)); return(perguntas.FirstOrDefault()); } var pgt = repoPergunta.GetAll().Result.Where(x => x.QuizzId == id); return(pgt.FirstOrDefault()); }
public IEnumerable <Resposta> GetAll() { return(_respostaRepository.GetAll()); }