Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

QuestionGroupBranch class: Difference between revisions

From Catglobe Wiki
No edit summary
No edit summary
Line 25: Line 25:


=== <span style="color:#DF8621">'''Examples'''</span> ===
=== <span style="color:#DF8621">'''Examples'''</span> ===
<span style="color:#DF8621"> QuestionGroupBranch is returned when calling [[QuestionGroupRoot_class]]</span>
<source lang="javascript">
<source lang="javascript">
number qnaireRId = 15644704;
//find a group by its name
number qnaireRId = 17148177;
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
//QuestionGroupRoot root = new QuestionnaireTemplate(new Questionnaire(17148177).TemplateId).Groups;
QuestionGroupBranch branch = root.FindByName("G1");
QuestionGroupBranch branch = root.FindByName("G1");
print(branch.GroupName);//G1
print(branch.GroupName);//G1
</source>
<source lang="javascript">
//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);
</source>
</source>

Revision as of 09:11, 11 May 2022

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);