Actions

Expression Manager/de: Difference between revisions

From LimeSurvey Manual

m (Text replacement - "sub-question" to "subquestion")
(Created page with "Dies ist eine Stichprobenerhebung. Auf der ersten Seite werden Sie gefragt, wie viele Personen bei Ihnen wohnen, und speichert dies in der Variablen "cohabs". Diese Seite wird...")
Line 41: Line 41:
===Betrachten / Bearbeiten Relevanz auf Gruppenebene===
===Betrachten / Bearbeiten Relevanz auf Gruppenebene===


This is a sample census survey.  The first page asks how many people live with you and stores that in the "cohabs" variable.  This page is only shown if you have more than one cohabitant (so it is shown for the second person cohabitating with you), and also only shows if you specified how Person One is related to you (p1_rel).
Dies ist eine Stichprobenerhebung. Auf der ersten Seite werden Sie gefragt, wie viele Personen bei Ihnen wohnen, und speichert dies in der Variablen "cohabs". Diese Seite wird nur angezeigt, wenn Sie mehr als einen Mitbewohner haben (also für die zweite Person, die mit Ihnen zusammen lebt) und auch nur, wenn Sie angegeben haben, wie Person 1 mit Ihnen verwandt ist (p1_rel).


[[File:tutorial4.jpg]]
[[File:tutorial4.jpg]]
Line 59: Line 59:
===Bedingte Gleichungen===
===Bedingte Gleichungen===


The Body Mass Index example shows the ability to compute a person's BMI, even while letting them enter their height in weight in metric or non-metric units.
The Body Mass Index example shows the ability to compute a person's BMI, even while letting them enter their height and weight in metric or non-metric units.


[[File:tailoring7.jpg]]
[[File:tailoring7.jpg]]


Here weight_kg is {if(weight_units == 'kg', weight, weight * .453592)}.  This if() function means that if the subject entered the weight using kilograms, use that value, otherwise multiple the entered value (which was in pounds) by .453592 to convert it to kilograms.  The height_m variable uses a similar approach to compute the person's height in meters, even if he entered his height in inches.
Here weight_kg is {if(weight_units == 'kg', weight, weight * .453592)}.  This if() function means that if the subject entered the weight using kilograms, use that value, otherwise multiply the entered value (which was in pounds) by .453592 to convert it to kilograms.  The height_m variable uses a similar approach to compute the person's height in meters, even if he entered his height in inches.


BMI computes the weight formula as {weight_kg / (height_m * height_m)}.
BMI computes the weight formula as {weight_kg / (height_m * height_m)}.
Line 105: Line 105:
In all of these cases, since the advanced question option is always considered an expression, you do not use curly braces when specifying it.
In all of these cases, since the advanced question option is always considered an expression, you do not use curly braces when specifying it.


The [[Expression Manager Sample Surveys|Sample Surveys]] pages shows many working examples of using expressions for validations.
The [[Expression Manager sample surveys|Sample Surveys]] pages shows many working examples of using expressions for validations.


=Einführung=
=Einführung=


LimeSurvey 1.92 and later uses the new Expression Manager (EM) module which will let LimeSurvey support more complex branching, assessments, validation, and tailoring.  It will replace how LimeSurvey manages Replacements, Conditions, and Assessments on the back-end.  It will also speed up processing considerably since it eliminates most run-time database reads.  EM was developed by Dr. Thomas White (TMSWhite).
LimeSurvey uses the new Expression Manager (EM) module which will let LimeSurvey support more complex branching, assessments, validation, and tailoring.  It will replace how LimeSurvey manages Replacements, Conditions, and Assessments on the back-end.  It will also speed up processing considerably since it eliminates most run-time database reads.  EM was developed by Dr. Thomas White (TMSWhite).


This wiki page is the definitive reference for Expression Manager syntax and functionality.
This wiki page is the definitive reference for Expression Manager syntax and functionality.
Line 118: Line 118:
#*The contents of Expressions are evaluted by EM, so they can contain mathematical formulas, functions, and complex string and date processing.
#*The contents of Expressions are evaluted by EM, so they can contain mathematical formulas, functions, and complex string and date processing.
#'''Tailoring''': Sometimes called "piping", this is the process of conditionally modifying text
#'''Tailoring''': Sometimes called "piping", this is the process of conditionally modifying text
#*You have access to all 'replacement fields', TOKENs, and INSERTANS values
#*You have access to all 'replacement fields', participant data, and response data.
#*You also have easier access to questions, answers, and their properties.
#*You also have easier access to questions, answers, and their properties.
#'''Relevance''' Equation:  A new question attribute controlling question visiblity
#'''Relevance''' Equation:  A new question attribute controlling question visiblity
Line 125: Line 125:
#'''Equation''' Question Type:  A new question type that saves calculations or reports to the database
#'''Equation''' Question Type:  A new question type that saves calculations or reports to the database
#*It is like a Boilerplate question, but its contents are saved to the database even if you set "Always Hide this Question"
#*It is like a Boilerplate question, but its contents are saved to the database even if you set "Always Hide this Question"
#'''SGQA''':  This is how variables are named in LimeSurvey <= 1.91+
#*Stands for Survey-Group-Question-Answer
#*SGQA variable names look like 123X5X382X971, and may have subquestion suffixes.
#*These variable names are specific to the underlying S/Q/G/A database codes, so often need to be changed
#'''Question Code''':  This is the preferred variable name for EM
#'''Question Code''':  This is the preferred variable name for EM
#*This can be a descriptive name indicating the purpose of the question, making it easier to read complex logic
#*This can be a descriptive name indicating the purpose of the question, making it easier to read complex logic
#*Although not required to be unique in <= 1.91+, it must be unique if you want to use EM
#*Valid question codes should NOT start with a number, so when using the question code to number your questions, simply use "q1", or "q1a" or "g1q2".
#*Valid question codes should NOT start with a number, so when using the question code to number your questions, simply use "q1", or "q1a" or "g1q2".
#*This is what currently becomes the variable name if you export data to SPSS or R, so if you do statistical analysis, you probably already made this unique.
#*This is what currently becomes the variable name if you export data to SPSS or R, so if you do statistical analysis, you probably already made this unique.
Line 258: Line 253:
#**All of the question attributes are also syntax highlighted.  This lets you set and see expressions within advanced question options (like basing the max/min number/sum of values on an expression)
#**All of the question attributes are also syntax highlighted.  This lets you set and see expressions within advanced question options (like basing the max/min number/sum of values on an expression)
#*The EM author used similar view (a little cleaner) to let his collaborating Epidemiologists and Institutional Review Board validate and authorize surveys with thousands of questions in highly branched and tailored structured interviews
#*The EM author used similar view (a little cleaner) to let his collaborating Epidemiologists and Institutional Review Board validate and authorize surveys with thousands of questions in highly branched and tailored structured interviews
==Wie rückwärtskompatibel ist der AM mit 1.91+?==
LimeSurvey 1.92 is fully backwards-compatible with 1.91+ with one exception/caveat:  1.92 handles less-than / greater-than comparisons against empty values differently than 1.91+.
Der Ausdrucksmanager ist ein Kernmodul welches LimeSurvey ermöglicht, komplexere Verzweigungen, Beurteilungen, Validierungen und Zuschnitte zu unterstützen. Außerdem wird es nicht nur neue Funtionen unterstützen, sondern die Art und Weise, mit der LimeSurvey Ersetzungen, Bedingungen und Beurteilungen verwaltet, am Backend ersetzen. Außerdem werden die Bearbeitungen viel schneller ablaufen, da auf die meisten Datenbankzugriffe während der Laufzeit verzichtet werden kann. Der Ausdrucksmanager wurde von Dr. Tom White (TMSWhite) entwickelt.
Auf dieser Wiki-Seite befindet sich eine Anleitung für die Syntax und Funktionalität des ExpressionManagers.


=Erste Schritte=
=Erste Schritte=


The best way to get started with EM is to:
<div class="mw-translate-fuzzy">
*Install the latest stable version from http://www.limesurvey.org/en/download
Hier sind die ersten Schritte:
*Import and explore the [[Expression Manager Sample Surveys|sample surveys]].
*Installiere Limesurve_CI
*Explore the [[Expression Manager HowTos|use cases and HowTos]] and [[Expression Manager Examples|step-by-step examples]].
**[[Accessing the source code|Downloade und installiere die Quellcodes]] von [https://limesurvey.svn.sourceforge.net/svnroot/limesurvey/source/limesurvey_ci dieser Seite].
*Explore the EM documentation (this page)
**Starte das Installationsskript:  http://localhost/limesurvey_ci/index.php/installer
*Examine the built-in EM test suite
*Entdecke alle Testfälle
**From any survey, under tools, select the EM option
**http://localhost/limesurvey_ci/index.php/admin/expressions/test
**Available Functions lists the 70+ functions and syntax
**Hinweis: Du musst dich vorher anmelden
**Unit Tests of Isolated Expressions
*Lade und spiele mit den Ausdrucksmanager Demos
***shows examples of using all EM functions and operators, and the PHP and JavaScript results
**[http://www.limesurvey.org/en/additional-downloads/Surveys/ExpressionManager-Demo/ ExpressionManager-Demo Umfrage]
***note there are few functions that generate different results in the PHP and JavaScript versions, so this page lets you plan your EM logic accordingly.
*Lese die folgenden Dokumentationen
**Und die [[Expression Manager HowTos|Anwendungsfälle und Anleitungen]]
**Und die [[Expression Manager for developers|Entwickler-Dokumentierungen]], wenn du dazu tendierst.
*Bitte gib uns in unseren Foren eine Rückmeldung, falls sie zusätzliche Dokumentationen oder Beispiele benötigen um den AM klarer und einfacher bedienen zu können
</div>


=Welche Funktionalität erweitert/ersetzt der Ausdrucksmanager? (LimeSurvey <= 1.91+)=
=Welche Funktionalität erweitert/ersetzt der Ausdrucksmanager? (LimeSurvey <= 1.91+)=
Line 320: Line 311:
===Relevanz und Kaskadierende Relevanz===
===Relevanz und Kaskadierende Relevanz===


Every question type now has a Relevance option which controls whether the question is displayed.  EM processes each of the Relevance Equations in the order they should appear in the survey.  If the expression is true (or missing - to support legacy surveys), the question will be displayed. If it is not relevant, then the question will be hidden, and the value will be NULLed in the database.  If there are no relevant questions in a group, the entire group will be skipped.
<div class="mw-translate-fuzzy">
Jeder Fragetyp hat nun auch eine Relevanzoption, die kontrolliert, ob die Frage angezeigt wird.
 
Der Ausdrucksmanager führt jede der Relevanzgleichungen in Reihenfolge aus. Wenn der Ausdruck wahr ist (oder fehlend - um Legacy-Umfragen zu unterstützen), wird die Frage angezeigt. Wenn er irrelevant ist, wird die Fragen nicht angezeigt und der Wert wird ausgeblendet (um zu zeigen, dass es nicht zutreffend ist).
 
Weiterhin, wenn es irgendwelche Variablen mit einem irrelevanten Ausdruck gibt, dann wird der Ausdruck als Falsch gewertet. Dies erlaubt kaskadierende Relevanzen, so dass du nicht sehr lange Relevanzgleichungen für jede Frage schreiben müssen.
</div>


Moreover, if any of the variables within an expression is irrelevant, then the expression always evaluates to false.  This enables Cascading Relevance so that you do not have to write very long Relevance equations for each question.
Moreover, if any of the variables within an expression is irrelevant, then the expression always evaluates to false.  This enables Cascading Relevance so that you do not have to write very long Relevance equations for each question.
Line 372: Line 369:
Note, it is OK for expressions to span multiple lines, as long as there is no whitespace after the opening  curly brace or before the closing curly brace.  This is especially helpful for nested if() statements like this:
Note, it is OK for expressions to span multiple lines, as long as there is no whitespace after the opening  curly brace or before the closing curly brace.  This is especially helpful for nested if() statements like this:


<div class="mw-translate-fuzzy">
<syntaxhighlight lang="java" enclose="div">{if(is_empty(PFTotals),
<syntaxhighlight lang="java" enclose="div">{if(is_empty(PFTotals),
 '',
 '',
Line 398: Line 396:
)}
)}
</syntaxhighlight>
</syntaxhighlight>
</div>


Der Ausdrucksmanager unterstützt folgenden Syntax:
Der Ausdrucksmanager unterstützt folgenden Syntax:
Line 442: Line 441:
===Caution about using Assignment Operator (=)===
===Caution about using Assignment Operator (=)===


Note, you should avoid using the assignment operators unless absolutely necessary, since they may cause unexpected side-effects.  For example, if you change the value of a previous response, the cascading relevance and validation logic between that question and the current question is not re-computed, so you could end up with internally inconsistent data (e.g. questions that stay answered but should have been NULLed, or questions that are skipped but should have been answered).  In general, if you want to assign a value to a variable, you sould create an Equation question type, and use an expression to set its value.  However, there are some rare times that people really need this operator, so we made it available.
Note, you should avoid using the assignment operators unless absolutely necessary, since they may cause unexpected side-effects.  For example, if you change the value of a previous response, the cascading relevance and validation logic between that question and the current question is not re-computed, so you could end up with internally inconsistent data (e.g. questions that stay answered but should have been NULLed, or questions that are skipped but should have been answered).  In general, if you want to assign a value to a variable, you should create an Equation question type, and use an expression to set its value.  However, there are some rare times that people really need this operator, so we made it available.


To help caution you about this operator, it is shown in red font within the syntax equations (so that you don't confuse it with "==")
To help caution you about this operator, it is shown in red font within the syntax equations (so that you don't confuse it with "==")


====Using Assignment Operator====
===Using Assignment Operator===
The main reasons you may want to use assignment are:
The main reasons you may want to use assignment are:
*You need to set the default value for a question that does not accept defaults via equation (such as list radio, where the user interface lets you pick one of the answer options, but does not let you enter an equation).  However, be careful, as LimeSurvey will not be able to validate that your equation generates one of the allowable answers for that question.
* You need to set the default value for a question that does not accept defaults via equation (such as list radio, where the user interface lets you pick one of the answer options, but does not let you enter an equation).  However, be careful, as LimeSurvey will not be able to validate that your equation generates one of the allowable answers for that question.
*You need to forcibly change the response to a previous question based upon a later response
* You need to forcibly change the response to a previous question based upon a later response
* You need complex quota : using one hidden single choice for quota and set it using assignment
* etc...
* etc...


You can use all expression manager system for this purpose. It's better to use an Equation question type to this purpose.
You can use all expression manager system for this purpose.  
 
{{Alert|Assignment is done only in PHP. This doesn't update any values on the same page, but only when the user navigates with next, previous, save ….}}
 
{{Alert|If you don't use an [[Question_type_-_Equation|equation question]] type for this purpose: the assignment is done only after the logic of the current page is done. The recommended method is to always use an [[Question_type_-_Equation|equation question]].}}


Some example:
Some example:
* Set answer to a short text question in lowercase : <code>{QCODE=strtolower(QCODE.NAOK)}</code>
* Set answer to a short text question in lowercase : <code>{QCODE=strtolower(QCODE.NAOK)}</code>
* Set a default answer to an array question type at start of a survey : <code>{Q1_SQ1=(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}</code>
* Set a default answer to an array texts question type at start of a survey : <code>{Q1_SQY1_SQX1 = (is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}</code>
* Set an answer with condition : <code>{QCODE=if(YesNo="Y","A1","")}</code>
* Set an answer with condition : <code>{QCODE=if(YesNo="Y","A1","")}</code>


Line 470: Line 476:
==Zugang zu Variablen==
==Zugang zu Variablen==


Expression Manager provides read-only access to whichever variables we might need.  For backwards compatibility, it provides access to the following:
<div class="mw-translate-fuzzy">
*TOKEN:xxx - the value of a TOKEN (e.g. TOKEN:FIRSTNAME, TOKEN:ATTRIBUTE_5) (Only for NOT anonymous survey).
Der Ausdrucksmanager lässt read-only und read-write Zugang zu jeder Variable zu. Zur Abwärtskompabilität bietet er Zugriff auf die Folgenden:
*[[Adding a question#Information_from_previous_answers||INSERTANS:SGQA]] - the display value of an answer (e.g. "Yes"). For Expression Manager it's the same that using {QCODE.shown}.
*TOKEN:xxx - der Wert eines TOKENs (e.g. TOKEN:VORNAME, TOKEN:ATTRIBUTE_5)
*All {XXX} values used by templates
*INSERTANS:SGQA - Der angezeigte Wert einer Antwort (e.g. "Ja")
*In question text, you can use {QID} replaced by the question id and {SGQ} replaced by the SGQA of the question
*All {XXX} Von Templates benutzte Werte
</div>


Zusätzlich erlaubt dir der Ausdrucksmanager dich auf Variablen über die Frage-Nummer zu beziehen (auch als Titel in der Datenbank bezeichnet). Dies ist auch das Label der Variable, welches genutzt wird, wenn Sie Ihre Daten zu SPSS, R oder SAS exportieren. Zum Beispiel, wenn Sie Fragen zu dem Namen, Alter und Geschlecht haben, könnten sie ihre Variablen "name", "alter" und "geschlecht" nennen. Dies macht die Gleichungen jedem leichter Verständlich und macht es möglich die Fragen durch zu mischen ohne ein Auge auf die Gruppen und Fragennummern haben zu müssen.
Zusätzlich erlaubt dir der Ausdrucksmanager dich auf Variablen über die Frage-Nummer zu beziehen (auch als Titel in der Datenbank bezeichnet). Dies ist auch das Label der Variable, welches genutzt wird, wenn Sie Ihre Daten zu SPSS, R oder SAS exportieren. Zum Beispiel, wenn Sie Fragen zu dem Namen, Alter und Geschlecht haben, könnten sie ihre Variablen "name", "alter" und "geschlecht" nennen. Dies macht die Gleichungen jedem leichter Verständlich und macht es möglich die Fragen durch zu mischen ohne ein Auge auf die Gruppen und Fragennummern haben zu müssen.
Line 485: Line 492:




{| class="wikitable"
<div class="mw-translate-fuzzy">
!Syntax!!Meaning!!Example!!Example Result
{|
|Syntax||Bedeutung||Beispiel||Beispiel Ergebnis
|-
|-
|Qcode||an alias for Qcode.code||{implode(',',name,gender)}||'Tom','M'
|Qcode||Der Code-Wert der Frage, wenn relevant (sonst leer)||{gender}||'M'
|-
|-
|Qcode.code||the selected response code for the question if it is relevant (otherwise blank), or the text value if it is not a coded question||{implode(',',name.code,gender.code)}||'Tom','M'
|Qcode.NAOK||das gleiche wie Qcode - siehe die Diskussion über NAOK||{gender.NAOK}||'M'
|-
|-
|Qcode.NAOK||same as Qcode - see discussion of NAOK||{gender.NAOK}||'M'
|Qcode.shown||der Anzeigewert der Frage||{gender.shown}||'Male'
|-
|-
|Qcode.value||the assessment value for the question if it is relevant (otherwise blank), or the text value if it is not a coded question||{gender.value}||'1'
|Qcode.question||der Fragetext||{gender.question}||'What is your gender?'
|-
|-
|Qcode.valueNAOK||same as Qcode.value - see discussion about NAOK||{gender.valueNAOK}||'1'
|Qcode.mandatory||ob die Frage verpflichtend ist (J/N)||{gender.mandatory}||'N'
|-
|-
|Qcode.shown||the dispay value for the question||{implode(',',name.shown,gender.shown)}||'Tom','Male'
|Qcode.qid||die interne Nummer der Frage (nicht die fortlaufende Nummer)||{gender.qid}||337
|-
|-
|Qcode.question||the text of the question||{gender.question}||'What is your gender?'
|Qcode.type||der Fragetyp||{gender.type}||'G'
|-
|-
|Qcode.mandatory||whether the question is mandatory (Y/N)||{gender.mandatory}||'N'
|Qcode.jsName||der Javascriptname der Frage||{gender.jsName}||'java1827X3X337'
|-
|-
|Qcode.qid||the internal question number (not the sequential number)||{gender.qid}||337
|
|-
|Qcode.type||the question type||{gender.type}||'G'
|-
|Qcode.jsName||the correct javascript name for the question, regardless whether declared on or off this page||{gender.jsName}||'java1827X3X337'
|-
|Qcode.gid||the internal group number (not the sequential number)||{gender.gid}||3
|-
|Qcode.qseq||the sequential number of the question, starting from 0||{gender.qseq}||5
|-
|Qcode.gseq||the sequential number of the group, starting from 0||{gender.gseq}||1
|-
|Qcode.relevanceStatus||whether the question is currently relevant (0 or 1)||{gender.relevanceStatus}||1
|-
|Qcode.relevance||the question-level relevance equation||{gender.relevance}||'!is_empty(name)'
|-
|Qcode.grelevance||the  group-level relevance equation||{gender.grelevance}||'num_children >= 5'
|-
|Qcode.sgqa||the SGQA value for this question||{gender.sgqa}||'1827X3X337'
|}
|}
</div>


=== HTML editor issue===
=== HTML editor issue===


{{Alert|This issue is fixed after 2.06 build 140803}}  
{{Alert|This issue is fixed after 2.05 build 140803}}  


If you use HTML editor, some characters are replaced by HTML entities.
If you use HTML editor, some characters are replaced by HTML entities.
Line 547: Line 538:
   QuestionCode . '_' . SubQuestionID . '_' . ScaleId
   QuestionCode . '_' . SubQuestionID . '_' . ScaleId


For comment and other, question code are QuestionCode_comment and QuestionCode_other
For '''comment''' and '''other''', question code are QuestionCode_comment and QuestionCode_other


{| class="wikitable"
<div class="mw-translate-fuzzy">
!Type!!Description!!Code!!SubQs!!Answer Options!!Scales!!Answer Code!!Answer Shown!!Relevance
{|
|Typ||Beschreibung||Code||SubQs||Antwortoptionen||Skala||Antwortcodes||Angezeigte Antwort||Relevanz
|-
|-
|5||5 Point Choice Radio-Buttons||Q1|| ||1-5|| ||{Q1}||{Q1.shown}||{Q1==3}
|5||5 Punkte Auswahl Radio-Buttons||Q1|| ||1-5|| ||{Q1}||{Q1.shown}||{Q1==3}
|-
|-
|B||Array (10 Point Choice) Radio-Buttons||Q2||L1-L6||1-10|| ||{Q2_L2}||{Q2_L2.shown}||{Q2_L2==7}
|B||Array (10-Punkte-Wahl) Radio-Buttons||Q2||L1-L6||1-10|| ||{Q2_L2}||{Q2_L2.shown}||{Q2_L2==7}
|-
|-
|A||Array (5 Point Choice) Radio-Buttons||Q3||1-5||1-5|| ||{Q3_1}||{Q3_1.shown}||{Q3_1>=3}
|A||Array (5-Punkte-Wahl) Radio-Buttons||Q3||1-5||1-5|| ||{Q3_1}||{Q3_1.shown}||{Q3_1>=3}
|-
|-
|1||Array (Flexible Labels) Dual Scale||Q4||sq1-sq5||0:a1-a3||1:b1-b3||{Q4_sq1_0}||{Q4_sq1_1.shown}||{Q4_sq1_1=='b2'}
|1||Array (Flexible Labels) Duale Anzeige||Q4||sq1-sq5||0:a1-a3||1:b1-b3||{Q4_sq1_0}||{Q4_sq1_1.shown}||{Q4_sq1_1=='b2'}
|-
|-
|H||Array (Flexible) - Column Format||Q5||1-5||s,m,t|| ||{Q5_1}||{Q5_1.shown}||{Q5_1=='s'}
|H||Array (Flexible) - Spalten-Format||Q5||1-5||s,m,t|| ||{Q5_1}||{Q5_1.shown}||{Q5_1=='s'}
|-
|-
|F||Array (Flexible) - Row Format||Q6||F1-F5||1-5|| ||{Q6_F3}||{Q6_F3.shown}||{Q6_F3==4}
|F||Array (Flexible) - Reihen-Format||Q6||F1-F5||1-5|| ||{Q6_F3}||{Q6_F3.shown}||{Q6_F3==4}
|-
|-
|E||Array (Increase/Same/Decrease) Radio-Buttons||Q7||1-7||I,S,D|| ||{Q7_4}||{Q7_4.shown}||{Q7_4=='D'}
|E||Array (Vergrößern/Gleich/Verringern) Radio-Buttons||Q7||1-7||I,S,D|| ||{Q7_4}||{Q7_4.shown}||{Q7_4=='D'}
|-
|-
|:||Array (Multi Flexi) 1 To 10||Q8||ls1,todo,ls2||min,max,avg|| ||{Q8_ls1_max}||{Q8_ls2_avg.shown}||{Q8_ls2_min==7}
|:||Array (Multi Flexi) 1 To 10||Q8||ls1,todo,ls2||min,max,avg|| ||{Q8_ls1_max}||{Q8_ls2_avg.shown}||{Q8_ls2_min==7}
Line 570: Line 562:
|;||Array (Multi Flexi) Text||Q9||hp,st,sw||1st,2nd,3rd|| ||{Q9_hp_3rd}||{Q9_hp_3rd.shown}||{Q9_hp_3rd=='Peter'}
|;||Array (Multi Flexi) Text||Q9||hp,st,sw||1st,2nd,3rd|| ||{Q9_hp_3rd}||{Q9_hp_3rd.shown}||{Q9_hp_3rd=='Peter'}
|-
|-
|C||Array (Yes/Uncertain/No) Radio-Buttons||Q10||1-5||Y,N,U|| ||{Q10_1}||{Q10_1.shown}||{Q10_3=='Y'}
|C||Array (Ja/Unsicher/Nein) Radio-Buttons||Q10||1-5||Y,N,U|| ||{Q10_1}||{Q10_1.shown}||{Q10_3=='Y'}
|-
|-
|X||Boilerplate Question||Q11|| || || || ||{Q11.shown}||
|X||Boilerplate Frage||Q11|| || || || ||{Q11.shown}||
|-
|-
|D||Date||Q12|| || || ||{Q12}||{Q12.shown}||
|D||Datum||Q12|| || || ||{Q12}||{Q12.shown}||
|-
|-
|*||Equation||Q13|| || || ||{Q13}||{Q13.shown}||{Q13>5}
|*||Gleichung||Q13|| || || ||{Q13}||{Q13.shown}||{Q13>5}
|-
|-
|~124~||File Upload (records number of files uploaded)||Q14|| || || ||{Q14}|| ||{Q14>0}
|~124~||Dateiupload (zeichnet Anzahl der hochgelandenen Dateien auf)||Q14|| || || ||{Q14}|| ||{Q14>0}
|-
|-
|G||Gender Drop-Down List||Q15|| ||M,F|| ||{Q15}||{Q15.shown}||{Q15=='M'}
|G||Geschlechter Drop-Down Liste||Q15|| ||M,F|| ||{Q15}||{Q15.shown}||{Q15=='M'}
|-
|-
|U||Huge Free Text||Q16|| || || ||{Q16}||{Q16.shown}||{strlen(Q16)>100}
|U||Rießiger Freier Text||Q16|| || || ||{Q16}||{Q16.shown}||{strlen(Q16)>100}
|-
|-
|I||Language Question||Q17|| || || ||{Q17}||{Q17.shown}||{Q17=='en'}
|I||Sprach-Frage||Q17|| || || ||{Q17}||{Q17.shown}||{Q17=='en'}
|-
|-
|!||List - Dropdown||Q18|| ||1-5|| ||{Q18}||{Q18.shown}||{Q18==3}
|!||Liste - Dropdown||Q18|| ||1-5|| ||{Q18}||{Q18.shown}||{Q18==3}
|-
|-
|L||List Drop-Down/Radio-Button List||Q19|| ||A-Z|| ||{Q19}||{Q19.shown}||{Q19=='X'}
|L||Drop-Down/Radio-Button Liste||Q19|| ||A-Z|| ||{Q19}||{Q19.shown}||{Q19=='X'}
|-
|-
|O||List With Comment Drop-Down/Radio-Button List + Textarea||Q20|| ||A-F|| ||{Q20},{Q20comment}||{Q20.shown}||{Q20=='B'}
|O||Drop-Down Liste mit Kommentar/Radio-Button List + Texfeld||Q20|| ||A-F|| ||{Q20},{Q20_comment}||{Q20.shown}||{Q20=='B'}
|-
|-
|T||Long Free Text||Q21|| || || ||{Q21}||{Q21.shown}||{strstr(Q21,'hello')>0}
|T||Langer Freier Text||Q21|| || || ||{Q21}||{Q21.shown}||{strstr(Q21,'hello')>0}
|-
|-
|M||Multiple Choice Checkbox||Q22||A-F|| || ||{Q22_E}||{Q22_E.shown}||{Q22_E=='Y'}
|M||Mehrere Choice Checkbox||Q22||A-F|| || ||{Q22_E}||{Q22_E.shown}||{Q22_E=='Y'}
|-
|-
|P||Multiple Choice With Comments Checkbox + Text||Q23||A-F|| || ||{Q23_D}, {Q23_Dcomment}||{Q23_D.shown}||{!is_empty(Q23)}
|P||Mehrere Choice Checkbox mit Kommentar + Text||Q23||A-F|| || ||{Q23_D}, {Q23_D_comment}||{Q23_D.shown}||{!is_empty(Q23)}
|-
|-
|K||Multiple Numerical Question||Q24||self,mom,dad|| || ||{Q24_self}||{Q24_self.shown}||{Q24_self>30}
|K||Mehrere Zahlenmäßige Frage||Q24||self,mom,dad|| || ||{Q24_self}||{Q24_self.shown}||{Q24_self>30}
|-
|-
|Q||Multiple Short Text||Q25||A-F|| || ||{Q25_B}||{Q25_B.shown}||{substr(Q25_B,1,1)=='Q'}
|Q||Mehrere Kurztexte||Q25||A-F|| || ||{Q25_B}||{Q25_B.shown}||{substr(Q25_B,1,1)=='Q')}
|-
|-
|N||Numerical Question Type||Q26|| || || ||{Q26}||{Q26.shown}||{Q26 > 30}
|N||Zahlenmäßiger-Fragen-Typ||Q26|| || || ||{Q26}||{Q26.shown}||{Q26 > 30}
|-
|-
|R||Ranking Style||Q27||1-4|| || ||{Q27_1}||{Q27_1.shown}||{Q27_1==3}
|R||Ranking-Stil||Q27||1-4|| || ||{Q27_1}||{Q27_1.shown}||{Q27_1==3}
|-
|-
|S||Short Free Text||Q28|| || || ||{Q28}||{Q28.shown}||{Q28=='mine'}
|S||Kurzer freier Text||Q28|| || || ||{Q28}||{Q28.shown}||{Q28=='mine'}
|-
|-
|Y||Yes/No Radio-Buttons||Q29|| || || ||{Q29}||{Q29.shown}||{Q29=='Y'}
|Y||Ja/Nein Radio-Buttons||Q29|| || || ||{Q29}||{Q29.shown}||{Q29=='Y'}
|-
|
|}
|}
</div>


==The reserved 'this', 'self', and 'that' variables==
==The reserved 'this', 'self', and 'that' variables==
Line 626: Line 621:


''sub-selector'' is one of:
''sub-selector'' is one of:
*comments - only subquestions that are comments (e.g. from multiple choice with comment and list with comment)
*comments - only subquestions that are comments (e.g., from multiple choice with comment and list with comment)
*nocomments - only subquestions that are not comments
*nocomments - only subquestions that are not comments
*sq_X - where X is a row or column identifier.  Only subquestions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....
*sq_X - where X is a row or column identifier. Only subquestions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....
*nosq_X - where X is a row or column identifier. Only subquestions not matching pattern X are selected. Note that search is done on complete code identifier, then nosq_X match and does not include subquestions nX, X, Xn


Examples:
Examples:
Line 659: Line 655:


Also note that you should not use these variables if (a) you want to explicitly name each variable used in an equation, or (b) use variables that do not have subquestions (e.g. single response questions).  In those cases, prefixing a variable with 'that' is overkill, and you run the risk of getting unexpected results.
Also note that you should not use these variables if (a) you want to explicitly name each variable used in an equation, or (b) use variables that do not have subquestions (e.g. single response questions).  In those cases, prefixing a variable with 'that' is overkill, and you run the risk of getting unexpected results.
==Usage of NAOK==
NAOK --> "Not Applicable" (NA) is alright (OK)
Using NAOK, means that all or some of the variables are irrelevant (e.g. "Not Applicable" (NA) is alright (OK)).
When you put some variable from question in any equation : if this question (or subquestion) is hidden by condition : this disable all equation.
For example : count(Q1_SQ1,Q1_SQ2,Q1_SQ3,Q1_SQ4) give always an empty string if one subquestion of Q1 is filtered.
To count the number of checked subquestion in such question can be count(Q1_SQ1.NAOK,Q1_SQ2.NAOK,Q1_SQ3.NAOK,Q1_SQ4.NAOK). If the sub question is hidden :Expression manager return an empty string.
Without NAOK : if one question or one subquestion is hidden : Expression Manager return always an empty string, same to return false.
The .shown always use the NAOK system (empty string if hidden) but if you need the code of the answer : it's always a good idea to add .NAOK after the question code. Except if you need it and know what you do.
Another example and information is provided at [[#Overriding_Cascading_Conditions|Overriding Cascading Conditions]]


==Zugriff auf Funktionen==
==Zugriff auf Funktionen==
Line 668: Line 681:
Die folgenden Funktionen sind momentan verfügbar:
Die folgenden Funktionen sind momentan verfügbar:


{| class="wikitable"
<div class="mw-translate-fuzzy">
!Function!!Meaning!!Syntax
{|
|Funktion||Bedeutung||Syntax
|-
|-
|[http://www.php.net/manual/en/function.abs.php abs]||Absolute value||number abs(number)
|[http://www.php.net/manual/en/function.checkdate.php abs]||Absoluter Wert||number abs(number)
|-
|-
|[http://www.php.net/manual/en/function.acos.php acos]||Arc cosine||number acos(number)
|[http://www.php.net/manual/en/function.acos.php acos]||Arkuskosinus||number acos(number)
|-
|-
|[http://www.php.net/manual/en/function.addslashes.php addslashes]||Quote string with slashes||string addslashes(string)
|[http://www.php.net/manual/en/function.addslashes.php die Funktion addslashes]||Quote string with slashes||string addslashes(string)
|-
|-
|[http://www.php.net/manual/en/function.asin.php asin]||Arc sine||number asin(number)
|[http://www.php.net/manual/en/function.asin.php asin]||Arkussinus||number asin(number)
|-
|-
|[http://www.php.net/manual/en/function.atan.php atan]||Arc tangent||number atan(number)
|[http://www.php.net/manual/en/function.atan.php atan]||Arkustangens||number atan(number)
|-
|-
|[http://www.php.net/manual/en/function.atan2.php atan2]||Arc tangent of two variables||number atan2(number, number)
|[http://www.php.net/manual/en/function.atan2.php atan2]||Arkustangens zweier Variablen||number atan2(number, number)
|-
|-
|[http://www.php.net/manual/en/function.ceil.php ceil]||Round fractions up||number ceil(number)
|[http://www.php.net/manual/en/function.ceil.php ceil]||Aufrunden||number ceil(number)
|-
|-
|[http://www.php.net/manual/en/function.checkdate.php checkdate]||Returns true(1) if it is a valid date in gregorian calendar||bool checkdate(month,day,year)
|[http://www.php.net/manual/en/function.checkdate.php checkdate]||Gibt true(1) zurück, wenn es ein nach dem Gregorianischen Kalender gültiges Datum ist||bool checkdate(month,day,year)
|-
|-
|convert_value||Convert a numerical value using a inputTable and outputTable of numerical values||number convert_value(fValue, iStrict, sTranslateFromList, sTranslateToList)
|[http://www.php.net/manual/en/function.cos.php cos]||Kosinus||number cos(number)
|-
|-
|[http://www.php.net/manual/en/function.cos.php cos]||Cosine||number cos(number)
|[http://www.php.net/manual/en/function.date.php date]||Formatiere eine lokales Datum/Zeit||string date(format <nowiki>[</nowiki>, timestamp=time()])
|-
|-
|count||count the number of answered (non-blank)questions in the list||number count(arg1, arg12, ..., argN)
|[http://www.php.net/manual/en/function.exp.php exp]||Berechnet den Exponenten von e||number exp(number)
|-
|-
|countif||Count the number of answered questions in the list equal the first argument||number countif(matches, arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.floor.php floor]||Abrunden||number floor(number)
|-
|-
|countifop||Count the number of answered questions in the list which pass the criteria (arg op value)||number countifop(op, value, arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.gmdate.php gmdate]||Ein GMT Datum/Zeit formatieren||string gmdate(format <nowiki>[</nowiki>, timestamp=time()])
|-
|-
|[http://www.php.net/manual/en/function.date.php date]||Format a local date/time||string date(format <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.html-entity-decode.php html_entity_decode]||Konvertiert alle HTML Zeichen in geeignete Zeichen (immer mit ENT_QUOTES und UTF-8)||string html_entity_decode(string)
|-
|-
|[http://www.php.net/manual/en/function.exp.php exp]||Calculates the exponent of e||number exp(number)
|[http://www.php.net/manual/en/function.htmlentities.php htmlentities]||Wandelt alle geeigneten Zeichen in entsprechende HTML-Zeichen (immer mit ENT_QUOTES und UTF-8)||string htmlentities(string)
|-
|-
|fixnum||Display numbers with comma as radix separator, if needed||string fixnum(number)
|[http://www.php.net/manual/en/function.htmlspecialchars.php expr_mgr_htmlspecialchars]||Konvertiere Sonderzeichen in HTML-Zeichen (immer mit ENT_QUOTES und UTF-8)||string htmlspecialchars(string)
|-
|-
|[http://www.php.net/manual/en/function.floor.php floor]||Round fractions down||number floor(number)
|[http://www.php.net/manual/en/function.htmlspecialchars-decode.php expr_mgr_htmlspecialchars_decode]||Konvertiere HTML-Sonderzeichen zurück in Zeichen (immer mit ENT_QUOTES und UTF-8)||string htmlspecialchars_decode(string)
|-
|-
|[http://www.php.net/manual/en/function.gmdate.php gmdate]||Format a GMT date/time||string gmdate(format <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.idate.php idate]||Formatiere Zeit / Datum als ganze Zahl||string idate(string <nowiki>[</nowiki>, timestamp=time()])
|-
|-
|[http://www.php.net/manual/en/function.html-entity-decode.php html_entity_decode]||Convert all HTML entities to their applicable characters (always uses ENT_QUOTES and UTF-8)||string html_entity_decode(string)
|if||Excel-Style if(test,result_if_true,result_if_false)||if(test,result_if_true,result_if_false)
|-
|-
|[http://www.php.net/manual/en/function.htmlentities.php htmlentities]||Convert all applicable characters to HTML entities (always uses ENT_QUOTES and UTF-8)||string htmlentities(string)
|[http://www.php.net/manual/en/function.implode.php implode]||Verbindet Array-Elemente mit einem String||string implode(glue,arg1,arg2,...,argN)
|-
|-
|[http://www.php.net/manual/en/function.htmlspecialchars.php expr_mgr_htmlspecialchars]||Convert special characters to HTML entities (always uses ENT_QUOTES and UTF-8)||string htmlspecialchars(string)
|[http://www.php.net/manual/en/function.intval.php intval]||Bekomm den ganzzahligen Wert einer Variablen||int intval(number <nowiki>[</nowiki>, base=10])
|-
|-
|[http://www.php.net/manual/en/function.htmlspecialchars-decode.php expr_mgr_htmlspecialchars_decode]||Convert special HTML entities back to characters (always uses ENT_QUOTES and UTF-8)||string htmlspecialchars_decode(string)
|[http://www.php.net/manual/en/function.is-bool.php is_bool]||Prüft ob eine Variable ein Boolean ist||bool is_bool(var)
|-
|-
|[http://www.php.net/manual/en/function.idate.php idate]||Format a local time/date as integer||string idate(string <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.empty.php is_empty]||Bestimmen Sie, ob eine Variable als leer betrachtet wird||bool is_empty(var)
|-
|-
|if||Excel-style if(test,result_if_true,result_if_false)||if(test,result_if_true,result_if_false)
|[http://www.php.net/manual/en/function.is-float.php is_float]||Prüft ob die Variable ein Float ist||bool is_float(var)
|-
|-
|[http://www.php.net/manual/en/function.implode.php implode]||Join array elements with a string||string implode(glue,arg1,arg2,...,argN)
|[http://www.php.net/manual/en/function.is-int.php is_int]||Prüft ob die Variable ein Integer ist||bool is_int(var)
|-
|-
|[http://www.php.net/manual/en/function.intval.php intval]||Get the integer value of a variable||int intval(number <nowiki>[</nowiki>, base=10])
|[http://www.php.net/manual/en/function.is-nan.php is_nan]||Prüft ob die Variable eine Nummer ist||bool is_nan(var)
|-
|-
|[http://www.php.net/manual/en/function.empty.php is_empty]||Determine whether a variable is considered to be empty||bool is_empty(var)
|[http://www.php.net/manual/en/function.is-null.php is_null]||Prüft ob eine Variable NULL ist||bool is_null(var)
|-
|-
|[http://www.php.net/manual/en/function.is-float.php is_float]||Finds whether the type of a variable is float||bool is_float(var)
|[http://www.php.net/manual/en/function.is-numeric.php is_numeric]||Prüft ob eine Variable eine Zahl oder ein numerischer String ist||bool is_numeric(var)
|-
|-
|[http://www.php.net/manual/en/function.is-int.php is_int]||Find whether the type of a variable is integer||bool is_int(var)
|[http://www.php.net/manual/en/function.is-string.php is_string]||Prüft ob die Variable ein String ist||bool is_string(var)
|-
|-
|[http://www.php.net/manual/en/function.is-nan.php is_nan]||Finds whether a value is not a number||bool is_nan(var)
|list||Gibt eine komma-seperierte List der Werte zurück||string list(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.is-null.php is_null]||Finds whether a variable is NULL||bool is_null(var)
|[http://www.php.net/manual/en/function.log.php log]||Natürlicher Logarithmus||number log(number)
|-
|-
|[http://www.php.net/manual/en/function.is-numeric.php is_numeric]||Finds whether a variable is a number or a numeric string||bool is_numeric(var)
|[http://www.php.net/manual/en/function.ltrim.php ltrim]||Entfernt Leerzeichen (oder andere Zeichen) vom Anfang eines Strings||string ltrim(string <nowiki>[</nowiki>, charlist])
|-
|-
|[http://www.php.net/manual/en/function.is-string.php is_string]||Find whether the type of a variable is string||bool is_string(var)
|[http://www.php.net/manual/en/function.max.php max]||Findet den höchsten Wert||number max(arg1, arg2, ... argN)
|-
|-
|join{{NewIn|2.0|b=130129}}||Join elements as a new string||join(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.min.php min]||Findet den niedrigsten Wert||number min(arg1, arg2, ... argN)
|-
|-
|list||Return comma-separated list of non-blank values||string list(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.mktime.php mktime]||UNIX-Timestamp/Zeitstempel für ein Datum (jedes der 6 Argumente ist optional)||number mktime([hour [, minute [, second [, month [, day [, year ]]]]]])
|-
|-
|[http://www.php.net/manual/en/function.log.php log]|| The logarithm of number to base, if given, or the natural logarithm. ||number log(number,base=e)
|[http://www.php.net/manual/en/function.nl2br.php nl2br]||Fügt HTML-Zeilenumbrüche vor allen Zeilenumbrüchen eines Strings||string nl2br(string)
|-
|-
|[http://www.php.net/manual/en/function.ltrim.php ltrim]||Strip whitespace (or other characters) from the beginning of a string||string ltrim(string <nowiki>[</nowiki>, charlist])
|[http://www.php.net/manual/en/function.number-format.php number_format]||Formatiert eine Zahl mit Tausender-Gruppierung||string number_format(number)
|-
|-
|[http://www.php.net/manual/en/function.max.php max]||Find highest value||number max(arg1, arg2, ... argN)
|pi||Wert von pi||number pi()
|-
|-
|[http://www.php.net/manual/en/function.min.php min]||Find lowest value||number min(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.pow.php pow]||Exponentialausdruck||number pow(base, exp)
|-
|-
|[http://www.php.net/manual/en/function.mktime.php mktime]||Get UNIX timestamp for a date (each of the 6 arguments are optional)||number mktime([hour [, minute [, second [, month [, day [, year ]]]]]])
|[http://www.php.net/manual/en/function.quoted-printable-decode.php quoted_printable_decode]||Konvertiert einen quoted-printable String in einen 8-Bit-String||string quoted_printable_decode(string)
|-
|-
|modulo-function||The modulo function is '''not supported''' yet. You can use the floor() function instead||floor(x/y)==(x/y)
|[http://www.php.net/manual/en/function.quoted-printable-encode.php quoted_printable_encode]||Konvertiert einem 8-Bit-String in einen quoted-printable String||string quoted_printable_encode(string)
|-
|-
|[http://www.php.net/manual/en/function.nl2br.php nl2br]||Inserts HTML line breaks before all newlines in a string||string nl2br(string)
|[http://www.php.net/manual/en/function.quotemeta.php quotemeta]||Zitat Metazeichen||string quotemeta(string)
|-
|-
|[http://www.php.net/manual/en/function.number-format.php number_format]||Format a number with grouped thousands||string number_format(number)
|[http://www.php.net/manual/en/function.rand.php rand]||Generiere eine Zufallszahl||int rand() OR int rand(min, max)
|-
|-
|pi||Get value of pi||number pi()
|[http://www.php.net/manual/en/function.round.php round]||Rundet eine Zahl auf einer optionalen Genauigkeit||number round(val <nowiki>[</nowiki>, precision])
|-
|-
|[http://www.php.net/manual/en/function.pow.php pow]||Exponential expression||number pow(base, exp)
|[http://www.php.net/manual/en/function.rtrim.php rtrim]||Entfernt Leerzeichen (oder andere Zeichen) vom Ende eines Strings||string rtrim(string <nowiki>[</nowiki>, charlist])
|-
|-
|[http://www.php.net/manual/en/function.quoted-printable-decode.php quoted_printable_decode]||Convert a quoted-printable string to an 8 bit string||string quoted_printable_decode(string)
|[http://www.php.net/manual/en/function.sin.php sin]||Sinus||number sin(arg)
|-
|-
|[http://www.php.net/manual/en/function.quoted-printable-encode.php quoted_printable_encode]||Convert a 8 bit string to a quoted-printable string||string quoted_printable_encode(string)
|[http://www.php.net/manual/en/function.sprintf.php sprintf]||Gibt einen formatierten String zurück||string sprintf(format, arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.quotemeta.php quotemeta]||Quote meta characters||string quotemeta(string)
|[http://www.php.net/manual/en/function.sqrt.php sqrt]||Quadratwurzel||number sqrt(arg)
|-
|-
|[http://www.php.net/manual/en/function.rand.php rand]||Generate a random integer, see [[Expression Manager Sample Surveys#Randomly Ask One Question Per Group|this example]]||int rand() OR int rand(min, max)
|stddev||Berechne die Sample-Standardabweichung für die Liste der Nummern||number stddev(arg1, arg2, ... argN)
|-
|-
|regexMatch||compare a string to a [[Using regular expressions|regular expression]]||bool regexMatch(pattern,input)
|[http://www.php.net/manual/en/function.str-pad.php str_pad]||Fülle einen String auf eine bestimmte Länge mit einem anderen String||string str_pad(input, pad_length <nowiki>[</nowiki>, pad_string])
|-
|-
|[http://www.php.net/manual/en/function.round.php round]||Rounds a number to an optional precision||number round(val <nowiki>[</nowiki>, precision])
|[http://www.php.net/manual/en/function.str-repeat.php str_repeat]||Wiederhole einen String||string str_repeat(input, multiplier)
|-
|-
|[http://www.php.net/manual/en/function.rtrim.php rtrim]||Strip whitespace (or other characters) from the end of a string||string rtrim(string <nowiki>[</nowiki>, charlist])
|[http://www.php.net/manual/en/function.str-replace.php str_replace]||Ersetzen Sie alle Vorkommen des Suchstrings mit dem Ersatz-String||string str_replace(search, replace, subject)
|-
|-
|[http://www.php.net/manual/en/function.sin.php sin]||Sine||number sin(arg)
|[http://www.php.net/manual/en/function.strcasecmp.php strcasecmp]||Binärsichere Groß-und Kleinschreibungs String-Vergleich||int strcasecmp(str1, str2)
|-
|-
|[http://www.php.net/manual/en/function.sprintf.php sprintf]||Return a formatted string||string sprintf(format, arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.strcmp.php strcmp]||Binärsicherer String-Vergleich||int strcmp(str1, str2)
|-
|-
|[http://www.php.net/manual/en/function.sqrt.php sqrt]||Square root||number sqrt(arg)
|[http://www.php.net/manual/en/function.strip-tags.php strip_tags]||Entfernt HTML-und PHP-Tags aus einem String||string strip_tags(str, allowable_tags)
|-
|-
|stddev||Calculate the Sample Standard Deviation for the list of numbers||number stddev(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.stripos.php stripos]||Findet das erste Vorkommen eines  Case-Insensitiven Strings||int stripos(haystack, needle <nowiki>[</nowiki>, offset=0])
|-
|-
|[http://www.php.net/manual/en/function.str-pad.php str_pad]||Pad a string to a certain length with another string||string str_pad(input, pad_length <nowiki>[</nowiki>, pad_string])
|[http://www.php.net/manual/en/function.stripslashes.php stripslashes]||Entfernt die Anführungszeichen einer Zeichenfolge in Anführungszeichen||string stripslashes(string)
|-
|-
|[http://www.php.net/manual/en/function.str-repeat.php str_repeat]||Repeat a string||string str_repeat(input, multiplier)
|[http://www.php.net/manual/en/function.stristr.php stristr]||Case-Insensitiven strstr||string stristr(haystack, needle <nowiki>[</nowiki>, before_needle=false])
|-
|-
|[http://www.php.net/manual/en/function.str-replace.php str_replace]||Replace all occurrences of the search string with the replacement string||string str_replace(search, replace, subject)
|[http://www.php.net/manual/en/function.strlen.php strlen]||String-Länge||int strlen(string)
|-
|-
|[http://www.php.net/manual/en/function.strcasecmp.php strcasecmp]||Binary safe case-insensitive string comparison||int strcasecmp(str1, str2)
|[http://www.php.net/manual/en/function.strpos.php strpos]||Findet das erste Vorkommen eines Strings||int strpos(haystack, needle <nowiki>[</nowiki> offset=0])
|-
|-
|[http://www.php.net/manual/en/function.strcmp.php strcmp]||Binary safe string comparison||int strcmp(str1, str2)
|[http://www.php.net/manual/en/function.strrev.php strrev]||Umkehren einer Zeichenfolge||string strrev(string)
|-
|-
|[http://www.php.net/manual/en/function.strip-tags.php strip_tags]||Strip HTML and PHP tags from a string||string strip_tags(str, allowable_tags)
|[http://www.php.net/manual/en/function.strstr.php strstr]||Findet das erste Vorkommen eines Strings||string strstr(haystack, needle)
|-
|-
|[http://www.php.net/manual/en/function.stripos.php stripos]||Find position of first occurrence of a case-insensitive string||int stripos(haystack, needle <nowiki>[</nowiki>, offset=0])
|[http://www.php.net/manual/en/function.strtolower.php strtolower]||Setzt einen String in Kleinbuchstaben||string strtolower(string)
|-
|-
|[http://www.php.net/manual/en/function.stripslashes.php stripslashes]||Un-quotes a quoted string||string stripslashes(string)
|[http://www.php.net/manual/en/function.strtoupper.php strtoupper]||Setzt einen String in Großbuchstaben||string strtoupper(string)
|-
|-
|[http://www.php.net/manual/en/function.stristr.php stristr]||Case-insensitive strstr||string stristr(haystack, needle <nowiki>[</nowiki>, before_needle=false])
|[http://www.php.net/manual/en/function.substr.php substr]||Gibt einen Teil eines Strings zurück||string substr(string, start <nowiki>[</nowiki>, length])
|-
|-
|[http://www.php.net/manual/en/function.strlen.php strlen]||Get string length||int strlen(string)
|sum||Berechne die Summe der Werte in einem Array||number sum(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.strpos.php strpos]||Find position of first occurrence of a string||int strpos(haystack, needle <nowiki>[</nowiki> offset=0])
|[http://www.php.net/manual/en/function.tan.php tan]||Tangens||number tan(arg)
|-
|-
|[http://www.php.net/manual/en/function.strrev.php strrev]||Reverse a string||string strrev(string)
|[http://www.php.net/manual/en/function.time.php time]||Liefert die aktuelle UNIX-Timestamp||number time()
|-
|-
|[http://www.php.net/manual/en/function.strstr.php strstr]||Find first occurrence of a string||string strstr(haystack, needle)
|[http://www.php.net/manual/en/function.trim.php trim]||Entfernt Leerzeichen (oder andere Zeichen) vom Anfang und Ende eines Strings||string trim(string <nowiki>[</nowiki>, charlist])
|-
|-
|[http://www.php.net/manual/en/function.strtolower.php strtolower]||Make a string lowercase||string strtolower(string)
|[http://www.php.net/manual/en/function.ucwords.php ucwords]||Großbuchstaben den ersten Buchstaben jedes Wortes in einem String||string ucwords(string)
|-
|-
|[http://www.php.net/manual/en/function.strtotime.php strtotime]||Parse about any English textual datetime description into a Unix timestamp||int strtotime(string)
|
|-
|[http://www.php.net/manual/en/function.strtoupper.php strtoupper]||Make a string uppercase||string strtoupper(string)
|-
|[http://www.php.net/manual/en/function.substr.php substr]||Return part of a string||string substr(string, start <nowiki>[</nowiki>, length])
|-
|sum||Calculate the sum of values in an array||number sum(arg1, arg2, ... argN)
|-
|sumifop||Sum the values of answered questions in the list which pass the criteria (arg op value)||number sumifop(op, value, arg1, arg2, ... argN)
|-
|[http://www.php.net/manual/en/function.tan.php tan]||Tangent||number tan(arg)
|-
|[http://www.php.net/manual/en/function.time.php time]||Return current UNIX timestamp||number time()
|-
|[http://www.php.net/manual/en/function.trim.php trim]||Strip whitespace (or other characters) from the beginning and end of a string||string trim(string <nowiki>[</nowiki>, charlist])
|-
|[http://www.php.net/manual/en/function.ucwords.php ucwords]||Uppercase the first character of each word in a string||string ucwords(string)
|-
|unique||Returns true if all non-empty responses are unique||boolean unique(arg1, ..., argN)
|}
|}
</div>


===Geplante Funktionen (oder die zumindest in Betracht gezogen werden)===
===Geplante Funktionen (oder die zumindest in Betracht gezogen werden)===
Line 836: Line 833:
Andere Funktionen, die geplant (oder die zumindest in Betracht gezogen) sind, aber bis jetzt noch nicht enthalten sind, sind in der folgenden Liste aufgezählt. Einige von diesen sind für die Abwärtskompatibilität mit anderen Umfragetools.
Andere Funktionen, die geplant (oder die zumindest in Betracht gezogen) sind, aber bis jetzt noch nicht enthalten sind, sind in der folgenden Liste aufgezählt. Einige von diesen sind für die Abwärtskompatibilität mit anderen Umfragetools.


{| class="wikitable"
<div class="mw-translate-fuzzy">
!Syntax!!Meaning!!Comments
{|
|Syntax||Bedeutung||Kommentar
|-
|count(X,...)||die Anzahl der relevanten Werte||
|-
|e()||liefert den Wert von e||
|-
|formatDate(X,PAT)||Gibt den String Wert des Datums, formatiert nach dem Java Datenformat PAT||
|-
|formatNumber(X,PAT)||Liefert den String Wert der Zahl X, formatiert nach Java Zahlenformat PAT||
|-
|-
|e()||returns the value of e||
|getAnsOption(X)||Liefert den Text entsprechend der gewählten Option für die Antwort X||das Gleiche wie X.shown
|-
|-
|formatDate(X,PAT)||return the string value of date X formatted according to Java data format pattern PAT||
|getAnsOption(X,Y)||Liefert den Text entsprechend der Option bei Index Y des Knoten X||
|-
|-
|formatNumber(X,PAT)||return the string value of number X formatted according to Java number format pattern PAT||
|getRelevance(X)||gibt die Relevanz Gleichung für Frage X||
|-
|-
|getAnsOption(X)||returns the text corresponding to the selected option for answer X||this is the same as X.shown
|getStartTime()||gibt das Datum entsprechend der Systemzeit als das Interview begonnen wurde||
|-
|-
|getAnsOption(X,Y)||returns the text corresponding to the option at index Y of node X||
|getType(X)||liefert den String-Namen des Datentyps - e.g. *NA* bei isNA()||
|-
|-
|getRelevance(X)||returns the relevance equation for question X||
|gotoFirst()||springt zu der ersten Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems||
|-
|-
|getStartTime()||returns the date corresponding to the system time when the interview was started||
|gotoNext()||springt zu der nächsten Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems||
|-
|-
|getType(X)||returns the string name of the datatype - e.g. *NA* if isNA()||
|gotoPrevious()||springt zu der vorherigen Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems||
|-
|-
|gotoFirst()||jumps to the first relevant set of questions - this violates the normal flow of the system||
|isAnswered(X)||liefert true, wenn die Antwort weder (*UNASKED* noch *INVALID*) ist, und ist nicht leer, wenn die Antwort vom Typ STRING ist||
|-
|-
|gotoNext()||jumps to the next set of relevant questions - this violates the normal flow of the system||
|isAsked(X)||liefert true, wenn die Antwort weder *NA*, *INVALID*, noch *UNASKED* ist||
|-
|-
|gotoPrevious()||jumps to the previous set of relevant questions - this violates the normal flow of the system||
|isInvalid(X)||liefert true, wenn die Antwort vom Typ *INVALID* ist||
|-
|-
|isAsked(X)||returns true if the answer is neither *NA*, *INVALID*, nor *UNASKED*||
|isNA(X)||liefert true, wenn die Antwort vom Typ *NA* ist||
|-
|-
|isInvalid(X)||returns true if the answer is of type *INVALID*||
|isNotUnderstood(X)||liefert true, wenn die Antwort vom Typ *HUH* ist||
|-
|-
|isNA(X)||returns true if the answer is of type *NA*||
|isRefused(X)||liefert true, wenn die Antwort vom Typ *REFUSED* ist||
|-
|-
|isNotUnderstood(X)||returns true if the answer if of type *HUH*||
|isSpecial(X)||liefert true, wenn die Antwort vom Typ *UNASKED*, *NA*, *REFUSED*, *INVALID*, *UNKNOWN*, oder *HUH* ist||
|-
|-
|isRefused(X)||returns true if the answer is of type *REFUSED*||
|isUnknown(X)||liefert true, wenn die Antwort vom Typ *UNKNOWN* ist||
|-
|-
|isSpecial(X)||returns true if the answer is of type *UNASKED*, *NA*, *REFUSED*, *INVALID*, *UNKNOWN*, or *HUH*||
|jumpTo(X)||Sprung zur Gruppe mit der benannten Frage - dies verstößt gegen den normalen Ablauf des Systems||
|-
|-
|isUnknown(X)||returns true if the answer is of type *UNKNOWN*||
|jumpToFirstUnasked()||Springt zur ersten ungestellten Frage - unter Umgehung vorher beantworteter Fragen - dies verstößt gegen den normalen Ablauf des Systems||
|-
|-
|jumpTo(X)||jump to the group containing the named question -- this violates the normal flow of the system||
|lastIndexOf(X,Y)||liefert den letzten Index (Basis 0) des Strings Y im String X. Gibt -1, wenn Y nicht innerhalb von X enthalten ist||
|-
|-
|jumpToFirstUnasked()||jump to the first unasked question <strike> thus bypassing previous answered questions </strike> this violates the normal flow of the system||
|list(X,...)||ein String, der eine kommaseperierte Liste positiver Werte unter Abtrennung der letzten beiden durch "and"||
|-
|-
|lastIndexOf(X,Y)||returns the last index (base 0) of string Y in string X. Returns -1 if Y is not contained within X||
|mean(X,...)||gibt den Mittelwert einer Liste von Werten||
|-
|-
|list(X,...)||a string containing a comma separated list of the positive values with "and" separating the last two||
|numAnsOptions(X)||gibt die Anzahl der Antwortmöglichkeiten, die Frage X hat||
|-
|-
|mean(X,...)||returns the mean of a list of values||
|orlist(X,...)||ein String mit einer Komma getrennten Liste der positiven Werte, unter Abtrennung der letzten beiden durch "or"||
|-
|-
|numAnsOptions(X)||returns the number of answer options that question X has||
|parseDate(X,PAT)||liefert den Datumswert von String X mit dem Java Datumsformat PAT geparsed||
|-
|-
|orlist(X,...)||a string containing a comma separated list of the positive values, with "or" separting the last two||
|parseNumber(X,PAT)||liefert den Nummernwert von String X mit dem Java Datumsformat PAT geparsed||
|-
|-
|parseDate(X,PAT)||returns the date value of string X parsed with Java date format pattern PAT||
|regexMatch(X,Y)||liefert Boolean, ob String X dem Muster des regulären Ausdrucks Y entspricht||
|-
|-
|parseNumber(X,PAT)||returns the numerical value of string X parsed with Java number format pattern PAT||
|showAllResponsesExcept(questionList,attributeList,attributeTitleList)||questionList = Pipe-separierte Liste von Frage-Identifiern; attributeList = Pipe-separierte Liste von Attributen (wie question#, title, text, type - So kannst du entscheiden, was gezeigt werden soll); attributeTitleList = Pipe-separierte Liste von Tabellen-Headern, sodass Sie den Bericht Internationalisieren können.||
|-
|-
|showAllResponsesExcept( questionList,attributeList,attributeTitleList)||questionList = pipe-delimited list of question identifiers; attributeList = pipe-delimited list of attributes (like question#, title, text, type - so you can decide what to show); attributeTitleList = pipe-delimited list of table headers, so can internationalize the report.||
|showTheseResponses(questionList,attributeList,attributeTitleList)||questionList = Pipe-separierte Liste von Frage-Identifiern; attributeList = Pipe-separierte Liste von Attributen (wie question#, title, text, type - So kannst du entscheiden, was gezeigt werden soll); attributeTitleList = Pipe-separierte Liste von Tabellen-Headern, sodass Sie den Bericht Internationalisieren können.||
|-
|-
|showTheseResponses( questionList,attributeList,attributeTitleList)||questionList = pipe-delimited list of question identifiers; attributeList = pipe-delimited list of attributes (like question#, title, text, type - so you can decide what to show); attributeTitleList = pipe-delimited list of table headers, so can internationalize the report.||  
|
|}
|}
</div>


==Der Ausdrucksmanager weiß, welche Variablen lokal sind==
==Der Ausdrucksmanager weiß, welche Variablen lokal sind==
Line 906: Line 913:
Um es genauer zu sagen, wenn eine der Variablen irrelevant ist, wird die gesamte Gleichung irrelevant (false). In der folgenden Tabelle bedeutet N/A zum Beispiel, dass eine der Variablen nicht relevant war.
Um es genauer zu sagen, wenn eine der Variablen irrelevant ist, wird die gesamte Gleichung irrelevant (false). In der folgenden Tabelle bedeutet N/A zum Beispiel, dass eine der Variablen nicht relevant war.


{| class="wikitable"
<div class="mw-translate-fuzzy">
!Operator!!Example!!a!!b!!Result
{|
|Operator||Beispiel||a||b||Ergebnis
|-
|-
|<nowiki>+ (unary)</nowiki>||<nowiki>+a</nowiki>||N/A|| ||false
|<nowiki>+</nowiki> (unary)||<nowiki>+</nowiki>a||N/A|| ||false
|-
|-
|- (unary)||-a||N/A|| ||false
|<nowiki>-</nowiki> (unary)||<nowiki>-</nowiki>a||N/A|| ||false
|-
|-
|!||!a||N/A|| ||false
|!||!a||N/A|| ||false
|-
|-
|== (or eq)||a == b||N/A||5||false
|== (oder eq)||a == b||N/A||5||false
|-
|-
|== (or eq)||a == b||N/A||0||false
|== (oder eq)||a == b||N/A||0||false
|-
|-
|== (or eq)||a == b||N/A||N/A||false
|== (oder eq)||a == b||N/A||N/A||false
|-
|-
|!= (or ne)||a != b||N/A||5|| false
|!= (oder ne)||a != b||N/A||5|| false
|-
|-
|!= (or ne)||a != b||N/A||N/A|| false
|!= (oder ne)||a != b||N/A||N/A|| false
|-
|-
|!= (or ne)||a != b||N/A||0||false
|!= (oder ne)||a != b||N/A||0||false
|-
|-
|> (or gt)||a > b||N/A||5|| false
|> (oder gt)||a > b||N/A||5|| false
|-
|-
|>= (or ge)||a >= b||N/A||5||false
|>= (oder ge)||a >= b||N/A||5||false
|-
|-
|< (or lt)||a < b||N/A||5||false
|< (oder lt)||a < b||N/A||5||false
|-
|-
|<= (or le)||a <= b||N/A||5||false
|<= (oder le)||a <= b||N/A||5||false
|-
|-
|and||a and b||N/A||5||false
|and||a and b||N/A||5||false
Line 943: Line 951:
|or||a or b||N/A||5||false
|or||a or b||N/A||5||false
|-
|-
|<nowiki>+</nowiki>||a + b||N/A||5||false
|<nowiki>+</nowiki>||a <nowiki>+</nowiki> b||N/A||5||false
|-
|-
|-||a - b||N/A||5||false
|-||a - b||N/A||5||false
Line 969: Line 977:
|function||is_empty(a)||N/A|| ||false
|function||is_empty(a)||N/A|| ||false
|-
|-
|function||is_empty(a)||0 (or blank)|| ||true
|function||is_empty(a)||0 (oder leer)|| ||true
|-
|-
|function||!is_empty(a)||N/A|| ||false
|function||!is_empty(a)||N/A|| ||false
|-
|
|}
|}
</div>


===Überschreiben kaskadierender Bedingungen===
===Überschreiben kaskadierender Bedingungen===


Say you want to show a running total of all relevant answers.  You might try to use the equation {sum(q1,q2,q3,...,qN)}.  However, this gets translated internally to LEMif(LEManyNA('q1','q2','q3',...,'qN'),'',sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN'))).  So, if any of the values q1-qN are irrelevant, the equation will always return false.  In this case, the sum() will show 0 until all questions are answered.
<div class="mw-translate-fuzzy">
Nehmen wir an, du möchtest eine fortlaufende Summe aller relevanten Antworten. Du könntest vielleicht versuchen die Gleichung {sum(q1,q2,q3,...,qN)} zu benutzen. Jedoch wird dieses intern zuLEMif(LEManyNA('q1','q2','q3',...,'qN'),'',sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN')) übersetzt. Sodass wenn irgendeiner der Werte q1-qN irrelevant ist, die Gleichung immer "false" zurückgeben wird. In diesem Fall wird die sum() Funktion 0 ausgeben, bis alle Fragen beantwortet sind.
</div>


To get around this, each variable can have a ".NAOK" suffix (meaning that Not Applicable is OK) added to it.  In such cases, the following behavior occurs.  Say you have a variable q1.NAOK
<div class="mw-translate-fuzzy">
#q1 is not added to the LEManyNA() clause
Um dies zu umgehen, kann jede Variable ein ".NAOK" Suffix haben (welches bedeutet, dass "Keine Angabe" OK ist). In solchen Fällen tritt das folgenden Verhalten auf. Gehen wir davon aus, du hast eine Variable q1.NAOK
#LEMval('q1') will  continue to check whether the response is relevant, and will return <nowiki>''</nowiki> if it is not (so individual irrelevant responses will be ignored, but they will not void the entire expression).
#q1 ist nicht dem LEManyNA() Satz hinzugefügt
#LEMval('q1') wird weiterhin validieren ob die Antwort relevant ist, und wird '' zurückgeben, wenn sie es nicht ist (somit werden einzelne irrelevante Antworten ignoriert, anstatt dass sie den gesamten Ausdruck auf 0 setzen)
</div>


Somit ist die Lösung zu dem laufende-Summe-Problem, die Gleichung sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK) zu benutzen.
Somit ist die Lösung zu dem laufende-Summe-Problem, die Gleichung sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK) zu benutzen.
Line 1,030: Line 1,045:
==Abbildung von LimeSurvey 1.91+ zur Ausdrucksmanager Funktionalität==
==Abbildung von LimeSurvey 1.91+ zur Ausdrucksmanager Funktionalität==


{| class="wikitable"
<div class="mw-translate-fuzzy">
!Old Feature!!New Feature!!Comments
{|
|Altes Feature||Neues Feature||Kommentare
|-
|Conditions||Relevance||Du kannst sehr komplexe bedingte Gleichungen benutzen und auf ein breiteres Spektrum von Variablen zugreifen
|-
|-
|Conditions||Relevance||You can use very complex conditional equations, and access a broader range of variables
|Assessments||Equation||Alle Bewertungs-Scores können in einer Gleichung restrukturiert werden. Dies stellt sicher, dass sowohl die Partitur in die Datenbank geschrieben wird, und auch dynamische Änderungen am Score-Wert auf der aktuellen Seite gesehen werden können
|-
|-
|Assessments||Equation||Any assessment scores can be re-structured into an Equation. This both ensures that the score is written to the database, and also lets you see dynamic changes to the score value on the current page
|Replacements||Ausdrucksmanager||Die Kern-Engine übernimmt die Eingabezeichenfolgen und behandelt alles, was in geschweiften Klammern steht als Ausdruck - so kümmert sie sich um alle alten Ersatz-Typen. Um zu verhindern, dass eingebetteter JavaScript Code durcheinandergebracht wird, verarbeitet der Ausdrucksmanager nur Conten zwischen geschweiften Klammern, solange (a) es keine anführenden Leerzeichen in den geschweiften Klammern gibt - e.g. {expr} ist ein Ausdruck, aber { expr}, {expr }, und { expr } sind keine Ausdrücke. Zusätzlich verarbeitet er keine geschweiften Strings in geschweiften Strings (e.g. {list('hi','there {braces}'} führt zu "hi there {braces}"). Er ignoriert auch escapete geschweifte Klammern (e.g. \{this is not an expression\})
|-
|-
|Replacements||Expression Manager||The core engine takes the input string and treats everything within curly braces as an Expression - so it handles all historical replacements types.  To avoid messing up embedded JavaScript, Expression Manager only processes content between curly braces as long as (a)  there is no leading or trailing whitespace within the curly braces - e.g. {expr} is an expression, but { expr}, {expr }, and { expr } are not expressions.  Furthermore, Expression Manager does not process content within its own strings (e.g. {list('hi','there {braces}')} generates "hi there {braces}").  It also ignores escaped curly braces (e.g. \{this is not an expression\})
|Validation||Ausdrucksmanager||Der Plan ist die aktuellen min/max Frage-Attribute zu nehmen und den Ausdrucksmanager sie verarbeiten lassen. So können die min/max Werte selbst Ausdrücke sein.
|-
|-
|Validation||Expression Manager||The plan is to take the current min/max Question Attributes and have Expression Manager process them.  That way the min/max values can be expressions themselves
|
|}
|}


=Beziehung zu LimeSurvey Ideen / Feature-Requests=
==Syntax Highlighting==


To help with entering and validating expressions, EM provides syntax highlighting with the following features:
Um bei der Eingabe und dem Validieren von Ausdrücken zu helfen, liefert der Ausdrucksmanager eine Syntax Hervorhebung mit den folgenden Features mit sich:


==Types and Meanings of Syntax Highlighting==
{|
 
|Farbe||Bedeutung||Tooltip||Kommentar
{| class="wikitable"
!Color!!Sample!!Meaning!!Tooltip!!Comments
|-
|-
|tan background||style='background-color: #eee8aa'|Sample||the whole equation||none||Anything within curly braces that is recognized as an equation (e.g. there is no leading or trailing whitepace) will be color-coded with a tan background to help distinguish it from surrounding text
|hellbrauner Hintergrund || die ganze Gleichung || none || Alles in geschweiften Klammern das als eine Gleichung (z.B. gibt es keine führenden oder nachgestellten Leerzeichen) erkannt wird, wird mit einem hellbraunen Hintergrund markiert werden, um es vom umgebenden Text zu unterscheiden
|-
|-
|blue bold text||style='color:blue; background-color:#eee8aa'|'''Sample'''||function name||meaning and allowable syntax||function names, or things that should be functions since they are followed by an opening parenthesis, are presented in bold blue text. Tooltips show the meaning and allowable syntax for the function.
|blaue Fettschrift || Funktionsname || Bedeutung und zulässige Syntax || Funktionsnamen, oder Dinge, die Funktionen sein sollten, da sie durch eine öffnende Klammer gefolgt werden, werden fett blau angezeigt. Tooltips zeigen die Bedeutung und die zulässige Syntax für die Funktion.
|-
|-
|grey text||style='color:grey; background-color:#eee8aa'|Sample||string||none||single and double-quoted strings are shown in grey text
|grauer Text || string || none || Strings mit einfachen oder doppelten Anführungszeichen werden in grauer Schrift angezeigt
|-
|-
|bold maroon text||style='color:maroon; background-color:#eee8aa'|'''Sample'''||variable set on the same page, but after the current question||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on the same page but after the current question is shown in bold maroon text. This color coding should alert authors to possible errors in question sequencing; but it is allowed since some authors may want this sequence of variables a page, especially for dynamic reports.  The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|fetter kastanienbrauner Text || Variable auf der aktuellen Seite || JavaScript ID; Wert || Jede Variable, die auf der aktuellen Seite gesetzt ist, wird fett kastanienbraun angezeigt. Das Bewegen der Maus über den Wert, zeigt eine Meldung im Pop-up-Tooltip mit der JavaScript-ID (sofern vorhanden), und den aktuellen Wert (oder leer, wenn nicht gesetzt)
|-
|-
|bold cyan text||style='color:#4C88BE; background-color:#eee8aa'|'''Sample'''||variable set on the same page, prior to the current question||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on the same page and prior to the current question is shown in bold cyan text. The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set). If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|fetter grüner Text || Variable auf einer andere Seite gesetzt || JavaScript ID; Wert || Jede Variable, die auf einer anderen Seite (entweder vor oder nach der aktuellen) gesetzt ist, wird in fetter grüner Schrift angezeigt. Der Tooltip zeigt den JavaScript-Namen (sofern vorhanden), und den Wert (falls bekannt). Beachten Sie, dass TOKEN und INSERTANS Ersatz keine JavaScript-IDs haben.
|-
|-
|bold green text||style='color:green; background-color:#eee8aa'|'''Sample'''||variable set on a prior page||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on a prior page is shown in bold green text. The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|roter Text || Zuweisungsoperatoren || Warnung || Wenn Sie eine der Zuweisungsoperatoren (=,+=,-=,*=,/=) benutzen, wird dieser in roter Schrift angezeigt werden. Dies soll Ihnen helfen, unabsichtliche Neuzuweisungen von Werten zu verhindern, wenn z.B. in Wirklichkeit nur validiert werden sollte, ob a == b ist, anstatt den Wert direkt zuzuweisen (a = b).
|-
|-
|bold pink text||style='color:#FF00FF; background-color:#eee8aa'|'''Sample'''||variable set on a later page||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on a prior page is shown in bold pink text.  These are erorrs since the variable is  being used before it is declareed.  The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|normaler schwarzer Text || Satzzeichen || none || Alle andere Zeichensetzung im Ausdruck wird als normaler schwarzer Text angezeigt.
|-
|-
|bold tan text||style='color:#996600; background-color:#eee8aa'|'''Sample'''||a lime replacement value||the value||Lime Replacement Strings (like {TOKEN:xxx}, {PRIVACY_MESSAGE}) are shown in bold tan text. 
|rot umkastelt || Syntaxfehler || Beschreibung des Fehlers || Alle erkannten Syntax-Fehler werden durch den roten Kasten rund um den Fehler dargestellt. Der Tooltip zeigt den Fehler. Beispiele hierfür sind falsch gesetzte Klammern, die Verwendung von undefinierten Funktionen, weitergabe der falschen Anzahl von Argumenten an Funktionen, schlecht strukturierte Ausdrücke (z.B. fehlende Operatoren zwischen Variablen), der Versuch, Werte einer Read-Only oder nicht existierenden Variablen zuzuweisen oder die Verwendung ungeeigneten Syntaxes
|-
|-
|red text||style='color:red; background-color:#eee8aa'|Sample||assignment operator||warning message||If you use one of the assignment operator (=) that operator will be displayed in red text.  This is meant to help prevent accidental re-assignment of values when you really meant to check whether a == b instead of  setting the value of a = b.
|
|-
|normal black text||style='color:black; background-color:#eee8aa'|Sample||punctuation||none||All other punctuation within the expression is shown as normal black text.
|-
|red-boxed text||a bold red line surrounds the error||syntax error||description of the error||Any detected syntax errors are shown by surrounding the error with a red box.  The tooltip shows the error.  Examples include unmatched parentheses, use of undefined functions, passing the wrong number of arguments to functions, poorly structured expressions (e.g. missing operators between variables), trying to assign a new value to a read-only variable, trying to assign values to non-variables, or using unsupported syntax.  Note that the syntax error dectection system may only report one error in an expression even if there are multiple errors; however, if any errors are detected, at least one error will be shown.
|}
|}
</div>
=Beziehung zu LimeSurvey Ideen / Feature-Requests=
To help with entering and validating expressions, EM provides syntax highlighting with the following features:
==Types and Meanings of Syntax Highlighting==
<div class="mw-translate-fuzzy">
Der Ausdrucksmanager liefert vollständige oder teilweise vollständige Lösungen zu jedem der Folgenden:
*[http://ideas.limesurvey.org/ideatorrent/idea/1 Bedingungen]
*[http://ideas.limesurvey.org/ideatorrent/idea/3/ Answercounts]
*[http://ideas.limesurvey.org/ideatorrent/idea/5 Erweiterte Berichterstattung für Beurteilungen]
**teilweise: Gleichungen lassen dich die Beurteilungswerte in der Datenbank speichern und Mikro-Tailoring kann einfach formatierte Berichte daraus generieren. Autoren können auf diese Gleichungs-Werte zugreifen, wenn sie komplexere Reporting-Anforderungen haben.
*[http://ideas.limesurvey.org/ideatorrent/idea/6 Evaluierungsberichte]
**teilweise:  Da die Gleichungen Assessment-Scores speichern, sollte es möglich sein, Statistiken zu verwenden, um die Verteilungen dieser Werte zu zeigen, und Quoten um die Anzahl der Antworten dieser Scores zu begrenzen.
*[http://ideas.limesurvey.org/ideatorrent/idea/7 Speichern von Assessment-Ergebnisse zur weiteren Auswertung]
**Gleichungen lassen einen die Assessment-Werte in der Datenbank speichern --> komplette Lösung des Problems
*[http://ideas.limesurvey.org/ideatorrent/idea/22/ anspruchsvollere Zustand Regeln]
*[http://ideas.limesurvey.org/ideatorrent/idea/28 Öffne Answertable, sodass die Formatierung verändert werden kann]
**teilweise:  Alle Frage Attribute sind verfügbar, so können Autoren eigene AnswerTable Äquivalente als eine Frage erstellen. Sobald implementiert, können sie auch die showTheseResponses() oder showAllResponsesExecpt()-Funktionen nutzen.
*[http://ideas.limesurvey.org/ideatorrent/idea/37 Export der Umfrageergebnisse mit voller Fragen, die Bilder enthalten]
**da Tailoring Zugriff auf die vollen Fragetext hat, kann es auch Bilder in den Export aufnehmen
*[http://ideas.limesurvey.org/ideatorrent/idea/63 Liste der Frage Codes und SGQA Identifier]
**Eine der Test-Ansichten für Ausdrucksmanager löst dieses Problem:  http://localhost/limesurvey_ci/index.php/admin/expressions/text/data
**Darüber hinaus musst du nicht mehr die SGQA Codes verwenden, um sich auf Variablen zu beziehen - du kannst die Frage-Codes / Titel verwenden.
*[http://ideas.limesurvey.org/ideatorrent/idea/69 Branch / Sprung auf eine andere Frage (früher oder später) auf aktuelle Frage basierend]
*[http://ideas.limesurvey.org/ideatorrent/idea/86 Quota für Gesamt-Antworten]
**Wenn die letzte Frage eine Gleichung ist, die die Umfrage als komplett markiert (so ist NULL, wenn ein Befragter nicht zu der Seite kommt), können Quoten benutzt werden um die Anzahl an fertiggestellten Antworten zu kontrollieren
*[http://ideas.limesurvey.org/ideatorrent/idea/101 Validieren aller Bedingungen]
**Eine der Test-Ansichten für Ausdrucksmanager löst dieses Problem:  http://localhost/limesurvey_ci/index.php/admin/expressions/text/data
*[http://ideas.limesurvey.org/ideatorrent/idea/105 Validieren aller Fragen + Gruppen]
**Eine der Test-Ansichten für Ausdrucksmanager löst dieses Problem:  http://localhost/limesurvey_ci/index.php/admin/expressions/text/data
*[http://ideas.limesurvey.org/ideatorrent/idea/107 Wie Fragen, Logik & Konditionen  visualisieren]
**Eine der Test-Ansichten für Ausdrucksmanager löst dieses Problem:  http://localhost/limesurvey_ci/index.php/admin/expressions/text/data
**Wir haben ähnliche Views (ein wenig sauberer) verwendet, damit unsere Epidemiologen und Institutional Review Boards Umfragen mit Tausenden von Fragen in stark verzweigten und maßgeschneidert strukturierten Interviews validieren und genehmigen
*[http://ideas.limesurvey.org/ideatorrent/idea/113 offline-Befragungen]
**Die Durchführung einer Erhebung mit allen Fragen auf der gleichen Seite würde Ihnen off-line Datenerfassung erlauben (z.B. E-Mail, die HTML-Seite und zugehöriges JavaScript). Allerdings würden Sie immer noch einen Weg  wollen, um die Ergebnisse zu übertragen, damit sie nicht verloren gehen. Es kann möglich sein, "Als HTML speichern" zu verwenden, um die teilweise abgeschlossenen Antworten zu speichern.
*[http://ideas.limesurvey.org/ideatorrent/idea/120 Entfernen INSERTANS aus Fragetext bei Umfrageergebnissen]
**INSERTANS wird nicht länger gebraucht. DU kannst eine Variable durch ihren SGQA Code (ohne Voranstellen von INSERTANS:) oder mit ihrem Frage-Code ansprechen.
*[http://ideas.limesurvey.org/ideatorrent/idea/137 Informed Consent and Authorization Funktionalität]
**Du kannst die Einwilligung auf der Startseite zeigen, dann noch weitere notwendige Fragen stellen (um sicherzustellen, dass diejenigen den Studien Inklusions / Exklusions Kriterien entsprechen), und in einer Ja / Nein-Frage um deren Zustimmung bitten. Dann machst du alle restlichen Fragen von dem Ja/Nein abhängig. Zum Beispiel, wenn die Frage ''Zustimmung'' genannt wird, würdest du die Relevanz für die übrigen Fragen auf ''Zustimmung == "Y"''(''möglicherweise ''and''ing, damit welche zusätzlichen Bedingungen auch immer du benötigst, um die Bedürfnisse ihrer Branch zu decken, gegeben sind.
*[http://ideas.limesurvey.org/ideatorrent/idea/199 Zeige Codes anstelle von Antworten mit INSERTANS]
**{Qcode} gibt den Code anstelle des Antwort-Textes (den du über {INSERTANS: SGQA} bekommen kannst, oder {Qcode.shown}
*[http://ideas.limesurvey.org/ideatorrent/idea/204 Benötige Group-Mean oder Berechnungen für Beurteilungen]
**Expression-Manager hat bereits stddev(), so wäre es leicht  mean() zu Werten einer Umfrage hinzuzufügen. Die Berechnung des Mittelwerts über eine Reihe von Befragten hinweg würde die Erweiterung der Quota-Funktionalität erfordern.
*[http://ideas.limesurvey.org/ideatorrent/idea/222 Um eine Sprache abhängig Text einzufügen]
**Tailoring erlaubt es Ihnen in jeder Sprache Verben zu konjugieren und Nomen zu deklinieren
*[http://ideas.limesurvey.org/ideatorrent/idea/225 Befragte sollten ihre Antworten akzeptieren]
**Benutzerdefinierte Fragen mit Tailoring, oder die showAllResponsesExcept()-Funktion lässt Befragte alle Fragen und Antworten sehen, bevor sie auf Senden klicken. Wenn das Navigations-Menü-Option aktiviert ist, ist es leicht zurückzukehren und Antworten zu korrigieren.
*[http://ideas.limesurvey.org/ideatorrent/idea/250 Ergänzung zu #answernnXnnXnnn Methode von Targeting-Formular-Elemente]
**Du kannst nun zu Fragen und Antworten über ihren Frage-Code verweisen, somit gibt es keine Notwendigkeit mehr, SGQA Werte zu ändern.
*[http://ideas.limesurvey.org/ideatorrent/idea/262 Mehr Flexibilität mit versteckten Fragen]
*[http://ideas.limesurvey.org/ideatorrent/idea/265 Entfernen von bestimmten Bedingungen aus mehreren Fragen]
**Du kannst nun Relevanz benutzen, die einfacher als Bedingungen zu verwalten ist. Bei Bedarf kannst du alles aus der Datenbank exportieren, in einer Tabellenkalkulation bearbeiten und wieder importieren.
*[http://ideas.limesurvey.org/ideatorrent/idea/268 Cross-Umfrageauswertung]
**Durch die Verwendung von einzigartigen Frage-Codes, kannst du Daten aus mehreren Umfragen und / oder Konsolidierung zu vergleichen
*[http://ideas.limesurvey.org/ideatorrent/idea/275 Vereinfachte Integration mit anderen Tools]
**Ausdrucksmanager verwendet Question Codes statt SGQA, wodurch es leichter wird, mit anderen Tools zu integrieren.
*[http://ideas.limesurvey.org/ideatorrent/idea/290 Offenbare Beurteilungs-Werte an 3rd-Party-App-Verarbeitung]
**Dies kann mit Gleichungs-Fragetyp erreicht werden
*[http://ideas.limesurvey.org/ideatorrent/idea/309 Mehrere danke Seiten]
**Dies kann über bedingte Relevanz, Verzweigungen und Anpassung unterstützt werden
</div>


=Zusätzliche Themen=
=Zusätzliche Themen=


==[[Expression Manager Sample Surveys|Expression Manager Sample Surveys]]==
==[[Expression Manager sample surveys|Expression Manager sample surveys]]==


==[[Expression Manager HowTos|Use Cases and HowTos]]==
==[[Expression Manager how-tos|Use Cases and HowTos]]==


==[[Expression Manager Examples|Step-by-Step Examples]].==
==[[Expression Manager examples|Step-by-Step examples]]==


==[[Expression Manager for developers|Reference for Developers]]==
==[[Expression Manager for developers|Reference for Developers]]==


==[[Expression Manager Roadmap|RoadMap/Status/ToDo List]]==
==[[Expression Manager roadmap|RoadMap/Status/ToDo List]]==

Revision as of 17:17, 3 May 2019

Hinweis: Dieses Feature steht erst seit LimeSurvey 1.92 zur Verfügung.

Was ist der Ausdrucksmanager?

Übersicht

Um Umfragen auf die eigenen Bedürfnisse anzupassen benötigt man in der Regel folgende Möglichkeiten:

  1. "Navigation/Verzweigungen" - verändert die Reihenfolge der Fragen z.B. auf Grundlage der Antworten auf vorangegangene Fragen
  2. "Tailoring/Piping" - Anpassung des Fragetextes (in Bezug auf vorangegangene Frage oder die Anzahl oder das Geschlecht des Teilnehmers), oder von Berichten (Bewertungs-scores oder spezifische Empfehlungen).
  3. "Validierung" - stellt sicher, daß die gegebene Anwort bestimmten Kriterien entspricht (z.B. einem Maximal- oder Minimalwert oder einem bestimmten Eingabemuster).

Mit Hilfe des Ausdrucksmanagers ("Expression Manager", EM) ist es möglich all dies in intuitiver Art und Weise umzusetzen. Nahezu alles, was man mit einer mathematischen Formel beschreiben kann, kann auch als Ausdruck dienen; sogar der Aufruf von Funktionen ist möglich. EM stellt augenblicklich >70 Funktionen bereit und kann mit relativ wenig Aufwand erweitert werden. Sämtliche Variablen aus der jeweiligen Umfrage stehen unter ihrem "menschen-lesbaren" Variablennamen zur Verfügung.

Die folgenden Abschnitte beschreiben wo der Ausdrucksmanager zu Einsatz kommt

Relevanz (für Navigation/Verzweigung)

Einige Umfrageapplikationen verwenden eine "Sprung-Logik", so dass, wenn Sie die Frage 1 mit der Option C beantworten, dann springe Sie zu Frage 5. Dieser Ansatz ist sehr begrenzt, da es schwer zu validieren ist, und leicht schief geht, wenn Sie Fragen neu ordnen. AM verwendet eine Boolesche Relevanz-Gleichung um zu spezifizieren unter welchen Bedingungen eine Frage gültig sein könnte. Wenn die Frage relevant ist, dann wird die Frage gestellt, ansonsten ist Sie Nicht Anwendbar, und der Wert NULL wird in der Datenbank gespeichert. Dies ist ähnlich zu dem, was über dem Bedingungseditor gemacht werden kann, aber mit EM können Sie einfacher viel komplexere und leistungsfähige Kriterien festlegen (und Sie können Variablennamen statt SGQA Namensgebung nutzen).

Dieses Bild zeigt einen Weg, um die Relevanz-Logik für eine Umfrage zu überprüfen. Es berechnet den Body-Mass-Index (BMI). Die Relevanz Gleichung wird in eckigen Klammern direkt nach dem Variablennamen (grün) gezeigt. So sind die Bedeutung von Gewicht (weight), weight_units, Größe (height) und height_units alle 1, was bedeutet, dass diese Fragen immer gestellt werden. Allerdings ist die Relevanz für BMI {! IS_EMPTY (height) und! IS_EMPTY (weight)}, was bedeutet, dass der BMI nur berechnet wird, wenn der Teilnehmer einen Wert für Höhe und Gewicht eingibt(wodurch das Risiko einer Division durch Null vermieden wird). Auch wird die Frage Bericht (Report) nur angezeigt, wenn der Teilnehmer Antworten auf vier Fragen (height, height_units, weight, weight_units) gibt.

Relevanz wird an folgenden Stellen gezeigt und ist bearbeitbar:

Betrachten / Bearbeiten der Relevanz auf Fragenebene

Diese Gleichung berechnet den Body-Mass-Index (BMI). Dies wird nur gefragt, wenn die Person vorher ihre Größe und Gewicht eingegeben hat.

Dies ist der Bearbeitungs-Bildschirm für die BMI Frage.

Beachten Sie, dass Sie geschweiften Klammern nicht nutzen dürfen, wenn Sie eine Relevanz Gleichung eingeben.

Betrachten / Bearbeiten Relevanz auf Gruppenebene

Dies ist eine Stichprobenerhebung. Auf der ersten Seite werden Sie gefragt, wie viele Personen bei Ihnen wohnen, und speichert dies in der Variablen "cohabs". Diese Seite wird nur angezeigt, wenn Sie mehr als einen Mitbewohner haben (also für die zweite Person, die mit Ihnen zusammen lebt) und auch nur, wenn Sie angegeben haben, wie Person 1 mit Ihnen verwandt ist (p1_rel).

As you can see, the group also has question-level relevance criteria, such that each question only appears once you have answered the question before it (e.g. {!is_empty(p1_sex)}).  EM combines the Group and Question-level relevance for you.  Questions in a group are only asked  if the group as a whole is relevant.  Then, only the subset of questions within the group that are relevant are asked.

Here is the screen for editing the group-level relevance for that question:

Beachten Sie, dass Sie geschweiften Klammern nicht nutzen dürfen, wenn Sie eine Relevanzgleichung eingeben.

Tailoring/Piping

EM lets you easily do simple and complex conditional tailoring of your questions.  Sometimes you just need simple substitution, like saying, "You said you purchased [Product].  What did you like best about it?".  Sometimes you need conditional substitution like "[Mr./Mrs.] [LastName], would you be willing to complete our survey?".  In this case,  you want to use Mr. or Mrs. based upon the person's gender.  Other times you need even more complex substitution (such as based upon a mathematical computation).  EM supports each of these types of tailoring/piping.

Bedingte Gleichungen

The Body Mass Index example shows the ability to compute a person's BMI, even while letting them enter their height and weight in metric or non-metric units.

Here weight_kg is {if(weight_units == 'kg', weight, weight * .453592)}.  This if() function means that if the subject entered the weight using kilograms, use that value, otherwise multiply the entered value (which was in pounds) by .453592 to convert it to kilograms.  The height_m variable uses a similar approach to compute the person's height in meters, even if he entered his height in inches.

BMI computes the weight formula as {weight_kg / (height_m * height_m)}.

Lastly, the report conditionally tailors the message for the subject, telling him what he entered. ("You said you are 2 meters tall and weight 70 kg.")

Although not well shown in the above image, weight_status uses nested if() statements to categorize the person as underweight to severely obese.  You can see its equation in the Show Logic View

From the edit window for this question, you can see two things:

  1. Tailoring must surround expressions with Curly Braces
  2. Expressions can span multiple lines if, as in this case, you want to make it easier to read the nested conditional logic.

Tailored Questions, Answers, and Reports

Note: Dynamic tailoring may not work if answer options are made available in select boxes on the same question page. This results from the fact that tailoring inserts a <span> tag which is not valid inside select options.

Dieses Beispiel zeigt den BMI-Bericht.

Hier ist das Bearbeitungs-Fenster für die gleiche Frage.

As you can see, anything in curly braces is treated as an expression, so is syntax-highlighted (color coded) in the prior image.  If you had any typos (such as misspelled or undefined variable names or functions), EM would show an error, such as this, showing that height_unit is an undefined variable name (it is actually height_units), and rnd() is an undefined function (the proper function name is round()).  In both cases, the errors are surrounded by a red box to make it easier to spot and fix them.

You can also see that you can quickly create complex reports, such as a table of entered values or tailored advice.

Please remember that all tailoring must surround expressions with Curly Braces, so that LimeSurvey knows which parts of the question are free text and which should be parsed through Expression Manager.

Validierung

EM controls how most of the advanced question options work.  These control aspects like min/max numbers of answers; min/max individual values; min/max sum values; and checking that entered values match specified string patterns.  You continue to enter those advanced question options as usual.  However, now any value in one of those fields is considered an expression, so you can have min/max criteria with complex conditional relationships to other questions.

In all of these cases, since the advanced question option is always considered an expression, you do not use curly braces when specifying it.

The Sample Surveys pages shows many working examples of using expressions for validations.

Einführung

LimeSurvey uses the new Expression Manager (EM) module which will let LimeSurvey support more complex branching, assessments, validation, and tailoring.  It will replace how LimeSurvey manages Replacements, Conditions, and Assessments on the back-end.  It will also speed up processing considerably since it eliminates most run-time database reads.  EM was developed by Dr. Thomas White (TMSWhite).

This wiki page is the definitive reference for Expression Manager syntax and functionality.

Key Definitions

  1. Expression:  Anything surrounded by curly braces
    • As long as there is no white space immediately after the opening brace or before the closing curly brace
    • The contents of Expressions are evaluted by EM, so they can contain mathematical formulas, functions, and complex string and date processing.
  2. Tailoring: Sometimes called "piping", this is the process of conditionally modifying text
    • You have access to all 'replacement fields', participant data, and response data.
    • You also have easier access to questions, answers, and their properties.
  3. Relevance Equation:  A new question attribute controlling question visiblity
    • If there is a relevance equation, then the question is only shown if the relevance evaluates to true.
    • Internally, all array_filter and array_filter_exclude commands become subquestion-level relevance
  4. Equation Question Type:  A new question type that saves calculations or reports to the database
    • It is like a Boilerplate question, but its contents are saved to the database even if you set "Always Hide this Question"
  5. Question Code:  This is the preferred variable name for EM
    • This can be a descriptive name indicating the purpose of the question, making it easier to read complex logic
    • Valid question codes should NOT start with a number, so when using the question code to number your questions, simply use "q1", or "q1a" or "g1q2".
    • This is what currently becomes the variable name if you export data to SPSS or R, so if you do statistical analysis, you probably already made this unique.

Muss ich den AM benutzen?

Die kurze Antwort ist Nein (aber auch Ja).

EM is fully backwards-compatible with existing surveys.  So, if you are happy to use Conditions and Assessments in the style that LimeSurvey used in versions <= 1.91+, you can continue to do so.

However, EM completely replaces how LimeSurvey internally deals with Conditions.  Although you can still use the Conditions Editor to create and manage conditions, LimeSurvey 1.92 will convert those to the equivalent Relevance Equations.  As part of the upgrade, LimeSurvey 1.92 will auto-convert all existing Conditions to Relevance Equations.

This should give you the best of both worlds - you can continue using LimeSurvey as you are used to, but will see the Relevance Equation equivalent so you can gradually migrate to Relevance Equations directly whenever you see fit.

Kann ich eine Mischung aus Bedingungen und Relevanz nutzen?

Yes. You can use the Conditions editor for some questions and the Relevance editor for others.  Conditions are auto-converted to Relevance when you save the question.

Note, we assume that if you are using the Conditions editor, that you want those Conditions to over-write any manually entered Relevance equation.  So, if you have existing Conditions and want to manually edit the Relevance, please delete the Conditions for that question first.  Specifically, copy the generated relevance equation to a text editor, use the Conditions menu to delete all of the conditions for that question (which will also delete the relevance), then edit the question and paste the generated relevance equation from the text editor back into the relevance field for that question (and save the question).  If there is enough demand for deleting conditions without deleting the generated relevance equation, we could add a bulk conversion process.

How should I choose between Conditions and Relevance?

Here is a list of pros and cons of each style:

Style Pros Cons
Conditions 1. Nice GUI for creating simple conditions
2. GUI well documented and understood by support team
1. Only supports simple comparisons and does not AND/OR conditions well
2. Cascading conditions work erratically
3. Slow - database intensive, so can slow down long surveys
4. Some reported problems with re-loading conditions
5. GUI doesn't scale well when there are dozens, hundreds, or thousands of questions
6. May be slow to convert paper-based surveys since must use SGQA names
7. Often need a programmer to custom-code logic needed for complex branching
Relevance 1. Supports very complex logic, including 80+ functions and math/string operators
2. Perfect support for cascading logic
3. Fast - no extra database calls, so supports 1000+ question surveys
4. No problems with re-loading logic since does not require SGQA codes
5. Syntax-highlighting scales to 1000+ question surveys
6. Easy and fast to use for groups wanting to computerize existing paper-based suveys.  
7. Easily supports semi-structured interviews and epidemiological surveys without needing a programmers
1. No GUI for simple conditions - use syntax-highlighting instead
2. New, so support teams have not mastered EM yet.

The bottom is that if you are happy with how LimeSurvey 1.91+ works, there is no reason to change what you do.

Was sind andere Vorteile der Verwendung von AM?

Here are some of the other reasons you might want to use EM.

  1. Calculations - you can create any calculation you can think of:
    • You have access to all common mathematical operators and functions
    • You have access to 70+ mathematical, date, and string processing functions
    • It is fairly easy for developers to add new functions if users need them
  2. Storing Calculations to Database
    • You can now compute simple and complex calculations and/or scale scores AND have them stored in the database without needing JavaScript.
    • You use the Equation question type to accomplish this.
  3. Assessments
    • You can now create assessments or scale scores from any question type, not just the subset that used to be supported
    • You can use Tailoring to show running or total assessment scores anywhere needed - even on the same page
    • You have more control over the reports generated based upon those assessment scores
    • You can store assessment scores in the database without needing JavaScript
    • You can hide assessment scores without needing JavaScript or CSS
  4. Replacement Fields
    • Instead of using {INSERTANS:SGQA}, you can just use the Question Code - this makes it easier to read and validate.
    • This also avoids the common need to edit questions to change the SGQA code to make everything work.
  5. Tailoring - you can conditionally display text based upon other values
    • Use the appropriate title for a subject, like (e.g. "Hello [Mr./Mrs.] Smith")
    • Output gramatically correct sentences based when singular/plural matter:  (e.g. "You have 1 child" vs. "You have 2 children")
    • Appropriately conjugate verbs and decline nouns based upon subject's gender and plurality.
  6. New Variable Attributes - you can access the following to do your tailoring:
    • (no suffix) -  an alias for qcode.code
    • .code - the selected response code for the question if it is relevant (otherwise blank), or the text value if it is not a coded question
    • .NAOK - same as .code, but can be part of calculations or lists even if irrelevant
    • .value - the assessment value for the question if it is relevant (otherwise blank), or the text value if it is not a coded question
    • .valueNAOK - same as .value, but can be part of calculations or lists even if irrelevant
    • .shown - the answer as displayed to the user (this is what {INSERTANS:xxx}  does)
    • .qid - the question ID
    • .gid - the group ID
    • .sgqa - the SGQA value for the question
    • .jsName - the correct javascript variable name for the question, regardless whether defined on this page or another
    • .qseq - the question sequence (starting from 0)
    • .gseq - the group sequence (starting from 0)
    • .mandatory - whether the question is mandatory (Y/N)
    • .question - the text of the question
    • .relevance - the relevance equation for the question
    • .grelevance - the relevance equation for the group
    • .relevanceStatus - whether or not the question is currently relevant (1 if true, 0 if false)
    • .type - the question type (the one character code)
  7. Dynamic On-Page Changes
    • All Relevance, Calculation, and Tailoring works dynamically on a page - so changes in values instantly update the page
    • So, you have questions dynamically appear/disappear based upon whether they are relevant
    • Questions are also dynamically tailored based upon responses on the page, so you can see running totals, tailored sentences and customized reports.
  8. New Data Entry Screen
    • In addition to using the current data-entry system, you can just use Survey-All-In-One.
    • This supports the on-page relevance and tailoring, so data entry clerks can quickly tab through and they will only have to enter the relevant responses
    • This can be critical if your data entry person needs to see the tailoring, which is also dynamic.
  9. Eliminates the need for most custom JavaScript
    • EM easily supports complicated computations, scoring, tailoring and conditional logic.
    • Some things will still need JavaScript (like custom layouts and conditionally hiding question sub-elements), but your JavaScript can use the EM functions so that you can access questions by their Qcode instead of SGQA, and access any of the question properties listed above.

What are some other helpful new features enabled by EM?

Regardless of whether you continue to use the Conditions Editor or manually compose Relevance Equations, you get these additional benefits:

  1. You can create more complex validation criteria
    • All of the advanced question attribute (like max_answers, min_num_value_n, max_num_value) can use Expressions.  So, you min/max criteria can be easily adjusted based upon prior responses, even if they are on the same page.
    • EM also handles all regular-expression-based validation, so you can robustly combine preg and equation-based question attributes.
  2. Easy Re-ordering (or deleting) of Questions and Groups
    • Prior to version 1.92, you could not re-order questions or groups if LimeSurvey thought that such-re-ordering could break conditions in which they were used.  Similarly, you could not delete questions if any other questions depended upon them.
    • With EM's syntax highlighting, it is easy to see and validate whether you try to use questions before they are declared.  So, we now let you re-order or delete questions and groups whenever you like.  EM will update all of the syntax highlighting to show you potential errors.
    • The re-order questions view has been enhanced to help with such review.  It now shows the question's relevance equation and tailoring, so you can immediately see whether any variables become pink (meaning they are used before being declared).
  3. The Question/Group Navigation Index is always available and accurate
    • Prior to version 1.92, these indexes were not available if there were complex conditions
    • With EM, we can guarantee that they are accurate.
    • Subjects can even jump back, to a prior question, change the answer, then jump forward (or submit)
      • When jumping forwards, EM will re-validate all of the intervening questions/groups.
      • If any questions become irrelevant, they will be NULLed in the database so that your data is internally consistent
      • If any questions become relevant or newly fail mandatory or validation rules, EM will stop on that page and force the user to answer those questions before jumping to their final destination.
  4. Auto-conversion of Conditions to Relevance
    • When you upgrade your database, all existing surveys that have conditions will have relevance equations generated for them
    • Whenever you import a survey, relevance equations will be created as needed
    • Whenever you add, delete, or modify conditions, EM will generate the appropriate relevance equation.
  5. Convenient Syntax Highlighting
    • When EM shows the relevance equation, it will show the Qcode, even if you entered an SGQA code, as we assume this will be easier to read.
    • All variables are color coded to show whether they were declared before or after the current question (or before or after the current group).  This lets you quickly detect and fix cases where you try to use variables for relevance (including array_filter), tailoring, or validation equations prior to declaring them.
    • In addition, if you hover your mouse over the color-coded variable, you will see the most important metadata about that question.   This includes the Group Sequence #, Question Sequence #, Qcode, Text of the question, and all available answer choices (if it is a question type with enumerated answer choices).
      • The list of answer choices uses this syntax:  'answers':{key:val, ... }.
      • key has the syntax 'scale~code' where scale is the answer scale (e.g. for dual scale), and code is the answer code.
      • val has the syntax 'value~shown' where value is the assessment value (if using assessments, otherwise code)(e.g. Qcode.value), and shown is the display value as seen by the subject (e.g. Qcode.shown)
      • This means that many surveys can use calculations without needing assessment mode.  If you have enumerated answer options  that are unique, non-decimal, and non-negative, you can simply do calculations on the Qcode.code values.
  6. Easy review of entire survey logic and content
    • There is a new Show Survey Logic feature that lets you see everything about the survey (or group or question) on a single page.
    • It shows the Group, Question, Sub-Question, and Answer-level details for the selected scope (survey vs. group vs. question)
    • It also shows the relevance, subquestion-level relevance (for array_filter and array_filter_exclude), and generated validation equation (for preg and any validation rules like min/max sum/number of values), and all non-blank question attributes.
    • Everything is syntax-highlighted so that you can see potential syntax errors (like unbalanced parentheses or use of variables before they were declared)
    • The syntax-highligting supports rapid navigation and editing of the survey.
      • If you click on a variable name, it opens a browser window (or tab) that shows you that question and lets you edit it.
      • If you click on a group name, it opens a browser window (or tab) showing the group-reorder view so that you can easily move questions around.
      • All of the question attributes are also syntax highlighted.  This lets you set and see expressions within advanced question options (like basing the max/min number/sum of values on an expression)
    • The EM author used similar view (a little cleaner) to let his collaborating Epidemiologists and Institutional Review Board validate and authorize surveys with thousands of questions in highly branched and tailored structured interviews

Erste Schritte

Hier sind die ersten Schritte:

Welche Funktionalität erweitert/ersetzt der Ausdrucksmanager? (LimeSurvey <= 1.91+)

Bewertungen => Gleichungen und Micro-Tailoring

Mit Bewertungen konnten Benutzer Punktzahlen aus einer Sammlung von Fragen erstellen. Jedoch passten sie sich nicht dynamisch an die aktuelle Seite an und die Werte waren nicht in der Datenbank abgespeichert. Man musste außerdem die LimeSurvey Datenbanken anpassen.

Ersatz => Micro-Tailoring

Benutzer konnten einige Nachrichten und Fragen anhand der vorherigen Antworten anpassen. Eine Frage könnte zum Beispiel {TOKEN:VORNAME}, und Sie sagten noch, dass {INSERTANS:111X3X4} Ihre Lieblingssportart wäre sein. Jedoch konnte man nicht bedingt anpassen, Verben konjugieren oder Nomen deklinieren ohne JavaScript zu benutzen.

Replacements => Micro-Tailoring

Users could tailor some messages and questions based  upon prior responses.  For example, a question might be, {TOKEN:FIRSTNAME}, you said {INSERTANS:111X3X4} was your favorite sport.  However, it was not possible to do conditional tailoring (like say "Mr." or "Mrs." depending upon the person's gender), or conjugate verbs or decline nouns without fancy JavaScript.  Authors could implement surveys that seemed to tailor questions, but it required separate questions for each permutation, and complex conditions to decide which questions to display.

Validierung

Fragen konnten mit regulären Ausdrücken, oder mit Minimal- oder Maximalwerten validiert werden. Außerdem konnte man eine SGQA Antwort als Mindest- oder Höchstbetrag nehmen. Jedoch konnten Berechnungen von anderen Variablen ohne JavaScript nicht für die Überprüfungen verwendet werden.

Gleichungen

Gleichungen wurden ohne JavaScript nicht unterstützt.

Gleichungs-Fragetyp

Gleichungen konnten ohne JavaScript nicht in der Datenbank abgespeichert werden (zum Beispiel die Endpunktzahl für eine Beurteilung).

Wie wird der Ausdrucksmanager diese Funktion ersetzen oder erweitern?

Der Ausdrucksmanager ist ein neues Modul in LimeSurvey, es stark vereinfacht komplexe Funktionen zu unterstützen für die früher angepasstes JavaScript verwendet werden musste. Er ersetzt auch die Art und Weise mit der LimeSurvey Bedingungen und Beurteilungen verwaltet.

Neue Bezeichnungsweisen des Ausdrucksmanagers

Der Ausdrucksmanager "denkt" über seine Funktionalität folgend:

  • Relevanzbasierte Verzweigung - ist eine Frage relevant, stelle sie, ansonsten nicht (z.B. mach sie unsichtbar)
  • Anpassung - Sobald du weißt, welche Fragen gestellt werden sollten, wird durch das Micro-Tailoring angegeben wie die Fragen zu stellen sind. Dadurch können sie nicht nur einfache Dinge austauschen (wie z.B. {TOKEN:VORNAME}), sondern auch die Konjungation von Verben und Deklination von Substantiven basierend auf dem Geschlecht und der Anzahl der Subjekte durchführen. Es erlaubt dir auch die Antwort danach zu verändern, ob die anderen Fragen (oder wie die anderen Fragen) beantwortet wurden.
  • Gleichung - Der Ausdrucksmanager fügt auch einen neuen Fragetypen namens Gleichungen hinzu, der die Ergebnisse der Ausdrücke speichert. Der eine Zeichentyp für Gleichungen ist das Asterixzeichen "*".

Relevanz und Kaskadierende Relevanz

Jeder Fragetyp hat nun auch eine Relevanzoption, die kontrolliert, ob die Frage angezeigt wird.

Der Ausdrucksmanager führt jede der Relevanzgleichungen in Reihenfolge aus. Wenn der Ausdruck wahr ist (oder fehlend - um Legacy-Umfragen zu unterstützen), wird die Frage angezeigt. Wenn er irrelevant ist, wird die Fragen nicht angezeigt und der Wert wird ausgeblendet (um zu zeigen, dass es nicht zutreffend ist).

Weiterhin, wenn es irgendwelche Variablen mit einem irrelevanten Ausdruck gibt, dann wird der Ausdruck als Falsch gewertet. Dies erlaubt kaskadierende Relevanzen, so dass du nicht sehr lange Relevanzgleichungen für jede Frage schreiben müssen.

Moreover, if any of the variables within an expression is irrelevant, then the expression always evaluates to false.  This enables Cascading Relevance so that you do not have to write very long Relevance equations for each question.

Sagen wir mal, dass es 5 Fragen, Q1-Q5 gibt. Du willst aber nur, dass Q2 angezeigt wird, wenn Q1 beantwortet wurde, und Q3 wenn Q2 beantwortet wurde und so weiter. Die notwendigen Gleichungen wären dann:

Frage-Nummer Relevanz Frage
Q1 1 Wie heißen Sie?
Q2 Q1 {Q1}, wie alt sind Sie?
Q3 Q2 Also, Sie sind {Q2} Jahre alt. Sind Sie verheiratet?
Q4 Q3 == "Y" {Q1}, wie lange sind Sie schon verheiratet?
Q5 Q4 Wie viele Kinder haben Sie, {Q1}?

Diese Berechnungen werden auch von JavaScript unterstützt - also können Sie die Fragen auf einer Seite platzieren und alles funktioniert weiterhin.

As long as you are on the same page, any data you entered will still be there, just hidden.  So, if you enter some information, then choose an option that makes them irrelevant, then make them relevant again, your answers will still be available.  However, as soon as you move to a different page, all irrelevant responses will be lost to integrity of the dataset.

Group-Level Relevance

Expression Manager also supports group-level relevance.  This makes it easier to implement looping.   Say you want to collect information about up to 10 entities (such a products or people in a household), where you first determine how many entities need follow-up (such as by asking how many people live in a household, or having people check which products they like from a long list).  After knowning how many entities need follow-up, you can use Group-level relevance like {count >= 1}, {count >=2}, ... {count >= 10} for each of the 10 groups of follow-up questions.  Within each group, you can have question-level conditional logic (e.g. gender or age-specific follow-up questions for each subject).  The question and group-level relevance equations are ANDed together to determine which should be shown.

Tailoring / Piping

Alles innerhalb von geschweiften Klammern wird nun als Ausdruck behandelt (mit einer Ausnahme, die unten beschrieben wird). Ausdrücke haben zugang zu allen LimeReplacement-Feldern, zu allen Variablen (über verschiedene Aliase), allen typischen Gleichungsoperatoren (mathematisch, logisch und Vergleich) und dutzenden Funktionen (die sogar dynamisch auf Client-Seite funktionieren).

Durch die Benutzung dieser Gleichungen, kannst du z.B. solche Dinge machen:

  1. Den Befragten maßgeschneiderte Nachrichten abhängig von früheren Antworten zeigen
  2. Beurteilungen erstellen und die Beurteilungsergebnisse (oder bedingte Verzweigungen oder Nachrichten) basierend auf diesen Ergebnissen anzeigen lassen. Alles ohne das Beurteilungsmodul selber zu benutzen.
  3. Verben konjugieren und Nomen deklinieren
  4. Sich Zusammenfassungen der Antworten vor der "Antworten anzeigen" Seite am Ende der Umfrage anzeigen lassen

Gleichungen

Es gibt einen neuen Fragetyp namens Gleichung. Er ist wie eine Boilerplate-Frage, bis darauf, dass er den gezeigten Wert in der Datenbank speichert. Also wenn der Gleichungs-Frage-Text eine Beurteilungs-Berechnung enthält, dann würde dieser Wert in der Datenbank in einer Variable, die in öffentlichen oder begrenzten Statistiken angezeigt werden kann, gespeichert werden.

Dies löst ein häufiges Featurerequest Beurteilungs-Wertungen in der Datenbank speichern zu können.

Syntax

Alles innerhalb von geschweiften Klammern wird jetzt als Ausdruck angesehen (mit einer Ausnahme: es darf keine führenden oder nachfolgenden Leerzeichen geben - dies ist notwendig, damit der Ausdrucksmanager nicht versucht eingebettetes JavaScript auszuführen).

Note, it is OK for expressions to span multiple lines, as long as there is no whitespace after the opening  curly brace or before the closing curly brace.  This is especially helpful for nested if() statements like this:

{if(is_empty(PFTotals),
 '',
 if(PFTotals >= -5 && PFTotals <= -4,
   'Very Soft',
   if(PFTotals >= -3 && PFTotals <= -2,
     'Soft',
     if(PFTotals == -1,
       'Somewhat Soft',
       if(PFTotals == 0,
         'Moderate',
         if(PFTotals == 1,
           'Somewhat Hard',
           if(PFTotals >= 2 && PFTotals <= 3,
             'Hard',
             if(PFTotals >= 4 && PFTotals <= 5,
               'Very Hard',
               ''
             )
           )
         )
       )
     )
   )
 )
)}

Der Ausdrucksmanager unterstützt folgenden Syntax:

  • Alle Standardmatheoperationen (e.g. +,-,*,/,!)
  • Alle Standardvergleichsoperationen (e.g. <,<=,==,!=,>,>=, sowie diese Äquivalenten:  lt,le,eq,ne,gt,ge)
  • Klammern (Sodass Unter-Ausdrücke gruppiert werden können)
  • Bedingungsoperatoren (e.g. &&,| | und diese Äquivalente: and,or)
  • Zeichenketten mit einfachen oder doppelten Anführungszeichen (die jeweils Zeichenketten mit dem anderen Anführungszeichen einbetten können)
  • Kommaoperatoren (Sodass Sie eine Liste von Ausdrücken haben können und nur das endgültige Ergebnis zurückgeben)
  • Zuordnungsoperatoren (=,+=,-=,*=,/=)
  • Vordefinierte Variablen (um sich auf Fragen und Antworten zu beziehen).
  • Vordefinierte Funktionen (mit der Möglichkeit weitere hinzuzufügen)

Operators

EM syntax follows normal operator precedence:

Level Operator(s) Description
1 () parentheses for grouping or calling functions
2 ! - + unary operators: not, negation, unary-plus
3 * / times, divide
4 + - plus, minus
5 < <= > >= lt le gt ge relative comparisons
6 == != eq ne equality comparisons
7 and logical AND
8 or logical OR
9 = assignment operator
10 , comma operator

Note, for consistency between JavaScript and PHP, the plus operator (+) does addition if both operands are numeric, but does concatenation if both parts are non-numeric strings.  However, we recommend using the join() function for concatenation, as that makes your intent more clear, and avoids unexpected results if you were expecting strings but got numbers instead (or vice versa).

Caution about using Assignment Operator (=)

Note, you should avoid using the assignment operators unless absolutely necessary, since they may cause unexpected side-effects.  For example, if you change the value of a previous response, the cascading relevance and validation logic between that question and the current question is not re-computed, so you could end up with internally inconsistent data (e.g. questions that stay answered but should have been NULLed, or questions that are skipped but should have been answered).  In general, if you want to assign a value to a variable, you should create an Equation question type, and use an expression to set its value.  However, there are some rare times that people really need this operator, so we made it available.

To help caution you about this operator, it is shown in red font within the syntax equations (so that you don't confuse it with "==")

Using Assignment Operator

The main reasons you may want to use assignment are:

  • You need to set the default value for a question that does not accept defaults via equation (such as list radio, where the user interface lets you pick one of the answer options, but does not let you enter an equation).  However, be careful, as LimeSurvey will not be able to validate that your equation generates one of the allowable answers for that question.
  • You need to forcibly change the response to a previous question based upon a later response
  • You need complex quota : using one hidden single choice for quota and set it using assignment
  • etc...

You can use all expression manager system for this purpose.

  Assignment is done only in PHP. This doesn't update any values on the same page, but only when the user navigates with next, previous, save ….


  If you don't use an equation question type for this purpose: the assignment is done only after the logic of the current page is done. The recommended method is to always use an equation question.


Some example:

  • Set answer to a short text question in lowercase : {QCODE=strtolower(QCODE.NAOK)}
  • Set a default answer to an array question type at start of a survey : {Q1_SQ1=(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
  • Set a default answer to an array texts question type at start of a survey : {Q1_SQY1_SQX1 = (is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}
  • Set an answer with condition : {QCODE=if(YesNo="Y","A1","")}

XSS security

With XSS enable, some expression manager system can not be used :

  • starting a HTML tag in expression but ending in another expression
  • use a complex expression in URL.

Example and workaround

  • {if( 1 ,"<strong>","")}information{if( 1 ,"</strong>","")} is broken with XSS security, here you can use {if(1,"<strong>information</strong>","information")}
  • <a href="/script.php?value={if(QCODE == "Y","yes","no")}">next</a>, here you can use an equation question because using a complete question code is OK : <a href="/script.php?value={EQUATION.NAOK}">next</a>

Zugang zu Variablen

Der Ausdrucksmanager lässt read-only und read-write Zugang zu jeder Variable zu. Zur Abwärtskompabilität bietet er Zugriff auf die Folgenden:

  • TOKEN:xxx - der Wert eines TOKENs (e.g. TOKEN:VORNAME, TOKEN:ATTRIBUTE_5)
  • INSERTANS:SGQA - Der angezeigte Wert einer Antwort (e.g. "Ja")
  • All {XXX} Von Templates benutzte Werte

Zusätzlich erlaubt dir der Ausdrucksmanager dich auf Variablen über die Frage-Nummer zu beziehen (auch als Titel in der Datenbank bezeichnet). Dies ist auch das Label der Variable, welches genutzt wird, wenn Sie Ihre Daten zu SPSS, R oder SAS exportieren. Zum Beispiel, wenn Sie Fragen zu dem Namen, Alter und Geschlecht haben, könnten sie ihre Variablen "name", "alter" und "geschlecht" nennen. Dies macht die Gleichungen jedem leichter Verständlich und macht es möglich die Fragen durch zu mischen ohne ein Auge auf die Gruppen und Fragennummern haben zu müssen.

Important: It is only safe to refer to variables that occur in preceding pages or questions.

Außerdem erlaubt der Ausdrucksmanager auf bestimmte Eigenschaften der Fragen zuzugreifen.


Syntax Bedeutung Beispiel Beispiel Ergebnis
Qcode Der Code-Wert der Frage, wenn relevant (sonst leer) {gender} 'M'
Qcode.NAOK das gleiche wie Qcode - siehe die Diskussion über NAOK {gender.NAOK} 'M'
Qcode.shown der Anzeigewert der Frage {gender.shown} 'Male'
Qcode.question der Fragetext {gender.question} 'What is your gender?'
Qcode.mandatory ob die Frage verpflichtend ist (J/N) {gender.mandatory} 'N'
Qcode.qid die interne Nummer der Frage (nicht die fortlaufende Nummer) {gender.qid} 337
Qcode.type der Fragetyp {gender.type} 'G'
Qcode.jsName der Javascriptname der Frage {gender.jsName} 'java1827X3X337'

HTML editor issue

  This issue is fixed after 2.05 build 140803


If you use HTML editor, some characters are replaced by HTML entities.

  • & by &amp;
  • < by &lt;
  • > by &gt;

If you use HTML editor you need to use :

  • and for &
  • lt for <
  • le for <=
  • gt for >
  • ge for >=

Qcode Variable Naming

Hier sind die Details, wie ein Qcode konstruiert wird (und auf einige Eigenschaften zugegriffen wird), geordnet nach Fragetyp. Generell werden Qcodes wie folgt konstruiert:

 QuestionCode . '_' . SubQuestionID . '_' . ScaleId

For comment and other, question code are QuestionCode_comment and QuestionCode_other

Typ Beschreibung Code SubQs Antwortoptionen Skala Antwortcodes Angezeigte Antwort Relevanz
5 5 Punkte Auswahl Radio-Buttons Q1 1-5 {Q1} {Q1.shown} {Q1==3}
B Array (10-Punkte-Wahl) Radio-Buttons Q2 L1-L6 1-10 {Q2_L2} {Q2_L2.shown} {Q2_L2==7}
A Array (5-Punkte-Wahl) Radio-Buttons Q3 1-5 1-5 {Q3_1} {Q3_1.shown} {Q3_1>=3}
1 Array (Flexible Labels) Duale Anzeige Q4 sq1-sq5 0:a1-a3 1:b1-b3 {Q4_sq1_0} {Q4_sq1_1.shown} {Q4_sq1_1=='b2'}
H Array (Flexible) - Spalten-Format Q5 1-5 s,m,t {Q5_1} {Q5_1.shown} {Q5_1=='s'}
F Array (Flexible) - Reihen-Format Q6 F1-F5 1-5 {Q6_F3} {Q6_F3.shown} {Q6_F3==4}
E Array (Vergrößern/Gleich/Verringern) Radio-Buttons Q7 1-7 I,S,D {Q7_4} {Q7_4.shown} {Q7_4=='D'}
: Array (Multi Flexi) 1 To 10 Q8 ls1,todo,ls2 min,max,avg {Q8_ls1_max} {Q8_ls2_avg.shown} {Q8_ls2_min==7}
; Array (Multi Flexi) Text Q9 hp,st,sw 1st,2nd,3rd {Q9_hp_3rd} {Q9_hp_3rd.shown} {Q9_hp_3rd=='Peter'}
C Array (Ja/Unsicher/Nein) Radio-Buttons Q10 1-5 Y,N,U {Q10_1} {Q10_1.shown} {Q10_3=='Y'}
X Boilerplate Frage Q11 {Q11.shown}
D Datum Q12 {Q12} {Q12.shown}
* Gleichung Q13 {Q13} {Q13.shown} {Q13>5}
~124~ Dateiupload (zeichnet Anzahl der hochgelandenen Dateien auf) Q14 {Q14} {Q14>0}
G Geschlechter Drop-Down Liste Q15 M,F {Q15} {Q15.shown} {Q15=='M'}
U Rießiger Freier Text Q16 {Q16} {Q16.shown} {strlen(Q16)>100}
I Sprach-Frage Q17 {Q17} {Q17.shown} {Q17=='en'}
! Liste - Dropdown Q18 1-5 {Q18} {Q18.shown} {Q18==3}
L Drop-Down/Radio-Button Liste Q19 A-Z {Q19} {Q19.shown} {Q19=='X'}
O Drop-Down Liste mit Kommentar/Radio-Button List + Texfeld Q20 A-F {Q20},{Q20_comment} {Q20.shown} {Q20=='B'}
T Langer Freier Text Q21 {Q21} {Q21.shown} {strstr(Q21,'hello')>0}
M Mehrere Choice Checkbox Q22 A-F {Q22_E} {Q22_E.shown} {Q22_E=='Y'}
P Mehrere Choice Checkbox mit Kommentar + Text Q23 A-F {Q23_D}, {Q23_D_comment} {Q23_D.shown} {!is_empty(Q23)}
K Mehrere Zahlenmäßige Frage Q24 self,mom,dad {Q24_self} {Q24_self.shown} {Q24_self>30}
Q Mehrere Kurztexte Q25 A-F {Q25_B} {Q25_B.shown} {substr(Q25_B,1,1)=='Q')}
N Zahlenmäßiger-Fragen-Typ Q26 {Q26} {Q26.shown} {Q26 > 30}
R Ranking-Stil Q27 1-4 {Q27_1} {Q27_1.shown} {Q27_1==3}
S Kurzer freier Text Q28 {Q28} {Q28.shown} {Q28=='mine'}
Y Ja/Nein Radio-Buttons Q29 {Q29} {Q29.shown} {Q29=='Y'}

The reserved 'this', 'self', and 'that' variables

Quite often, you want to evalute all parts of a question, such as counting how many subquestions have been answered, or summing the scores.  Other times, you want to process just certain rows or columns of a question (such as getting the row or column sums and storing them in the database).  These reserved variables make that process relatively painless.

The 'this' variable is used exclusively within the "Whole question validation equation" and "Sub-question validation equation" advanced question options.  It expands to the variable names of each of the cells within those questions.  So, if you want to make sure that each entry is greater than three, you would set the "Sub-question validation equation" to (this > 3).

The 'self' and 'that' variable are more powerful, and serve as macros which are expanded prior to processing equations.  The syntax choices are:

  • self
  • self.suffix
  • self.sub-selector
  • self.sub-selector.suffix

suffix is any of the normal qcode suffixes (e.g. NAOK, value, shown)

sub-selector is one of:

  • comments - only subquestions that are comments (e.g., from multiple choice with comment and list with comment)
  • nocomments - only subquestions that are not comments
  • sq_X - where X is a row or column identifier. Only subquestions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....
  • nosq_X - where X is a row or column identifier. Only subquestions not matching pattern X are selected. Note that search is done on complete code identifier, then nosq_X match and does not include subquestions nX, X, Xn

Examples:

  • Has any part of a question been answered?  {count(self.NAOK)>0}
  • What is the assessment score for this question?  {sum(self.value)}

You can also use these to get row and column totals.  Say you have a array of numbers with rows A-E and columns 1-5.

  • What is the grand total?  {sum(self.NAOK)}
  • What is the total of row B?  {sum(self.sq_B.NAOK)}
  • What is the total of column 3? {sum(self.sq_3.NAOK)}

The 'that' variable is like the 'self' variable, but lets you refer to other questions.  Its syntax is:

  • that.qname
  • that.qname.suffix
  • that.qname.sub-selector
  • that.qname.sub-selector.suffix

qname is the question name without any subquestion extensions.  So, say you create a question 'q1', that is its qname

Examples:

  • Has any part of question q1 been answered?  {count(that.q1.NAOK)>0}
  • What is the assessment score for q2?  {sum(that.q2.NAOK)}
  • What is the grand total of q3? {sum(that.q3.NAOK)}
  • What is the total of row C in q4?  {sum(that.q4.sq_C.NAOK)}
  • What is the total of column 2 in q4? {sum(that.q4.sq_2.NAOK)}

The 'self' and 'that' variables can be used in any relevance,  validation, or tailoring.

The one caveat is that when you use the Show Logic File feature, it will show you the expanded value of 'self' and 'that'.  This lets you see the actual equation that will be generated so that you (and Expression Manager) can validate that the variables exist.  This may seem confusing since you may see quite lenghty equations.  However, if you edit the question, you will see the original equation using 'self' and/or 'that'

Also note that you should not use these variables if (a) you want to explicitly name each variable used in an equation, or (b) use variables that do not have subquestions (e.g. single response questions).  In those cases, prefixing a variable with 'that' is overkill, and you run the risk of getting unexpected results.

Usage of NAOK

NAOK --> "Not Applicable" (NA) is alright (OK)

Using NAOK, means that all or some of the variables are irrelevant (e.g. "Not Applicable" (NA) is alright (OK)).

When you put some variable from question in any equation : if this question (or subquestion) is hidden by condition : this disable all equation.

For example : count(Q1_SQ1,Q1_SQ2,Q1_SQ3,Q1_SQ4) give always an empty string if one subquestion of Q1 is filtered. To count the number of checked subquestion in such question can be count(Q1_SQ1.NAOK,Q1_SQ2.NAOK,Q1_SQ3.NAOK,Q1_SQ4.NAOK). If the sub question is hidden :Expression manager return an empty string.

Without NAOK : if one question or one subquestion is hidden : Expression Manager return always an empty string, same to return false.

The .shown always use the NAOK system (empty string if hidden) but if you need the code of the answer : it's always a good idea to add .NAOK after the question code. Except if you need it and know what you do.

Another example and information is provided at Overriding Cascading Conditions

Zugriff auf Funktionen

Der Ausdrucksmanager liefert Zugang zu mathematischen, zeichenketten und nutzerdefinierten Funktionen, wie folgend gezeigt. Er hat PHP und JavaScript Äquivalenten für diese Funktionen, sodass diese server- und clientsetig identisch arbeiten. Es ist einfach neue Funktionen hinzuzufügen.

Implementierte Funktionen

Die folgenden Funktionen sind momentan verfügbar:

Funktion Bedeutung Syntax
abs Absoluter Wert number abs(number)
acos Arkuskosinus number acos(number)
die Funktion addslashes Quote string with slashes string addslashes(string)
asin Arkussinus number asin(number)
atan Arkustangens number atan(number)
atan2 Arkustangens zweier Variablen number atan2(number, number)
ceil Aufrunden number ceil(number)
checkdate Gibt true(1) zurück, wenn es ein nach dem Gregorianischen Kalender gültiges Datum ist bool checkdate(month,day,year)
cos Kosinus number cos(number)
date Formatiere eine lokales Datum/Zeit string date(format [, timestamp=time()])
exp Berechnet den Exponenten von e number exp(number)
floor Abrunden number floor(number)
gmdate Ein GMT Datum/Zeit formatieren string gmdate(format [, timestamp=time()])
html_entity_decode Konvertiert alle HTML Zeichen in geeignete Zeichen (immer mit ENT_QUOTES und UTF-8) string html_entity_decode(string)
htmlentities Wandelt alle geeigneten Zeichen in entsprechende HTML-Zeichen (immer mit ENT_QUOTES und UTF-8) string htmlentities(string)
expr_mgr_htmlspecialchars Konvertiere Sonderzeichen in HTML-Zeichen (immer mit ENT_QUOTES und UTF-8) string htmlspecialchars(string)
expr_mgr_htmlspecialchars_decode Konvertiere HTML-Sonderzeichen zurück in Zeichen (immer mit ENT_QUOTES und UTF-8) string htmlspecialchars_decode(string)
idate Formatiere Zeit / Datum als ganze Zahl string idate(string [, timestamp=time()])
if Excel-Style if(test,result_if_true,result_if_false) if(test,result_if_true,result_if_false)
implode Verbindet Array-Elemente mit einem String string implode(glue,arg1,arg2,...,argN)
intval Bekomm den ganzzahligen Wert einer Variablen int intval(number [, base=10])
is_bool Prüft ob eine Variable ein Boolean ist bool is_bool(var)
is_empty Bestimmen Sie, ob eine Variable als leer betrachtet wird bool is_empty(var)
is_float Prüft ob die Variable ein Float ist bool is_float(var)
is_int Prüft ob die Variable ein Integer ist bool is_int(var)
is_nan Prüft ob die Variable eine Nummer ist bool is_nan(var)
is_null Prüft ob eine Variable NULL ist bool is_null(var)
is_numeric Prüft ob eine Variable eine Zahl oder ein numerischer String ist bool is_numeric(var)
is_string Prüft ob die Variable ein String ist bool is_string(var)
list Gibt eine komma-seperierte List der Werte zurück string list(arg1, arg2, ... argN)
log Natürlicher Logarithmus number log(number)
ltrim Entfernt Leerzeichen (oder andere Zeichen) vom Anfang eines Strings string ltrim(string [, charlist])
max Findet den höchsten Wert number max(arg1, arg2, ... argN)
min Findet den niedrigsten Wert number min(arg1, arg2, ... argN)
mktime UNIX-Timestamp/Zeitstempel für ein Datum (jedes der 6 Argumente ist optional) number mktime([hour [, minute [, second [, month [, day [, year ]]]]]])
nl2br Fügt HTML-Zeilenumbrüche vor allen Zeilenumbrüchen eines Strings string nl2br(string)
number_format Formatiert eine Zahl mit Tausender-Gruppierung string number_format(number)
pi Wert von pi number pi()
pow Exponentialausdruck number pow(base, exp)
quoted_printable_decode Konvertiert einen quoted-printable String in einen 8-Bit-String string quoted_printable_decode(string)
quoted_printable_encode Konvertiert einem 8-Bit-String in einen quoted-printable String string quoted_printable_encode(string)
quotemeta Zitat Metazeichen string quotemeta(string)
rand Generiere eine Zufallszahl int rand() OR int rand(min, max)
round Rundet eine Zahl auf einer optionalen Genauigkeit number round(val [, precision])
rtrim Entfernt Leerzeichen (oder andere Zeichen) vom Ende eines Strings string rtrim(string [, charlist])
sin Sinus number sin(arg)
sprintf Gibt einen formatierten String zurück string sprintf(format, arg1, arg2, ... argN)
sqrt Quadratwurzel number sqrt(arg)
stddev Berechne die Sample-Standardabweichung für die Liste der Nummern number stddev(arg1, arg2, ... argN)
str_pad Fülle einen String auf eine bestimmte Länge mit einem anderen String string str_pad(input, pad_length [, pad_string])
str_repeat Wiederhole einen String string str_repeat(input, multiplier)
str_replace Ersetzen Sie alle Vorkommen des Suchstrings mit dem Ersatz-String string str_replace(search, replace, subject)
strcasecmp Binärsichere Groß-und Kleinschreibungs String-Vergleich int strcasecmp(str1, str2)
strcmp Binärsicherer String-Vergleich int strcmp(str1, str2)
strip_tags Entfernt HTML-und PHP-Tags aus einem String string strip_tags(str, allowable_tags)
stripos Findet das erste Vorkommen eines  Case-Insensitiven Strings int stripos(haystack, needle [, offset=0])
stripslashes Entfernt die Anführungszeichen einer Zeichenfolge in Anführungszeichen string stripslashes(string)
stristr Case-Insensitiven strstr string stristr(haystack, needle [, before_needle=false])
strlen String-Länge int strlen(string)
strpos Findet das erste Vorkommen eines Strings int strpos(haystack, needle [ offset=0])
strrev Umkehren einer Zeichenfolge string strrev(string)
strstr Findet das erste Vorkommen eines Strings string strstr(haystack, needle)
strtolower Setzt einen String in Kleinbuchstaben string strtolower(string)
strtoupper Setzt einen String in Großbuchstaben string strtoupper(string)
substr Gibt einen Teil eines Strings zurück string substr(string, start [, length])
sum Berechne die Summe der Werte in einem Array number sum(arg1, arg2, ... argN)
tan Tangens number tan(arg)
time Liefert die aktuelle UNIX-Timestamp number time()
trim Entfernt Leerzeichen (oder andere Zeichen) vom Anfang und Ende eines Strings string trim(string [, charlist])
ucwords Großbuchstaben den ersten Buchstaben jedes Wortes in einem String string ucwords(string)

Geplante Funktionen (oder die zumindest in Betracht gezogen werden)

Andere Funktionen, die geplant (oder die zumindest in Betracht gezogen) sind, aber bis jetzt noch nicht enthalten sind, sind in der folgenden Liste aufgezählt. Einige von diesen sind für die Abwärtskompatibilität mit anderen Umfragetools.

Syntax Bedeutung Kommentar
count(X,...) die Anzahl der relevanten Werte
e() liefert den Wert von e
formatDate(X,PAT) Gibt den String Wert des Datums, formatiert nach dem Java Datenformat PAT
formatNumber(X,PAT) Liefert den String Wert der Zahl X, formatiert nach Java Zahlenformat PAT
getAnsOption(X) Liefert den Text entsprechend der gewählten Option für die Antwort X das Gleiche wie X.shown
getAnsOption(X,Y) Liefert den Text entsprechend der Option bei Index Y des Knoten X
getRelevance(X) gibt die Relevanz Gleichung für Frage X
getStartTime() gibt das Datum entsprechend der Systemzeit als das Interview begonnen wurde
getType(X) liefert den String-Namen des Datentyps - e.g. *NA* bei isNA()
gotoFirst() springt zu der ersten Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems
gotoNext() springt zu der nächsten Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems
gotoPrevious() springt zu der vorherigen Reihe relevanter Fragen - dies verstößt gegen den normalen Ablauf des Systems
isAnswered(X) liefert true, wenn die Antwort weder (*UNASKED* noch *INVALID*) ist, und ist nicht leer, wenn die Antwort vom Typ STRING ist
isAsked(X) liefert true, wenn die Antwort weder *NA*, *INVALID*, noch *UNASKED* ist
isInvalid(X) liefert true, wenn die Antwort vom Typ *INVALID* ist
isNA(X) liefert true, wenn die Antwort vom Typ *NA* ist
isNotUnderstood(X) liefert true, wenn die Antwort vom Typ *HUH* ist
isRefused(X) liefert true, wenn die Antwort vom Typ *REFUSED* ist
isSpecial(X) liefert true, wenn die Antwort vom Typ *UNASKED*, *NA*, *REFUSED*, *INVALID*, *UNKNOWN*, oder *HUH* ist
isUnknown(X) liefert true, wenn die Antwort vom Typ *UNKNOWN* ist
jumpTo(X) Sprung zur Gruppe mit der benannten Frage - dies verstößt gegen den normalen Ablauf des Systems
jumpToFirstUnasked() Springt zur ersten ungestellten Frage - unter Umgehung vorher beantworteter Fragen - dies verstößt gegen den normalen Ablauf des Systems
lastIndexOf(X,Y) liefert den letzten Index (Basis 0) des Strings Y im String X. Gibt -1, wenn Y nicht innerhalb von X enthalten ist
list(X,...) ein String, der eine kommaseperierte Liste positiver Werte unter Abtrennung der letzten beiden durch "and"
mean(X,...) gibt den Mittelwert einer Liste von Werten
numAnsOptions(X) gibt die Anzahl der Antwortmöglichkeiten, die Frage X hat
orlist(X,...) ein String mit einer Komma getrennten Liste der positiven Werte, unter Abtrennung der letzten beiden durch "or"
parseDate(X,PAT) liefert den Datumswert von String X mit dem Java Datumsformat PAT geparsed
parseNumber(X,PAT) liefert den Nummernwert von String X mit dem Java Datumsformat PAT geparsed
regexMatch(X,Y) liefert Boolean, ob String X dem Muster des regulären Ausdrucks Y entspricht
showAllResponsesExcept(questionList,attributeList,attributeTitleList) questionList = Pipe-separierte Liste von Frage-Identifiern; attributeList = Pipe-separierte Liste von Attributen (wie question#, title, text, type - So kannst du entscheiden, was gezeigt werden soll); attributeTitleList = Pipe-separierte Liste von Tabellen-Headern, sodass Sie den Bericht Internationalisieren können.
showTheseResponses(questionList,attributeList,attributeTitleList) questionList = Pipe-separierte Liste von Frage-Identifiern; attributeList = Pipe-separierte Liste von Attributen (wie question#, title, text, type - So kannst du entscheiden, was gezeigt werden soll); attributeTitleList = Pipe-separierte Liste von Tabellen-Headern, sodass Sie den Bericht Internationalisieren können.

Der Ausdrucksmanager weiß, welche Variablen lokal sind

Um ordnungsgemäß JavaScript für die Seite zu konstruieren muss der Ausdrucksmanager wissen, welche Variablen auf der Seite gesetzt sind und wie ihre ID ist (e.g. für document.getElementById(x)). Er muss auch wissen, welche Variablen auf anderen Seiten gesetzt sind (sodass sichergestellt werden kann, dass die benötigten <input type='hidden' value='x'> Felder präsent und ausgefüllt sind).

Kaskadierende Bedingungen

Um es genauer zu sagen, wenn eine der Variablen irrelevant ist, wird die gesamte Gleichung irrelevant (false). In der folgenden Tabelle bedeutet N/A zum Beispiel, dass eine der Variablen nicht relevant war.

Operator Beispiel a b Ergebnis
+ (unary) +a N/A false
- (unary) -a N/A false
! !a N/A false
== (oder eq) a == b N/A 5 false
== (oder eq) a == b N/A 0 false
== (oder eq) a == b N/A N/A false
!= (oder ne) a != b N/A 5 false
!= (oder ne) a != b N/A N/A false
!= (oder ne) a != b N/A 0 false
> (oder gt) a > b N/A 5 false
>= (oder ge) a >= b N/A 5 false
< (oder lt) a < b N/A 5 false
<= (oder le) a <= b N/A 5 false
and a and b N/A 5 false
and a and b N/A N/A false
or a or b N/A N/A false
or a or b N/A 5 false
+ a + b N/A 5 false
* a * b N/A 5 false
/ a / b 5 N/A false
() (a) N/A false
(exp) (a && b) N/A 5 false
(exp) op (exp) (b + b) > (a && b) N/A 5 false
function sum(a,b,b) N/A 5 false
function max(a,b) N/A 5 false
function min(a,b) N/A 5 false
function implode(', ',a,b,a,b) N/A 5 false
function if(a,a,b) N/A 5 false
function is_empty(a) N/A false
function is_empty(a) 0 (oder leer) true
function !is_empty(a) N/A false

Überschreiben kaskadierender Bedingungen

Nehmen wir an, du möchtest eine fortlaufende Summe aller relevanten Antworten. Du könntest vielleicht versuchen die Gleichung {sum(q1,q2,q3,...,qN)} zu benutzen. Jedoch wird dieses intern zuLEMif(LEManyNA('q1','q2','q3',...,'qN'),,sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN')) übersetzt. Sodass wenn irgendeiner der Werte q1-qN irrelevant ist, die Gleichung immer "false" zurückgeben wird. In diesem Fall wird die sum() Funktion 0 ausgeben, bis alle Fragen beantwortet sind.

Um dies zu umgehen, kann jede Variable ein ".NAOK" Suffix haben (welches bedeutet, dass "Keine Angabe" OK ist). In solchen Fällen tritt das folgenden Verhalten auf. Gehen wir davon aus, du hast eine Variable q1.NAOK

  1. q1 ist nicht dem LEManyNA() Satz hinzugefügt
  2. LEMval('q1') wird weiterhin validieren ob die Antwort relevant ist, und wird zurückgeben, wenn sie es nicht ist (somit werden einzelne irrelevante Antworten ignoriert, anstatt dass sie den gesamten Ausdruck auf 0 setzen)

Somit ist die Lösung zu dem laufende-Summe-Problem, die Gleichung sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK) zu benutzen.

Die Benutzung des .NAOK Suffixes lässt Autoren auch Umfragen gestalten, die verschiedene mögliche Pfade haben, aber dies kommt später. Zum Beispiel, sagen wir das Subjekt beantwortet die Umfrage in einem Umfang außerhalb des normalen Antwortbereiches. Der Autor könnte das Subjekt benachrichtigen, dass es möglicherweise keine richtigen Ergebnisse bekommen würde und dann fragen ob es so wirklich mit der Umfrage fortfahren wolle. Wenn es Ja sagt, wird der Rest der Fragen gezeigt. Die Bedingungen der restlichen Fragen würden validieren, ob die ersten Antworten in einem normalen Bereich beantwortet wurden, oder ob das Subjekt Ja zu der Frage gesagt hat, die nur dann relevant ist, wenn die anderen Antworten außerhalb des normalen Bereiches lagen.

Wie unterstützt der Ausdrucksmanager Bedingungs-Mikro-Anpassungen?

Hier ist ein Beispiel für Mikro-Anpassungen (der Frage-Typ=='expr' bedeutet Gleichung):

Frage-Nummer Relevanz Frage-Typ Frage
name 1 text Wie heißen Sie?
age 1 text Wie alt sind Sie?
badage age expr {(age<16) oder (age>80)}
agestop badage message Sorry, {name}, Sie sind zu {if( (age<16),'jung',if( (age>80),'alt','middle-aged') ) } für diesen Test.
kids !badage yesno Haben Sie Kinder?
parents 1 expr {!badage && kids=='Y'}
numKids parents text Wie viele Kinder haben Sie?
kid1 parents && numKids >= 1 text Wie alt ist Ihr erstes Kind?
kid2 parents && numKids >= 2 text Wie alt ist Ihr zweites Kind?
kid3 parents && numKids >= 3 text Wie alt ist Ihr drittes Kind?
kid4 parents && numKids >= 4 text Wie alt ist Ihr viertes Kind?
kid5 parents && numKids >= 5 text Wie alt ist Ihr fünftes Kind?
sumage 1 expr {sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK,kid5.NAOK)}
report parents yesno {name}, Sie haben behauptet Sie seien {age} und hätten {numKids}.  Die Summe der Alter ihrere ersten {min(numKids,5)} Kinder ist {sumage}

Alle diese Fragen können auf einer einzelnen Seite sein (e.g. in der gleichen Gruppe) und nur relevante Fragen werden angezeigt. Weiterhin, indem sie das Alter der Kinder eintragen wird der sum() Ausdruck in der letzten Frage dynamisch die Seite aktualisieren.

Der Ausdrucksmanager stellt diese Funktionalität zur Verfügung indem jeder Ausdruck mit einem benannten Element eingefasst wird. Jedes mal wenn sich ein Wert verändert, berechnet es den Ausdruck der in dem Element erscheinen sollte neu und aktualisiert die Anzeige. Sie können duzende oder sogar hunderte von solchen zugeschnittenen Elementen auf der gleichen Seite haben und die Seite wird diese wieder innerhalb einer einzigen Bildschirmaktualisierung anzeigen.

Abbildung von LimeSurvey 1.91+ zur Ausdrucksmanager Funktionalität

Altes Feature Neues Feature Kommentare
Conditions Relevance Du kannst sehr komplexe bedingte Gleichungen benutzen und auf ein breiteres Spektrum von Variablen zugreifen
Assessments Equation Alle Bewertungs-Scores können in einer Gleichung restrukturiert werden. Dies stellt sicher, dass sowohl die Partitur in die Datenbank geschrieben wird, und auch dynamische Änderungen am Score-Wert auf der aktuellen Seite gesehen werden können
Replacements Ausdrucksmanager Die Kern-Engine übernimmt die Eingabezeichenfolgen und behandelt alles, was in geschweiften Klammern steht als Ausdruck - so kümmert sie sich um alle alten Ersatz-Typen. Um zu verhindern, dass eingebetteter JavaScript Code durcheinandergebracht wird, verarbeitet der Ausdrucksmanager nur Conten zwischen geschweiften Klammern, solange (a) es keine anführenden Leerzeichen in den geschweiften Klammern gibt - e.g. {expr} ist ein Ausdruck, aber { expr}, {expr }, und { expr } sind keine Ausdrücke. Zusätzlich verarbeitet er keine geschweiften Strings in geschweiften Strings (e.g. {list('hi','there {braces}'} führt zu "hi there {braces}"). Er ignoriert auch escapete geschweifte Klammern (e.g. \{this is not an expression\})
Validation Ausdrucksmanager Der Plan ist die aktuellen min/max Frage-Attribute zu nehmen und den Ausdrucksmanager sie verarbeiten lassen. So können die min/max Werte selbst Ausdrücke sein.

Syntax Highlighting

Um bei der Eingabe und dem Validieren von Ausdrücken zu helfen, liefert der Ausdrucksmanager eine Syntax Hervorhebung mit den folgenden Features mit sich:

Farbe Bedeutung Tooltip Kommentar
hellbrauner Hintergrund die ganze Gleichung none Alles in geschweiften Klammern das als eine Gleichung (z.B. gibt es keine führenden oder nachgestellten Leerzeichen) erkannt wird, wird mit einem hellbraunen Hintergrund markiert werden, um es vom umgebenden Text zu unterscheiden
blaue Fettschrift Funktionsname Bedeutung und zulässige Syntax Funktionsnamen, oder Dinge, die Funktionen sein sollten, da sie durch eine öffnende Klammer gefolgt werden, werden fett blau angezeigt. Tooltips zeigen die Bedeutung und die zulässige Syntax für die Funktion.
grauer Text string none Strings mit einfachen oder doppelten Anführungszeichen werden in grauer Schrift angezeigt
fetter kastanienbrauner Text Variable auf der aktuellen Seite JavaScript ID; Wert Jede Variable, die auf der aktuellen Seite gesetzt ist, wird fett kastanienbraun angezeigt. Das Bewegen der Maus über den Wert, zeigt eine Meldung im Pop-up-Tooltip mit der JavaScript-ID (sofern vorhanden), und den aktuellen Wert (oder leer, wenn nicht gesetzt)
fetter grüner Text Variable auf einer andere Seite gesetzt JavaScript ID; Wert Jede Variable, die auf einer anderen Seite (entweder vor oder nach der aktuellen) gesetzt ist, wird in fetter grüner Schrift angezeigt. Der Tooltip zeigt den JavaScript-Namen (sofern vorhanden), und den Wert (falls bekannt). Beachten Sie, dass TOKEN und INSERTANS Ersatz keine JavaScript-IDs haben.
roter Text Zuweisungsoperatoren Warnung Wenn Sie eine der Zuweisungsoperatoren (=,+=,-=,*=,/=) benutzen, wird dieser in roter Schrift angezeigt werden. Dies soll Ihnen helfen, unabsichtliche Neuzuweisungen von Werten zu verhindern, wenn z.B. in Wirklichkeit nur validiert werden sollte, ob a == b ist, anstatt den Wert direkt zuzuweisen (a = b).
normaler schwarzer Text Satzzeichen none Alle andere Zeichensetzung im Ausdruck wird als normaler schwarzer Text angezeigt.
rot umkastelt Syntaxfehler Beschreibung des Fehlers Alle erkannten Syntax-Fehler werden durch den roten Kasten rund um den Fehler dargestellt. Der Tooltip zeigt den Fehler. Beispiele hierfür sind falsch gesetzte Klammern, die Verwendung von undefinierten Funktionen, weitergabe der falschen Anzahl von Argumenten an Funktionen, schlecht strukturierte Ausdrücke (z.B. fehlende Operatoren zwischen Variablen), der Versuch, Werte einer Read-Only oder nicht existierenden Variablen zuzuweisen oder die Verwendung ungeeigneten Syntaxes

Beziehung zu LimeSurvey Ideen / Feature-Requests

To help with entering and validating expressions, EM provides syntax highlighting with the following features:

Types and Meanings of Syntax Highlighting

Der Ausdrucksmanager liefert vollständige oder teilweise vollständige Lösungen zu jedem der Folgenden:

Zusätzliche Themen

Expression Manager sample surveys

Use Cases and HowTos

Step-by-Step examples

Reference for Developers

RoadMap/Status/ToDo List