Difference between revisions of "GroupBuilderParticipationPeriodVariable class"
Nguyenduyan (talk | contribs) (Created page with "{{CGscriptClass_Template |Name=GroupBuilderParticipationPeriodVariable |Description=Represents a group builder variable for users that has participated in a list of questionna...") |
Nguyenduyan (talk | contribs) |
||
Line 25: | Line 25: | ||
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} | ||
}} | }} | ||
+ | === <span style="color:#DF8621">'''Examples'''</span> === | ||
+ | '''Example: Add questionnaire''' | ||
+ | <source lang="javascript"> | ||
+ | //Create a new group | ||
+ | string groupName = "Test Group Builder: participationPeriodVariable"; | ||
+ | number groupTemplateResourceId=2066; | ||
+ | number parentResourceId = 11088827; | ||
+ | array group = Group_new(groupName, groupTemplateResourceId, parentResourceId); | ||
+ | Group_save(group); | ||
+ | number groupRId = group[GROUP_RESOURCE_ID ]; | ||
+ | //Create rule for the group | ||
+ | GroupBuilderRoot root = new GroupBuilderRoot (groupRId); | ||
+ | GroupBuilderParticipationPeriodVariable participationPeriodVariable = new GroupBuilderParticipationPeriodVariable(); | ||
+ | number questionnaireResourceId = 15546533 ; | ||
+ | participationPeriodVariable.Add(questionnaireResourceId ); | ||
+ | participationPeriodVariable.Add(15559234 ); | ||
+ | participationPeriodVariable.ResourceTemplateResourceId = 43086; | ||
+ | DateTime date = new DateTime("2017-4-19"); | ||
+ | participationPeriodVariable.FromDate = date; | ||
+ | participationPeriodVariable.ToDate = date; | ||
+ | participationPeriodVariable.FromDateStartDate= false; | ||
+ | participationPeriodVariable.ToDateStartDate= false; | ||
+ | GroupBuilderRule rule = new GroupBuilderRule (root); | ||
+ | rule.Add(participationPeriodVariable); | ||
+ | GroupBuilderRuleCollection ruleColection = root.RootRules; | ||
+ | ruleColection.Add(rule); | ||
+ | root.Save(); | ||
+ | </source> | ||
+ | <br/> | ||
+ | '''Example: Remove questionnaire''' | ||
+ | <source lang="javascript"> | ||
+ | GroupBuilderRoot root = new GroupBuilderRoot (15560826); | ||
+ | GroupBuilderRuleCollection ruleColection = root.RootRules; | ||
+ | GroupBuilderParticipationPeriodVariable participationPeriodVariable = ruleColection[0][0]; | ||
+ | print(participationPeriodVariable.Count);//2 | ||
+ | number questionnaireResourceId = participationPeriodVariable[1]; | ||
+ | participationPeriodVariable.Remove(questionnaireResourceId); | ||
+ | print(participationPeriodVariable.Count);//1 | ||
+ | root.Save(); | ||
+ | </source> |
Revision as of 03:44, 19 April 2017
GroupBuilderParticipationPeriodVariable
Represents a group builder variable for users that has participated in a list of questionnaires.
Constructors
- () - Create new variable
Methods
- Empty Add(int questionnaireResourceId "Questionnaire resource id to add") - Add a new questionnaire
- int this[] { get; }(int index "Index") - Get questionnaire resource id at index
- bool Remove(int questionnaireResourceId "Questionnaire resource id to remove") - Remove questionnaire. Return true if removed
- string ToString() - The string representation of the object.
Properties
- int Count { get; } - Number of specific questionnaires
- DateTime FromDate { get; set; } - From date
- bool FromDateStartDate { get; set; } - From date is the start date, or if false the end date
- string ObjectTypeName { get; } - The name of the type of object.
- int ResourceTemplateResourceId { get; set; } - Questionnaire resource template to get users from, instead of individual questionnaires
- DateTime ToDate { get; set; } - To date
- bool ToDateStartDate { get; set; } - To date is the start date, or if false the end date
- TypeInformation TypeInformation { get; } - Get information about this class.
Examples
Example: Add questionnaire
//Create a new group
string groupName = "Test Group Builder: participationPeriodVariable";
number groupTemplateResourceId=2066;
number parentResourceId = 11088827;
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId);
Group_save(group);
number groupRId = group[GROUP_RESOURCE_ID ];
//Create rule for the group
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);
GroupBuilderParticipationPeriodVariable participationPeriodVariable = new GroupBuilderParticipationPeriodVariable();
number questionnaireResourceId = 15546533 ;
participationPeriodVariable.Add(questionnaireResourceId );
participationPeriodVariable.Add(15559234 );
participationPeriodVariable.ResourceTemplateResourceId = 43086;
DateTime date = new DateTime("2017-4-19");
participationPeriodVariable.FromDate = date;
participationPeriodVariable.ToDate = date;
participationPeriodVariable.FromDateStartDate= false;
participationPeriodVariable.ToDateStartDate= false;
GroupBuilderRule rule = new GroupBuilderRule (root);
rule.Add(participationPeriodVariable);
GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule);
root.Save();
Example: Remove questionnaire
GroupBuilderRoot root = new GroupBuilderRoot (15560826);
GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderParticipationPeriodVariable participationPeriodVariable = ruleColection[0][0];
print(participationPeriodVariable.Count);//2
number questionnaireResourceId = participationPeriodVariable[1];
participationPeriodVariable.Remove(questionnaireResourceId);
print(participationPeriodVariable.Count);//1
root.Save();