Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:create:variables [05.02.2015 21:04]
alexander.ritter [Working with Variables]
en:create:variables [27.08.2018 15:46]
admin Custom variable IDs
Line 10: Line 10:
  
   * **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 variables** ​save 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 [[:​de:​create:​inputs-custom|custom form elements]].
  
- + 
 +===== Data Set Variables ===== 
 + 
 +Most questions create a variable in the data set, moreover you can use the question type [[:​en:​create:​questions:​internal]] (see below) to create additional variables in the data set that store user-defined data. 
 + 
 +In addition, there are [[:​en:​results:​variables|additional variables]] containing meta and para data for each record. 
 + 
 +When questions are created, the variables are assigned an ID consisting of the question ID (e.g. "​AB01"​) and (optionally) an suffix (e.g. "​_01"​ or "​x1"​). For questions with subordinate items (e.g. scales), the suffix usually corresponds to the number of the item. 
 + 
 + 
 +==== Custom Variable IDs ==== 
 + 
 +In the tab "​Variables"​ of a question you can change the ID of one or more variables. 
 + 
 +{{ :​de:​create:​scr.variables.custom-labels.png?​nolink |Karteireiter Variablen in einer Frage}} 
 + 
 +Click the edit button ({{:​de:​create:​symbol.edit.png?​nolink|Edit button}}) to change the ID. Enter the desired new ID for the variable. The ID must comply with the following rules: 
 + 
 +  * The letters A to Z (upper or lower case), the digits 0 to 9 and the underscore (''​_''​) can be used. The first character must be a letter. 
 +  * The IDs can be a maximum of 64 characters long. 
 +  * To avoid possible overlaps with the automatically assigned IDs, the third and fourth characters __must not be both__ digits. The identifiers "​var01",​ "​v01",​ or "​age"​ are therefore possible, but not "​va00",​ "​v001",​ or "​xy123"​. 
 + 
 +If you do not enter anything in the input field for the ID, the automatic ID is restored. 
 + 
 +Two buttons are available to set the new ID: 
 + 
 +  * The button {{:​de:​create:​symbol.check.png?​nolink|button to confirm}} sets the ID only for the one variable. 
 +  * The button {{:​de:​create:​symbol.checkMulti.png?​nolink|button for confirming all subsequent variables}} additionally sets the IDs for all subsequent variables, with SoSci Survey automatically incrementing a number at the end. For example, if you enter the ID "​sus01"​ for the first variable, the other variables are assigned the IDs "​sus02,​ "​sus03",​ and so on. 
 + 
 +The changed identifiers are used as variable names in [[:​en:​results:​download]] and can be used in [[:​en:​create:​php-filters|PHP-Filters]] or the function ''​[[:​en:​create:​functions:​value]]]''​. The automatically assigned ID also remains valid. 
  
 ===== Internal Variables ===== ===== Internal Variables =====
Line 142: Line 172:
 It makes sense that the stations are queried in the same order in both questions. In order to do so, first of a list ([[:​en:​create:​array|Array]]) of the item IDs in a random order is created using ''​[[:​en:​create:​functions:​random_items|random_items()]]''​. This list is stored in the variable ''​$items''​. It makes sense that the stations are queried in the same order in both questions. In order to do so, first of a list ([[:​en:​create:​array|Array]]) of the item IDs in a random order is created using ''​[[:​en:​create:​functions:​random_items|random_items()]]''​. This list is stored in the variable ''​$items''​.
  
-The variable ''​$items''​ is not only needed on the current page, but on the following page for question "​AB02"​ as well. Theefore, this is made available ​for future PHP code elements using ''​[[:​en:​create:​functions:​registervariable|registerVariable()]]''​. Subsequently,​ question "​AB01"​ will be displayed ​with the shuffled order. ​+The variable ''​$items''​ is not only needed on the current page, but on the following page for question "​AB02"​ as well. This is therefore ​made accessible ​for future PHP code elements using ''​[[:​en:​create:​functions:​registervariable|registerVariable()]]''​. Subsequently,​ question "​AB01"​ will be displayed ​in the shuffled order. ​
  
 <code php> <code php>
en/create/variables.txt · Last modified: 27.08.2018 15:46 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