Beispiel #1
0
        public async Task <ActionResult <List <Quiz_DTO> > > Get()
        {
            var model = await quizRepo.GetAllQuizzesAsync();

            List <Quiz_DTO> model_DTO = new List <Quiz_DTO>();

            foreach (Quiz quiz in model)
            {
                var result = new Quiz_DTO();
                model_DTO.Add(QuizMapper.ConvertQuizTo_DTO(quiz, ref result, quizRepo));
            }
            return(Ok(model_DTO));
        }
Beispiel #2
0
        public async Task <ActionResult> Index()
        {
            var quizzes = await quizRepo.GetAllQuizzesAsync();

            List <QuizClass> valids = new List <QuizClass>();

            foreach (QuizClass quiz in quizzes)
            {
                var questions = await quizRepo.GetQuizQuestionsAsync(quiz.QuizId);

                if (questions.Count() != 0)
                {
                    valids.Add(quiz);
                }
            }
            return(View(valids.AsEnumerable()));
        }
        //Quizzes
        public async Task <IActionResult> Quizzes(string?exc)
        {
            if (exc != null)
            {
                ViewData["Exception"] = exc;
            }
            IEnumerable <Quiz> quizzes = null;

            quizzes = await quizRepo.GetAllQuizzesAsync();

            foreach (Quiz quiz in quizzes)
            {
                IEnumerable <Question> questionsEnum = await quizRepo.GetAllQuestionsByQuizId(quiz.Id);

                List <Question> questions = questionsEnum.ToList();
                quiz.Questions = questions;
            }
            return(View(quizzes));
        }
Beispiel #4
0
        public async Task <IActionResult> Quizzes()
        {
            QuizController.score           = 0;
            QuizController.currentQuestion = 0;
            QuizController.potentialScore  = 0;
            QuizController.wrongQuestions  = new List <Question>();

            IEnumerable <Quiz> quizzes = null;

            quizzes = await quizRepo.GetAllQuizzesAsync();

            foreach (Quiz quiz in quizzes)
            {
                foreach (Question question in quiz.Questions)
                {
                    IEnumerable <Answer> answersEnum = await quizRepo.GetAllAnswersByQuestionId(question.Id);

                    List <Answer> answers = answersEnum.ToList();
                    question.Answers = answers;
                }
            }
            return(View(quizzes));
        }
        public async Task <ActionResult> Index()
        {
            var result = await quizRepo.GetAllQuizzesAsync();

            return(View(result));
        }
Beispiel #6
0
        public async Task <IActionResult> GetQuizzes()
        {
            var quizzes = await quizRepo.GetAllQuizzesAsync();

            return(Ok(quizzes));
        }