Exemplo n.º 1
0
        /// <summary>
        /// If CanExecuteConnectionCommand return true you can navigate to new windows
        /// </summary>
        /// <param name="parameter"></param>
        private void ExecuteNextQuestionCommand(object parameter)
        {
            if (_ViewModelQuestions.ItemsSource.Count() == resultAnswers.Count())
            {
                this.Item.textQuestion = GlobalConstant.END_QCM;
                this.Item.goodAnswer.answerQuestion = GlobalConstant.END_QCM;
                this.Item.badAnswer1.badAnswer      = GlobalConstant.END_QCM;
                this.Item.badAnswer2.badAnswer      = GlobalConstant.END_QCM;
            }
            else
            {
                //Add answer selected to list for send after with POST method
                if (!_IsSelectedBadAnswer || !_IsSelectedGoodAnswer)
                {
                    if (getBadAnswer != null)
                    {
                        UserAnswer userAnswer = new UserAnswer();

                        userAnswer.idQcm      = Item.idQcm;
                        userAnswer.idQuestion = Item.id;
                        userAnswer.idAnswer   = getBadAnswer.id;

                        resultAnswers.Add(userAnswer);
                    }
                    else
                    {
                        UserAnswer userAnswer = new UserAnswer();

                        userAnswer.idQcm      = Item.idQcm;
                        userAnswer.idQuestion = Item.id;
                        userAnswer.idAnswer   = getGoodAnswer.id;

                        resultAnswers.Add(userAnswer);
                    }
                }
            }

            //Get the next Question
            nextValue++;
            if (nextValue < _ViewModelQuestions.ItemsSource.Count())
            {
                this.Item = _ViewModelQuestions.ItemsSource.ElementAt <Question>(nextValue);

                _ViewModelGoodAnswers.IdQuestion = this.Item.id;
                _ViewModelGoodAnswers.LoadData();
                _ViewModelGoodAnswers.DataLoaded += (sender, args) =>
                {
                    this.Item.goodAnswer = _ViewModelGoodAnswers.ItemsSource.FirstOrDefault();
                };

                _ViewModelBadAnswers.IdQuestion = this.Item.id;
                _ViewModelBadAnswers.LoadData();
                _ViewModelBadAnswers.DataLoaded += (sender, args) =>
                {
                    this.Item.badAnswer1 = _ViewModelBadAnswers.ItemsSource.FirstOrDefault();
                    this.Item.badAnswer2 = _ViewModelBadAnswers.ItemsSource.LastOrDefault();
                };
            }
        }
Exemplo n.º 2
0
 public override void LoadData()
 {
     _ViewModelBadAnswers.LoadData();
 }