QuestionGroupBranch class

From Catglobe Wiki
Revision as of 10:19, 11 May 2022 by Administrator (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

QuestionGroupBranch


Question group.

Parent class

Inherits from QuestionGroupTree

Constructors

Methods

  • Array of QuestionGroupTree GetChildGroups() - Return all child groups.
  • Empty SetChildGroups(Array of QuestionGroupTree groups "Question groups") - Set child groups.
  • (From object) string ToString() - The string representation of the object.

Properties


Examples

//find a group by its name
number qnaireRId = 17148177;
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
//QuestionGroupRoot root = new QuestionnaireTemplate(new Questionnaire(17148177).TemplateId).Groups;
QuestionGroupBranch branch = root.FindByName("G1");
print(branch.GroupName);//G1
//create new group branch 
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupBranch branch = new QuestionGroupBranch ("G1", qt);
QuestionGroupLeaf leaf = qt.Groups.FindByQuestion("Q1");
branch.SetChildGroups({leaf});
//add new group to group root
array groupRoot = qt.Groups.GetChildGroups();
groupRoot.Remove(leaf);
groupRoot.Add(branch);
qt.Groups.SetChildGroups(groupRoot);
qt.Save(true);
//add more goup leaf to a group branch
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupBranch branch = qt.Groups.FindByName("G1");
QuestionGroupLeaf leaf = qt.Groups.FindByQuestion("Q2");
array childGroup = branch.GetChildGroups();
childGroup.Add(leaf);//add the leaf to branch
branch.SetChildGroups(childGroup);//reset group branch
array groupRoot = qt.Groups.GetChildGroups();
groupRoot.Remove(leaf);// remove the leaf from root
qt.Groups.SetChildGroups(groupRoot);// reset group root
qt.Save(true);