コード例 #1
0
        public QuestionModel GetNextQuestion()
        {
            List <int> activeIds;

            lock (ActiveQuestions) {
                activeIds = ActiveQuestions.Select(q => q.Value).ToList();
            }

            var next = _questionProvider.GetNextQuestion();

            for (var i = 0; i < 999; i++)
            {
                if (!activeIds.Contains(next.Id))
                {
                    break;
                }
                next = _questionProvider.GetNextQuestion();
            }

            lock (ActiveQuestions) {
                ActiveQuestions[Context.ConnectionId] = next.Id;
            }

            return(next);
        }
コード例 #2
0
        IQuestionPack IQuestionProvider.GetNextQuestion()
        {
            questionsDone++;

            if (questionsDone == 1)
            {
                return(sunQuestion);
            }
            else if (questionsDone == 2)
            {
                return(moonQuestion);
            }
            else
            {
                var data = provider.GetNextQuestion();

                var correct = data.GetCorrectAnswers();
                var wrong   = data.GetWrongAnswers();

                var correctImages = correct.ToArray();
                var wrongImages   = wrong.ToArray();

                for (int i = 0; i < correctImages.Length; ++i)
                {
                    correctImages[i] = new LL_ImageData(correctImages[i].Id);
                }

                for (int i = 0; i < wrongImages.Length; ++i)
                {
                    wrongImages[i] = new LL_ImageData(wrongImages[i].Id);
                }

                return(new SampleQuestionPack(data.GetQuestion(), wrongImages, correctImages));
            }
        }
コード例 #3
0
        public IQuestion GetNextQuestion()
        {
            Debug.Log("GetNextQuestion");
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            List <IAnswer>    answers      = new List <IAnswer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________


            foreach (var wrong in currentPack.GetWrongAnswers())
            {
                var wrongAnsw = GenerateWrongAnswer(wrong);

                answers.Add(wrongAnsw);
                totalAnswers.Add(wrongAnsw);
            }

            Debug.Log("PRE");
            int correctCount = 0;

            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                var correctAnsw = GenerateCorrectAnswer(correct);
                Debug.Log("Added");
                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }
            Debug.Log("POST");

            partialAnswers = answers.ToArray();

            // Generate the question
            var question = GenerateQuestion(questionData, correctCount);

            totalQuestions.Add(question);

            // Generate placeholders
            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                GeneratePlaceHolder(question);
            }

            return(question);
        }
コード例 #4
0
        public ILivingLetterData getNewLetter()
        {
            ILivingLetterData newLetter = null;

            IQuestionProvider newQuestionProvider = SickLettersConfiguration.Instance.Questions;
            IQuestionPack     nextQuestionPack    = newQuestionProvider.GetNextQuestion();

            foreach (ILivingLetterData letterData in nextQuestionPack.GetCorrectAnswers())
            {
                newLetter = letterData;
            }

            return(newLetter);
        }
コード例 #5
0
    public void GetNextQuestion()
    {
      m_currentQuestion = m_questionProvider.GetNextQuestion();
      Question = m_currentQuestion.Body;
      TextAnswers = new List<string>() { string.Empty, string.Empty, string.Empty, string.Empty };

      OnPropertyChanged(nameof(Question));
      OnPropertyChanged(nameof(TextAnswers));

      Task.Run(() => {
        System.Threading.Thread.Sleep(5000);
        TextAnswers = m_currentQuestion.GetAnswersInRandomOrder().GetAnswers();
        StartTimer();
        OnPropertyChanged(nameof(TextAnswers));
      });
    }
コード例 #6
0
        /// <summary>
        /// Draw the Questions/Answers for the whole game session (6 answers)
        /// It is called just once before the 3 rounds. Answers are removed
        /// from Buckets when GetNextQuestion is called.
        /// </summary>
        private void FillBuckets(IQuestionProvider questionProvider)
        {
            int max = numberOfRounds * numberOfMaxAnswers;

            for (int i = 0; i < max; i++)
            {
                var pack = questionProvider.GetNextQuestion();

                foreach (var answ in pack.GetCorrectAnswers())
                {
                    //Arabic has different order!
                    for (int j = 0; j < categoryProvider.GetCategories(); j++)
                    {
                        if (categoryProvider.Compare(j, answ))
                        {
                            answersBuckets[j].Add(pack.GetQuestion());
                        }
                    }
                }
            }
        }
コード例 #7
0
        private void FillBuckets()
        {
            // We need to aggregate answers before so we can later generate Questions
            int max = numberOfRounds * numberOfMaxAnswers;

            for (int i = 0; i < max; i++)
            {
                var pack = provider.GetNextQuestion();
                foreach (var answ in pack.GetCorrectAnswers())
                {
                    for (int j = 0; j < numberOfCategories; j++)
                    {
                        Debug.Log("##CATEGORY:" + answ.TextForLivingLetter);
                        if (categoryProvider.Compare(j, answ))
                        {
                            Debug.Log("##ADDED");
                            answersBuckets[j].Add(pack.GetQuestion());
                        }
                    }
                }
            }
        }
コード例 #8
0
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            List <IAnswer>    answers      = new List <IAnswer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________

            if (missingLetter)
            {
                // ### MISSING LETTER ###
                foreach (var wrong in currentPack.GetWrongAnswers())
                {
                    var wrongAnsw = GenerateWrongAnswer(wrong);

                    answers.Add(wrongAnsw);
                    totalAnswers.Add(wrongAnsw);
                }

                var correct     = currentPack.GetCorrectAnswers().ToList()[0];
                var correctAnsw = GenerateCorrectAnswer(correct);

                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);

                partialAnswers = answers.ToArray();

                // Generate the question
                var question = GenerateMissingLetterQuestion(questionData, correct);
                totalQuestions.Add(question);
                GeneratePlaceHolder(question);
                return(question);
            }
            else
            {
                // ### ORDER LETTERS ###
                foreach (var correct in currentPack.GetCorrectAnswers())
                {
                    var correctAnsw = GenerateCorrectAnswer(correct);
                    answers.Add(correctAnsw);
                    totalAnswers.Add(correctAnsw);
                }

                partialAnswers = answers.ToArray();

                // Generate the question
                var question = GenerateQuestion(questionData);
                totalQuestions.Add(question);

                return(question);
            }
        }
コード例 #9
0
        public ILivingLetterData getNewLetter()
        {
            var question = provider.GetNextQuestion();

            return(question.GetCorrectAnswers().First());
        }
コード例 #10
0
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

            currentPack = provider.GetNextQuestion();

            if (config == DefaultQuestionType.MissingForm || config == DefaultQuestionType.VisibleForm)
            {
                return(CustomQuestion());
            }

            List <Answer>     answers      = new List <Answer>();
            ILivingLetterData questionData = currentPack.GetQuestion();

            //____________________________________
            //Prepare answers for next method call
            //____________________________________


            foreach (var wrong in currentPack.GetWrongAnswers())
            {
                var wrongAnsw = GenerateWrongAnswer(wrong);

                answers.Add(wrongAnsw);
                totalAnswers.Add(wrongAnsw);
            }

            int    correctCount      = 0;
            Answer greenAnswerLetter = null;

            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                var correctAnsw = GenerateCorrectAnswer(correct);
                if (correctCount == 0)
                {
                    greenAnswerLetter = correctAnsw;
                }
                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }

            partialAnswers = answers.ToArray();

            // Generate the question
            var question = GenerateQuestion(questionData, correctCount);

            totalQuestions.Add(question);
            greenHighlightList.Add(new Tuple <IQuestion, Answer>(question, greenAnswerLetter));

            // Generate placeholders
            foreach (var correct in currentPack.GetCorrectAnswers())
            {
                GeneratePlaceHolder(question, AssessmentOptions.Instance.AnswerType);
            }
            return(question);
        }