Exemplo n.º 1
0
        public QuestionListVM(Quiz quiz)
        {
            questionContext = new QuestionDBAccess();
            categoryContext = new CategoryDBAcess();
            answerContext   = new AnswerDBAccess();

            this.quiz        = quiz;
            SelectedQuestion = new QuestionVM();
            SelectedAnswer   = new AnswerVM();

            if (quiz.Questions == null)
            {
                Questions = new ObservableCollection <QuestionVM>();
            }
            else
            {
                Questions = new ObservableCollection <QuestionVM>(quiz.Questions.Select(q => new QuestionVM(q)));
            }

            Categories = new ObservableCollection <CategoryVM>(categoryContext.All().Select(c => new CategoryVM(c)));

            SaveQuestion   = new RelayCommand(saveQuestion, canSave);
            DeleteQuestion = new RelayCommand(removeQuestion, canRemove);
            ClearQuestion  = new RelayCommand(clearQuestion, canClear);
            SaveAnswer     = new RelayCommand(saveAnswer, canSaveAnswer);
            DeleteAnswer   = new RelayCommand(deleteAnswer, canDelete);
            ClearAnswer    = new RelayCommand(clearAnswer, canClear);
        }
Exemplo n.º 2
0
 public GameVM(Quiz quiz)
 {
     this.quiz            = quiz;
     CurrentQuestion      = new QuestionVM(quiz.Questions.First());
     currentQuestionIndex = 1;
     currentScore         = 0;
     IsFinished           = false;
     SelectAnswer         = new RelayCommand(selectAnswer, canSelect);
 }
Exemplo n.º 3
0
 public void NextQuestion()
 {
     if (currentQuestionIndex < quiz.Questions.Count())
     {
         CurrentQuestion = new QuestionVM(quiz.Questions.ElementAt(currentQuestionIndex));
         currentQuestionIndex++;
     }
     else
     {
         IsFinished      = true;
         CurrentQuestion = new QuestionVM();
     }
 }
Exemplo n.º 4
0
 private void clearQuestion(object parameter)
 {
     SelectedQuestion = new QuestionVM();
 }
Exemplo n.º 5
0
 private void removeQuestion(object parameter)
 {
     questionContext.Delete(_question.Question);
     Questions.Remove(_question);
     SelectedQuestion = new QuestionVM();
 }