Actions

Setting conditions/nl: Difference between revisions

From LimeSurvey Manual

(Created page with "Wanneer je een nieuwe elementaire conditie aanmaakt, dan kun je het aan een ander dan het Standaard scenario koppelen.")
(Created page with "Scenario's worden aangegeven met een nummer, het "Standaard scenario" heeft nummer '1' als identificerend gegeven.")
Line 248: Line 248:
Wanneer je een nieuwe elementaire conditie aanmaakt, dan kun je het aan een ander dan het Standaard scenario koppelen.
Wanneer je een nieuwe elementaire conditie aanmaakt, dan kun je het aan een ander dan het Standaard scenario koppelen.


Scenarios are identified by a simple number, the "Default scenario" having number '1' as its identifier.
Scenario's worden aangegeven met een nummer, het "Standaard scenario" heeft  nummer '1' als identificerend gegeven.


==Een vraag toevoegen aan een ander scenario==
==Een vraag toevoegen aan een ander scenario==

Revision as of 16:16, 6 August 2013

Wijzigingen vanaf versie 1.92

Vanaf versie 1.92 wordt alle navigatie gedaan onder controle van Expressie Beheer.  Je kunt de conditie editor nog wel gebruiken, maar intern wordt een conditie dus door expressie beheer omgezet in een relevantie vergelijking.

Je hoeft de conditie editor dus niet te gebruiken. Als je dat wilt dan kun je de relevantie vergelijking met qcode zelf intikken.

Met expressie beheer kun je ruim 100 functies en allerlei operatoren gebruiken, dus kun je complexe relevantie vergelijkingen maken, iets wat je in de conditie editor niet kunt doen.

NB.:  We gaan er nu vanuit, dat als je in de Conditie Editor waarden invult, je er in de relevantie vergelijking handmatig iets in wilt wijzigen. Als je inderdaad een eerste versie wilt maken, doe dan het volgende:
  1. Maak, als je gewoon was te doen, je condities aan met de conditie editor
  2. Bewaar de condities - je ziet dan ook de relevantie vergelijking voor de vraag
  3. Selecteer en kopieer deze gemarkeerde vergelijking en plak de tekst in een tekstverwerker als Notepad
  4. Open de Conditie editor opnieuw, verwijder alle condities van de vraag (en sla het op) - de relevantie vergelijking is nu weg
  5. Wijzig de vraag, kopieer de oude relevantie vergelijking uit Notepad, bewerk het eventueel, sla de vraag op

De Expressie Beheer documentatie vergelijkt condities en relevantie, in het bijzonder deze tabel.

Overzicht van condities

LimeSurvey heeft een krachtige functie voor navigatie.

Hier beschrijven we:

  • welke condities zijn er
  • wat kun je wel/niet met condities
  • welke stappen je moet leren kennen om simpele of moeilijke condities te maken

Er is een video en er is een voorbeeld enquête: download voorbeeld enquête met condities.

Verbergen/tonen tegenover springen

Je kunt logische vertakkingen ontwerpen met LimeSurvey, daarmee bedoelen wij dat je kunt beslissen dat je een vraag alleen wilt tonen als er aan een conditie is voldaan. (Toon vraag X als vraag Y was beantwoord met Z)

De aanpak is een Verberg/Toon vertakking:

  • je kunt een of meer conditie(s) definiëren bij een of meer vragen in je enquête: als aan de conditie wordt voldaan, dan wordt de vraag getoond.

Eenvoudig gezegd:

  • een vraag zonder conditie wordt altijd getoond
  • een vraag met een conditie wordt alleen getoond als aan de conditie voldaan is

Deze aanpak is anders dan de Spring vertakking logica die soms bij andere software gehanteerd wordt. Bij deze aanpak wordt als actie op een conditie waaraan voldaan wordt gesprongen naar een andere vraag (dat is ook een vorm van het verbergen van tussenliggende vragen). LimeSurvey doet het dus anders, hier wordt bij alle vragen dezelfde conditie gezet als je ze niet wilt tonen. Als je bijvoorbeeld bij vraag 2 de conditie wilt stellen, spring naar vraag 5, als het antwoord op vraag 1 'Ja' is", dan wordt het:

  • zet een conditie op vragen 2, 3 en 4 alleen tonen als "het antwoord op vraag1 NIET 'Ja' is".

  • Je kunt in LimeSurvey een conditie gemakkelijk op meerdere vragen zetten door een conditie te kopiëren van een vraag naar meerdere andere vragen. In het voorbeeld hierboven zet je dus de conditie op vraag2, en op hetzelfde scherm kun je die conditie kopiëren naar vraag3 en vraag4.

Ondersteunde conditie types

Een conditie vergelijkt waarden en het resultaat is true of false.

Waarden die vergeleken kunnen worden zijn:

  • antwoorden op vorige vragen
    • voorbeeld: "Als je 'Ja' antwoord op vraag1"

Het is belangrijk om te begrijpen wat wordt verstaan onder een geschikte vraag-entry voor de conditie editor:

Een vraag-entry is of:

  • een simpele vraag (voor alle vraagtypes uitgezonderd array vragen)
    • voorbeeld: tekst vragen, radioknoppen, selectielijsten en ook meerkeuzevragen
  • of een rij in een Array vraag (niet Array Dubbele schaal en Array (getallen) en Array (teksten)),
    • voorbeeld: Array (5 punten)
  • of het linkerdeel / rechterdeel van een Array Dubbele schaal
  • of elke cell van een Array

Om het op deze pagina en in de conditie editor wat eenvoudiger te houden noemen we vraag-entries gewoon vragen.

  • constante waarden
    • voorbeeld: "Als je hebt meer dan 3 dagen hebt geantwoord op Vraag2"

  • Deelnemersgegevens Om Toegangscode attributen te kunnen gebruiken moet de optie "Anonieme responses?" op Nee staan.  Deze optie staat in Algemene instellingen -> tab Toegangscodes.

Verschillende operatoren voor vergelijking worden ondersteund:

  • De basisvormen zijn gelijk en ongelijk
  • Ook groter/kleiner dan zijn beschikbaar, deze zijn meestal alleen bruikbaar voor numerieke vragen
    • Bij numerieke vergelijkingen is 2 < 10
    • Als een vraagtype tekst is, dan wordt de vergelijking "2" > "10" (tekst volgorde)!
    • Numerieke en tekst vragen (als het 'Uitsluitend getallen' attribuut bij de vraag is gezet), zullen de numerieke volgorde van vergelijkingen gebruiken
  • Een geavanceerde vergelijkingsoperator met gebruik van reguliere expressies is ook beschikbaar.
  • De "Reguliere expressie" operator (als je niet weet wat het is, heb je het vermoedelijk niet nodig)
    • het pattern is not tussen '/' tekens
    • voorbeeld
      [a-zA-Z]$

Combineren van condities

Je kunt complexe conditions maken door condities te combineren met AND en OR logische operators.

Het is van belang te begrijpen dat LimeSurvey automatisch bepaald welke logische operator gebruikt moet worden: het gebruik van OR of AND operators wordt bepaald volgens de context van de conditie.

We beginnen met een elementaire conditie.

Begrijpen van elementaire condities

De editor gaan gebruiken

Eerst moet je de conditie editor aanroepen:

  • open het conditie menu door te klikken op het icoon condities in de vraag toolbar bij het bekijken van een vraag.
  • klik dan op het icoon Voeg conditie toe en pas aan, het wijzigscherm voor condities wordt getoond, waarmee je condities voor de huisdige vraag kunt aanmaken, wijzigen en verwijderen.

Je krijgt het volgende scherm:

NB.: Wijzig voorlopig NIET het standaard scenario () dit wordt automatisch geselecteerd in het scherm waarin de conditie wordt toegevoegd. We komen hierop later terug.

Definitie van elementaire conditie

Een elementaire conditie is een enkele conditie zonder een logische operator (OR,AND).

Het bestaat uit een:

  • een linker operand: de te testen waarde
    • je kunt eerst het type te testen waarde selecteren door een tab te selecteren

  • een vergelijkingsoperator
    • Je kunt deze waarde kiezen uit een dropdown lijst

File:Conditions-operators.png

  • een rechter operand: de vergelijkingswaarde
    • je kunt eerst het type van deze waarde selecteren door een tab te selecteren

Aanmaken van een elementaire conditie

  • Toon vraag ALS "het antwoord op vraag1 was de voorgedefinieerde waarde 'Man'"
    • te testen waarde = antwoord op vraag1
    • vergelijkingsoperator = Gelijk aan
    • vergelijkingswaarde = de code behorend bij antwoordoptie 'Man'

  • Toon vraag ALS "het antwoord op vraag2 groter was dan 5 (numeriek)"
    • te testen waarde = antwoord op vraag2
    • vergelijkingsoperator = "Groter dan"
    • vergelijkingswaarde = de waarde 5

Waarschuwing: Als je een constante 'vergelijkingswaarde' gebruikt bij een datum vraagtype, dan moet je de datum opgeven in het formaat YYYY-MM-DD, ongeacht het formaat dat is ingesteld voor de enquête.

  • Toon vraag ALS "het antwoord op vraag3 was groter dan het antwoord op vraag2"
    • te testen waarde value = antwoord op vraag3
    • vergelijkingsoperator = "Groter dan"
    • vergelijkingswaarde = antwoord op vraag2

File:Edit-simple-condition-prevQuestion.png

  • Toon vraag ALS "de 'Department' waarde van de respondent (Toegangscodeveld van de uitnodiging) gelijk is aan de string 'Accounting'"
    • te testen waarde = de 'Department' waarde uit het token / toegangscode
    • vergelijkingsoperatortor = "Gelijk aan"
    • vergelijkingswaarde = de constante 'Accounting'

Hoe je dit voorbeeld kunt toevoegen staat beschreven in de blog post: "Conditions based on token attributes"

Standaard conditie combinaties

Zoals al eerder aangegeven, zal LimeSurvey automatisch op grond van de context beslissen welke logische operator (AND of OR) wordt toegepast tussen condities.

De volgorde waarin je elementaire condities definieert is niet van belang, want LimeSurvey zal automatisch een eigen volgorde kiezen.

Dit gaan we in detail bekijken.

Eerste regel: condities met dezelfde te testen waarde worden met OR samengevoegd

Als je meerdere condities hebt dan worden ze met OR samengevoegd als ze dezelfde te testen waarde hebben

  • voorbeeld: meerdere mogelijke antwoorden op dezelfde voorafgaande vraag: "Als antwoord op vraag1 is 'groen' OR  antwoord op vraag1 is 'rood'  OR  antwoord op vraag1 is 'blauw'"

Tweede regel: condities met verschillende te testen waarden worden met AND samengevoegd

Als je meerdere condities hebt dan worden ze met AND samengevoegd als ze niet dezelfde te testen waarde hebben

  • voorbeeld: meerdere condities met verschillende vragen: "ALS antwoord op vraag1 is '4' AND "antwoord op vraag2 is 'groen'"

   

Derde regel: condities met OR gaan voor condities met AND

Stel, je hebt de volgende condities aangemaakt:

  • ALS antwoord op vraagtype "!" was 'Groen'
  • ALS antwoord op vraagtype "5" was '4'
  • ALS antwoord op vraagtype "A" was '4' of '5'

  • Dan zal het resultaat van de condities zijn:

    • Met hoofdletter 'OR' en de kleine letters 'and' willen we hier aangeven dat met OR samengevoegde condities geëvalueerd worden als ze prioriteit hebben gekregen met haakjes
    • De volgorde van aanmaak van de elementaire condities niet bewaard wordt en dat daar ook geen reden voor is
    • Het resultaat is: ALS (antwoord op vraagtype "A" was '4' OR  antwoord op vraagtype "A" was '4') AND (ALS antwoord op vraagtype "5" was '4') AND (ALS antwoord op vraagtype "!" was 'Groen')

Meervoudige optie vragen

In deze paragraaf worden de vraagtypes Meerkeuzevraag en Meerkeuzevraag met opmerking behandeld, dus niet het vraagtype Array (getallen) (hier is elke checkbox een vraag, het wordt dus anders afgehandeld als andere meervoudige opties vragen).

Bij Meerkeuzevragen (met/zonder opmerking) vraagtypes, komen in het deel te testen waarde in de condities editor twee mogelijkheden voor

  • een Groep checkboxen waarbij je condities kunt maken op alle mogelijke antwoorden van de vraag
  • een groep van enkele checkbox waarbij je conditie(s) kunt zetten op elke checkbox

En nu een quiz over condities::

  • Ik heb een meerkeuzevraag:
    • Onderwerp A: Hoe kan ik met OR condities samenvoegen van verschillende antwoorden op een vraag
    • Onderwerp B: Hoe kan ik met AND condities samenvoegen van verschillende antwoorden op een vraag

...

...

...

En nu de antwoorden...

Onderwerp A:

  • Gebruik de Groep van checkboxen als je te testen waarde en selecteer alle gewilde antwoorden

Voor onderwerp B:

  • Gebruik de Enkele checkbox die overeenkomt met je eerste antwoord waarop je de conditie wilt zetten en zet de vergelijkingswaarde op aangevinkt

File:Edit-conditions-MultipleOptionsAND1.png

  • Gebruik de Enkele checkbox die overeenkomt met het tweede antwoord wat je nodig hebt in de conditie en zet de vergelijkingswaarde op aangevinkt

  • Bewonder het resultaat:

Gebruik OR condities tussen verschillende vragen: gebruik van scenario

Je kunt zeggen dat je soms met OR condities wilt samenvoegen, zelfs als ze gezet zijn op verschillende vragen (dus op verschillende te testen waarden): dan kun je een scenario gebruiken.

File:Multi scenario.png

Definitie van een scenario

Een scenario is een handmatige groepering van condities waarin condities onafhankelijk van condities in andere scenario's worden geëvalueerd. Het resultaat van de meerdere scenario's is dat het voldoet als er maar een scenario voldoet. Met andere woorden: een scenario is een logische groepering van condities, volgens de bovenstaande regels, en die met OR worden samengevoegd om complexe condities te maken.

Alles wat hierboven hebben beschreven is waar binnen een scenario, standaard worden alle nieuwe condities aangemaakt binnen een "Standaard scenario".

Wanneer je een nieuwe elementaire conditie aanmaakt, dan kun je het aan een ander dan het Standaard scenario koppelen.

Scenario's worden aangegeven met een nummer, het "Standaard scenario" heeft nummer '1' als identificerend gegeven.

Een vraag toevoegen aan een ander scenario

When you create (or edit) a condition, you can modify the scenario in which the condition is stored:

If you need to define a condition in another scenario than the default one, click the new scenario icon File:Plus.png, and type in the scenario number: File:Default scenario edit.png

The number id of a scenario has no importance and different scenarios can have non-continuous ids.

Gebruik van de editor

Overzicht editor

First you access the condition editor:

  • open the condition menu by clicking on the conditions icon in the question button bar, when viewing a question.

The top part of the window always shows any conditions already set for this question:

File:Existing conditions.png

In the example above question B is set to only display if:

  • The answer to the question-entry FBI of previous question A is "1"
  • AND
    • EITHER the answer to the question-entry CIA of previous question A is "5"
    • OR the answer to the question-entry CIA of previous question A is "3"

In Add/Edit mode File:Conditions add.png, some specific actions are possible on each line such as:

  • edit condition
  • delete all conditions , delete this condition , delete all conditions from this scenario
  • edit scenario

File:Edit-conditions-EditModeButtons.png

In Copy mode , each line is prepended with a checkbox allowing you to select those conditions you want to copy to later questions:

File:Copying conditions.png

Instellen nieuwe condities

Selecteer eerst het scenario

If you don't need ORed conditions between different question-entries, just don't modify the default scenario () that is automatically selected in the condition edition form.

On the contrary, if you need to define a condition in another scenario than the default one, click the new scenario icon File:Plus.png, and type in the scenario number: File:Default scenario edit.png

The number id of a scenario has no importance and different scenarios can have non-continuous ids.

Selecteer de te testen waarde

Click on the tab corresponding to the type of the tested value you want: it is either a previous question or a value taken from the profile of the participant (token attribute).

Note that in order to use the Token your survey must:

  • not use anonymous answers
  • use a token table and closed access

Then select the entry you want as tested value.

If you select a question-entry (from the 'Previous questions' tab) and if this question uses predefined answers then the corresponding predefined answers are displayed in the Predefined tab of the comparison value selection.

Selecteer de operator voor de vergelijking

Several comparison operators can be used:

  • The basic ones are equality, and inequality
  • The greater/less than operator family is also available, and is usually only useful when using numeric question-entries
    • Please note that comparisons on numeric fields honor the numeric order: for instance 2 < 10
    • If you're using a question entry whose type is text, then the condition could be evaluated as "2" > "10" (string order).
    • Numeric questions, as well as text questions having the 'numbers_only' attribute set, will use the numeric order for comparisons
  • An advanced comparison operator using regular expressions is also available. When selected, the answer input box will automatically switch to the advanced mode.

Selecteren van vergelijkingswaarde

Select the tab that corresponds to the type of comparison value you need: it can be a predefined answers, a constant value, an answer from a previous question, a value from a token attribute, or a regular expression (reserved for the advanced regular expression operator).

Then select or type in the value you want to use.

Note that if you select a value in a tab, then change the tab and select another value in this other tab, the first option you selected is lost.

When using predefined answers, you can then select one or more predefined answers:

  • the possible answers for that question
    • Choose the answer that you want to use
    • You can choose multiple answers in one go by using the CTRL button and clicking on more than one answer in the right hand select list

After that click on the "Add Condition" button.

Wijzigen/Verwijderen condities

Apart from adding new conditions, the Add/Edit can be used to

  • edit conditions
  • delete conditions
  • edit scenario

Wijzig conditie

By clicking on the edit icon on a condition line, the edit condition form at the bottom is automatically displayed with the current settings for this condition. Note that in this mode you can only select one predefined answer.

Click the update condition button to update this condition.

Verwijder conditie

You can:

  • delete a single condition by clicking on this icon
  • delete all conditions within a scenario by clicking on this icon
  • delete all conditions from this question by clicking on this icon

Wijzig scenario

You can change the number assigned to a scenario by clicking this Icon and fill-in the form that appears on the same line.

Alternatively, you can renumber scenarios by clicking on this icon .

As said above, scenario numbers have no impact in the way conditions are evaluated. However, modifying the scenario numbers are needed in order to:

  • decide in which order the scenario are displayed when using the printable version of a survey
  • merge conditions from 2 scenarios (in order to merge scenario 10 to scenario 1, just renumber scenario 10 with scenario id 1).

Kopieer conditie naar een latere vraag

It is not uncommon for a group of questions to have the same condition. Luckily you can copy this condition to any subsequent question from the conditions designer once a first condition has been set.

Switch to the copy mode by clicking the on the Copy conditions icon .

File:Copy conditions example.png

The conditions applying to the current questions are displayed with a checkbox on their left. You can:

  • select each condition individually by checking the checkbox on the left of the condition
  • or select all conditions from a scenario at a time by checking the checkbox on the left of the scenario

Then select all subsequent questions in the survey on which you want to copy the selected conditions from the bottom Select box by highlighting them (using the CTRL key to select multiples). Then click on the "Copy Conditions" button to copy them across.

It is usually best to leave this until you have finished entering all your survey questions, and are satisfied with the question order.

Aandachtspunten

Algemene overwegingen

There are a few basic rules you should keep in mind before setting conditions on a question:

  • Once a single condition has been set for a question, that question will not display unless that condition is met.
  • Conditions can only be set based on questions that appear before the question on which the condition is set.
  • If you change the order of questions in your survey after you create conditions LimeSurvey does not warn you if the changed order will break a condition. You should always leave the creation of conditions until you are satisifed with the order of questions and groups in your survey.
  • You can modify conditions even after a survey has been activated. This should be done with caution, as there is no "consistency checking" applied here.

Conditions using the 'no answer' predefined answer

Setting the following condition "Show question Q20 if answer to question Q1 is 'no answer'" really means "show question Q20 if question Q1 was displayed and received no answer". This is not equivalent to "show question Q20 if question Q1 was not displayed"

Chained conditions

If you set conditions on a question that, itself, has conditions, then there may arise occasions where the survey behaves in ways you might not have predicted. For example a typical side-effect is that if you hide all questions in a group with chained conditions that the group header will still be shown unless you correct these conditions as explained below.

In the example above a question is displayed 'Do you like being male?' which has conditions set, and which will only display if the answer to What is your gender? is M. If you were to add a condition to this question requiring a specific answer from the Do you like being male? question, then this question will never display, because the question Do you like being male will not be presented.

It is highly recommended that you copy the conditions from the earlier question to the one you're editting.

For instance, you want the following:

  • Q1 is a Gender question
  • Q2 is a Yes/No and is displayed if answer to Q1 is Male
  • Q3 is a ranking question and is displayed if Q2 is Yes

What you really need to setup is the following set of conditions:

  • on Q2: display question if answer to Q1 is Yes
  • on Q3: display question if answer to Q1 is Male AND answer to Q2 is Yes

After correction, the correct set of conditions for Q3 should look like:

So if you are designing a complicated survey with large number of conditions, make sure you test the survey for as many different combinations of results as you can think of.

Limitations and workarounds

Progress-bar

If you create a survey where many questions get skipped because of conditions, the progress bar will jump a big step forward, or the survey ends at 50%.

To avoid such behavior, the questions that could be skipped, should be arranged between the shown questions, so that only one or two questions get skipped per answer.

For Example: based on question one (yes or no question) 15 questions will be asked question 1A to 15A when the answer of question one was yes, 1B to 15B when the answer to question one was no.

If you arrange the questions in one group and arrange them like: 2A, 2B, 3A, 3B, and so on you will get a nearly correct progress bar, while arranging the questions like 2A, 3A, 4A, [...], 2B, 3B, 4B, ... you will get a progress bar from 0 to 50% or from 50% to 100%, depending on the answer to the first question.

Setting a constant comparison value for a "Date" Question Type

You have to use the internal representation of Date values, which is YYYY-MM-DD to define your constant comparison value.

Setting conditions for "Other" Options in the Multiple Options Question Type

In the multiple options question type, you can use the "Other" provided in the question type as a valid choice but you cannot set conditions on it. For example: Question No 1 says "Which color do your prefer to use?" Answer checkbox choices are Blue, Black and Other. If the participant chooses Blue, you can set a condition. If the participant chooses Black, you can set a different condition. However, if the participant chooses "Other" and types in something in the text box, there is NO way a condition can be set. LimeSurvey does not recognize if the participant chose the "Other" condition. This is NOT a bug but a limitation.

There is no real field recorded for the 'other' checkbox for this question type. Thus, the only way to know if the user has answered the 'other' part of the question or not would be to check if the value of the text written in the other input field is empty or not.

However, due to the specific way we handle Multiple choice questions, testing the 'other' text input field has never been implemented.

As a workaround, add an explicit answer option called 'Other' and do not use the built-in 'other' option of these question types. Then add an additional short text question which will be displayed if this 'Other' checkbox was clicked.

How to use parenthesis for the boolean expressions?

You can't!

If you want to design something like:

 (condition1 OR condition2) AND (condition3 OR condition4)

you'll have to set up:

 (condition1 AND condition3) OR

 (condition1 AND condition4) OR

 (condition2 AND condition3) OR

 (condition2 AND condition4)