示例#1
0
        private Question CreateExclusiveChoiceQuestion(XElement questionIterator, Category parent)
        {
            ExclusiveChoiceQuestion exclusiveQuestion = new ExclusiveChoiceQuestion(parent);

            ExclusiveChoiceQuestion.ChoiceItem exclusiveChoiceItem;
            foreach (XElement item in questionIterator.Elements("item"))
            {
                exclusiveChoiceItem = new ExclusiveChoiceQuestion.ChoiceItem(exclusiveQuestion);
                if (item.Attribute("def") != null)
                {
                    exclusiveChoiceItem.IsChosen = item.Attribute("def").Value == "1";
                }
                exclusiveChoiceItem.IsMoreDetailsEnabled = item.Attribute("otr").Value == "1";
                exclusiveChoiceItem.Name = item.Value;
                exclusiveQuestion.ChoiceItems.Add(exclusiveChoiceItem);
            }

            XElement skipLogic = questionIterator.Element("SkipLogic");

            if (skipLogic != null)
            {
                int  index   = Convert.ToInt32(skipLogic.Attribute("operand").Value);
                bool inverse = skipLogic.Attribute("operator").Value == "1";
                exclusiveQuestion.ChoiceItems[index].SetAsSkipLogic(Convert.ToInt32(skipLogic.Attribute("skipTo").Value), inverse);
            }
            return(exclusiveQuestion);
        }
示例#2
0
        /// <summary>
        /// Creates a copy of the question.
        /// </summary>
        /// <param name="parent">Instance of <see cref="Category"/> that question belongs to.</param>
        /// <returns>New instance of question.</returns>
        public Question Copy(Category parent)
        {
            ExclusiveChoiceQuestion copy = new ExclusiveChoiceQuestion(parent)
            {
                Description = this.Description, Id = this.Id
            };

            foreach (ChoiceItem item in ChoiceItems)
            {
                copy.ChoiceItems.Add(new ChoiceItem(item, copy));
            }
            return(copy);
        }
        /// <summary>
        /// Creates a copy of the question.
        /// </summary>
        /// <param name="parent">Instance of <see cref="Category"/> that question belongs to.</param>
        /// <returns>New instance of question.</returns>
        public Question Copy(Category parent)
        {
            ExclusiveChoiceQuestion copy = new ExclusiveChoiceQuestion(parent) { Description = this.Description, Id = this.Id };

            foreach (ChoiceItem item in ChoiceItems)
            {
                copy.ChoiceItems.Add(new ChoiceItem(item, copy));
            }
            return copy;
        }
示例#4
0
        private Question CreateExclusiveChoiceQuestion(XElement questionIterator, Category parent)
        {
            ExclusiveChoiceQuestion exclusiveQuestion = new ExclusiveChoiceQuestion(parent);
            ExclusiveChoiceQuestion.ChoiceItem exclusiveChoiceItem;
            foreach (XElement item in questionIterator.Elements("item"))
            {
                exclusiveChoiceItem = new ExclusiveChoiceQuestion.ChoiceItem(exclusiveQuestion);
                if (item.Attribute("def") != null)
                {
                    exclusiveChoiceItem.IsChosen = item.Attribute("def").Value == "1";
                }
                exclusiveChoiceItem.IsMoreDetailsEnabled = item.Attribute("otr").Value == "1";
                exclusiveChoiceItem.Name = item.Value;
                exclusiveQuestion.ChoiceItems.Add(exclusiveChoiceItem);
            }

            XElement skipLogic = questionIterator.Element("SkipLogic");
            if (skipLogic!= null)
            {
                int index = Convert.ToInt32(skipLogic.Attribute("operand").Value);
                bool inverse = skipLogic.Attribute("operator").Value == "1";
                exclusiveQuestion.ChoiceItems[index].SetAsSkipLogic(Convert.ToInt32(skipLogic.Attribute("skipTo").Value), inverse);
            }
            return exclusiveQuestion;
        }