public ImageQuestionGenerator(IQuestionProvider provider, bool missingLetter)
 {
     this.provider      = provider;
     this.missingLetter = missingLetter;
     state = QuestionGeneratorState.Uninitialized;
     ClearCache();
 }
        public void CompleteRound()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.Completed;
        }
        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);
        }
        public IAnswer[] GetNextAnswers()
        {
            if (state != QuestionGeneratorState.QuestionFeeded)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.Initialized;
            return(partialAnswers);
        }
        public void InitRound()
        {
            if (state != QuestionGeneratorState.Uninitialized && state != QuestionGeneratorState.Completed)
            {
                throw new InvalidOperationException("Cannot initialized");
            }

            state = QuestionGeneratorState.Initialized;
            ClearCache();
        }
        public CategoryQuestionGenerator(IQuestionProvider provider, ICategoryProvider categoryProvider, int maxAnsw, int rounds)
        {
            this.provider         = provider;
            state                 = QuestionGeneratorState.Uninitialized;
            numberOfMaxAnswers    = maxAnsw;
            numberOfCategories    = categoryProvider.GetCategories();
            numberOfRounds        = rounds;
            answersBuckets        = new List <ILivingLetterData> [3];
            this.categoryProvider = categoryProvider;
            for (int i = 0; i < 3; i++)
            {
                answersBuckets[i] = new List <ILivingLetterData>();
            }

            ClearCache();
            FillBuckets();
        }
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }
            state = QuestionGeneratorState.QuestionFeeded;

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

            // Assumption: Here each category have enough elements
            int amount  = roundElementsForCategory[currentCategory];
            var answers = new List <Answer>();

            int correctCount = 0;

            for (int i = 0; i < amount; i++)
            {
                var answer      = answersBuckets[currentCategory].Pull();
                var correctAnsw = GenerateCorrectAnswer(answer);

                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }

            partialAnswers = answers.ToArray();

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

            totalQuestions.Add(question);

            // Generate placeholders
            for (int i = 0; i < numberOfMaxAnswers; i++)
            {
                GeneratePlaceHolder(question, AssessmentOptions.Instance.AnswerType);
            }
            currentCategory++;
            return(question);
        }
        public CategoryQuestionGenerator(IQuestionProvider questionProvider,
                                         ArabicCategoryProvider categoryProvider,
                                         AssessmentAudioManager dialogues,
                                         int maxAnsw, int rounds)
        {
            state = QuestionGeneratorState.Uninitialized;
            numberOfMaxAnswers    = maxAnsw;
            numberOfRounds        = rounds;
            answersBuckets        = new List <ILivingLetterData> [3];
            this.categoryProvider = categoryProvider;
            this.dialogues        = dialogues;

            for (int i = 0; i < 3; i++)
            {
                answersBuckets[i] = new List <ILivingLetterData>();
            }
            ClearCache();
            FillBuckets(questionProvider);
        }
Пример #9
0
        public ImageQuestionGenerator(IQuestionProvider provider, bool missingLetter,
                                      AssessmentAudioManager audioManager,
                                      AssessmentEvents events)
        {
            this.provider      = provider;
            this.missingLetter = missingLetter;
            this.audioManager  = audioManager;

            if (AssessmentOptions.Instance.CompleteWordOnAnswered)
            {
                events.OnAllQuestionsAnswered = CompleteWordCoroutine;
            }

            if (AssessmentOptions.Instance.ShowFullWordOnAnswered)
            {
                events.OnAllQuestionsAnswered = ShowFullWordCoroutine;
            }

            state = QuestionGeneratorState.Uninitialized;
            ClearCache();
        }
Пример #10
0
        // ##################################
        //             INIT
        // ##################################

        public DefaultQuestionGenerator(IQuestionProvider provider,
                                        AssessmentAudioManager dialogues,
                                        AssessmentEvents events,
                                        DefaultQuestionType config)
        {
            this.provider  = provider;
            this.dialogues = dialogues;
            this.config    = config;

            if (config == DefaultQuestionType.MissingForm)
            {
                events.OnAllQuestionsAnswered = CompleteWordsWithForm;
            }
            if (config == DefaultQuestionType.WordsWithLetter)
            {
                events.OnPreQuestionsAnswered = ShowGreenLetterInWord;
            }
            if (AssessmentOptions.Instance.ReadQuestionAndAnswer)
            {
                events.OnAllQuestionsAnswered = ReadQuestionAndReplyEvent;
            }
            state = QuestionGeneratorState.Uninitialized;
            ClearCache();
        }
        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);
            }
        }
Пример #12
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);
        }
        public IQuestion GetNextQuestion()
        {
            if (state != QuestionGeneratorState.Initialized)
            {
                throw new InvalidOperationException("Not Initialized");
            }

            state = QuestionGeneratorState.QuestionFeeded;

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

            // Assumption: Here each category have enough elements
            int amount = 0;

            if (currentCategory == 0)
            {
                amount = category1ForThisRound;
            }
            else
            if (currentCategory == 1)
            {
                amount = category2ForThisRound;
            }
            else
            if (currentCategory == 2)
            {
                amount = category3ForThisRound;
            }

            List <IAnswer> answers = new List <IAnswer>();

            int correctCount = 0;

            for (int i = 0; i < amount; i++)
            {
                // If crashed here => not enough buckets => Because teacher cannot find enough data
                // Session number X.X.XX should probably raised a bit.
                var answer      = answersBuckets[currentCategory].Pull();
                var correctAnsw = GenerateCorrectAnswer(answer);

                correctCount++;
                answers.Add(correctAnsw);
                totalAnswers.Add(correctAnsw);
            }

            partialAnswers = answers.ToArray();

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

            totalQuestions.Add(question);

            // Generate placeholders
            for (int i = 0; i < numberOfMaxAnswers; i++)
            {
                GeneratePlaceHolder(question);
            }

            currentCategory++;
            return(question);
        }
 public DefaultQuestionGenerator(IQuestionProvider provider)
 {
     this.provider = provider;
     state         = QuestionGeneratorState.Uninitialized;
     ClearCache();
 }