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:functions:valuesum [21.01.2015 12:35] – [valueSum()] alexander.ritteren:create:functions:valuesum [05.09.2023 23:11] (current) swissel.uni-mannheim
Line 1: Line 1:
 ====== valueSum() ====== ====== valueSum() ======
  
-''float **valueSum**(string //question//)''+''float **valueSum**(string //Question//)''
  
-''float **valueSum**(string //question//, string|array //items//)''+''float **valueSum**(string //Question//, string|array //Items//)''
  
-''float **valueSum**(array //variables//)''+''float **valueSum**(array //Variables//)''
  
-Calculates the sum of the answer codes for all items in a question (e.g. a scale), for selected itemsor for a list of variables.+Calculates the sum of answer codes for all items of a question (e.g. a scale), for selected items or for a list of variables.
  
-  * //question// -- ID of a question (as a string+  * //Question// -- Die Kennung einer Frage (als String
-  * //items// -- A list of items (string or array) e.g.+  * //Items// -- A list (string or array) of items, e.g.
     * ''array(2,4,6)''     * ''array(2,4,6)''
 +    * ''[2,4,6]''
     * '''1-3,5,7'''     * '''1-3,5,7'''
-  * //variables// -- A list (array) of variable IDs, as stated in the **Variables Overview** e.g. +  * //Variables// -- A list (array) of variable identifiers according to the **Variables overview**e.g. 
-    * ''array('AB01_01', 'AB01_02', 'BB01', 'BC01')''+    * ''['AB01_01', 'AB01_02', 'BB01', 'BC01']'' 
 + 
 +     
 +**Note:** The function ''valueSum()'' can only read regular variables from questions and items. The dwell time ("TIME001", "TIME002", ...) cannot be read by means of ''valueSum()''. Please use the function [[:en:create:functions:casetime]] and the operator for addition (''+'') for this.
  
 ===== Examples ===== ===== Examples =====
  
-Calculate the sum of all responses in scale AB01.+Calculate sum over all responses in scale AB01.
  
 <code php> <code php>
Line 24: Line 28:
 </code> </code>
  
-Sum of items 2, 4, 6 and 8 in scale AB01.+Sum over items 2, 4, 6and 8 of the AB01 scale.
 <code php> <code php>
-$sum = valueSum('AB01', array(2,4,6,8));+$sum = valueSum('AB01', [2,4,6,8]);
 </code> </code>
  
-Sum of the first 4 items in scale AB01.+Sum over the first 4 items of the AB01 scale.
 <code php> <code php>
 $sum = valueSum('AB01', '1-4'); $sum = valueSum('AB01', '1-4');
 </code> </code>
  
-Sum of the responses in variables AB01_01, AB01_03 and BB01_02.+Sum over the responses in variables AB01_01, AB01_03and BB01_02 (as [[:en:create:array|array]] in square brackets).
  
 <code php> <code php>
-$sum = valueSum(array('AB01_01','AB01_03','BB01_02'));+$sum = valueSum(['AB01_01','AB01_03','BB01_02']);
 </code> </code>
  
-The same command written a little more clearly+The same command again a little more clearly
 <code php> <code php>
-$sum = valueSum( +$sum = valueSum([
-         array(+
            'AB01_01',            'AB01_01',
            'AB01_03',            'AB01_03',
            'BB01_02'            'BB01_02'
-         ) +       ]);
-       );+
 </code> </code>
en/create/functions/valuesum.txt · Last modified: 05.09.2023 23:11 by swissel.uni-mannheim
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki