Actions

ExpressionAnswerOptions: Difference between revisions

From LimeSurvey Manual

(Page creation, please correct english …)
 
m (More detail (from README))
 
Line 3: Line 3:
=Usage=
=Usage=


Allow to get answer text of question related to specific code.
Make answer option text available inside survey by expression function.
 
The function getAnswerOptionText get 3 parameters
* The question id or title
* The answer code to get
* The scale (for array dual scale question)
 
=More detail=


The function can be used with question id or question code. The result are not updated on same page.
The function can be used with question id or question code. The result are not updated on same page.
Line 20: Line 27:
* Get the answer text of option A1 of array question with code 'Qcode' : <code>{getAnswerOptionText("Qcode","A1")}</code>
* Get the answer text of option A1 of array question with code 'Qcode' : <code>{getAnswerOptionText("Qcode","A1")}</code>
* Get the answer text of same option choice done in a previous question with code prev of current single choice question : <code>{getAnswerOptionText(self.qid,prev.NAOK)}</code> (if 'prev' question are in same group, the answer was not updated).
* Get the answer text of same option choice done in a previous question with code prev of current single choice question : <code>{getAnswerOptionText(self.qid,prev.NAOK)}</code> (if 'prev' question are in same group, the answer was not updated).
[[Category:Plugins]][[Category:Core Plugins]]

Latest revision as of 08:25, 6 April 2022

 Hint: This features is available starting in version 5.3.0


Usage

Make answer option text available inside survey by expression function.

The function getAnswerOptionText get 3 parameters

  • The question id or title
  • The answer code to get
  • The scale (for array dual scale question)

More detail

The function can be used with question id or question code. The result are not updated on same page.

Each parameters can use expression, the expression are checked before send to function.

The function use the result of the expression then, for question parameter: if it's a numeric value : start to check if the question id exist in this survey, and get the primary question if it's a sub question; if it's a string search the primary question title in this survey.

For the answer code : the result of the expression is used directly.

  Before using these functions : the plugin must be activated in Plugin Manager.


Example

  • Get the answer text of option A1 of current single choice question : {getAnswerOptionText(self.qid,"A1")}
  • Get the answer text of option A1 of array question with code 'Qcode' : {getAnswerOptionText("Qcode","A1")}
  • Get the answer text of same option choice done in a previous question with code prev of current single choice question : {getAnswerOptionText(self.qid,prev.NAOK)} (if 'prev' question are in same group, the answer was not updated).