Actions

ExpressionScript How-tos/nl: Difference between revisions

From LimeSurvey Manual

m (FuzzyBot moved page Expression Manager how-tos/nl to ExpressionScript How-tos/nl without leaving a redirect: Part of translatable page "Expression Manager how-tos")
(Updating to match new version of source page)
Line 1: Line 1:
<languages />
<languages />
__TOC__
__TOC__




=Samenvatting van eerdere uitleg over Expressiebeheer=
=Overview of what has been previously explained=




Als je de index van de LimeSurvey-handleiding tot nu toe hebt gevolgd, betekent dit dat je de [[Expression_Manager _-_ presentation/nl#Definities|LimeSurvey-terminologie]] al kent. We hebben expressies en variabelen behandeld om te laten zien hoe we onze enquêtes kunnen verbeteren. Daarna zijn we overgegaan op de manieren en betekenissen van [[Expression_Manager _-_ presentation/nl#Syntax markeren|syntax highlighting]] om te laten zien hoe je syntaxisfouten kunt verbeteren.  
If you have followed so far the structure of the LimeSurvey manual, it means that you already the [[Expression_Manager_-_presentation#Key_Definitions|LimeSurvey terminology]]. Next, we covered expressions and variables in order to learn how to enhance our surveys. In the next part, we moved to the types and meanings of [[Expression_Manager_-_presentation#Syntax Highlighting|syntax highlighting]] to learn how to correct syntax errors.  


Met dit als kennis kunnen we naar de voorbeelden gaan en laten zien hoe in LimeSurvey expressies werken.  
With these basic notions covered, we could move towards examples and explaining how expressions work within LimeSurvey.  




=Syntax highlighting=
=Syntax Highlighting=




De volgende screenshots geven voorbeelden zonder de tooltips. Een tooltip is een informatieve box die wordt weergegeven wanneer je de muisaanwijzer op een vetgedrukt woord plaatst.
The following screenshots give examples, but do not show the values of the tooltips. A tooltip is an informative box which is displayed whenever you hover the mouse over any bold colored words.


Door de markering van de syntaxis is het eenvoudig om correcte gecompliceerde expressies samen te stellen. Hoewel het LimeSurvey-team van plan is om een ​​grafische gebruikersinterface te maken, kun je de bestaande highlighting gebruiken om fouten snel te zien en op te lossen. Je kunt ook de tooltips gebruiken om de nauwkeurigheid van de expressies te valideren (bijv. bevestig dat je de gewenste variabele(n) hebt geselecteerd).
Because of this syntax highlighting, it is very easy to compose correct expressions, even the ones that are complicated. Although the LimeSurvey team plans to try to build an Expression Builder GUI, you can use the existing syntax-highlighting to quickly identify and fix typos. You can also use the tooltips to validate the accuracy of your expressions (e.g., confirm you have selected the desired variable(s)).


In elk voorbeeld zijn er drie kolommen:
In each of the examples, there are three columns:
#Source : dit is de onbewerkte tekst die je zou invoeren in het LimeSurvey-vragenveld.
#Source - this is the raw text that you would enter into the LimeSurvey question field
#Pretty Print : dit is hetzelfde met syntaxis-markering.
#Pretty Print - this is the syntax-highlighted equivalent of what you entered
#* Merk op dat expressies worden weergegeven met een geelbruine achtergrond, maar niet omringd worden door accolades in deze markering.
#*Note that Expressions are shown with a tan background, but not surrounded by curly braces in this highlighting.
#* Aangezien expressiebeheer recursieve vervanging ondersteunt, zou het tonen van accolades in de markering syntaxisfouten veroorzaken.
#*Since EM supports recursive substitution, showing curly braces in the highlighting would cause syntax errors
#Result : dit is de output die wordt gegenereerd wanneer expressiebeheer de invoer verwerkt.
#Result - this is the output generated when EM processes the source
#* Alles dat goed vervangen kan worden, vervangen is.
#*Everything that can be properly substituted is
#* Expressies met fouten worden in-line getoond, met syntax highlighting. Fouten worden getoond met een rood-omlijnd veld.
#*Expressions with errors are shown in-line, with syntax highlighting. Errors are surrounded by a red-lined box.




== Juiste syntaxis ==
==Proper Syntax==




Hieronder staan voorbeelden:
You may find below examples of proper syntax:
#Waarden: geeft aan dat bekende variabelen een kleurcode hebben afhankelijk van of ze op de huidige pagina zijn ingesteld. INSERTANS xxxx: in oude stijl krijgt zijn eigen kleurcoderingsstijl
#Values: shows that known variables are color coded according to whether are set on the current page. Old-style INSERTANS:xxxx gets its own color-coding style
#Vraagattributen: laat zien dat de puntnotatie toegang heeft tot een aantal eigenschappen van vragen.
#Question Attributes: shows that dot notation can access some properties of questions
#Berekeningen: laat zien dat eenvoudige en complexe berekeningen worden ondersteund.
#Math: shows that basic and complex calculations are supported
#Tekstverwerking: toont enkele van de beschikbare tekstverwerkingsfuncties.
#TextProcessing: shows some of the available text-processing functions
#Datum: toont twee van de beschikbare datumgerelateerde functies.
#Dates: shows two of the available date-related functions
#Conditioneel: toont het gebruik van de if-functie. De keuzes kunnen worden genest.
#Conditional: shows the usage of the if() function. The choices can be nested.
#Maatwerk: u kunt een rapport volledig aanpassen op basis van eerdere waarden.
#Tailored paragraph: you can completely customize a report based upon prior values
#processen binnen strings: toont aan dat het vervangingen binnen strings kan uitvoeren. Dit voorbeeld genereert een aangepaste afbeeldingsnaam.
#EM processes within strings: shows that it can do substitutions within strings. This example generates a tailored image name.
#Expressiebeheer verwerkt accolades niet zoals deze: laat zien dat als de accolades worden geëscaped of er een witruimte is tussen de expressie en de accolades, de expressie wordt dan genegeerd.
#EM doesn't process curly braces like these: shows that if the curly braces are escaped, or there is a white space between the expression and the curly braces, EM ignores the expression.




Line 48: Line 46:




==Syntaxis met fouten==
==EM Syntax Containing Errors==




Hier zijn voorbeelden van veelvoorkomende fouten bij het gebruik van expressies. Kijk of er een tooltip met informatie is.
Here are examples of common errors when typing EM expressions. Note that the tooltips provide additional information.
#Inline JavaScript zonder spatie na accolades.
#Inline Javascript that forgot to add spaces after curly brace
#* Omdat "document.write" direct na een accolade staat, wordt het door Expressiebeheer als een expressie gezien en komt er een rode box om "document" en "write" omdat het ongedefinieerde variabele en functies zijn.
#*Since "document.write" appears right after a curly brace, EM thinks it is an expression, and red-boxes "document" and "write" since they are undefined variable and functions, respectively
# Onbekende / verkeerd gespelde variabelen, functies en operatoren.
#Unknown/Misspelled variables, functions and operators
#* Hier zijn we vergeten dat we de variabelenaam "gender" gebruiken in plaats van "sex". Ook is '++' geen ondersteunde operator.
#*Here we forgot that we are using the variable name "gender" instead of "sex", but EM catches that error. It also red-boxes '++', since that is not a supported operator.
# Waarschuwt als use = in plaats van eq, of voer waarde-toewijzingen uit.
#Warns if use = instead of eq, or perform value assignments
#* Merk op dat de '=' en '+ =' in rode tekst zijn in plaats van in zwart. Als je er met de muis overheen beweegt, zie je waarschuwingen dat je een waarde toekent.
#*Note that the '=' and '+=' are in red text instead of black. If you hover the mouse over them, you will see warnings that you are assigning a value.
#Verkeerd aantal argumenten bij functies.
#Wrong number of arguments for functions
#* If-functie heeft 3 argumenten, maar hier staan er 4, dus is er een rode box bij de "if", de ondersteunde syntaxis wordt weergeven.
#*if() takes 3 arguments, but it has been given 4, so hovering over the red-boxed "if" will explain the error and show the supported syntax
#* sum-functie heeft een onbeperkt aantal argumenten, maar we hadden een komma achteraan voor de sluithaakjes, dus dat is in het rood.
#*sum() takes an unlimited number of arguments, but we had a trailing comma before the closing parentheses, so that is red-boxed
# Niet-overeenkomende haakjes.
#Mismatched parentheses
#* Dit is een van de meest voorkomende fouten bij het schrijven van expressies.
#*This is one of the most common errors when writing expressions.
#* Hier ziet u twee voorbeelden van ontbrekende sluithaakjes en een voorbeeld van één sluithaakje te veel
#*This shows two examples of missing closing parentheses, and one example of having one too many closing parentheses.
#Niet ondersteunde syntaxis
#Unsuported syntax
#* Als je een operator of interpunctie gebruikt die niet wordt ondersteund, dan krijg je een rood vak.
#*If you use an operator or punctuation that EM does not support, it will red-box it.
# Ongeldige toewijzingen.
#Invalid assignments
#* Sommige variabelen zijn readWrite en kunnen hun waarden laten wijzigen. Andere zijn alleen-lezen.
#*Some variables are readWrite and can have their values changed. Others are read-only.
#* Als je de waarde van een alleen-lezen variabele probeert te wijzigen, dan mislukt dat.
#*If you try to change the value of a read-only variable, you can't. EM will red-box the attempt.
#* Als je probeert een waarde toe te kennen aan een expressie of een string, krijg je ook een foutmelding.
#*If you try to assign a value to an equation or a string, you will also get an error




Line 75: Line 73:




== "Live" voorbeelden van syntaxis markering met actieve tooltips ==
=="Live" examples of Syntax Highlighting with active tooltips==




<table border="1">
<table border="1">
<tr><th> Bron </th><th> Opmaak </th><th> Resultaat </th></tr><tr><td> <b>Hier is een voorbeeld van OK syntaxis met tooltips</b> <br> Hallo {if (geslacht == 'M', 'Mr.', 'Mevr.')} {achternaam}, het is nu {date ('g: i a', time ())}. Weet je waar je {sum (numPets, numKids)} kinderen en huisdieren zijn?
<tr><th>Source</th><th>Pretty Print</th><th>Result</th></tr><tr><td><b>Here is an example of OK syntax with tooltips</b><br>Hello {if(gender=='M','Mr.','Mrs.')} {surname}, it is now {date('g:i a',time())}. Do you know where your {sum(numPets,numKids)} children and pets are?


</td><td> <b>Hier is een voorbeeld van goede syntaxis met tooltips</b> <br> Hallo <span style="background-color: #eee8aa;"><span title="Excel-stijl if (test, result_if_true, result_if_false); if (test result_if_true, result_if_false)" style="color: blue; font-weight: bold">if</span> ( <span title="[java61764X1X5] [G: 2] [V: 110]: Wat is uw geslacht (man / vrouw) ?; value = M" style="color: green; font-weight: bold">geslacht</span> == <span title="" style="color: gray">'M'</span> , <span title="" style="color: gray">'Mr.'</span> , <span title="" style="color: gray">'Mevr.'</span> )</span> <span style="background-color: #eee8aa;"><span title="[java61764X1X1] [G: 1] [V: 20]: Wat is uw achternaam?; value = Smith" style="color: green; font-weight: bold">achternaam</span></span> , het is nu <span style="background-color: #eee8aa;"><span title="Formatteer een lokale datum / tijd; string date (format [, timestamp = time ()])" style="color: blue; font-weight: bold">date</span> ( <span title="" style="color: gray">'g: i a'</span> , <span title="Retourneer huidig UNIX-tijdstempel; nummer tijd ()" style="color: blue; font-weight: bold">time</span> ())</span> . Weet je waar je <span style="background-color: #eee8aa;"><span title="Bereken de som van waarden in een array; getalsom (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span> ( <span title="[java61764X1X4] [G: 2] [V: 50]: Hoeveel huisdieren heb je ?; waarde = 1" style="color: maroon; font-weight: bold">numPets</span> , <span title="[java61764X1X3] [G: 2] [V: 40]: Hoeveel kinderen heb je ?; waarde = 2" style="color: green; font-weight: bold">numKids</span> )</span> kinderen en huisdieren zijn?
</td><td><b>Here is an example of OK syntax with tooltips</b><br>Hello <span style="background-color: #eee8aa;"><span title="Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span>(<span title="[java61764X1X5][G:2][Q:110]: What is your gender (male/female)?; value=M" style="color: green; font-weight: bold">gender</span> == <span title="" style="color: gray">'M'</span>,<span title="" style="color: gray">'Mr.'</span>,<span title="" style="color: gray">'Mrs.'</span>)</span> <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:20]: What is your last/surname?; value=Smith" style="color: green; font-weight: bold">surname</span></span>, it is now <span style="background-color: #eee8aa;"><span title="Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span>(<span title="" style="color: gray">'g:i a'</span>,<span title="Return current UNIX timestamp; number time()" style="color: blue; font-weight: bold">time</span>())</span>. Do you know where your <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span> children and pets are?


</td><td> <b>Hier is een voorbeeld van goede syntaxis met tooltips</b> <br> Hallo <span id="LEMtailor_Q_40_1">Mr.</span> <span id="LEMtailor_Q_40_2">Smith</span> , het is nu 06:07 uur. Weet je waar je <span id="LEMtailor_Q_40_4">3</span> kinderen en huisdieren zijn?
</td><td><b>Here is an example of OK syntax with tooltips</b><br>Hello <span id="LEMtailor_Q_40_1">Mr.</span> <span id="LEMtailor_Q_40_2">Smith</span>, it is now 6:07 am. Do you know where your <span id="LEMtailor_Q_40_4">3</span> children and pets are?
</td></tr>
</td></tr>
<tr><td> <b>Dit zijn veelvoorkomende fouten, zodat je de tooltips kunt zien</b> <br> Variabelen die zijn gebruikt voordat ze zijn gedeclareerd: {notSetYet} <br> Onbekende functie: {iff (numPets> numKids, 1,2)} <br> Onbekende variabele: {sum (age, num_pets, numKids)} <br> Verkeerde # parameters: {sprintf ()}, {if (1,2)}, {date ()} <br> Wijs alleen-lezen-vars toe: {TOKEN: ATTRIBUTE_1 + = 10}, {name = 'Sally'} <br> Ongebalanceerde haakjes: {pow (3,4}, {(pow (3,4)}, {pow (3,4))}
<tr><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared: {notSetYet}<br>Unknown Function: {iff(numPets&gt;numKids,1,2)}<br>Unknown Variable: {sum(age,num_pets,numKids)}<br>Wrong # parameters: {sprintf()},{if(1,2)},{date()}<br>Assign read-only-vars:{TOKEN:ATTRIBUTE_1+=10},{name='Sally'}<br>Unbalanced parentheses: {pow(3,4},{(pow(3,4)},{pow(3,4))}


</td><td> <b>Dit zijn veelvoorkomende fouten, zodat je de tooltips kunt zien</b> <br> Variabelen die zijn gebruikt voordat ze zijn gedeclareerd: <span style="background-color: #eee8aa;"><span title="Deze variabele wordt pas gedeclareerd op een latere pagina; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Deze variabele wordt pas gedeclareerd op een latere pagina; Geen geldige expressie; [java61764X3X6] [G: 3] [Q: 200]: Wie wint de volgende verkiezing ?; value =?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span> <br> Onbekende functie: <span style="background-color: #eee8aa;"><span title="Ongedefinieerde functie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Ongedefinieerde functie" style="color: blue; font-weight: bold">iff</span></span> ( <span title="[java61764X1X4] [G: 2] [V: 50]: Hoeveel huisdieren heb je ?; waarde = 1" style="color: maroon; font-weight: bold">numPets</span> > <span title="[java61764X1X3] [G: 2] [V: 40]: Hoeveel kinderen heb je ?; waarde = 2" style="color: green; font-weight: bold">numKids</span> , 1,2)</span> <br> Onbekende variabele: <span style="background-color: #eee8aa;"><span title="Bereken de som van waarden in een array; getalsom (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span> ( <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">age</span> , <span title="ongedefinieerde variabele" style="border-style: solid; border-width: 2px; border-color: red;"><span title="ongedefinieerde variabele" style="color: red; font-weight: bold">num_pets</span></span> , <span title="[java61764X1X3] [G: 2] [V: 40]: Hoeveel kinderen heb je ?; waarde = 2" style="color: green; font-weight: bold">numKids</span> )</span> <br> Verkeerde # parameters: <span style="background-color: #eee8aa;"><span title="Functie moet ten minste één argument (en) bevatten; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie moet ten minste één argument (en) bevatten; Geen geldige expressie; Retourneer een geformatteerde string; string sprintf (formaat, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span> ()</span> , <span style="background-color: #eee8aa;"><span title="Functie ondersteunt dit aantal argumenten niet: 2. Functie ondersteunt zoveel argumenten, waarbij -1 = onbeperkt: 3; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie ondersteunt dit aantal argumenten niet: 2. Functie ondersteunt zo veel argumenten, waarbij -1 = onbeperkt: 3; Geen geldige expressie; Excel-stijl if (test, result_if_true, result_if_false); if (test result_if_true, result_if_false)" style="color: blue; font-weight: bold">if</span></span> (1,2)</span> , <span style="background-color: #eee8aa;"><span title="Functie ondersteunt dit aantal argumenten niet: 0. Functie ondersteunt zo veel argumenten, waarbij -1 = onbeperkt: 1,2; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie ondersteunt dit aantal argumenten niet: 0. Functie ondersteunt dit veel argumenten, waarbij -1 = onbeperkt: 1,2; Geen geldige expressie; Formatteer een lokale datum / tijd; string date (format [, timestamp = time ()])" style="color: blue; font-weight: bold">date</span></span> ()</span> <br> Wijs alleen-lezen-vars toe: <span style="background-color: #eee8aa;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie; ; value = worker" style="color: #996600; font-weight: bold">TOKEN: ATTRIBUTE_1</span></span> <span title="Een nieuwe waarde toewijzen aan een variabele" style="color: red; font-weight: bold">+ =</span> 10</span> , <span style="background-color: #eee8aa;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie; [java61764X1X1] [G: 1] [V: 10]: Wat is je voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span></span> <span title="Een nieuwe waarde toewijzen aan een variabele" style="color: red; font-weight: bold">=</span> <span title="" style="color: gray">'Sally'</span></span> <br> Ongebalanceerde haakjes: <span style="background-color: #eee8aa;"><span title="Haakjes niet gebalanceerd" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Haakjes niet gebalanceerd; Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span></span> (3,4</span> , <span style="background-color: #eee8aa;"><span title="Haakjes niet gebalanceerd" style="border-style: solid; border-width: 2px; border-color: red;">(</span> <span title="Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span> (3,4)</span> , <span style="background-color: #eee8aa;"><span title="Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span> (3,4) <span title="Extra rechterhaakje gedetecteerd" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>
</td><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared: <span style="background-color: #eee8aa;"><span title="This variable is not declared until a later page; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="This variable is not declared until a later page; Not a valid expression; [java61764X3X6][G:3][Q:200]: Who will win the next election?; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span><br>Unknown Function: <span style="background-color: #eee8aa;"><span title="Undefined function" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined function" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>Unknown Variable: <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Undefined variable" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined variable" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>Wrong # parameters: <span style="background-color: #eee8aa;"><span title="Function must have at least 1 argument(s); Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function must have at least 1 argument(s); Not a valid expression; Return a formatted string; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments: 2. Function supports this many arguments, where -1=unlimited: 3; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments: 2. Function supports this many arguments, where -1=unlimited: 3; Not a valid expression; Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments: 0. Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments: 0. Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression; Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>Assign read-only-vars:<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">+=</span>10</span>,<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; [java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span><br>Unbalanced parentheses: <span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Parentheses not balanced; Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="Extra right parentheses detected" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>


</td><td> <b>Hier is een voorbeeld van goede syntaxis met tooltips</b> <br> Variabelen die zijn gebruikt voordat ze zijn gedeclareerd: <span id="LEMtailor_Q_40_5"><span style="background-color: #eee8aa;"><span title="Deze variabele wordt pas gedeclareerd op een latere pagina; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Deze variabele wordt pas gedeclareerd op een latere pagina; Geen geldige expressie; [java61764X3X6] [G: 3] [Q: 200]: Wie wint de volgende verkiezing ?; value =?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span></span> <br> Onbekende functie: <span style="background-color: #eee8aa;"><span title="Ongedefinieerde functie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Ongedefinieerde functie" style="color: blue; font-weight: bold">iff</span></span> ( <span title="[java61764X1X4] [G: 2] [V: 50]: Hoeveel huisdieren heb je ?; waarde = 1" style="color: maroon; font-weight: bold">numPets</span> > <span title="[java61764X1X3] [G: 2] [V: 40]: Hoeveel kinderen heb je ?; waarde = 2" style="color: green; font-weight: bold">numKids</span> , 1,2)</span> <br> Onbekende variabele: <span style="background-color: #eee8aa;"><span title="Bereken de som van waarden in een array; getalsom (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span> ( <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">age</span> , <span title="ongedefinieerde variabele" style="border-style: solid; border-width: 2px; border-color: red;"><span title="ongedefinieerde variabele" style="color: red; font-weight: bold">num_pets</span></span> , <span title="[java61764X1X3] [G: 2] [V: 40]: Hoeveel kinderen heb je ?; waarde = 2" style="color: green; font-weight: bold">numKids</span> )</span> <br> Verkeerde # parameters: <span style="background-color: #eee8aa;"><span title="Functie moet ten minste één argument (en) bevatten; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie moet ten minste één argument (en) bevatten; Geen geldige expressie; Retourneer een geformatteerde string; string sprintf (formaat, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span> ()</span> , <span style="background-color: #eee8aa;"><span title="Functie ondersteunt dit aantal argumenten niet: 2. Functie ondersteunt zo veel argumenten, waarbij -1 = onbeperkt: 3; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie ondersteunt dit aantal argumenten niet: 2. Functie ondersteunt dit veel argumenten, waarbij -1 = onbeperkt: 3; Geen geldige expressie; Excel-stijl if (test, result_if_true, result_if_false); if (test result_if_true, result_if_false)" style="color: blue; font-weight: bold">if</span></span> (1,2)</span> , <span style="background-color: #eee8aa;"><span title="Functie ondersteunt dit aantal argumenten niet: 0. Functie ondersteunt dit veel argumenten, waarbij -1 = onbeperkt: 1,2; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Functie ondersteunt dit aantal argumenten niet: 0. Functie ondersteunt zo veel argumenten, waarbij -1 = onbeperkt: 1,2; Geen geldige expressie; Formatteer een lokale datum / tijd; string date (format [, timestamp = time ()])" style="color: blue; font-weight: bold">date</span></span> ()</span> <br> Wijs alleen-lezen-vars toe: <span style="background-color: #eee8aa;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie; ; value = worker" style="color: #996600; font-weight: bold">TOKEN: ATTRIBUTE_1</span></span> <span title="Een nieuwe waarde toewijzen aan een variabele" style="color: red; font-weight: bold">+ =</span> 10</span> , <span id="LEMtailor_Q_40_12"><span style="background-color: #eee8aa;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie" style="border-style: solid; border-width: 2px; border-color: red;"><span title="De waarde van deze variabele kan niet worden gewijzigd; Geen geldige expressie; [java61764X1X1] [G: 1] [V: 10]: Wat is je eerste / voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span></span> <span title="Een nieuwe waarde toewijzen aan een variabele" style="color: red; font-weight: bold">=</span> <span title="" style="color: gray">'Sally'</span></span></span> <br> Ongebalanceerde haakjes: <span style="background-color: #eee8aa;"><span title="Haakjes niet gebalanceerd" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Haakjes niet gebalanceerd; Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span></span> (3,4</span> , <span style="background-color: #eee8aa;"><span title="Haakjes niet gebalanceerd" style="border-style: solid; border-width: 2px; border-color: red;">(</span> <span title="Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span> (3,4)</span> , <span style="background-color: #eee8aa;"><span title="Exponentiële expressie; nummer pow (base, exp)" style="color: blue; font-weight: bold">pow</span> (3,4) <span title="Extra rechterhaakje gedetecteerd" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>
</td><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared: <span id="LEMtailor_Q_40_5"><span style="background-color: #eee8aa;"><span title="This variable is not declared until a later page; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="This variable is not declared until a later page; Not a valid expression; [java61764X3X6][G:3][Q:200]: Who will win the next election?; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span></span><br>Unknown Function: <span style="background-color: #eee8aa;"><span title="Undefined function" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined function" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>Unknown Variable: <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Undefined variable" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined variable" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>Wrong # parameters: <span style="background-color: #eee8aa;"><span title="Function must have at least 1 argument(s); Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function must have at least 1 argument(s); Not a valid expression; Return a formatted string; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments: 2. Function supports this many arguments, where -1=unlimited: 3; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments: 2. Function supports this many arguments, where -1=unlimited: 3; Not a valid expression; Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments: 0. Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments: 0. Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression; Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>Assign read-only-vars:<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">+=</span>10</span>,<span id="LEMtailor_Q_40_12"><span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; [java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span></span><br>Unbalanced parentheses: <span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Parentheses not balanced; Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="Extra right parentheses detected" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>


</td></tr>
</td></tr>
<tr><td> <b>Hier is een deel van de niet-ondersteunde syntaxis</b> <br> Geen ondersteuning voor '++', '-', '%', ';': {min (++ age, --age, age% 2);} <br> Noch '|', '&', '^': {(som (2 | 3,3 & 4,5 ^ 6)}} <br> No arrays: {name [2], name ['mine']}
<tr><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': {min(++age, --age,age % 2);}<br>Nor '|', '&amp;', '^': {(sum(2 | 3,3 &amp; 4,5 ^ 6)}}<br>Nor arrays: {name[2], name['mine']}
</td><td> <b>Hier is een deel van de niet-ondersteunde syntaxis</b> <br> Geen ondersteuning voor '++', '-', '%', ';': <span style="background-color: #eee8aa;"><span title="Vind de laagste waarde; aantal min (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span> ( <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">++</span> <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> , <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">-</span> <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> , <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">%</span> 2) <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">;</span></span> <br> Noch '|', '&', '^': <span style="background-color: #eee8aa;">( <span title="Bereken de som van waarden in een array; getalsom (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">som</span> (2 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">|</span> 3,3 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">&</span> 4,5 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">^</span> 6)</span> } <br> No arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1] [G: 1] [V: 10]: Wat is je eerste / voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">[</span> 2 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">]</span> , <span title="[java61764X1X1] [G: 1] [V: 10]: Wat is je voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">[</span> <span title="" style="color: gray">'mine'</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">]</span></span>
</td><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': <span style="background-color: #eee8aa;"><span title="Find lowest value; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>Nor '|', '&amp;', '^': <span style="background-color: #eee8aa;">(<span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>Nor arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>


</td><td> <b>Hier is een deel van de niet-ondersteunde syntaxis</b> <br> Geen ondersteuning voor '++', '-', '%', ';': <span style="background-color: #eee8aa;"><span title="Vind de laagste waarde; aantal min (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span> ( <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">++</span> <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> , <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">-</span> <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> , <span title="[java61764X1X2] [G: 2] [V: 30]: Hoe oud ben je ?; waarde = 45" style="color: green; font-weight: bold">leeftijd</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">%</span> 2) <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">;</span></span> <br> Noch '|', '&', '^': <span style="background-color: #eee8aa;">( <span title="Bereken de som van waarden in een array; getalsom (arg1, arg2, ... argN)" style="color: blue; font-weight: bold">som</span> (2 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">|</span> 3,3 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">&</span> 4,5 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">^</span> 6)</span> } <br> No arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1] [G: 1] [V: 10]: Wat is je eerste / voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">[</span> 2 <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">]</span> , <span title="[java61764X1X1] [G: 1] [V: 10]: Wat is je voornaam ?; value = Peter" style="color: green; font-weight: bold">name</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">[</span> <span title="" style="color: gray">'mine'</span> <span title="Niet-ondersteunde syntaxis" style="border-style: solid; border-width: 2px; border-color: red;">]</span></span>
</td><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': <span style="background-color: #eee8aa;"><span title="Find lowest value; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>Nor '|', '&amp;', '^': <span style="background-color: #eee8aa;">(<span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>Nor arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>


</td></tr>
</td></tr>
Line 101: Line 99:




=Voorbeelden maatwerk (bijv.uitbreiding {INSERTANS:xxx})=
=Tailoring Examples (e.g. extending {INSERTANS:xxx})=




==Aanhef==
=="Dear {Mr}/{Mrs} Smith..."==




Gebruik de if-functie om voorwaardelijk te kiezen of 'Mr.' wordt weergegeven of 'Mrs.'.
Use the if() function to conditionally choose whether to display 'Mr.' or 'Mrs.'.


The syntaxis is if(test,do_if_true,do_if_false).
The syntax is if(test,do_if_true,do_if_false).


{|
{|
|#||Code||Vraag||Type
|#||Code||Question||Type
|-
|-
|1|| geslacht||What is your gender?||Gender
|1||gender||What is your gender?||Gender
|-
|-
|2||voorbeeld1||Dear {if (gender == 'M', 'Mr.', 'Mrs.')} Smith, ... ||Lange vrije tekst
|2||example1||Dear {if(gender=='M','Mr.','Mrs.')} Smith, ...||Long free text
|}
|}


Line 123: Line 121:




Zoals hier kan worden opgemerkt, zijn "Mr" en "Mrs" afgestemd op wat de deelnemer als antwoord op vraag "gender" selecteert.
As it can be observed below, "Mr" and "Mrs" are tailored to what the respondent selects as answer to question "gender".




Line 130: Line 128:




==Aanhef in e-mail uitnodiging==
=="Dear {Mr}/{Mrs} Smith..." in invitation email==




U kunt het bovenstaande voorbeeld in de uitnodiging gebruiken met behulp van attributen uit de token-tabel. Gebruik de if-functie om te kiezen of 'Mr.' of 'Mrs.' in de tekst van de e-mail moet worden gebruikt.
You can use the example above in the invitation email using attributes from the token table. Use the if() function to choose whether 'Mr.' or 'Mrs.' should be used in the email.




De syntaxis is "if(test,do_if_true,do_if_false)".
The syntax is "if(test,do_if_true,do_if_false)".


{|
{|
|#||attribuut||waarde
|#||attribute||value
|-
|-
|1||Achternaam||Smith
|1||Last name||Smith
|-
|-
|2||E-mailadres||test@test.com
|2||Email address||test@test.com
|-
|-
|3||ATTRIBUTE_2||M
|3||ATTRIBUTE_2||M
Line 149: Line 147:




Tekst in uitnodiging:
Text in invitation email:


<syntaxhighlight lang="php" enclose="div">
<syntaxhighlight lang="php" enclose="div">
Line 165: Line 163:




E-mail:
email View:




Line 171: Line 169:




=Voorbeelden berekening /beoordeling=
=Calculation / Assessment Examples=




==Berekenen beoordelingswaarden bij uitvoering en opslaan van de resultaten==
==Calculate assessment values at runtime and store the results in the survey data==




In dit voorbeeld worden alle functies van Expressiebeheer gebruikt, waaronder Relevantie, Maatwerk en het vraagtype Vergelijking.
This example uses all of EM's features, including Relevance, Tailoring, and the Equation question type.


Het laat ook zien dat ze allemaal JavaScript-enabled zijn, dus als je deze functies op een pagina hebt, zal deze dynamisch veranderen als de deelnemer het antwoord invult of aanpast.
It also shows that all of them are JavaScript-enabled, so if you have these features on a page, it will dynamically change as people set and change their answers.


{|
{|
|#||Code||Vraag||Type||Relevantie
|#||Code||Question||Type||Relevance
|-
|-
|1|| numKids ||Hoeveel kinderen heeft u?||Numerieke invoer||1
|1||numKids||How many children do you have?||Numerical input||1
|-
|-
|2||kid1||Hoe oud is uw eerste kind?||Numerieke invoer||numKids>= 1
|2||kid1||How old is your first child?||Numerical input||numKids >= 1
|-
|-
|3||kid2||Hoe oud is uw tweede kind?||Numerieke invoer||numKids>= 2
|3||kid2||How old is your second child?||Numerical input||numKids >= 2
|-
|-
|4||kid3||Hoe oud is uw derde kind?||Numerieke invoer||numKids>= 3
|4||kid3||How old is your third child?||Numerical input||numKids >= 3
|-
|-
|5||kid4||Hoe oud is uw vierde kind?||Numerieke invoer||numKids>= 4
|5||kid4||How old is your fourth child?||Numerical input||numKids >= 4
|-
|-
|6||sumKidAges||{sum (kid1.NAOK,kid2. NAOK,kid3.NAOK,kid4.NAOK)} || Vergelijking||1
|6||sumKidAges||{sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK)}||Equation||1
|-
|-
|7||kidSummary||U zei dat u {numKids} heeft. {If (numKids == 1, 'kind', 'kinderen')}. {if (numKids> 1, implode ('', 'De som van leeftijden van uw eerste', min (numKids, 4), 'kids is', sumKidAges, '.'), '')}||Tekstweergave| |! 1
|7||kidSummary||You said that you have {numKids}. {if(numKids==1,'child','children')}. {if(numKids>1,implode(' ','The sum of ages of your first ',min(numKids,4),' kids is ',sumKidAges,'.'),' ')}||Text display||1
|}
|}




Voorbeeld [[Media:Assessments_survey_example.zip|downloaden]].
To download this example, please click on the following link: [[Media:Assessments_survey_example.zip|Assessments_survey_example]].




Hieronder staan schermafbeeldingen van representatieve vragen. Zoals je kunt zien, markeert Expressiebeheer alle velden die mogelijk maatwerk bevatten. Hier ziet u voorbeelden van accentuering van de relevantie, het vraagtype Vergelijking en vervangingen binnen een vraag. U kunt ook vervangingen gebruiken in Help, Groepskoptekstweergave, Welkomsttekst en Afsluittekst.
You may find below screenshots of representative questions. As you can see, EM syntax-highlights all fields that might contain tailoring. Here, you see examples of syntax-highlighting Relevance, the Equation question type, and substitutions within a question. You can also use substitutions within Help, Group header display, Welcome message, and End message.


In het volgende voorbeeld is, omdat de relevantie {numKids> = 2) is, de vraag alleen zichtbaar als de deelnemer aangeeft minstens 2 kinderen te hebben.
In the next example, since the relevance is {numKids >= 2), the question will only be visible if the respondent reports that she has at least two children.




Line 211: Line 209:




Hieronder zie je dat aan elke variabele het .NAOK-achtervoegsel wordt gebruikt. Dit komt door de manier waarop cascade-relevantie wordt ondersteunt. Als u geen .NAOK had, dan zou de som alleen worden berekend als de persoon 4 kinderen heeft (bijv. Als alle variabelen relevant zijn). Het gebruik van .NAOK betekent dat we de som willen berekenen, zelfs als alle of sommige variabelen irrelevant zijn (bijv. "Niet van toepassing" (NA) is goed (OK)).
Below, you may observe that each variable has the .NAOK suffix attached to it. This is because of how EM supports cascading relevance. If you did not have .NAOK, then the sum would only be computed if the person said she has 4 children (e.g., if all of the variables are relevant). The usage of .NAOK means that we want to compute the sum even if all or some of the variables are irrelevant (e.g., "Not Applicable" (NA) is alright (OK)).


Het attribuut .NAOK heeft echter alleen invloed op de vraag of variabelen worden doorgegeven aan Expressiebeheer. Als de deelnemer aanvankelijk zegt 3 kinderen te hebben maar dat later aanpast in twee, dan willen we niet de som van de 3 ingevoerde waarden zien, aangezien het derde kind "niet van toepassing is":
However, the .NAOK attribute only affects whether variables are passed into EM. If the respondent initially says she has 3 children, and enters ages for each, then changes her mind and says she has 2, we don't want to see the sum of the 3 entered values - since the third child is "not applicable" in our case anymore:




Line 219: Line 217:




Elke afzonderlijke expressie heeft een kleurcode met een lichtbruine  achtergrond. Zoals je kunt zien, zijn er hier drie afzonderlijke expressies. De laatste bevat een bericht dat alleen wordt weergegeven als de persoon meer dan één kind heeft.
Each separate Expression is color coded with a tan background. As you can see, there are three separate Expressions here. The last one contains a message that is conditionally shown only if the person has more than one child.




Line 225: Line 223:




Eindelijk, de screenshots.
Now, here are screenshots of the survey in action.


Wanneer de pagina voor het eerst wordt getoond, staat er: "You have 0 '''children'''" in plaats van "You have 0 '''child'''".
When you first visit the page, you see this. Note that is says "You have 0 '''children'''" instead of "You have 0 '''child'''".




Line 233: Line 231:




Als ik de waarde voor het aantal kinderen in 1 verander, dan wordt dit direct aangepast, ook al staat het op dezelfde pagina.
If I change the value for number of children to 1, the display instantly changes to this, even though it is on the same page:




Line 239: Line 237:




Merk op dat de grammatica correct is: "You have 1 '''child'''".
Now notice that the grammar is correct: "You have 1 '''child'''".


Nu verander ik de waarde voor het aantal kinderen in 3 en het resultaat wordt direct:
Now I change the value for number of children to 3, and the display instantly changes to this.


Let op het voorwaardelijke bericht onderaan: "The sum of ages of your first 3 kids is 0.".
Notice that you now see the conditional message at the bottom:  "The sum of ages of your first 3 kids is 0.".




Line 249: Line 247:




Nu voer ik leeftijden in voor mijn 'kinderen', en ik krijg dit scherm, waarin hun leeftijden worden opgeteld:
Now I'll enter ages for my imaginary children, and I get this display, summing up their ages:




Line 255: Line 253:




Nogmaals, de score en het display worden onmiddellijk bijgewerkt terwijl ik de waarden invoeg, zodat je dit kunt gebruiken om een ​​lopend totaal van een beoordelingsscore te laten zien.
Again, the score and display updates instantly as I enter the values, so you can use this to show a running total of an Assessment Score.




Nu verander ik de waarde voor het aantal kinderen in 2 en de pagina wordt:
Now, I change the value for the number of children to 2. The display has changed to this:




Line 264: Line 262:




Merk op dat hoewel ik een waarde van 5.5 had ingevoerd voor het derde kind, het overzicht nu alleen de waarden van de eerste 2 kinderen optelt.
Notice that although I had entered a value of 5.5 for the third child, the report now only sums the values of my first 2 children.


De reden hiervoor is dat de 3e waarde nu irrelevant is, en irrelevante waarden worden actief genegeerd door Expressiebeheer.
The reason for this is that the 3rd value is now irrelevant, and irrelevant values are actively ignored by EM.


Als ik het aantal kinderen weer op 3 zou zetten, zou ik de eerder ingevulde waarde van 5.5 weer zien. Dus ik verlies geen informatie die ik op de pagina heb ingevuld.
If I were to change the number of kids back to 3, I would see the value of 5.5 I entered again. So, I don't lose any information I enter on the page.


Als ik echter naar een andere pagina blader, worden alle irrelevante waarden NULLED in de sessie en in de database. Dus, als ik de waarde op 2 zou houden, naar de volgende pagina ga en weer terug ga en vervolgens het aantal kinderen op 3 zet, dan ben je de waarde 5,5 kwijt.
However, if I navigate to the Next or Previous page, all irrelevant values will be NULLed out in the session and in the database. So, if I were to keep the value at 2, go to the next page, and then come back and state that I actually have 3 kids, I would no longer see the age of 5.5.




==Gegevens invullen en zien dat de gegevens dynamisch op dezelfde pagina worden bijgewerkt==
==Enter data and see a dynamically changing report of what was entered on the same page==




Dit voorbeeld toont het maatwerk.
This example presents the Tailoring process within LimeSurvey.


Voorbeeld [[Media:Dynamic_change_of_the_report_when_data_is_entered_on_the_same_page_survey.zip|downloaden]].
To download this example, click on the following link: [[Media:Dynamic_change_of_the_report_when_data_is_entered_on_the_same_page_survey.zip|Dynamic changes survey example]].


Dit is hoe de pagina er in eerste instantie uitziet. Je ziet alleen de vraag in welke stad je woont:
Here is what the page looks like initially. You only see the question asking what city you live in:




Line 286: Line 284:




Kijk wat er gebeurd als je een antwoord invult:
Once you start to enter an answer, the tailoring process is also starting:


<center>[[File:em-on_page_report-usage-2.jpg]]</center>
<center>[[File:em-on_page_report-usage-2.jpg]]</center>




Terwijl je antwoordt, wordt de tabel onder aan de pagina bijgewerkt om de antwoordcodes en waarden van je antwoorden weer te geven.
As you enter answers, the table at the bottom of the page is updated to show the answer codes and values of your responses.




<center>[[File:em-on_page_report-usage-3.jpg]]</center>
<center>[[File:em-on_page_report-usage-3.jpg]]</center>


=Voorbeeld gebruikelijke foutopsporing=
=Common Debugging Examples=




==Geneste if-statements (Conditionele logica)==
==Nested if() Statements (Conditional Logic)==




Expressiebeheer ondersteunt de functie "if (test, do_if_true, do_if_false)", zodat je voorwaardelijke logica of maatwerk kunt uitvoeren. Deze functie kan worden genest om het equivalent van "if {} else if {} else {}" te doen. Je krijgt een melding bij fouten, haakjes niet gebalanceerd (je mist bijv. een sluithaakje), of dat je extra sluithaakjes hebt. Je moet proberen de haakjes te tellen als je lange geneste if-instructies maakt, deze opslaat, controleren op syntaxisfouten en deze oplossen. Laten we samen het onderstaande voorbeeld bekijken.  
EM supports the function "if(test,do_if_true,do_if_false)" so that you can perform conditional logic or tailoring. This function can be nested to do the equivalent of "if { } else if { } else {  }". EM will let you know if the parentheses are not balanced (e.g., you are missing a closing right parenthesis), or if you have any extra right parentheses. You should try to count the parentheses as you compose long nested if statements, save it, check for syntax errors, and fix them if any are found. Let's check together the below example.  


Voorbeeld [[Media:Example_tailoring_group11.zip|downloaden]]
The group of questions used below can be accessed from here: [[Media:Example_tailoring_group11.zip|Tailoring survey example.lsg]]




Ten eerste, als er niets is ingevoerd, zie je gewoon 'Hello'.
First, with nothing entered, you just see "Hello."




Line 313: Line 311:




Als je een naam invoert, staat er: "Hello {naam}."
If you enter a name, it says, "Hello {name}."




Line 319: Line 317:




Als je een leeftijd invoert, krijg je een bericht op maat, afhankelijk van of je al dan niet een kind bent in de pre-schoolleeftijd:
If you enter an age, you get a tailored message, depending upon whether you are a pre-school-age child or not:




Line 325: Line 323:




School ouder, tiener of volwassen. Hier is een tiener die anoniem wil zijn:
School aged, teenager, or adult. Here is a  teenager who wants to be anonymous:




Line 331: Line 329:




Hier is het logica-bestand van de groep. Zoals je kunt zien in de "if-based" vraag, zijn er geneste if-statements gebaseerd op de leeftijd van de persoon.
Here is the logic file of the group. As you can see in the "if-based" question, there are nested if statements based upon the person's age.




Line 337: Line 335:




Wanneer je een vraag bewerkt, kun je op een gegeven moment een verkeerd aantal haakjes krijgen. Dit is wat er gebeurt als je er te weinig hebt:
Als je een naam invoert, staat er: "Hello {naam}."




<center>[[File:em-nested-if-missing-closing-paren.jpg]]</center>
<center>[[File:em-nested-if-name.jpg]]</center>




Als je over het woord "if" gaat, dat is omgeven door een rood kader, staat er "haakjes niet gebalanceerd". In dit geval moeten er vier haakjes worden gesloten na 'al een volwassene!', maar er zijn er maar drie.
If you hover over the word "if", which is surrounded by a red box, it says "Parentheses not balanced". In this case, there should be four closing parentheses after "already an adult!", but there are only three.


Als je daarentegen een extra rechterhaakje hebt, dan staat dat haakje in een rood vakje:
If, on the other hand, you have an extra right parenthesis, it will be surrounded by a red box, like this:




Line 351: Line 349:




Wanneer je de vraag bewerkt, ziet de vraag er als volgt uit:
When you are actually editing the question, the question looks like this:




<center>[[File:em-nested-if-edit-screen.jpg]]</center>
<center>[[File:em-nested-if-edit-screen.jpg]]</center>

Revision as of 10:15, 3 March 2020


Overview of what has been previously explained

If you have followed so far the structure of the LimeSurvey manual, it means that you already the LimeSurvey terminology. Next, we covered expressions and variables in order to learn how to enhance our surveys. In the next part, we moved to the types and meanings of syntax highlighting to learn how to correct syntax errors.

With these basic notions covered, we could move towards examples and explaining how expressions work within LimeSurvey.


Syntax Highlighting

The following screenshots give examples, but do not show the values of the tooltips. A tooltip is an informative box which is displayed whenever you hover the mouse over any bold colored words.

Because of this syntax highlighting, it is very easy to compose correct expressions, even the ones that are complicated. Although the LimeSurvey team plans to try to build an Expression Builder GUI, you can use the existing syntax-highlighting to quickly identify and fix typos. You can also use the tooltips to validate the accuracy of your expressions (e.g., confirm you have selected the desired variable(s)).

In each of the examples, there are three columns:

  1. Source - this is the raw text that you would enter into the LimeSurvey question field
  2. Pretty Print - this is the syntax-highlighted equivalent of what you entered
    • Note that Expressions are shown with a tan background, but not surrounded by curly braces in this highlighting.
    • Since EM supports recursive substitution, showing curly braces in the highlighting would cause syntax errors
  3. Result - this is the output generated when EM processes the source
    • Everything that can be properly substituted is
    • Expressions with errors are shown in-line, with syntax highlighting. Errors are surrounded by a red-lined box.


Proper Syntax

You may find below examples of proper syntax:

  1. Values: shows that known variables are color coded according to whether are set on the current page. Old-style INSERTANS:xxxx gets its own color-coding style
  2. Question Attributes: shows that dot notation can access some properties of questions
  3. Math: shows that basic and complex calculations are supported
  4. TextProcessing: shows some of the available text-processing functions
  5. Dates: shows two of the available date-related functions
  6. Conditional: shows the usage of the if() function. The choices can be nested.
  7. Tailored paragraph: you can completely customize a report based upon prior values
  8. EM processes within strings: shows that it can do substitutions within strings. This example generates a tailored image name.
  9. EM doesn't process curly braces like these: shows that if the curly braces are escaped, or there is a white space between the expression and the curly braces, EM ignores the expression.



EM Syntax Containing Errors

Here are examples of common errors when typing EM expressions. Note that the tooltips provide additional information.

  1. Inline Javascript that forgot to add spaces after curly brace
    • Since "document.write" appears right after a curly brace, EM thinks it is an expression, and red-boxes "document" and "write" since they are undefined variable and functions, respectively
  2. Unknown/Misspelled variables, functions and operators
    • Here we forgot that we are using the variable name "gender" instead of "sex", but EM catches that error. It also red-boxes '++', since that is not a supported operator.
  3. Warns if use = instead of eq, or perform value assignments
    • Note that the '=' and '+=' are in red text instead of black. If you hover the mouse over them, you will see warnings that you are assigning a value.
  4. Wrong number of arguments for functions
    • if() takes 3 arguments, but it has been given 4, so hovering over the red-boxed "if" will explain the error and show the supported syntax
    • sum() takes an unlimited number of arguments, but we had a trailing comma before the closing parentheses, so that is red-boxed
  5. Mismatched parentheses
    • This is one of the most common errors when writing expressions.
    • This shows two examples of missing closing parentheses, and one example of having one too many closing parentheses.
  6. Unsuported syntax
    • If you use an operator or punctuation that EM does not support, it will red-box it.
  7. Invalid assignments
    • Some variables are readWrite and can have their values changed. Others are read-only.
    • If you try to change the value of a read-only variable, you can't. EM will red-box the attempt.
    • If you try to assign a value to an equation or a string, you will also get an error



"Live" examples of Syntax Highlighting with active tooltips

SourcePretty PrintResult
Here is an example of OK syntax with tooltips
Hello {if(gender=='M','Mr.','Mrs.')} {surname}, it is now {date('g:i a',time())}. Do you know where your {sum(numPets,numKids)} children and pets are?
Here is an example of OK syntax with tooltips
Hello if(gender == 'M','Mr.','Mrs.') surname, it is now date('g:i a',time()). Do you know where your sum(numPets,numKids) children and pets are?
Here is an example of OK syntax with tooltips
Hello Mr. Smith, it is now 6:07 am. Do you know where your 3 children and pets are?
Here are common errors so you can see the tooltips
Variables used before they are declared: {notSetYet}
Unknown Function: {iff(numPets>numKids,1,2)}
Unknown Variable: {sum(age,num_pets,numKids)}
Wrong # parameters: {sprintf()},{if(1,2)},{date()}
Assign read-only-vars:{TOKEN:ATTRIBUTE_1+=10},{name='Sally'}
Unbalanced parentheses: {pow(3,4},{(pow(3,4)},{pow(3,4))}
Here are common errors so you can see the tooltips
Variables used before they are declared: notSetYet
Unknown Function: iff(numPets > numKids,1,2)
Unknown Variable: sum(age,num_pets,numKids)
Wrong # parameters: sprintf(),if(1,2),date()
Assign read-only-vars:TOKEN:ATTRIBUTE_1+=10,name='Sally'
Unbalanced parentheses: pow(3,4,(pow(3,4),pow(3,4))
Here are common errors so you can see the tooltips
Variables used before they are declared: notSetYet
Unknown Function: iff(numPets > numKids,1,2)
Unknown Variable: sum(age,num_pets,numKids)
Wrong # parameters: sprintf(),if(1,2),date()
Assign read-only-vars:TOKEN:ATTRIBUTE_1+=10,name='Sally'
Unbalanced parentheses: pow(3,4,(pow(3,4),pow(3,4))
Here is some of the unsupported syntax
No support for '++', '--', '%',';': {min(++age, --age,age % 2);}
Nor '|', '&', '^': {(sum(2 | 3,3 & 4,5 ^ 6)}}
Nor arrays: {name[2], name['mine']}
Here is some of the unsupported syntax
No support for '++', '--', '%',';': min( ++ age, -- age,age % 2) ;
Nor '|', '&', '^': (sum(2 | 3,3 & 4,5 ^ 6)}
Nor arrays: name [ 2 ] ,name [ 'mine' ]
Here is some of the unsupported syntax
No support for '++', '--', '%',';': min( ++ age, -- age,age % 2) ;
Nor '|', '&', '^': (sum(2 | 3,3 & 4,5 ^ 6)}
Nor arrays: name [ 2 ] ,name [ 'mine' ]


Tailoring Examples (e.g. extending {INSERTANS:xxx})

"Dear {Mr}/{Mrs} Smith..."

Use the if() function to conditionally choose whether to display 'Mr.' or 'Mrs.'.

The syntax is if(test,do_if_true,do_if_false).

# Code Question Type
1 gender What is your gender? Gender
2 example1 Dear {if(gender=='M','Mr.','Mrs.')} Smith, ... Long free text



As it can be observed below, "Mr" and "Mrs" are tailored to what the respondent selects as answer to question "gender".



"Dear {Mr}/{Mrs} Smith..." in invitation email

You can use the example above in the invitation email using attributes from the token table. Use the if() function to choose whether 'Mr.' or 'Mrs.' should be used in the email.


The syntax is "if(test,do_if_true,do_if_false)".

# attribute value
1 Last name Smith
2 Email address test@test.com
3 ATTRIBUTE_2 M


Text in invitation email:

Dear {if(ATTRIBUTE_2=='M','Mr','Mrs')} {LASTNAME},

you have been invited to participate in a survey:

https:/...



email View:



Calculation / Assessment Examples

Calculate assessment values at runtime and store the results in the survey data

This example uses all of EM's features, including Relevance, Tailoring, and the Equation question type.

It also shows that all of them are JavaScript-enabled, so if you have these features on a page, it will dynamically change as people set and change their answers.

# Code Question Type Relevance
1 numKids How many children do you have? Numerical input 1
2 kid1 How old is your first child? Numerical input numKids >= 1
3 kid2 How old is your second child? Numerical input numKids >= 2
4 kid3 How old is your third child? Numerical input numKids >= 3
5 kid4 How old is your fourth child? Numerical input numKids >= 4
6 sumKidAges {sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK)} Equation 1
7 kidSummary You said that you have {numKids}. {if(numKids==1,'child','children')}. {if(numKids>1,implode(' ','The sum of ages of your first ',min(numKids,4),' kids is ',sumKidAges,'.'),' ')} Text display 1


To download this example, please click on the following link: Assessments_survey_example.


You may find below screenshots of representative questions. As you can see, EM syntax-highlights all fields that might contain tailoring. Here, you see examples of syntax-highlighting Relevance, the Equation question type, and substitutions within a question. You can also use substitutions within Help, Group header display, Welcome message, and End message.

In the next example, since the relevance is {numKids >= 2), the question will only be visible if the respondent reports that she has at least two children.



Below, you may observe that each variable has the .NAOK suffix attached to it. This is because of how EM supports cascading relevance. If you did not have .NAOK, then the sum would only be computed if the person said she has 4 children (e.g., if all of the variables are relevant). The usage of .NAOK means that we want to compute the sum even if all or some of the variables are irrelevant (e.g., "Not Applicable" (NA) is alright (OK)).

However, the .NAOK attribute only affects whether variables are passed into EM. If the respondent initially says she has 3 children, and enters ages for each, then changes her mind and says she has 2, we don't want to see the sum of the 3 entered values - since the third child is "not applicable" in our case anymore:



Each separate Expression is color coded with a tan background. As you can see, there are three separate Expressions here. The last one contains a message that is conditionally shown only if the person has more than one child.



Now, here are screenshots of the survey in action.

When you first visit the page, you see this. Note that is says "You have 0 children" instead of "You have 0 child".



If I change the value for number of children to 1, the display instantly changes to this, even though it is on the same page:



Now notice that the grammar is correct: "You have 1 child".

Now I change the value for number of children to 3, and the display instantly changes to this.

Notice that you now see the conditional message at the bottom:  "The sum of ages of your first 3 kids is 0.".



Now I'll enter ages for my imaginary children, and I get this display, summing up their ages:



Again, the score and display updates instantly as I enter the values, so you can use this to show a running total of an Assessment Score.


Now, I change the value for the number of children to 2. The display has changed to this:



Notice that although I had entered a value of 5.5 for the third child, the report now only sums the values of my first 2 children.

The reason for this is that the 3rd value is now irrelevant, and irrelevant values are actively ignored by EM.

If I were to change the number of kids back to 3, I would see the value of 5.5 I entered again. So, I don't lose any information I enter on the page.

However, if I navigate to the Next or Previous page, all irrelevant values will be NULLed out in the session and in the database. So, if I were to keep the value at 2, go to the next page, and then come back and state that I actually have 3 kids, I would no longer see the age of 5.5.


Enter data and see a dynamically changing report of what was entered on the same page

This example presents the Tailoring process within LimeSurvey.

To download this example, click on the following link: Dynamic changes survey example.

Here is what the page looks like initially. You only see the question asking what city you live in:



Once you start to enter an answer, the tailoring process is also starting:


As you enter answers, the table at the bottom of the page is updated to show the answer codes and values of your responses.


Common Debugging Examples

Nested if() Statements (Conditional Logic)

EM supports the function "if(test,do_if_true,do_if_false)" so that you can perform conditional logic or tailoring. This function can be nested to do the equivalent of "if { } else if { } else {  }". EM will let you know if the parentheses are not balanced (e.g., you are missing a closing right parenthesis), or if you have any extra right parentheses. You should try to count the parentheses as you compose long nested if statements, save it, check for syntax errors, and fix them if any are found. Let's check together the below example.

The group of questions used below can be accessed from here: Tailoring survey example.lsg


First, with nothing entered, you just see "Hello."



If you enter a name, it says, "Hello {name}."



If you enter an age, you get a tailored message, depending upon whether you are a pre-school-age child or not:



School aged, teenager, or adult. Here is a  teenager who wants to be anonymous:



Here is the logic file of the group. As you can see in the "if-based" question, there are nested if statements based upon the person's age.



Als je een naam invoert, staat er: "Hello {naam}."



If you hover over the word "if", which is surrounded by a red box, it says "Parentheses not balanced". In this case, there should be four closing parentheses after "already an adult!", but there are only three.

If, on the other hand, you have an extra right parenthesis, it will be surrounded by a red box, like this:



When you are actually editing the question, the question looks like this: