예제 #1
0
 public void EditQuestion(FormQuestionViewModel formQuestionViewModel)
 {
     this.InEditMode = true;
     this.editFormQuestionViewModel = formQuestionViewModel;
     this.Question = formQuestionViewModel.Question;
     FieldQuestionType.SelectedValue = this.dropDownItems.GetOption(formQuestionViewModel.QuestionType);
     this.QuestionType   = formQuestionViewModel.QuestionType;
     this.MultpleChoices = formQuestionViewModel.MultpleChoices;
     this.Instructions   = formQuestionViewModel.Instructions;
     FillableList.SetOptions(this.MultpleChoices);
     SaveBtn.Content = "Update";
     Bindings.Update();
 }
예제 #2
0
        private void onSaveClick(object sender, TappedRoutedEventArgs e)
        {
            // TODO: Validate
            FieldQuestion.HideError();
            FieldQuestionType.HideError();

            if ((this.Question == null) || this.Question == "")
            {
                FieldQuestion.ShowError("Vraag mag niet leeg zijn");
                return;
            }

            if (this.QuestionType == null)
            {
                FieldQuestionType.ShowError("Type mag niet leeg zijn");
                return;
            }

            if (this.QuestionType == "multiple_choice")
            {
                if (this.MultpleChoices.Count <= 1)
                {
                    FillableList.ShowError("Minimaal 2 antwoorden toevoegen");
                    return;
                }
            }

            // emit the save event
            if (InEditMode)
            {
                var options = new List <string>();

                this.editFormQuestionViewModel.Question     = this.Question;
                this.editFormQuestionViewModel.QuestionType = this.QuestionType;
                if (this.QuestionType == "multiple_choice")
                {
                    this.MultpleChoices.ForEach(x => options.Add(x.ToString()));
                }
                this.editFormQuestionViewModel.MultpleChoices = options;
                this.editFormQuestionViewModel.Instructions   = this.Instructions;
            }
            else
            {
                var options = new List <string>();
                this.MultpleChoices.ForEach(x => options.Add(x.ToString()));
                onSaveEvent(new FormQuestionViewModel()
                {
                    Question       = this.Question,
                    QuestionType   = this.QuestionType,
                    MultpleChoices = options,
                    Instructions   = this.Instructions
                });
            }

            // reset the builder
            this.Question       = null;
            this.QuestionType   = null;
            this.Instructions   = null;
            this.MultpleChoices = new List <string>();
            this.InEditMode     = false;
            SaveBtn.Content     = "Toevoegen";
            FieldQuestionType.Reset();
            FillableList.Reset();
            Bindings.Update();
        }