예제 #1
0
        public PossibleAnswersMenu(QuestionModel question)
        {
            List <AnswerModel> possibleAnswers = SQLiteDataAccess.SelectAnswersByQuestionId(question.Id);

            Add(new Menu.MenuItem()
            {
                Name = question.QuestionText, Distance = 2, Unselectable = true
            });
            possibleAnswers.Shuffle().ForEach(x =>
            {
                Add(new Menu.MenuItem()
                {
                    Name = x.AnswerText, Distance = 1, BoolFunction = IsCorrect, Parameter = x.IsCorrect
                });
            });
        }
예제 #2
0
        private void DeleteQuestionById(object obj)
        {
            QuestionModel deletedQuestion = SQLiteDataAccess.SelectQuestionById((int)obj);

            try
            {
                SQLiteDataAccess.DeleteQuestionById((int)obj);

                Console.WriteLine("Poprawnie usunieto z bazy pytan pytanie: \n");
                Console.WriteLine(deletedQuestion);
            }
            catch (Exception)
            {
                Console.WriteLine("Nie udalo sie usunac pytania");
            }

            Console.ReadKey(true);
        }
예제 #3
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();
        }
예제 #4
0
        private void DeleteAnswerById(object obj)
        {
            AnswerModel deletedAnswer = SQLiteDataAccess.SelectAnswerById((int)obj);

            try
            {
                SQLiteDataAccess.DeleteAnswerById((int)obj);


                Console.WriteLine("Poprawnie usunieto z bazy odpowiedzi odpowiedz: \n");
                Console.WriteLine(deletedAnswer);
            }
            catch (Exception)
            {
                Console.WriteLine("Nie udalo sie usunac odpowiedzi");
            }

            Console.ReadKey(true);
        }
예제 #5
0
        private void DeleteQuizesById(object obj)
        {
            QuizModel deletedQuiz = SQLiteDataAccess.SelectQuizById((int)obj);

            try
            {
                SQLiteDataAccess.DeleteQuizById((int)obj);

                Console.WriteLine("Poprawnie usunieto z bazy pytan pytanie: \n");
                Console.WriteLine(deletedQuiz);
            }
            catch (Exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Nie udalo sie usunac pytania.");
                Console.ResetColor();
            }

            Console.ReadKey(true);
        }
예제 #6
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);
            }
            ;
        }
예제 #7
0
        public DeleteQuestionMenu()
        {
            var questions = SQLiteDataAccess.LoadQuestions();

            if (questions.Count != 0)
            {
                foreach (var item in questions)
                {
                    Add(new Menu.MenuItem()
                    {
                        Name      = item.ToString(),
                        Function  = DeleteQuestionById,
                        Parameter = item.Id
                    });
                }
            }
            else
            {
                Add(new Menu.MenuItem()
                {
                    Name = "P U S T O"
                });
            }
        }
예제 #8
0
        public DeleteAnswerMenu()
        {
            var answers = SQLiteDataAccess.LoadAnswers();

            if (answers.Count != 0)
            {
                foreach (var item in answers)
                {
                    Add(new Menu.MenuItem()
                    {
                        Name      = item.ToString().Substring(0, 98) + Environment.NewLine,
                        Function  = DeleteAnswerById,
                        Parameter = item.Id
                    });
                }
            }
            else
            {
                Add(new Menu.MenuItem()
                {
                    Name = "P U S T O"
                });
            }
        }
예제 #9
0
        private void ShowQuizes(object obj)
        {
            var quizes = SQLiteDataAccess.LoadQuizes();

            ShowElementsIfListNotEmpty(quizes);
        }
예제 #10
0
        private void ShowAnswers(object obj)
        {
            var answers = SQLiteDataAccess.LoadAnswers();

            ShowElementsIfListNotEmpty(answers);
        }