예제 #1
0
        static List<QuestionnaireQuestion> GetQuestions(aladdinService.QuestionnaireQuestion[] questions)
        {
            List<QuestionnaireQuestion> qs = new List<QuestionnaireQuestion>();

            if (questions != null)
            {
                foreach (var qqFS in questions.OrderBy(q => q.position))
                {
                    QuestionnaireQuestionAnswerType answerType = (QuestionnaireQuestionAnswerType)Enum.Parse(typeof(QuestionnaireQuestionAnswerType), qqFS.type);
                    QuestionnaireQuestion qq = new QuestionnaireQuestion(qqFS.id, qqFS.title, answerType);
                    List<QuestionnaireQuestionAnswer> answers = new List<QuestionnaireQuestionAnswer>();

                    List<aladdinService.QuestionnaireQuestionAnswer> answersFS = new List<aladdinService.QuestionnaireQuestionAnswer>();
                    answersFS = qqFS.answers.OrderBy(a => a.position).ToList();

                    foreach (var aFS in answersFS)
                    {
                        var a = new QuestionnaireQuestionAnswer();
                        a.Answer = aFS.description;
                        a.Value = aFS.value.ToString();
                        a.GlobalID = System.Convert.ToString(qqFS.GlobalID);
                        answers.Add(a);
                    }
                    qq.GlobalID = System.Convert.ToString(qqFS.GlobalID);
                    qq.Answers = answers.ToArray();
                    qq.Condition = qqFS.condition.ToString();
                    qq.Questions = GetQuestions(qqFS.questions);
                    qq.FixChildrenParentID();
                    qs.Add(qq);
                }
            }

            return qs;
        }
        public void FillAnswers(QuestionnaireQuestion question)
        {
            this.AnswersStackPanel.Children.Clear();
            foreach (QuestionnaireQuestionAnswer answer in question.Answers)
            {
                RadioButton rb = new RadioButton { MinWidth = 100, Content = answer.Answer, Tag = answer.Value };
                rb.Click += new RoutedEventHandler(RadioButton_Click);

                this.AnswersStackPanel.Children.Add(rb);
            }
        }