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.

AnswerOption class: Difference between revisions

From Catglobe Wiki
Created page with "{{CGscriptClass_Template |Name=<nowiki>AnswerOption</nowiki> |Description=<nowiki>The answer option template</nowiki> |InheritsFrom=object|Constructors= {{CGscriptConstructors..."
 
No edit summary
 
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 05: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);