Beispiel #1
0
        // Update is called once per frame
        void Update()
        {
            if (_resumeFromError || (_currentQuestion >= 0 && _currentQuestion < _totalQuestions && _displayedQuestion != _currentQuestion))
            {
                _resumeFromError   = false;
                _displayedQuestion = _currentQuestion;
                _question          = _currentQuestionSet.Questions[_currentQuestion];
                while (_question == null && _currentQuestion < _totalQuestions)
                {
                    _currentQuestion++;
                    _question = _currentQuestionSet.Questions[_currentQuestion];
                }

                _menuManager.InstantiateAndShowMenu("QuestionPlaceholder", "Questionnaire");
                _questionPlaceholder      = _menuManager.CurrentMenu.gameObject;
                _questionPlaceholder.name = "QuestionPlaceholder";
                _questionContent          = _questionPlaceholder.transform
                                            .Find("Panel")
                                            .Find("QuestionContent").transform;
                _dynamicFieldsWithScrollbar = _questionContent
                                              .Find("DynFieldsWithScrollbar").transform;
                _dynamicField = _dynamicFieldsWithScrollbar
                                .Find("DynFields").transform;

                var questionMenuButtons = _questionPlaceholder.GetComponent <QuestionMenuButtons>();
                questionMenuButtons.AddBackAndNextButtons(GoBackOneQuestion, GoToNextQuestion);
                if (_showedQuestions <= _lastValidQuestion)
                {
                    questionMenuButtons.DisableBackButton();
                }

                DisplayQuestion();

                _oldAnswers = new Dictionary <int, string>();
            }
            else if (_currentQuestion >= _totalQuestions)
            {
                _log.InsertLiveSystemEvent("QuestionnaireSystem", "End Set", null, _questionSets[_questionSetIndex].Name);
                if (_currentQuestionSet == _questionSets.Last())
                {
                    if (_once)
                    {
                        return;
                    }
                    _once = true;
                    CloseQuestionnaire();
                }
                else
                {
                    LoadQuestionSetAt(++_questionSetIndex);
                }
            }
        }
Beispiel #2
0
        public void GoToNextQuestion()
        {
            //make sure that the question-window gave the information about the answers to the questionObject before saving answers!!!
            if (_question.IsAnswered())
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                var answer = _question.GetAnswer();
                if (answer != null)
                {
                    _log.InsertAnswer(_question.Name, _currentQuestionSet.Name, answer);
                }

                _previousQuestion.Push(_currentQuestion);
                _showedQuestions++;

                var jumpDest = _question.GetJumpDestination();
                if (jumpDest == null)
                {
                    _currentQuestion++;
                }
                else
                {
                    _currentQuestion = jumpDest.Equals("*") ? _totalQuestions : _questionNames.IndexOf(jumpDest);
                }

                if (_currentQuestion >= _totalQuestions)
                {
                    return;
                }
                _question   = _currentQuestionSet.Questions[_currentQuestion];
                _oldAnswers = _log.ReadAnswer(_question.Name);

                _previousNofAnswers.Push(_numberOfAnswers);
                _numberOfAnswers++;
            }
            else
            {
                var tempAnswer = _question.GetAnswer();
                _oldAnswers = new Dictionary <int, string>();
                foreach (var keyValuePair in tempAnswer)
                {
                    _oldAnswers.Add(keyValuePair.Key, keyValuePair.Value);
                }
                enabled = false;
                _menuManager.DisplayErrorMessage("Please answer the question!", "Questionnaire", "QuestionnaireSystem");
            }
        }