Difference between revisions of "QuestionGroupRoot class"

From Catglobe Wiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
 
{{CGscriptMethods_Template|ReturnType=Array of QuestionGroupTree|Name=<nowiki>GetChildGroups</nowiki>|Description=<nowiki>Return all child groups.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Array of QuestionGroupTree|Name=<nowiki>GetChildGroups</nowiki>|Description=<nowiki>Return all child groups.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Array of strings|Name=<nowiki>GetPermutation</nowiki>|Description=<nowiki>Get a sequence of questions following the question group rules</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Array of strings|Name=<nowiki>GetPermutation</nowiki>|Description=<nowiki>Get a sequence of questions following the question group rules</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetChildGroups</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=Array of QuestionGroupTree|Name=<nowiki>groups</nowiki>|Description=<nowiki>Question groups</nowiki>}}
 +
|Description=<nowiki>Set root question groups</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
Line 18: Line 21:
  
 
=== <span style="color:#DF8621">'''Examples'''</span> ===
 
=== <span style="color:#DF8621">'''Examples'''</span> ===
<span style="color:#DF8621"> QuestionGroupRoot is returned when calling [[Questionnaire_getQuestionGroups]]</span>
 
 
<source lang="javascript">
 
<source lang="javascript">
number qnaireRId = 15644704;
+
//get question groups from Questionnaire_getQuestionGroups
 +
number qnaireRId = 17148177;
 
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
 
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
 +
</source>
 +
<source lang="javascript">
 +
//get question groups from QuestionnaireTemplate
 +
Questionnaire qnaire = new Questionnaire (17148177);
 +
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
 +
qt.Groups;//QuestionGroupRoot
 +
array a = qt.Groups.GetChildGroups();//{QuestionGroupLeaf,QuestionGroupBranch, ...}
 +
</source>
 +
<source lang="javascript">
 +
//create new group branch and leaf
 +
Questionnaire qnaire = new Questionnaire (17148177);
 +
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
 +
QuestionGroupBranch g1 = new QuestionGroupBranch ("G1", qt);
 +
QuestionGroupLeaf g2 = new QuestionGroupLeaf ("G2", qt);
 +
g2.SetQuestions({"Q1", "Q2"});//Questions must in order
 +
g1.SetChildGroups({g2});
 +
//add new group to group root
 +
array groupRoot = qt.Groups.GetChildGroups();
 +
groupRoot.Add(g1);
 +
qt.Groups.SetChildGroups(groupRoot);
 +
qt.Save(true);
 
</source>
 
</source>

Latest revision as of 10:58, 11 May 2022

QuestionGroupRoot



Information about question groups in questionnaire.

Parent class

Inherits from object

Methods

  • QuestionGroupTree FindByName(string name "Question group name") - Find a question group by name
  • QuestionGroupLeaf FindByQuestion(string label "Question label") - Find the question group that contains the given question
  • Array of QuestionGroupTree GetChildGroups() - Return all child groups.
  • Array of string GetPermutation() - Get a sequence of questions following the question group rules
  • Empty SetChildGroups(Array of QuestionGroupTree groups "Question groups") - Set root question groups
  • (From object) string ToString() - The string representation of the object.

Properties

  • string ObjectTypeName { get; } - The name of the type of object.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.


Examples

//get question groups from Questionnaire_getQuestionGroups
number qnaireRId = 17148177;
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
//get question groups from QuestionnaireTemplate 
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
qt.Groups;//QuestionGroupRoot
array a = qt.Groups.GetChildGroups();//{QuestionGroupLeaf,QuestionGroupBranch, ...}
//create new group branch and leaf
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupBranch g1 = new QuestionGroupBranch ("G1", qt);
QuestionGroupLeaf g2 = new QuestionGroupLeaf ("G2", qt);
g2.SetQuestions({"Q1", "Q2"});//Questions must in order
g1.SetChildGroups({g2});
//add new group to group root
array groupRoot = qt.Groups.GetChildGroups();
groupRoot.Add(g1);
qt.Groups.SetChildGroups(groupRoot);
qt.Save(true);