コード例 #1
0
        public virtual void attachChoice(QuestionDef q)
        {
            if (q.DynamicChoices != null)
            {
                //can't attach dynamic choices because they aren't guaranteed to exist yet
                return;
            }

            SelectChoice choice = null;

            if (index != -1 && index < q.NumChoices)
            {
                choice = q.getChoice(index);
            }
            else if (xmlValue != null && xmlValue.Length > 0)
            {
                choice = q.getChoiceForValue(xmlValue);
            }

            if (choice != null)
            {
                attachChoice(choice);
            }
            else
            {
                throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.TextID + ".  Check to see if value " + xmlValue + " is a valid option for question " + q.TextID + ".");
            }
        }
コード例 #2
0
        private static Selection getSelection(System.String choiceValue, QuestionDef q)
        {
            Selection s;

            if (q == null || q.DynamicChoices != null)
            {
                s = new Selection(choiceValue);
            }
            else
            {
                SelectChoice choice = q.getChoiceForValue(choiceValue);
                s = (choice != null?choice.selection():null);
            }

            return(s);
        }