Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:create:variables [27.08.2018 15:46] – Custom variable IDs adminen:create:variables [23.10.2026 14:44] (current) – external edit 127.0.0.1
Line 11: Line 11:
   * **PHP variables** are a feature of the programming language PHP. They appear directly in the PHP code (i.e. a //PHP code// element when composing the questionnaire), and start with a dollar sign (''$''), e.g. ''$age''. PHP variables are described in detail [[#php_variables|below]].   * **PHP variables** are a feature of the programming language PHP. They appear directly in the PHP code (i.e. a //PHP code// element when composing the questionnaire), and start with a dollar sign (''$''), e.g. ''$age''. PHP variables are described in detail [[#php_variables|below]].
   * **Data set variables** store the participant's responses -- they are accessible later on in the data record as variables for the analysis. Each questionnaire that is filled out generates a new case in the data record. A list of all data variables in a survey project can be seen in the **Variables Overview**. The current value of a data variable, for example, the answer given by a respondent, can be read with the function ''[[:en:create:functions:value|value()]]'' and used in a [[:en:create:filters|filter]].   * **Data set variables** store the participant's responses -- they are accessible later on in the data record as variables for the analysis. Each questionnaire that is filled out generates a new case in the data record. A list of all data variables in a survey project can be seen in the **Variables Overview**. The current value of a data variable, for example, the answer given by a respondent, can be read with the function ''[[:en:create:functions:value|value()]]'' and used in a [[:en:create:filters|filter]].
-  * **Internal Variables** are specific data variables. They are used to make values in the data record accessible that were calculated with PHP code or drawn. In addition, internal variables can save responses that were collected with [[:de:create:inputs-custom|custom form elements]].+  * **Internal Variables** are specific data variables. They are used to make values in the data record accessible that were calculated with PHP code or drawn. In addition, internal variables can save responses that were collected with [[:en:create:inputs-custom|custom form elements]].
  
  
Line 98: Line 98:
 The hidden form fields can be accessed by using JavaScript. This means responses or measured values gathered with JavaScript can be conveniently stored in the data record.  The hidden form fields can be accessed by using JavaScript. This means responses or measured values gathered with JavaScript can be conveniently stored in the data record. 
  
-The following example assumes that a question type "internal variables" with ID "PC01" was created with two variables in it, which have IDs "PC01_01" and "PC01_02". The hidden form element for variable "PC01_01" can be accessed in JavaScript by using ''%%document.getElementById("PC01_01")%%''. The width and height of the screen should be generated (in [[:de:glossary#pixel|pixels]]) via JavaScript, and stored in the data record.+The following example assumes that a question type "internal variables" with ID "PC01" was created with two variables in it, which have IDs "PC01_01" and "PC01_02". The hidden form element for variable "PC01_01" can be accessed in JavaScript by using ''%%document.getElementById("PC01_01")%%''. The width and height of the screen should be generated (in [[:en:glossary#pixels|pixels]]) via JavaScript, and stored in the data record.
  
 In addition, question "PC01" is dragged onto the questionnaire page, and the following JavaScript code is placed underneath it as a text element.  In addition, question "PC01" is dragged onto the questionnaire page, and the following JavaScript code is placed underneath it as a text element. 
Line 176: Line 176:
 <code php> <code php>
 $items = random_items('AB01'); // randomized order of items in question AB01 $items = random_items('AB01'); // randomized order of items in question AB01
-registerVariable('items');+registerVariable($items);
 question('AB01', $items);  // ask question with randomized items question('AB01', $items);  // ask question with randomized items
 </code> </code>
en/create/variables.1535377613.txt.gz · Last modified: by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki