QuestionCondition class

From Catglobe Wiki
Jump to: navigation, search

QuestionCondition



The question condition.

Parent class

Inherits from object

Constructors

  • (int id "Question condition id") - Fetch exists question condition
  • (ConditionType constant type "Condition type, use constant Condition_Type_xxx", QuestionTemplate question "Question contains this condition") - Create new condition and add it to question template

Methods

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

Properties

  • ConditionType constant ConditionType { get; set; } - Get/Set ConditionType of the question condition, use constant Condition_Type_xxx
  • string ConditionTypeAsString { get; } - Get ConditionType as string of the question condition
  • string Expression { get; set; } - Get/Set Expression of the question condition
  • int Id { get; } - Get Id of the question condition
  • string Label { get; set; } - Get/Set Label of the question condition
  • string ObjectTypeName { get; } - The name of the type of object.
  • int QuestionID { get; } - Get QuestionID of the question condition
  • string Range { get; set; } - Get/Set Range of the question condition
  • Dictionary Replacements { get; set; } - Get/Set Replacements of the question condition (only valid for ReplaceIf). Its value is a Dictionary with key is label to replace and value is LocalizedString
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.


Examples

//new condition for a question
//noted that, system not validate wrong condition info (label/expression...)
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");
QuestionCondition c = new QuestionCondition (Condition_Type_GotoIf, q);
c.Label = "EndOutside";
c.Expression = "Q1 == [4]" ;
qt.Save(true);
//edit existing condition 
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");
print(q.Conditions);//{QuestionCondition, ...}
for(i for 0; q.Conditions.Count){
	QuestionCondition c = q.Conditions[i];
	if (c.ConditionTypeAsString == "GotoIf"){
		c.Label = "EndOutside";
		c.Expression= "Q1== [3]";	
	}	
}
qt.Save(true);