Actions

SetVariableExpressionEnd

From LimeSurvey Manual

Revision as of 16:43, 5 August 2019 by DenisChenu (talk | contribs) (Page creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 Hint: This features is available starting in version 4.0.0


  This feature is currently implemented in beta version of LimeSurvey.



Usage

This event happen when Expression Manager is constructed. It allow to update know variables array by expression.

Input

  • surveyId : the related survey id
  • language : the related language
  • knownVars : the current known Variables by expression.
  • newExpressionSuffixes : and empty array by default. To be added as expression suffix (like .question, .NAOK etc …)

Possible output

  • knownVars : The new knowVars

Some detail of knowVars

knowVars are array of variables know by expression manager. Key are the variables

LimeSurvey core have 2 types of variables for knowVars :

  • Value fixed by template or survey or current view : SID, SURVEYURL, QID …
  • Value from response of the user.

Fixed variables are stored as

$knownVars[$variable] = array(
    'code' => // the static value for the variable
    'type' => // ''
    'jsName_on' => // ''
    'jsName' => // ''
    'readWrite' => // 'N' - since these are always read-only variables
);

Dynamic variables are stored as

$knownVars[$sgqa] = array(
    'jsName_on' => // the name of the javascript variable if it is defined on the current page - often 'answerSGQA'
    'jsName' => // the name of the javascript variable when referenced  on different pages - usually 'javaSGQA'
    'readWrite' => // 'Y' for yes, 'N' for no - currently not used
    'hidden' => // 1 if the question attribute 'hidden' is true, otherwise 0
    'question' => // the text of the question (or subquestion)
    'qid' => // the numeric question id - e.g. the Q part of the SGQA name
    'gid' => // the numeric group id - e.g. the G part of the SGQA name
    'grelevance' =>  // the group level relevance string
    'relevance' => // the question level relevance string
    'qcode' => // the qcode-style variable name for this question  (or subquestion)
    'qseq' => // the 0-based index of the question within the survey
    'gseq' => // the 0-based index of the group within the survey
    'type' => // the single character type code for the question
    'sgqa' => // the SGQA name for the variable
    'ansList' => // ansArray converted to a JavaScript fragment - e.g. ",'answers':{ 'M':'Male','F':'Female'}"
    'ansArray' => // PHP array of answer strings, keyed on the answer code = e.g. array['M']='Male';
    'scale_id' => // '0' for most answers.  '1' for second scale within dual-scale questions
    'rootVarName' => // the root code / name / title for the question, without any subquestion or answer-level suffix.  This is from the title column in the questions table
    'subqtext' => // the subquestion text
    'rowdivid' => // the JavaScript ID of the row identifier for a question.  This is used to show/hide entire question rows
    'onlynum' => // 1 if only numbers are allowed for this variable.  If so, then extra processing is needed to ensure that can use comma as a decimal separator
);