コード例 #1
0
        public void GerarTeste(Teste teste, Materia materia, Questao questao)
        {
            try
            {
                IList <Questao> questaoList = questaoDAO.GetAllRandom(teste, materia, questao);

                if (teste.QuantidadeQuestoes > questaoList.Count)
                {
                    throw new Exception("A quantidade de questões do " + questao.Bimestre + " e na Matéria " + materia.Nome + " é de " + questaoList.Count);
                }
                else
                {
                    if (questaoList.Count < 1)
                    {
                        throw new Exception("Não há nenhuma questão cadastrada nesse Bimestre e nessa matéria");
                    }
                    else
                    {
                        int testeID = testeDAO.AdicionarTBTestes(teste);
                        teste.ID = testeID;

                        foreach (var item in questaoList)
                        {
                            testeDAO.AdicionarTBTestes_Questoes(Convert.ToInt32(item.ID), testeID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
 public IList <Questao> GetAllRandom(Teste teste, Materia materia, Questao questao)
 {
     try
     {
         var List = _questaoDAO.GetAllRandom(teste, materia, questao);
         return(List);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }