Example #1
0
        private void FullQuiz(object obj)
        {
            AddNewQuiz(null);
            int exitCode;

            do
            {
                AskOneQuestionAndItsAnswersAtTheTime();
                Menu.Menu yesNoMenu = new YesNoMenu();
                exitCode = yesNoMenu.Start();
            } while (exitCode != 0);

            QuizModel            latestQuiz     = SQLiteDataAccess.SelectLatestQuiz();
            List <QuestionModel> questionsCount = SQLiteDataAccess.SelectQuestionsByQuizesId(latestQuiz.Id);

            Console.WriteLine($"{questionsCount.Count} x Questions Have Been Added To Quiz: {latestQuiz.Name}");
            Console.ReadKey();
        }
Example #2
0
        private void AskOneQuestionAndItsAnswersAtTheTime()
        {
            string questionText;

            do
            {
                Console.Clear();
                Console.WriteLine("\nInput new Question:");
                Console.ForegroundColor = ConsoleColor.Blue;
                questionText            = Console.ReadLine();
                Console.ResetColor();
            } while (MyValidation.ValidateStringsWithRegex.ForQuestions(questionText));

            int           idquiz        = SQLiteDataAccess.SelectLatestQuiz().Id;
            QuestionModel questionModel = new QuestionModel(idquiz, questionText);

            SQLiteDataAccess.InsertQuestion(questionModel);

            Console.WriteLine("\nInput 4 consequtive answers. Of which only first one should be correct.");

            string correctAnswer = AddNextAnswer("Input correct answer:", ConsoleColor.Green);

            Console.WriteLine($"Saved : {correctAnswer}\n");

            string[] incorrectAnswers = new string[3];
            incorrectAnswers = Get3IncorrectAnswersFromUser(incorrectAnswers);

            var         latestQuestion = SQLiteDataAccess.SelectLatestQuestion();
            AnswerModel answerModel    = new AnswerModel(latestQuestion.Id, correctAnswer, true);

            SQLiteDataAccess.InsertAnswer(answerModel);

            for (int i = 0; i < incorrectAnswers.Length; i++)
            {
                AnswerModel _answerModel = new AnswerModel(latestQuestion.Id, incorrectAnswers[i], false);
                SQLiteDataAccess.InsertAnswer(_answerModel);
            }
            ;
        }