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.

QuestionProperty class

From Catglobe Wiki
Revision as of 07:08, 11 May 2022 by Administrator (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

QuestionProperty



The question property.

Parent class

Inherits from object

Constructors

  • (PropertyType constant type "Property type. Use constant named Question_Property_xxx", QuestionTemplate question "Question template contains this property") - Create new property and add it to question properties
  • (PropertyType constant type "Property type. Use constant named Question_Property_xxx", int gridNumber "Index of sub question that this property belong to", QuestionTemplate question "Question template contains this property") - Create new property and add it to question properties

Methods

  • (From object) string ToString() - The string representation of the object.

Properties

  • int GridNumber { get; set; } - Get/Set Index of sub question that this property belong to
  • bool HasText { get; } - [OBSOLETE] Get HasText of the question property
  • int Id { get; } - Get id of the question property
  • bool IsLocalize { get; } - Check value type of property should be use as LocalizedString
  • bool IsSpecialText { get; } - Get IsSpecialText of the question property that marked by system
  • string Name { get; set; } - Get or set Name of the this property.
  • string ObjectTypeName { get; } - The name of the type of object.
  • PropertyType constant PropertyType { get; } - Get constant of the property's type
  • string PropertyTypeAsString { get; } - Get PropertyType as string
  • int QuestionID { get; } - [OBSOLETE] Get QuestionID of the question property
  • Dictionary QuestionPropertyLanguages { get; } - [OBSOLETE] Get QuestionPropertyLanguages of the question property. Only valid when HasText is true
  • LocalizedString QuestionPropertyLanguagesLocalized { get; } - [OBSOLETE] Same as QuestionPropertyLanguages, just different container
  • int QuestionPropertyType { get; } - [OBSOLETE] Get QuestionPropertyType of the question property
  • string QuestionPropertyTypeAsString { get; } - [OBSOLETE] Get QuestionPropertyType as string of the question property
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.
  • string TypeValue { get; set; } - Get or set TypeValue of this property
  • object Value { get; set; } - Get or set value of the this property. Base on IsLocalize, it can be a String or LocalizedString


Examples

// Example to get Export/Report label on "Q7"

string questionName = "Q7";
number qnaireRId = 15644863;
array questionProperty = getQuestionProperties(questionName, qnaireRId);
for(number i = 0; i < questionProperty.Count; i++) 
{
	QuestionProperty qp = questionProperty[i];
	print(qp.QuestionPropertyType);//97
	print(qp.QuestionPropertyLanguages);//{"da-DK": Export Report label in DK, "en-GB": Export Report label in UK}
	print(qp.QuestionPropertyLanguagesLocalized.GetTranslationForLoggedInUser());//Export Report label in UK
	print(qp.QuestionPropertyLanguagesLocalized.GetSpecificTranslation("da-DK"));//Export Report label in DK
}
//Create a new question property
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");//QuestionTemplate
QuestionProperty p = new QuestionProperty (Question_Property_EndPoints, q);
p.Value = "50";
qt.Save(false);
print(q.GetProperty(Question_Property_EndPoints));//50
//Create new a question property or update it if already existed
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");//QuestionTemplate
q.SetProperty(Question_Property_EndPoints, "100");
qt.Save(false);
print(q.GetProperty(Question_Property_EndPoints));//100
//update an existing question property
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");//QuestionTemplate
print(q.Properties);//{QuestionProperty,...}
for(i for 0; q.Properties.Count){
	QuestionProperty p = q.Properties[i];
	if(p.PropertyType == Question_Property_EndPoints)
		p.Value = "200";
}
qt.Save(false);
print(q.GetProperty(Question_Property_EndPoints));//200