QuestionGroupLeaf class

From Catglobe Wiki
Jump to: navigation, search

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