Difference between revisions of "SampleRule class"
Nguyenduyan (talk | contribs) (Created page with "{{CGscriptClass_Template |Name=<nowiki>SampleRule</nowiki> |Description=<nowiki>Represents a SampleRule.</nowiki> |Methods= {{CGscriptMethods_Template|ReturnType=Empty|Name=<n...") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
|Name=<nowiki>SampleRule</nowiki> | |Name=<nowiki>SampleRule</nowiki> | ||
|Description=<nowiki>Represents a SampleRule.</nowiki> | |Description=<nowiki>Represents a SampleRule.</nowiki> | ||
+ | |InheritsFrom=object|Constructors= | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>id</nowiki>|Description=<nowiki>Sample rule resource id</nowiki>}} | ||
+ | |Description=<nowiki>Fetch exist sample rule</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of rule</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>questionnaireResourceId</nowiki>|Description=<nowiki>Resource id of questionnaire to sample to</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>Resource id of group to sample</nowiki>}} | ||
+ | |Description=<nowiki>Create new group samplerule</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of rule</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Questionnaire|Name=<nowiki>questionnaire</nowiki>|Description=<nowiki>The questionnaire contains this sample rule</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>groupId</nowiki>|Description=<nowiki>Resource id of group to sample</nowiki>}} | ||
+ | |Description=<nowiki>Create and add new group sample rule to questionnaire object</nowiki>}} | ||
|Methods= | |Methods= | ||
− | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Rebuild</nowiki>|Description=<nowiki>Rebuild sample rule</nowiki>}} |
− | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}} | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save the Samplerule</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=bool|Name=<nowiki>Active</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set if the SampleRule is active or not</nowiki>}} | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Active</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set if the SampleRule is active or not</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>ActualSize</nowiki>|HasGetter=1|Description=<nowiki>Get | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>ActualSize</nowiki>|HasGetter=1|Description=<nowiki>Get how many qas is currently sampled for this rule.</nowiki>}} |
− | + | {{CGscriptProperties_Template|ReturnType=DateTime|Name=<nowiki>DeletedDate</nowiki>|HasGetter=1|Description=<nowiki>Get/Set the DeletedDate of Samplerule</nowiki>}} | |
− | {{CGscriptProperties_Template|ReturnType=DateTime|Name=<nowiki>DeletedDate</nowiki>|HasGetter | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Description</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the Description of Samplerule</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Description</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the Description of Samplerule</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType= | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>GroupId</nowiki>|HasGetter=1|Description=<nowiki>Get id of group associated with this samplerule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki> | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>GroupResourceId</nowiki>|HasGetter=1|Description=<nowiki>Get resourceId of group associated with this samplerule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the Name of Samplerule</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Id</nowiki>|HasGetter=1|Description=<nowiki>Resource id of sample rule</nowiki>}} |
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the Name of Samplerule.</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= | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>QuestionnaireId</nowiki>|HasGetter=1|Description=<nowiki>Get id of questionnaire associated with this samplerule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType= | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>QuestionnaireResourceId</nowiki>|HasGetter=1|Description=<nowiki>Get resourceId of questionnaire associated with this samplerule</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType= | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>RequestedSize</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get how many qas is requested to sample for this rule.</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki> | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>SampleRuleType</nowiki>|HasGetter=1|Description=<nowiki>Get the Type of Samplerule.</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki> | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>SizeWithData</nowiki>|HasGetter=1|Description=<nowiki>Get how many qas for this rule have data</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki> | + | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>SizeWithoutData</nowiki>|HasGetter=1|Description=<nowiki>Get how many qas for this rule does not have data</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType= | + | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} |
− | {{ | + | |StaticMethods= |
− | {{ | + | {{CGscriptMethods_Template|ReturnType=Array of SampleRule|Name=<nowiki>SampleRule_getByGroupResourceId</nowiki>|Parameters= |
− | {{ | + | {{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>Resource id of the group to get samples from</nowiki>}} |
+ | |Description=<nowiki>Get all sample rules associated with a group</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of SampleRule|Name=<nowiki>SampleRule_getByQuestionnaireResourceId</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>questionnaireResourceId</nowiki>|Description=<nowiki>Resource id of the questionnaire to get samples from</nowiki>}} | ||
+ | |Description=<nowiki>Get all sample rules associated with a group</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SampleRule_rebuild</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Array of SampleRule|Name=<nowiki>samplesRules</nowiki>|Description=<nowiki>Sample rules to rebuild samples for</nowiki>}} | ||
+ | |Description=<nowiki>Rebuild the samples in the given sample rules</nowiki>}} | ||
}} | }} | ||
+ | |||
+ | === <span style="color:#DF8621">'''Examples'''</span> === | ||
+ | <source lang="javascript"> | ||
+ | number groupRId = 15644390; | ||
+ | array sampleRule = SampleRule_getByGroupResourceId(groupRId); | ||
+ | for(number i = 0; i<sampleRule.Count; i++) | ||
+ | { | ||
+ | print(sampleRule[i].Active); | ||
+ | print(sampleRule[i].ActualSize); | ||
+ | print(sampleRule[i].DeletedDate); | ||
+ | print(sampleRule[i].Description); | ||
+ | print(sampleRule[i].SampleRuleType ); | ||
+ | print(sampleRule[i].SizeWithData ); | ||
+ | print(sampleRule[i].SizeWithoutData ); | ||
+ | } | ||
+ | </source> | ||
+ | <source lang="javascript"> | ||
+ | //add sameple to qnaire and rebuild | ||
+ | Questionnaire qnaire = new Questionnaire (17148177); | ||
+ | number groupSample = 17146562; | ||
+ | SampleRule sampleRule = new SampleRule ("s1", qnaire, groupSample); | ||
+ | sampleRule.Save(); | ||
+ | sampleRule.Rebuild(); | ||
+ | </source> |
Latest revision as of 10:41, 11 May 2022
SampleRule
Represents a SampleRule.
Parent class
Inherits from object
Constructors
- (int id "Sample rule resource id") - Fetch exist sample rule
- (string name "Name of rule", int questionnaireResourceId "Resource id of questionnaire to sample to", int groupResourceId "Resource id of group to sample") - Create new group samplerule
- (string name "Name of rule", Questionnaire questionnaire "The questionnaire contains this sample rule", int groupId "Resource id of group to sample") - Create and add new group sample rule to questionnaire object
Methods
- Empty Rebuild() - Rebuild sample rule
- Empty Save() - Save the Samplerule
- (From object) string ToString() - The string representation of the object.
Properties
- bool Active { get; set; } - Get/Set if the SampleRule is active or not
- int ActualSize { get; } - Get how many qas is currently sampled for this rule.
- DateTime DeletedDate { get; } - Get/Set the DeletedDate of Samplerule
- string Description { get; set; } - Get/Set the Description of Samplerule
- int GroupId { get; } - Get id of group associated with this samplerule
- int GroupResourceId { get; } - Get resourceId of group associated with this samplerule
- int Id { get; } - Resource id of sample rule
- string Name { get; set; } - Get/Set the Name of Samplerule.
- string ObjectTypeName { get; } - The name of the type of object.
- int QuestionnaireId { get; } - Get id of questionnaire associated with this samplerule
- int QuestionnaireResourceId { get; } - Get resourceId of questionnaire associated with this samplerule
- int RequestedSize { get; set; } - Get how many qas is requested to sample for this rule.
- int SampleRuleType { get; } - Get the Type of Samplerule.
- int SizeWithData { get; } - Get how many qas for this rule have data
- int SizeWithoutData { get; } - Get how many qas for this rule does not have data
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
Static Methods
- Array of SampleRule SampleRule_getByGroupResourceId(int groupResourceId "Resource id of the group to get samples from") - Get all sample rules associated with a group
- Array of SampleRule SampleRule_getByQuestionnaireResourceId(int questionnaireResourceId "Resource id of the questionnaire to get samples from") - Get all sample rules associated with a group
- Empty SampleRule_rebuild(Array of SampleRule samplesRules "Sample rules to rebuild samples for") - Rebuild the samples in the given sample rules
Examples
number groupRId = 15644390;
array sampleRule = SampleRule_getByGroupResourceId(groupRId);
for(number i = 0; i<sampleRule.Count; i++)
{
print(sampleRule[i].Active);
print(sampleRule[i].ActualSize);
print(sampleRule[i].DeletedDate);
print(sampleRule[i].Description);
print(sampleRule[i].SampleRuleType );
print(sampleRule[i].SizeWithData );
print(sampleRule[i].SizeWithoutData );
}
//add sameple to qnaire and rebuild
Questionnaire qnaire = new Questionnaire (17148177);
number groupSample = 17146562;
SampleRule sampleRule = new SampleRule ("s1", qnaire, groupSample);
sampleRule.Save();
sampleRule.Rebuild();