private static void SampleQuestions()
 {
     var level = new GameLevel { DifficultySelector = new DifficultyDecider_Easy() };
     for (int i = 0; i < 15; i++)
     {
         var question = Program.QuestionRepository.GetNextQuestion(level);
         question.Usage.IncreaseCorrectAnswersCount();
         Program.QuestionRepository.SaveQuestion(question);
         Console.WriteLine(question.QuestionText);
     }
 }
        public QuizQuestion GetNextQuestion(GameLevel level)
        {
            DifficultyLevel difficulty = level.DifficultySelector.GetLevel();

            var query = from QuizQuestion qq in _db
                        where qq.Difficulty == difficulty
                        orderby qq.Usage.NumberOfTimesUsed,
                                qq.ShuffleIndex // randomizer
                        select qq;

            return query.First();
        }
Exemplo n.º 3
0
 public QuestionPresenter GetNewQuestion(GameLevel level)
 {
     CurrentQuestion = new QuestionPresenter(_repository.GetNextQuestion(level));
     return(CurrentQuestion);
 }
        public void Test()
        {
            GameLevel level = new GameLevel()
            {
                DifficultySelector = new DifficultyDecider_Easy()
            };

            QuizQuestion question = _repository.GetNextQuestion(level);
            string question1text = question.QuestionText;

            question.Usage.IncreaseCorrectAnswersCount();

            Assert.AreEqual(1, question.Usage.NumberOfTimesCorrect);
            Assert.AreEqual(0, question.Usage.NumberOfTimesWrong);
            Assert.AreEqual(1, question.Usage.NumberOfTimesUsed);

            _repository.SaveQuestion(question);

            question = _repository.GetNextQuestion(level);

            Assert.AreNotEqual(question1text, question.QuestionText);
        }
Exemplo n.º 5
0
        public void GetDifficultQuestion()
        {            
            GameLevel level = new GameLevel()
            {
                DifficultySelector = new DifficultyDecider_Difficult()
            };

            QuizQuestion question = _repository.GetNextQuestion(level);

            Assert.AreEqual(DifficultyLevel.Difficult, question.Difficulty);
            Assert.That(question.QuestionText.Equals("Question 5") 
                || question.QuestionText.Equals("Question 6"));
        }
Exemplo n.º 6
0
 public QuestionPresenter GetNewQuestion(GameLevel level)
 {
     CurrentQuestion = new QuestionPresenter(_repository.GetNextQuestion(level));
     return CurrentQuestion;
 }