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.

QuestionGroupLeaf class: Difference between revisions

From Catglobe Wiki
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
|Name=<nowiki>QuestionGroupLeaf</nowiki>
|Name=<nowiki>QuestionGroupLeaf</nowiki>
|Description=<nowiki>Question group leaf.</nowiki>
|Description=<nowiki>Question group leaf.</nowiki>
|InheritsFrom=QuestionGroupTree|Constructors=
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Group name</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=QuestionnaireTemplate|Name=<nowiki>qt</nowiki>|Description=<nowiki>Questionnaire template</nowiki>}}
|Description=<nowiki>Create s leaf group</nowiki>}}
|Methods=
|Methods=
{{CGscriptMethods_Template|ReturnType=Array of QuestionGroupTree|Name=<nowiki>GetChildGroups</nowiki>|Description=<nowiki>Return all child groups, if empty then it is a leaf.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Array of String|Name=<nowiki>GetQuestions</nowiki>|Description=<nowiki>Return label of questions in group</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetQuestions</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=Array of String|Name=<nowiki>labels</nowiki>|Description=<nowiki>Question labels</nowiki>}}
|Description=<nowiki>Set questions in group by their label</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=Array of strings|Name=<nowiki>AllQuestions</nowiki>|HasGetter=1|Description=<nowiki>Labels of all questions in this group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=Array of strings|Name=<nowiki>AllQuestions</nowiki>|HasGetter=1|Inherited=QuestionGroupTree|Description=<nowiki>Labels of all questions in this group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Count</nowiki>|HasGetter=1|Description=<nowiki>How many children in this group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Count</nowiki>|HasGetter=1|Description=<nowiki>How many children in this group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>GroupName</nowiki>|HasGetter=1|Description=<nowiki>Name of question group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>GroupName</nowiki>|HasGetter=1|HasSetter=1|Inherited=QuestionGroupTree|Description=<nowiki>Name of question group</nowiki>}}
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IsLeaf</nowiki>|HasGetter=1|Inherited=QuestionGroupTree|Description=<nowiki>Check if it is leaf group or not</nowiki>}}
{{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=string|Name=<nowiki>SequenceType</nowiki>|HasGetter=1|Description=<nowiki>Which kind of question group is it</nowiki>}}
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>SelectCount</nowiki>|HasGetter=1|HasSetter=1|Inherited=QuestionGroupTree|Description=<nowiki>How many child items will be used for Sequence_Command_RandomizedSelect or Sequence_Command_RotateSelect</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=SequenceCommand constant|Name=<nowiki>SequenceCommand</nowiki>|HasGetter=1|HasSetter=1|Inherited=QuestionGroupTree|Description=<nowiki>Which kind of this group is it, use constant Sequence_Command_xxx</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>SequenceType</nowiki>|HasGetter=1|Inherited=QuestionGroupTree|Description=<nowiki>Respent SequenceCommand as string</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> ===
<span style="color:#DF8621"> QuestionGroupLeaf is returned when calling [[QuestionGroupRoot_class]]</span>
<source lang="javascript">
<source lang="javascript">
number qnaireRId = 15644704;
//Find a group leaf by its question
number qnaireRId = 17148177;
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
//QuestionGroupRoot root = new QuestionnaireTemplate(new Questionnaire(17148177).TemplateId).Groups;
QuestionGroupLeaf leaf = root.FindByQuestion("Q1");
QuestionGroupLeaf leaf = root.FindByQuestion("Q1");
print(leaf.GroupName);//G2
print(leaf.GroupName);//G1
</source>
<source lang="javascript">
//create new group leaf
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupLeaf g1 = new QuestionGroupLeaf ("G1", qt);
g1.SetQuestions({"Q1", "Q2"});//Questions must in order
//add the group leaf to group root
array groupRoot = qt.Groups.GetChildGroups();
groupRoot.Add(g1);
qt.Groups.SetChildGroups(groupRoot);
qt.Save(true);
</source>
<source lang="javascript">
//add more questions for an existing group leaf
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupLeaf g1 = qt.Groups.FindByName("G1");
// add more question to questions array
array questions = g1.GetQuestions();
questions.Add("Q3");
g1.SetQuestions(questions);
qt.Save(true);
</source>
</source>

Latest revision as of 09:11, 11 May 2022

QuestionGroupLeaf


Question group leaf.

Parent class

Inherits from QuestionGroupTree

Constructors

Methods

  • Array of String GetQuestions() - Return label of questions in group
  • Empty SetQuestions(Array of String labels "Question labels") - Set questions in group by their label
  • (From object) string ToString() - The string representation of the object.

Properties


Examples

//Find a group leaf by its question
number qnaireRId = 17148177;
QuestionGroupRoot root = Questionnaire_getQuestionGroups(qnaireRId);
//QuestionGroupRoot root = new QuestionnaireTemplate(new Questionnaire(17148177).TemplateId).Groups;
QuestionGroupLeaf leaf = root.FindByQuestion("Q1");
print(leaf.GroupName);//G1
//create new group leaf
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupLeaf g1 = new QuestionGroupLeaf ("G1", qt);
g1.SetQuestions({"Q1", "Q2"});//Questions must in order
//add the group leaf to group root
array groupRoot = qt.Groups.GetChildGroups();
groupRoot.Add(g1);
qt.Groups.SetChildGroups(groupRoot);
qt.Save(true);
//add more questions for an existing group leaf
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionGroupLeaf g1 = qt.Groups.FindByName("G1");
// add more question to questions array
array questions = g1.GetQuestions();
questions.Add("Q3");
g1.SetQuestions(questions);
qt.Save(true);