Exemplo n.º 1
0
        private void NewQuestion(object sender, EventArgs e)
        {
            SectionNode nodeToBeAddedTo = trv_view_exam.SelectedNode.GetType() == typeof(SectionNode) ? (SectionNode)trv_view_exam.SelectedNode : (SectionNode)trv_view_exam.SelectedNode.Parent;
            Question    question        = new Question();

            question.No = nodeToBeAddedTo.Nodes.Count + 1;
            //
            QuestionNode questionNode = new QuestionNode(question);

            questionNode.ContextMenuStrip = cms_question;
            nodeToBeAddedTo.Nodes.Add(questionNode);
            //
            trv_view_exam.ExpandAll();
            //
            ChangeRepresentationObject obj = new ChangeRepresentationObject();

            obj.Action       = ActionType.Add;
            obj.Question     = question;
            obj.SectionTitle = nodeToBeAddedTo.Title;
            undoRedo.InsertObjectforUndoRedo(obj);
            //
            IsDirty = true;
        }
        public void Initialize()
        {
            var firstQuestion  = new QuestionNode(new Location(0, 0), "Q1", "Do you like puppies?", QValueType.BOOLEAN);
            var secondQuestion = new QuestionNode(new Location(0, 0), "Q2", "Do you like kittens?", QValueType.BOOLEAN);
            var thirdQuestion  = new QuestionNode(new Location(0, 0), "Q3", "Is this the first question?", QValueType.BOOLEAN);

            thirdQuestion.AddNode(new FormNode(new Location(0, 0), "InvalidFormInLowerLayer"));
            var forthQuestion = new QuestionNode(new Location(0, 0), "Q4", "Is this the forthQuestion?", QValueType.BOOLEAN);

            _validAST = new FormNode(new Location(0, 0), "TestForm");
            _validAST.AddNode(firstQuestion);
            _validAST.AddNode(secondQuestion);

            _multipleFormAST = new FormNode(new Location(0, 0), "TestForm");
            _multipleFormAST.AddNode(new FormNode(new Location(0, 0), "InvalidForm"));

            _multipleFormInLowerNodeAST = new FormNode(new Location(0, 0), "InvalidForm");
            _multipleFormInLowerNodeAST.AddNode(thirdQuestion);

            _multipleLayerValidForm = new FormNode(new Location(0, 0), "ValidForm");
            _multipleLayerValidForm.AddNode(forthQuestion);
            forthQuestion.AddNode(firstQuestion);
            forthQuestion.AddNode(secondQuestion);
        }
Exemplo n.º 3
0
    void CreateNode(Vector2 mousePos, int type)
    {
        Node n = null;

        if (lst_node.Count == 0)
        {
            n = new StartNode(this, new Vector2(120, 150));
        }
        else
        {
            switch (type)
            {
            case 0:
                n = new StartNode(this, mousePos - coordinate);
                plotNodeCount++;
                break;

            case 1:
                n = new DialogueNode(this, mousePos - coordinate);
                break;

            case 2:
                n = new QuestionNode(this, mousePos - coordinate);
                break;

            case 3:
                n = new DivergeNode(this, mousePos - coordinate);
                break;
            }
        }
        if (n != null)
        {
            lst_node.Add(n);
            rightPanel.SetQNodeList();
        }
    }
Exemplo n.º 4
0
        public override Node Visit(QuestionNode question)
        {
            var questionNode = new QuestionNode(question.Token, question.Description, question.Label, question.IsEvaluated, question.Type);

            foreach (var expression in question.ChildNodes)
            {
                var evaluatedNode = expression.Accept(this) as LiteralNode;
                _memory.AssignValue(question.Label, _valueFactory.CreateValueFromString(evaluatedNode.Value, question.Type));
                questionNode.AddChild(evaluatedNode);
            }

            if (!questionNode.ChildNodes.Any())
            {
                IValue memoryValue;
                if (!_memory.TryRetrieveValue(question.Label, out memoryValue))
                {
                    memoryValue = _valueFactory.CreateDefaultValue(question.Type);
                }

                questionNode.ChildNodes.Add(new LiteralNode(question.Token, memoryValue.ToString(), question.Type));
            }

            return(questionNode);
        }
Exemplo n.º 5
0
 private static void RecursivelyAdd(List <Question> list, QuestionNode node)
 {
     if (!node.IsDummy)
     {
         list.Add(node.Question);
     }
     if (node.Children != null)
     {
         node.Children.ForEach(s =>
         {
             RecursivelyAdd(list, s);
         });
     }
     if (node.ArrayOfChildren != null)
     {
         foreach (var array in node.ArrayOfChildren)
         {
             foreach (var q in array)
             {
                 RecursivelyAdd(list, q);
             }
         }
     }
 }
Exemplo n.º 6
0
 public KnowledgeNode(string n, QuestionNode mn)
 {
     name         = n;
     matchingNode = mn;
     learned      = true;
 }
Exemplo n.º 7
0
 public KnowledgeNode()
 {
     name         = "NONE";
     matchingNode = new QuestionNode();
     learned      = false;
 }
Exemplo n.º 8
0
 public QuestionNodeTest()
 {
     _target = new QuestionNode();
 }
Exemplo n.º 9
0
    private void Start()
    {
        //Agarro el model
        _model = GetComponent <Model>();

        //Creo la FSM
        _fsm = new FSM <string>();

        //Creo los estados
        IdleState <string>   idle   = new IdleState <string>(this);
        PatrolState <string> patrol = new PatrolState <string>(Waypoints, transform, this);
        ShootState <string>  shoot  = new ShootState <string>(this);
        AlertState <string>  alert  = new AlertState <string>(this, Sight, ExclamationMark);
        SearchState <string> search = new SearchState <string>(this);

        //Creo las transiciones
        idle.AddTransition(_patrolKey, patrol);
        idle.AddTransition(_shootKey, shoot);
        idle.AddTransition(_alertKey, alert);
        idle.AddTransition(_searchKey, search);
        idle.AddTransition(_idleKey, idle); //se tienen a si mismos por si llega a tener que volverse a ejecutar con el random

        patrol.AddTransition(_idleKey, idle);
        patrol.AddTransition(_shootKey, shoot);
        patrol.AddTransition(_alertKey, alert);
        patrol.AddTransition(_searchKey, search);

        alert.AddTransition(_idleKey, idle);
        alert.AddTransition(_shootKey, shoot);
        alert.AddTransition(_patrolKey, patrol);
        alert.AddTransition(_alertKey, alert);
        alert.AddTransition(_searchKey, search);

        search.AddTransition(_searchKey, search);
        search.AddTransition(_idleKey, idle);
        search.AddTransition(_shootKey, shoot);
        search.AddTransition(_patrolKey, patrol);
        search.AddTransition(_alertKey, alert);

        //diccionario de todos los estados de idle para la roulette
        _statesRoulette = new Dictionary <string, int>();
        _statesRoulette.Add(_idleKey, 30);
        _statesRoulette.Add(_patrolKey, 70);
        _statesRoulette.Add(_searchKey, 50);

        //inicializo la FSM
        _fsm.SetInitialState(idle);

        //Inicializo los nodos del Desicion Tree
        ActionNode _shootActionNode       = new ActionNode(ChangeToShootState); //Aca pasarle función
        ActionNode _alertActionNode       = new ActionNode(ChangeToAlertState);
        ActionNode _randomStateActionNode = new ActionNode(ChangeToRandomState);

        _isFirstTimeQuestionNode    = new QuestionNode(Sight.SawTargetOnce, _shootActionNode, _alertActionNode);
        _isSeeingPlayerQuestionNode = new QuestionNode(Sight.IsSeeingTarget, _isFirstTimeQuestionNode, _randomStateActionNode);

        Sight.SawTarget.AddListener(ExecuteTree);

        // Roulette
        _actionRoulette = new Roulette <string>();
    }
Exemplo n.º 10
0
    private void OnClickOpenMap(object asset)
    {
        ActionNode   auxAction;
        QuestionNode auxQuestion;

        if (asset.GetType() != typeof(AIcuñaMap))
        {
            EditorUtility.DisplayDialog("Error", "You must select an AIcuña Map.", "Ok. I'm Sorry.");
            return;
        }

        _currentMap = (AIcuñaMap)asset;

        if (_currentMap.actions == null)
        {
            _currentMap.actions = new List <ActionNode>();
        }
        if (_currentMap.questions == null)
        {
            _currentMap.questions = new List <QuestionNode>();
        }
        if (_currentMap.connections == null)
        {
            _currentMap.connections = new List <Connection>();
        }

        _mapName = _currentMap.name;

        _nodes       = new List <Node>();
        _connections = new List <Connection>();

        foreach (var item in _currentMap.actions)
        {
            auxAction = new ActionNode(item.rect.position, item.rect.width, item.rect.height,
                                       _nodeStyle, _selectedNodeStyle, _inPointStyle, OnClickInPoint, OnClickRemoveNode,
                                       item.id, item.inPoint.id);
            auxAction.goName     = item.goName;
            auxAction.scriptName = item.scriptName;
            auxAction.methodName = item.methodName;
            auxAction.SelectScript();
            auxAction.SelectMethod();
            _nodes.Add(auxAction);
        }

        foreach (var item in _currentMap.questions)
        {
            auxQuestion = new QuestionNode(item.rect.position, item.rect.width, item.rect.height,
                                           _nodeStyle, _selectedNodeStyle, _inPointStyle, _truePointStyle, _falsePointStyle,
                                           OnClickInPoint, OnClickOutPoint, OnClickRemoveNode,
                                           item.id, item.inPoint.id, item.truePoint.id, item.falsePoint.id);

            auxQuestion.goName     = item.goName;
            auxQuestion.scriptName = item.scriptName;
            auxQuestion.methodName = item.methodName;
            auxQuestion.SelectScript();
            auxQuestion.SelectMethod();
            _nodes.Add(auxQuestion);
        }

        foreach (var item in _currentMap.connections)
        {
            ConnectionPoint inPoint  = null;
            ConnectionPoint outPoint = null;

            foreach (var node in _nodes)
            {
                if (node.GetType() == typeof(ActionNode))
                {
                    ActionNode n = node as ActionNode;
                    if (item.inPoint.id == n.inPoint.id)
                    {
                        inPoint = n.inPoint;
                    }
                }
                else if (node.GetType() == typeof(QuestionNode))
                {
                    QuestionNode n = node as QuestionNode;
                    if (item.inPoint.id == n.inPoint.id)
                    {
                        inPoint = n.inPoint;
                    }
                    if (item.outPoint.id == n.truePoint.id)
                    {
                        outPoint = n.truePoint;
                    }
                    else if (item.outPoint.id == n.falsePoint.id)
                    {
                        outPoint = n.falsePoint;
                    }
                }
                if (inPoint != null && outPoint != null)
                {
                    break;
                }
            }

            if (inPoint != null && outPoint != null)
            {
                _connections.Add(new Connection(inPoint, outPoint, OnClickRemoveConnection));
            }
            else
            {
                EditorUtility.DisplayDialog("Error", "Something go wrong.", "Ok. This is a stupid msg.");
            }
        }

        EditorUtility.DisplayDialog("Success Open", "AIcuña map has been opened correctly.", "Ok. Let me work.");
    }
Exemplo n.º 11
0
            private static JContainer EnsureAllParentNodesExist(JObject response, QuestionNode node)
            {
                IEnumerable <string> nodeNames = null;

                if (node.IsDummy)
                {
                    nodeNames = node.NameSpace.Split('.');
                }
                else
                {
                    var splits = node.Question.APIRequestField.Split('.');
                    if (node.Question.APIRequestField.EndsWith("[]"))
                    {
                        nodeNames = splits;
                    }
                    else
                    {
                        nodeNames = splits.Take(splits.Count() - 1);
                    }
                }

                JContainer container = response;

                foreach (var nodeName in nodeNames)
                {
                    JContainer childContainer = GetExistingChildContainerByName(container, nodeName.TrimEnd('[', ']'));
                    if (childContainer == null)
                    {
                        if (nodeName.EndsWith("[]"))
                        {
                            var newContainer = new JArray();
                            if (container is JObject)
                            {
                                (container as JObject).Add(nodeName.TrimEnd('[', ']'), newContainer);
                            }
                            else if (container is JArray)
                            {
                                //Find the candidate object within the JArray where this new JArray can be inserted
                                JObject jObjectCandidate = (container as JArray).Children <JObject>()
                                                           .FirstOrDefault(o => o[nodeName.TrimEnd('[', ']')] == null);
                                if (jObjectCandidate == null)
                                {
                                    jObjectCandidate = new JObject();
                                    (jObjectCandidate as JObject).Add(node.NodeName, newContainer);
                                    container.Add(jObjectCandidate);
                                }
                                else if (jObjectCandidate is JObject)
                                {
                                    (jObjectCandidate as JObject).Add(node.NodeName, newContainer);
                                }
                                //(container as JArray).Add(newContainer);
                            }
                            container = newContainer;
                        }
                        else
                        {
                            var newContainer = new JObject();

                            if (container is JObject)
                            {
                                (container as JObject).Add(nodeName.TrimEnd('[', ']'), newContainer);
                            }
                            else if (container is JArray)
                            {
                                JObject jObjectCandidate = (container as JArray).Children <JObject>()
                                                           .FirstOrDefault(o => o[node.NodeName] == null);//This checks if this JArray has a no JObject elements by this name.
                                if (jObjectCandidate == null)
                                {
                                    container.Add(newContainer);
                                }
                                else
                                {
                                    //Remove this line
                                    //jObjectCandidate.Add(Guid.NewGuid().ToString(), "HERE");

                                    //TODO: If this node in not the leaf node then we have to add this node as a new object?

                                    newContainer = jObjectCandidate;
                                }
                            }
                            container = newContainer;
                        }
                    }
                    else
                    {
                        container = childContainer;
                    }
                }
                return(container);
            }
Exemplo n.º 12
0
 public ActionResult RenderQuestion(QuestionNode questionNode)
 {
     return(PartialView(questionNode));
 }
Exemplo n.º 13
0
 public QuestionNodeResponse(QuestionNode questionNode)
     : base(questionNode)
 {
     Question = questionNode.Question;
     Answers  = questionNode.Answers.Select(a => new AnswerResponse(a)).ToArray();
 }
 public override Node Visit(QuestionNode node)
 {
     Questions.Add(node);
     return(VisitChildren(node));
 }
Exemplo n.º 15
0
            /// </summary>
            /// <param name="fields"></param>
            /// <returns></returns>
            public static IEnumerable <QuestionNode> GetQuestionTree(IEnumerable <Question> questions)
            {
                var temp1 = questions.ToList().Select(s =>
                {
                    var splits         = s.APIRequestField.Split('.');
                    string groupName   = string.Empty;
                    bool isArrayHeader = s.APIRequestField.EndsWith("[]");
                    if (s.APIRequestField.EndsWith("[]"))
                    {
                        groupName = s.APIRequestField.TrimEnd('[', ']');
                    }
                    else
                    {
                        if (splits.Count() > 1)
                        {
                            groupName = splits.Take(splits.Count() - 1).Aggregate((a, b) => $"{a}.{b}");
                        }
                    }

                    return(new { Q = s, GroupName = groupName, IsArrayHeader = isArrayHeader });
                });
                var temp = temp1.GroupBy(s => s.GroupName)
                           .Select(t =>
                {
                    bool isArray      = t.FirstOrDefault(f => f.IsArrayHeader) != null;
                    QuestionNode node = new QuestionNode();
                    node.NodeName     = t.Key.Split('.').Last();
                    if (isArray)
                    {
                        node = new QuestionNode(t.FirstOrDefault(f => f.IsArrayHeader).Q);
                    }
                    node.NameSpace = t.Key;
                    if (node.NameSpace == null)
                    {
                        throw new InvalidOperationException("null namespace");
                    }
                    foreach (var q in t)
                    {
                        if (q.IsArrayHeader)
                        {
                            continue;
                        }

                        if (isArray)
                        {
                            if (node.Question.ChildSetCount > 0)
                            {
                                node.AddToArrayOfChildren(new QuestionNode(q.Q));
                            }
                        }
                        else
                        {
                            node.AddChild(new QuestionNode(q.Q));
                        }
                    }

                    return(node);
                }).ToList();

                List <QuestionNode> nodesToRemove = new List <QuestionNode>();

                foreach (var questionNode in temp)
                {
                    if (questionNode.ParentNameSpace != null)
                    {
                        var parent = temp.FirstOrDefault(s => s.NameSpace == questionNode.ParentNameSpace);
                        if (parent != null)
                        {
                            if (parent.IsDummy)
                            {
                                parent.Children.Add(questionNode);
                            }
                            else
                            {
                                parent.AddToArrayOfChildren(questionNode);
                            }
                            nodesToRemove.Add(questionNode);
                        }
                    }
                }
                nodesToRemove.ForEach(s => temp.Remove(s));


                return(temp);

                /*
                 * //new { Q = s, Group = s.APIRequestField.EndsWith("[]")? s.APIRequestField.Split('.').Take()})
                 * Dictionary<string, QuestionNode> dict = new Dictionary<string, QuestionNode>();
                 * foreach (var question in questions)
                 * {
                 *  var key = question.APIRequestField;//.TrimEnd('[', ']');
                 *  if (!dict.ContainsKey(key))
                 *      dict.Add(key, new QuestionNode(question));
                 *  else
                 *      throw new InvalidOperationException("Duplicate API Request Field" + question.Ref);
                 * }
                 * List<string> keysAddedtoTree = new List<string>();
                 * foreach (var question in questions)
                 * {
                 *  var key = question.APIRequestField.TrimEnd('[', ']');
                 *  var splits = key.Split('.');
                 *  var parentKeySplits = splits.Take(splits.Count() - 1);
                 *  if (parentKeySplits.Count() > 0)
                 *  {
                 *      var parentKey = parentKeySplits.Aggregate((a, b) => $"{a}.{b}");
                 *      if (dict.ContainsKey(parentKey) && dict.ContainsKey(key))
                 *      {
                 *          dict[parentKey].AddChild(dict[key]);
                 *          keysAddedtoTree.Add(key);
                 *      }
                 *      else if (dict.ContainsKey(parentKey+"[]") && dict.ContainsKey(key))
                 *      {
                 *          dict[parentKey + "[]"].AddToArrayOfChildren(dict[key]);
                 *          keysAddedtoTree.Add(key);
                 *      }
                 *  }
                 * }
                 *
                 * keysAddedtoTree.ForEach(s => dict.Remove(s));
                 * var tree = dict.Values.Select(s => s);
                 * return tree;
                 */
                /*
                 * dynamic response = new JObject();
                 * //response.ProductName = "Elbow Grease";
                 * //response.Enabled = true;
                 * //product.Price = 4.90m;
                 * //product.StockCount = 9000;
                 * //product.StockValue = 44100;
                 * //product.Tags = new JArray("Real", "OnSale");
                 *
                 * //Console.WriteLine(product.ToString());
                 * var jobject = response;
                 * foreach(var item in tree)
                 * {
                 *  var splits = item.Question.APIRequestField.Split('.');
                 *  //foreach(var jsonNode in splits)
                 *  for (int i = 0; i < splits.Count(); i++)
                 *  {
                 *      var key = splits[i].TrimEnd('[', ']');
                 *      if (DoesKeyExist(jobject, key) == false)
                 *      {
                 *          if (i == splits.Count() - 1 && splits[i].EndsWith("[]"))
                 *          {
                 *              JArray array = new JArray();
                 *              jobject.Add(key, array);
                 *          }
                 *          else
                 *          {
                 *              JObject newjo = new JObject();
                 *              jobject.Add(key, newjo);
                 *              jobject = newjo;
                 *          }
                 *      }
                 *
                 *  }
                 * }
                 */

                //Now walk the tree and flatten it.
            }
Exemplo n.º 16
0
 public void Visit(QuestionNode node)
 {
     return;
 }
Exemplo n.º 17
0
 public static string AsJSON(this IEnumerable <Question> questions)
 {
     return(QuestionNode.GetJSON2(questions));
 }
Exemplo n.º 18
0
 public static void PrintSection(QuestionNode question)
 {
     Console.WriteLine(question);
 }
Exemplo n.º 19
0
 public void AddChild(QuestionNode node)
 {
     Children.Add(node);
     node.Parent = this;
 }
Exemplo n.º 20
0
        private void Redo(object sender, EventArgs e)
        {
            ChangeRepresentationObject redoObject = undoRedo.Redo();

            if (redoObject == null)
            {
                return;
            }
            else
            {
                switch (redoObject.Action)
                {
                case ActionType.Add:
                    SectionNode sectionNode = trv_view_exam.Nodes[0].Nodes.Cast <SectionNode>().FirstOrDefault(s => s.Title == redoObject.SectionTitle);
                    if (sectionNode == null)
                    {
                        sectionNode = new SectionNode(redoObject.SectionTitle)
                        {
                            ContextMenuStrip = cms_section
                        };
                        //
                        QuestionNode questionNode = new QuestionNode(redoObject.Question)
                        {
                            ContextMenuStrip = cms_question
                        };
                        sectionNode.Nodes.Add(questionNode);
                        //
                        trv_view_exam.Nodes[0].Nodes.Add(sectionNode);
                        trv_view_exam.ExpandAll();
                    }
                    else
                    {
                        sectionNode.ContextMenuStrip = cms_section;
                        //
                        QuestionNode questionNode = new QuestionNode(redoObject.Question)
                        {
                            ContextMenuStrip = cms_question
                        };
                        sectionNode.Nodes.Add(questionNode);
                        //
                        trv_view_exam.ExpandAll();
                    }
                    //
                    int i = 1;
                    foreach (QuestionNode questionNode_ in sectionNode.Nodes)
                    {
                        questionNode_.Text        = "Question " + i;
                        questionNode_.Question.No = i;
                        i++;
                    }
                    break;

                case ActionType.Delete:
                    SectionNode _sectionNode = trv_view_exam.Nodes[0].Nodes.Cast <SectionNode>().FirstOrDefault(s => s.Title == redoObject.SectionTitle);
                    if (_sectionNode != null)
                    {
                        if (_sectionNode.Nodes.Count >= redoObject.Question.No)
                        {
                            exam.Sections.First(s => s.Title == redoObject.SectionTitle).Questions.RemoveAt(redoObject.Question.No - 1);
                            _sectionNode.Nodes.RemoveAt(redoObject.Question.No - 1);
                        }
                    }
                    //
                    int j = 1;
                    foreach (QuestionNode questionNode_ in _sectionNode.Nodes)
                    {
                        questionNode_.Text        = "Question " + j;
                        questionNode_.Question.No = j;
                        j++;
                    }
                    break;

                case ActionType.Modify:
                    SectionNode sectionNode_ = trv_view_exam.Nodes[0].Nodes.Cast <SectionNode>().FirstOrDefault(s => s.Title == redoObject.SectionTitle);
                    if (sectionNode_ != null)
                    {
                        QuestionNode questionNode = (QuestionNode)sectionNode_.Nodes[redoObject.Question.No - 1];
                        questionNode.Question = redoObject.Question;
                        //
                        txt_explanation.Text      = redoObject.Question.Explanation;
                        txt_question_text.Text    = redoObject.Question.Text;
                        lbl_section_question.Text = "Section: " + trv_view_exam.SelectedNode.Parent.Text + " Question " + redoObject.Question.No;
                        pct_image.Image           = redoObject.Question.Image;
                        //
                        pan_options.Controls.Clear();
                        //
                        int k = 0;
                        if (redoObject.Question.IsMultipleChoice)
                        {
                            foreach (var option in redoObject.Question.Options)
                            {
                                OptionsControl ctrl = new OptionsControl()
                                {
                                    Letter   = option.Alphabet,
                                    Text     = option.Text,
                                    Location = new Point(2, k * 36)
                                };
                                if (redoObject.Question.Answers.Contains(option.Alphabet))
                                {
                                    ctrl.Checked = true;
                                }
                                pan_options.Controls.Add(ctrl);
                                k++;
                            }
                        }
                        else
                        {
                            foreach (var option in redoObject.Question.Options)
                            {
                                OptionControl ctrl = new OptionControl()
                                {
                                    Letter   = option.Alphabet,
                                    Text     = option.Text,
                                    Location = new Point(2, k * 36)
                                };
                                if (option.Alphabet == redoObject.Question.Answer)
                                {
                                    ctrl.Checked = true;
                                }
                                pan_options.Controls.Add(ctrl);
                                k++;
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 21
0
        /*
         * contents.jewelleryAndWatches.value
         * contents.jewelleryAndWatches.valuableItems[]
         * contents.jewelleryAndWatches.hasSafe
         * contents.jewelleryAndWatches
         * contents.jewelleryAndWatches.valuableItems.type
         * contents.jewelleryAndWatches.valuableItems.desc
         * contents2.jewelleryAndWatches.hasSafe
         * contents2.jewelleryAndWatches
         * contents2.jewelleryAndWatches.valuableItems.type
         * contents.jewelleryAndWatches.valuableItems.desc
         * contents.jewelleryAndWatches.valuableItems.yearsOwned
         * contents.jewelleryAndWatches.valuableItems.value
         * contents.artAndCollections[]
         * contents.artAndCollections.category
         * contents.artAndCollections.value
         * contents.artAndCollections.valuableItems[]
         * contents.artAndCollections.valuableItems.desc
         * contents.artAndCollections.valuableItems.value
         * contents.artAndCollections.valuableItems.valuationYear
         * contents.otherValuableItems[]
         * contents.otherValuableItems.desc
         * contents.otherValuableItems.value
         * contents.totalValue
         *
         * will be ordered as
         *
         * contents.jewelleryAndWatches
         * contents.jewelleryAndWatches.value
         * contents.jewelleryAndWatches.hasSafe
         * contents.jewelleryAndWatches.valuableItems[]
         * contents.jewelleryAndWatches.valuableItems.type
         * contents.jewelleryAndWatches.valuableItems.desc
         * contents.jewelleryAndWatches.valuableItems.yearsOwned
         * contents.jewelleryAndWatches.valuableItems.value
         * contents.artAndCollections[]
         * contents.artAndCollections.category
         * contents.artAndCollections.value
         * contents.artAndCollections.valuableItems[]
         * contents.artAndCollections.valuableItems.desc
         * contents.artAndCollections.valuableItems.value
         * contents.artAndCollections.valuableItems.valuationYear
         * contents.otherValuableItems[]
         * contents.otherValuableItems.desc
         * contents.otherValuableItems.value
         * contents.totalValue
         * contents2.jewelleryAndWatches.hasSafe
         * contents2.jewelleryAndWatches
         * contents2.jewelleryAndWatches.valuableItems.type
         */

        /// <summary>
        /// Orders the questions based on the hierarchy of Question.APIRequestField as per the example above.
        ///
        /// </summary>
        /// <param name="questions"></param>
        /// <returns></returns>
        public static IEnumerable <Question> OrderByHierarchy(this IEnumerable <Question> questions)
        {
            return(QuestionNode.GetOrderedQuestionTree(questions));
        }