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 }); }); }
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); }
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(); }
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); }
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); }
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); } ; }
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" }); } }
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" }); } }
private void ShowQuizes(object obj) { var quizes = SQLiteDataAccess.LoadQuizes(); ShowElementsIfListNotEmpty(quizes); }
private void ShowAnswers(object obj) { var answers = SQLiteDataAccess.LoadAnswers(); ShowElementsIfListNotEmpty(answers); }