Difference between revisions of "QuestionGroupRoot class"
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
|Name=<nowiki>QuestionGroupRoot</nowiki> | |Name=<nowiki>QuestionGroupRoot</nowiki> | ||
|Description=<nowiki>Information about question groups in questionnaire.</nowiki> | |Description=<nowiki>Information about question groups in questionnaire.</nowiki> | ||
− | |Methods= | + | |InheritsFrom=object|Methods= |
{{CGscriptMethods_Template|ReturnType=QuestionGroupTree|Name=<nowiki>FindByName</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=QuestionGroupTree|Name=<nowiki>FindByName</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Question group name</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Question group name</nowiki>}} | ||
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=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</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>}} | ||
|Properties= | |Properties= | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} |
}} | }} | ||
+ | |||
=== <span style="color:#DF8621">'''Examples'''</span> === | === <span style="color:#DF8621">'''Examples'''</span> === | ||
<source lang="javascript"> | <source lang="javascript"> | ||
− | number qnaireRId = | + | //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 09: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);