public override List <int> CreateOtoExam(TextBox[] textBoxs)
        {
            Question         q        = new Question();
            QuestionSelector selector = new QuestionSelector();
            int lid = Convert.ToInt32(textBoxs[0].Text);

            int[]      counts      = { !string.IsNullOrEmpty(textBoxs[3].Text) ? Convert.ToInt32(textBoxs[3].Text) : 0, !string.IsNullOrEmpty(textBoxs[4].Text) ? Convert.ToInt32(textBoxs[4].Text) : 0, !string.IsNullOrEmpty(textBoxs[5].Text) ? Convert.ToInt32(textBoxs[5].Text) : 0 };
            List <int> questionIds = new List <int>();
            int        iterator    = 0;

            double[] diff  = ExamPercentage(q.GetDifficultyByInt(Convert.ToInt32(textBoxs[1].Text)));
            double   deger = 0;

            foreach (QuestionType type in Enum.GetValues(typeof(QuestionType)))
            {
                if (counts[iterator] != 0)
                {
                    deger = counts[iterator] * diff[0];
                    selector.QuestionSelect(questionIds, (int)Math.Round(deger), lid, type, DifficultyType.Zor);
                    deger = counts[iterator] * diff[1];
                    selector.QuestionSelect(questionIds, (int)Math.Round(deger), lid, type, DifficultyType.Orta);
                    deger = counts[iterator] * diff[2];
                    selector.QuestionSelect(questionIds, (int)Math.Round(deger), lid, type, DifficultyType.Kolay);
                }
                iterator++;
            }

            return(questionIds);
        }
Esempio n. 2
0
        async Task ChangeQuestion()
        {
            AcceptMessages = false;
            StopQuestionTimer();

            foreach (var gameplayer in GamePlayers)
            {
                await Program.Server.Client.SendChatActionAsync(gameplayer.Player.ChatId, ChatAction.Typing);

                gameplayer.Answered = false;
            }


            if (QuestionNum == 0)
            {
                SendToAll.SendText(GamePlayers, "First question:");
            }
            else if (QuestionNum == GameConfig.QuestionsPerGame)
            {
                SendToAll.SendText(GamePlayers, "Last question:");
            }
            else if (QuestionNum > GameConfig.QuestionsPerGame)
            {
                SendToAll.SendText(GamePlayers, "Playing untill getting winner:");
            }
            else
            {
                SendToAll.SendText(GamePlayers, "Question " + QuestionNum + ":");
            }

            Question = QuestionSelector.SelectQuestion();
            QuestionNum++;

            await Task.Delay(250);

            var outtext = Question.QuestionText;
            int i       = 0;

            foreach (var answer in Question.Answers)
            {
                i++;
                outtext += "\n" + i + ") " + answer;
            }
            SendToAll.SendText(GamePlayers, outtext);

            AcceptMessages = true;

            TillNewQuestionDelayer = DelayedTask.DelayTask(new List <DelayedTask>()
            {
                new DelayedTask(() => ChangeQuestion(), 60),
                new DelayedTask(() => SendToAll.SendText(GamePlayers, "30 seconds remaining"), 30),
                new DelayedTask(() => SendToAll.SendText(GamePlayers, "15 seconds remaining"), 45),
                new DelayedTask(() => SendToAll.SendText(GamePlayers, "5 seconds remaining"), 55)
            });
        }
Esempio n. 3
0
        public void QuestionSelector_should_work_in_a_happy_day_scenario()
        {
            // Arrange
            var service          = new QuestionSelector();
            var questionIds      = GetQuestionIds();
            var answerOccurences = GetAnswerOccurences();

            // Act
            var result = service.GetNextQuestionId(questionIds, answerOccurences);

            // Assert
            result.ShouldNotBe(1);
            result.ShouldBeInRange(2, 8);
        }