Difference between revisions of "AnswerOption class"

From Catglobe Wiki
Jump to: navigation, search
(Created page with "{{CGscriptClass_Template |Name=<nowiki>AnswerOption</nowiki> |Description=<nowiki>The answer option template</nowiki> |InheritsFrom=object|Constructors= {{CGscriptConstructors...")
 
 
Line 19: Line 19:
 
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Value</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Answer option value</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Value</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Answer option value</nowiki>}}
 
}}
 
}}
 +
=== <span style="color:#DF8621">'''Examples'''</span> ===
 +
<source lang="javascript">
 +
// new AnswerOption for a question
 +
Questionnaire qnaire = new Questionnaire (17148177);
 +
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
 +
QuestionTemplate q = qt.GetQuestion("Q1");
 +
AnswerOption ao = new AnswerOption (q);
 +
ao.Text.SetTranslation ("", "Option 3");
 +
qt.Save(true);
 +
</source>

Latest revision as of 07:16, 11 May 2022

AnswerOption



The answer option template

Parent class

Inherits from object

Constructors

  • (QuestionTemplate question "The question contains this answer option") - Create new answer option and add it into question. Default its value is max options + 1
  • (int id "Answer option id") - Fetch exist answer option template

Methods

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

Properties

  • bool HasData { get; } - Check if this answer option contains data or not
  • int Id { get; } - Answer option id
  • string ObjectTypeName { get; } - The name of the type of object.
  • LocalizedString Text { get; set; } - Answer option text
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.
  • int Value { get; set; } - Answer option value

Examples

// new AnswerOption for a question 
Questionnaire qnaire = new Questionnaire (17148177);
QuestionnaireTemplate qt = new QuestionnaireTemplate (qnaire.TemplateId);
QuestionTemplate q = qt.GetQuestion("Q1");
AnswerOption ao = new AnswerOption (q);
ao.Text.SetTranslation ("", "Option 3");
qt.Save(true);