Actions

Setting conditions/de: Difference between revisions

From LimeSurvey Manual

No edit summary
(Updating to match new version of source page)
(48 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages /> __TOC__
<languages /> __TOC__


=Allgemeines zu Bedingungen in LimeSurvey=
=Allgemeines zu Bedingungen in LimeSurvey=


LimeSurvey hat eine sehr leistungsfähiges Logik-Verzweigungsfeature.
[[File:conditions_icon.png]]


In diesem Kapitel beschreiben wir:
<div class="mw-translate-fuzzy">
* welche Bedingungen gibt es in LimeSurvey
LimeSurvey hat ein sehr leistungsfähiges Logik-Verzweigungsfeature.
* was du mit Bedingungen tun kannst und was nicht
[[File:Conditions_icon_GE.PNG]]
* welche Schritte man lernen muss, um einfache oder komplexere Bedingungen zu erstellen
</div>
 
<div class="mw-translate-fuzzy">
In diesem Kapitel wird beschrieben ...
* welche Bedingungen es in LimeSurvey gibt.
* was man mit Bedingungen tun kann und was nicht.
* welche Schritte erlernt werden müssen, um einfache oder komplexe Bedingungen zu erstellen.
</div>
 
<div class="mw-translate-fuzzy">
Eine Schritt-für-Schritt Video-Anleitung (Englisch) finden Sie [http://www.youtube.com/watch?v=oexr0z-eo9U hier] oder laden Sie die folgende Beispielumfrage herunter: [[Media:LimeSurvey_sample_survey_Conditions.lss|LimeSurvey_sample_survey_Conditions.lss]].
</div>
 
 
{{Hint|Text=The conditions functionalities work like a GUI for [[Expression Manager|the expressions and equations that can be applied to questions]], allowing the users to easily increase the complexity of their surveys without getting into expressions and relevance equations. However, [[Expression Manager|the Expression Manager]] must be studied/known to increase the range of options that is available within LimeSurvey.}}
 
 
==Verzweigung mittels Anzeigen/Verbergen oder Springen?==
 
 
Sie können in LimeSurvey logische Verzweigungen erstellen. Damit können Sie festlegen, dass einige Fragen nur angezeigt werden, wenn bestimmte Bedingungen erfüllt sind, wie z.B. "Zeige Frage X nur dann, wenn Frage Y mit 'Z' beantwortet wurde".
 
Der zugrunde liegende Ansatz ist eine "Verbergen/Anzeigen-Verzweigungslogik":
Sie können für jede Frage eine oder mehrere Bedingungen definieren. Erst wenn diese Bedingung(en) erfüllt ist/sind, wird die Frage angezeigt, sonst bleibt sie verborgen.
 


Eine Schritt-für-Schritt Video-Anleitung (Englisch) finden Sie [http://www.youtube.com/watch?v=oexr0z-eo9U hier] oder laden Sie folgende Beispielumfrage herunter: [[Media:LimeSurvey_sample_survey_Conditions.lss|LimeSurvey_sample_survey_Conditions.lss]].
<center>[[File:simple-condition-on-yes-question.png]]</center>


==Verzweigung oder Springen?==


Sie können mit LimeSurvey logische Verzweigungen erstellen. Damit können Sie festlegen, dass einige Fragen nur angezeigt werden, wenn bestimmte Bedingungen erfüllt sind, wie "Zeige die Frage X, wenn die Frage Y mit 'Z' beantwortet wurde".
<div class="mw-translate-fuzzy">
Dabei gilt:
* Eine Frage, für die keine Bedingung definiert ist, wird immer angezeigt.
* Eine Frage mit einer bzw. mehreren Bedingungen wird erst angezeigt, nachdem die Bedingung(en) erfüllt ist/sind.
</div>


Das Hide/Show- bzw. Verbergen/Anzeigen-Prinzip basiert auf einer Verzweigungslogik, sog. Wenn-Dann-Bedingung(en).  
<div class="mw-translate-fuzzy">
Sie können zu einer Frage eine oder mehrere Bedingungen definieren. Erst wenn die Bedingung(en) erfüllt ist/sind, wird die Frage angezeigt. Vorher bleibt die Frage verborgen (Hide)
Dieser Ansatz unterscheidet sich vom Ansatz der "Sprung-Verzweigungslogik", wie sie gelegentlich von anderer Software verwendet wird. Bei der 'Sprung-Verzweigungslogik' wird bei Erfüllung einer Bedingung zu einer Folgefrage gesprungen und die dazwischen liegenden Fragen ausgelassen werden.
LimeSurvey verfolgt einen anderen Ansatz: Wollen Sie eine Reihe von Fragen überspringen, müssen Sie die Anzeigen/Verbergen-Bedingung bei jeder Frage setzen, die Sie nicht anzeigen möchten.
Beispiel: Ihr Fragebogen umfasst die Fragen 1 bis 5. Möchten Sie zur Frage 5 springen, wenn die Antwort auf Frage 1 'Ja' ist (also Fragen 2 bis 4 überspringen), so müssen Sie die Bedingung bei Fragen 2, 3 und 4 so setzen, das diese nur angezeigt werden, wenn die Antwort auf die Frage 1 NICHT 'Ja' ist.
</div>


Einfach ausgedrückt:
<div class="mw-translate-fuzzy">
* eine Frage, für die keine Bedingung definiert ist, wird immer angezeigt
[[File:simple-condition-on-yes-question.png]]
* eine Frage mit einer bzw. mehreren Bedingungen wird erst angezeigt, nachdem die Bedingung(en) erfüllt ist/sind.
*LimeSurvey erleichtert das Erstellen von identischen Bedingungen (und damit das Nachbilden der "Sprung-Verzweigungslogik") für mehrere Fragen, indem Sie die Bedingung einer Frage auf andere Fragen übertragen bzw. kopieren können.
Im obigen Beispiel könnten Sie die Bedingung für Frage 2 erstellen und dann auf Frage 3 und 4 kopieren.
</div>


In LimeSurvey Ansatz unterscheidet sich der Ansatz von der 'Jump Branching Logic', wie sie gelegentlich von anderer Software verwendet wird. Dort führt die 'Jump Branching Logic' in der Regel dazu, dass bei einer bestimmten Antwort auf eine Frage zu einer späteren Frage gesprungen wird und die Fragen dazwischen ausgeblendet werden.
<div class='simplebox'> [[File:help.png]] To find out more details on how you can copy conditions within LimeSurvey, please continue reading the following [[Setting conditions#How to copy conditions|wiki section]].</div>
LimeSurvey verfolgt einen anderen Ansatz. Wollen Sie eine Reihe von Fragen überspringen, müssen Sie die Bedingung auf jede Frage setzen, die Sie nicht anzeigen möchten.
Beispiel: Möchten Sie, das wenn die Antwort auf die Frage 1 'Ja' ist, zur Frage 5 springen, so müssen Sie die Bedingung auf die Fragen 2, 3 und 4 so setzen, das diese nur angezeigt werden, wenn die Antwort auf die Frage 1 NICHT 'Ja' ist.


LimeSurvey macht das Erstellen von identischen Bedingungen (und damit die Umsetzung der "Jump Branching Logic") auf mehrere Fragen einfach, indem Sie die Bedingung einer Frage auf andere Fragen übertragen bzw. kopieren können.
Im obigen Beispiel würden Sie damit beginnen, indem Sie die Bedingung auf die Frage 2 auf die Bedingungen der Frage 3 und 4 kopieren.


==In LimeSurvey unterstütze Bedingungen==
==In LimeSurvey unterstütze Bedingungen==


Eine 'Bedingung' kann 'Werte' vergleichen und eine Antwort in Form von 'Richtig' (true) oder 'Falsch' (false) zurückgeben. Auf der Antwort 'Richtig' oder 'Falsch' basierend kann danach eine bestimmte 'Aktion' ausgelöst werden.


<div class="mw-translate-fuzzy">
Eine 'Bedingung' kann 'Werte' vergleichen und eine Antwort in Form von 'Richtig' (true) oder 'Falsch' (false) zurückgeben. Auf dem Rückgabewert 'Richtig' oder 'Falsch' basierend kann danach eine bestimmte 'Aktion' ausgelöst werden.
</div>
<div class="mw-translate-fuzzy">
Werte, die verglichen werden können sind:
Werte, die verglichen werden können sind:
* Antworten auf früherer Fragen
* '''Antworten auf frühere Fragen'''
** Zum Beispiel: Haben Sie auf die Frage 1 mit 'Ja' geantwortet?
** Zum Beispiel: "Wenn die Antwort bei Frage 1 mit 'Ja' war"
</div>


<div class="mw-translate-fuzzy">
[[File:simple-condition-on-F-question.png]]
[[File:simple-condition-on-F-question.png]]
</div>
<hr width="50%" style="margin:auto">
An dieser Stelle ist es wichtig zu verstehen, welche Antworten auf frühere Fragen im Bedingungseditor verwendet werden können:
<div class="mw-translate-fuzzy">
Verarbeitbare Antworten werden geliefert von:
* Einfachen Frage, wo die Antwort ein einzelner Wert (atomar) ist. Das sind alle Fragetypen abgesehen von Matrix-Fragen.
** Beispiel: Text-Antworten, Auswahl, Radio- oder Dropdown-Listen und Fragen mit mehreren Text-Antwortmöglichkeiten
* Einer Zeile einer Matrix-Frage (ausser für Matrix-Doppel-Skala und Matrix - Mehrere Flexible Fragen),
** Beispiel: Matrix mit 5 Radio-Buttons, Matrix mit Label-Fragen
* Entweder dem linke oder dem rechte Teil einer Matrix einer Doppel-Skala-Frage
* Jeder Zelle einer Matrix-Frage
</div>
{{Note|Check the following [[Question types|link]] to find out more about the available question types in LimeSurvey.}}
<div class="mw-translate-fuzzy">
Zur sprachlichen Vereinfachung werden in diesem Handbuch verarbeitbare Antworten als 'Frage' bezeichnet.
* '''Konstante Werte'''
** Beispiel: "Wenn Sie bei Frage 2 nach einer Dauer 'mehr als 3 Tage' gewählt haben".
</div>
<center>[[File:simple-condition-on-numerical-question.png]]</center>
<div class="mw-translate-fuzzy">
* '''Umfrageteilnehmer-Attribute''': Um darauf zugreifen zu können, muss 'Anonymisierte Antworten" auf AUS gesetzt sein. Diese Option finden Sie in 'Einstellungen -> Teilnehmereinstellungen'.
</div>
<center>[[File:simple-condition-on-token.png]]</center>
<hr width="50%" style="margin:auto">
<div class="mw-translate-fuzzy">
AM unterstützt diverse Vergleichoperatoren, vom einfachen Test auf Gleichheit bis hin zu komplexen regulären Ausdrücken.
* Die einfachsten Vergleichopratoren sind 'Gleich' und 'Ungleich'
* Ebenso verfügbar, wenngleich nur sinnvoll bei numerischen werten, sind 'Größer/Kleiner'-Vergleiche
** Bitte beachten Sie: bei numerischen Werten gilt die numerische Ordnung, z.B. gilt '2 < 10'
** Bei Textantworten (Strings) würde hingegen '2' > '10' gelten - hier wird alphabetisch sortiert!
** Bei numerischen Fragen - und wenn bei Textfragen das "Nur Zahlen:"-Attribut gesetzt ist - wird die numerische Ordnung verwendet
* Erweiterte Vergleichsoperatoren mit regulären Ausdrücken sind ebenso verfügbar
* Bei regulären Ausdrücken (wenn Sie nicht wissen, was das ist: keine Panik, dann benötigen Sie sie auch nicht!)
** darf das Suchmuster nicht in '/' eingeschlossen werden
** Beispiel: <div class="simplebox">[a-zA-Z]$
</div>
== Verknüpfung von Bedingungen ==
Man kann '''komplexe Bedingungen''' aus '''einfachen Bedingungen''' zusammensetzen, indem man sie mit den logischen Operatoren '''AND''' und '''OR''' verknüpft.
<center>[[File:simple-conditions-combination.png]]</center>


Es ist an dieser Stelle wichtig zu verstehen what is considered as an eligible question-entry for the condition editor:


Ein "Frage-Eintrag" ist entweder:
<div class="mw-translate-fuzzy">
* eine einfache Frage (für alle Fragetypen abgesehen von Array-Fragen)
Dabei ist zu beachten, dass LimeSurvey '''automatisch festlegt''', welcher der beiden Vergleichsoperatoren zur Anwendung kommt, d.h. es gibt eine kontextabhängige Priorität, ob '''OR''' oder '''AND''' stärker bindet.
** zum Beispiel: Text-Antworten, Auswahl, Radio- oder Dropdown-Listen und Fragen mit mehreren Text-Antwortmöglichkeiten
</div>
* oder eine Zeile im Array Fragen (ausser für Array-Doppel-Skala und Array Mehrere Flexible Fragen),
** zum Beispiel: Array mit 5 Radio-Buttons, Array mit Label-Fragen
* oder entweder der linke oder der Rechte Teil eines Arrays einer Doppel-Skala-Frage
* oder jeder Zelle eines Arrays mit flexiblen Fragen


Zur Vereinfachung werden in diesem Handbuch Antworten zu Fragen (question-entries) als 'Frage' bezeichnet.
<div class="mw-translate-fuzzy">
* Konstante Werte
Bevor wir zu den komplexen Bedingungen kommen, sollen zunächst einfache Bedingungen behandelt werden.
** Zum Beispiel: Sie antworten auf eine Frage nach einer Dauer mit 'mehr als 3 Tage'.
</div>


[[File:simple-condition-on-numerical-question.png]]
==Aufruf des Bedingungs-Designers==
* '''Participant's profile data''' To use '''Token attributes''', "Anonymized responses" must be set to NO.  This option can be found in General Settings -> Tokens tab.


[[File:simple-condition-on-token.png]]


Several comparison operators are supported from the simple "equals", to the advanced "Regular Expression":
First, you need to access the [[Question toolbar options#The question toolbar|conditions designer]]. To do that, click on the question you wish to apply the condition to:
* 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 (when they have the 'numbers_only' attribute set), will use the numeric order for comparisons
* An advanced comparison operator using regular expressions is also available.
* The "Regular Expression" operator (don't panic: If you don't know what this means, then you don't need it)
** the pattern is '''not''' to be enclosed in '/' characters
** for instance <div class="simplebox">[a-zA-Z]$


==How can I combine conditions==


[[File:simple-conditions-combination.png]]
<center>[[File:Question designer search question.png]]</center>


You can '''build complex conditions''' by '''combining simple conditions''' with the '''AND '''and '''OR '''logical operators.


However, it is important to understand that '''LimeSurvey automatically determines which logical operator to apply''': this means that the use of the '''OR '''or '''AND '''operators is determined '''according to the context''' of the condition.
Now, look for the '''Set conditions''' button located on the top question bar:


We'll talk about complex conditions later, but let's start by the simple ones first.


=Understanding Simple conditions: elementary conditions=
<center>[[File:Question designer set conditions.png]]</center>


==Accessing the editor screen==


First you need to access the condition editor:
Once accessed, the following page will be displayed:
* open the condition menu by clicking on the ''conditions icon'' in the question button bar, when viewing a question.
* then click on the ''Add and edit conditions icon'', the edit conditions screen will appear allowing you to create, edit or delete conditions for the current question.


The following screen will appear:


[[File:edit-conditions-EditorView.png]]
<center>[[File:Question designer top.png]]</center>


Note: for the moment '''don't modify the default scenario''' ([[File:default_scenario.png]]) that is automatically selected in the condition addition form: we'll discuss this later.


==Definition of elementary conditions==
The conditions designer panel can be divided into three sections:
* [[Setting conditions#The conditions designer toolbar|The conditions designer toolbar]]
* [[Setting conditions#Overview of the existent conditions|The current existent question conditions]]
* [[Setting conditions#Add/Edit conditions|Add/edit condition menu]]
 
 
==The conditions designer toolbar==
 
 
You may find on the toolbar the following options:
 
 
<center>[[File:Show conditions designer toolbar.png]]</center>
 
 
*'''Show conditions for this question''': Click on this button to get a quick overview of the current existent conditions that are applied to your question.
 
*'''Add and edit conditions''': It represents the default page that opens automatically once you click the '''Set conditions''' button. It is divided in two parts: (1) a table displaying all the existent conditions and scenarios, and (2) the [[Setting conditions#Add/Edit conditions|add/edit conditions menu]].
 
*'''Copy conditions''': Sometimes, you wish to apply the same condition to X questions in order to get questionY displayed at the end. For this, click on '''Copy conditions'''. A new window will open displaying the current existent conditions added to your question (let's call it question3). To add them to question5, check the desired conditions you wish to be copied, select question5, and click on the '''Copy conditions''' button located on the bottom left part of the panel. For further information, please continue reading the following [[Setting conditions#How to copy conditions|wiki section]].
 
*'''Save and close''': Once you are done with the changes, click '''Save and close''' to get your conditions saved.
 
*'''Move to question''': In order not to leave the conditions designer panel while moving to another question, use the following option to select from the dropdown list the next question you wish to apply conditions to. Please note that the dropdown list displays the questions that are displayed in the survey before and after the current question.
 
*'''Close''': If you wish to exit the panel without performing any changes, you can either go straight to the settings/structure tab and select the desired option or click '''Close''', which is located in the upper right of the screen.
 
 
==Overview of the existent conditions==
 
 
This section displays a table that contains all the existent scenarios and conditions of a question. Certain actions can be performed from here:
 
 
<center>[[FIle:Show conditions for this questions pic.png]]</center>
 
 
*In the top right part, three actions are available:
**Quick-add conditions - it fastens the process of adding conditions (read [[Setting conditions#Add/Edit conditions|below]] to learn about all the options)
**Renumber scenarios - if clicked, the scenarios will be renumbered with incremental numbers beginning from one. Please note that this option is displayed only if two or more scenarios are applied to your question.
**Delete all conditions - you can delete via this action all the current existent conditions and scenarios applied to your question.
 
 
<center>[[FIle:Conditions designer quickadd and delete.png]]</center>
 
 
*Besides the id number of each scenario there are three buttons that allow you to perform the following actions:
**Delete scenario
**Change scenario number
**Add condition to this scenario - click on this button to add another condition to the desired scenario
 
 
<center>[[FIle:Conditions Designer table scenarios.png]]</center>
 
 
*Two actions can be performed on each condition:
**Delete condition
**Edit condition - if clicked, you will be able to edit the condition from the [[Setting conditions#Add/Edit conditions|conditions menu]]
 
 
<center>[[FIle:Conditions Designer table conditions.png]]</center>
 
==Add/Edit conditions==
 
 
The bottom part of the screen is allocated to the Add/edit conditions menu:
 
 
<center>[[File:Add_edit_condition_q.png]]</center>
 
 
<div class='simplebox'> You can also edit the condition from the same location if you pressed before on the green pencil that corresponds to the question you wish to be edited (see the [[Setting conditions#Overview of the existent conditions|conditions and scenarios table]]).</div>
 
To understand how the conditions feature works in LimeSurvey, we will first present the elementary conditions.
 
 
<div class='simplebox'>[[File:help.png]] '''Note''': For the moment '''don't modify the default scenario''' ([[File:default_scenario.png]]) that is automatically selected in the condition addition form. It will be covered later within this [[Setting conditions#The usage of scenarios - Using ORed conditions between different questions|wiki section]].</div>
 
 
===Definition of elementary conditions===
 


An elementary condition is simply a single condition '''without any OR or AND''' logical operators.
An elementary condition is simply a single condition '''without any OR or AND''' logical operators.


It is composed by:
It is composed by:
* a left operand: the ''tested value''
* a left operand: the ''tested value''. You can choose the ''tested value'' type by selecting the appropriate tab in the condition editor. It can either be a previous question or a [[Survey participants|survey participant]] attribute.
** you can choose the ''tested value'' type by selecting the appropriate tab in the condition editor
 
 
<center>[[File:edit-conditions-testedvalueTab.png]]</center>
 
 
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 under the '''Predefined''' tab of the comparison value selection.
 
 
<div class='simplebox'> [[File:help.png]] Note that in order to use the Token your survey must:
*not use [[Participant settings|anonymous answers]]
*use a [[Survey participants|survey participants table]] and [[Participant settings|closed access]].</div>
 
 
* a ''comparison operator''. Choose the ''comparison operator'' you want to apply from the dropdown list (''less than'', ''less than or equal to'', ''equals'', ''not equal to'', ''greater than or equal to'', ''greater than'', ''[[Expression Manager|regular expression]]'').
 
 
* a right operand: the ''comparison value''. You can choose the ''comparison value'' type by selecting the appropriate tab in the condition editor. When you create a condition, you can select as the comparison value a predefined value (answer), a constant, a question, a survey participant attribute, or a regular expression:


[[File:edit-conditions-testedvalueTab.png]]
* a ''comparison operator''
** Choose the ''comparison operator'' you want to apply in the dropdown list


[[File:conditions-operators.png]]
<center>[[File:edit-conditions-comparisonvalueTab.png]]</center>
* a right operand: the ''comparison value''
** you can choose the ''comparison value'' type by selecting the appropriate tab in the condition editor


[[File:edit-conditions-comparisonvalueTab.png]]
===Example of elementary conditions and how to create them===


==Example of elementary conditions and how to create them==
 
* Show question IF "the answer to Question1 was the predefined answer 'Male'"
* Show Question 'AAMN' '''if''' "the answer to Question 'Gender' is the predefined answer 'Male'"
** ''tested value'' = answer to Question1
** ''tested value'' = answer to Question 'Gender'
** ''comparison operator'' = equals
** ''comparison operator'' = equals
** ''comparison value'' = answer code of the 'Male' answer
** ''comparison value'' = predefined answer code (the 'Male' answer in this case)
 
 
<center>[[File:edit-simple-condition-predefanswer.png]]</center>
 
 
* Show Question 'Alcohol' '''if''' "the answer to Question 'Age' is greater or equal than the numerical value '18'"
** ''tested value'' = answer to Question 'Age'
** ''comparison operator'' = greater than or equal to
** ''comparison value'' = the constant value '18'


[[File:edit-simple-condition-predefanswer.png]]
* Show question IF "the answer to Question2 was greater than the numerical value '5'"
** ''tested value''= answer to Question2
** ''comparison operator''= greater than
** ''comparison value''= the constant value 5


[[File:edit-simple-condition-constant.png]]
<center>[[File:edit-simple-condition-constant.png]]</center>


</div>'''Caution''': When using a constant 'comparison value' for a date question, you must enter the value with the YYY-MM-DD format, whatever the date format is set for current survey.<div class="simplebox">
* Show question IF "the answer to Question3 was greater than the answer to Question2"
** ''tested value''= answer to Question3
** ''comparison operator''= greater than
** ''comparison value''= answer to Question2


[[File:edit-simple-condition-prevQuestion.png]]
{{Alert|title=Attention|text=When using a constant 'comparison value' for a date question, regardless of the date format set in your survey, you must use the YYYY-MM-DD date format.}}
* Show question IF "the 'Department' value from the participant's profile (Token Attribute from the invitation) equals the 'Accounting' string"
** ''tested value''= the 'Department' value taken from the token invitation
** ''comparison operator''= equals
** ''comparison value''= the constant value 'Accounting'


[[File:edit-simple-condition-leftToken.png]]


Detailed instructions on how to set up the above example can be found at this blog post: "[http://www.limesurvey-consulting.com/limesurvey-conditions-based-on-token-attributes/ Conditions based on token attributes]"
* Show Question 'Alcohol' '''if''' "the answer to Question 'BirthDate' is greater than 2000-01-01'''"
** ''tested value'' = answer to Question 'BirthDate'
** ''comparison operator'' = Greater than or equal to
** ''comparison value'' = '2000-01-01' (the format in the constant field: 2000-01-01)
 
 
<center>[[File:Date time example condition.png]]</center>
 
 
* Show Question 'Alcohol' '''if''' "the the 'DrinkingHistory' [[Survey participants|participant's attribute]]" matches the 'Yes' string.
** ''tested value''= the 'DrinkingHistory' value taken from the [[Survey participants#Manage attributes|survey participants table]]
** ''comparison operator'' = equals
** ''comparison value'' = the constant value 'Yes'
 
 
<center>[[File:edit-simple-condition-leftToken.png]]</center>
 
=Conditions and scenarios in LimeSurvey=
 
 
==Default condition combinations==


=Default condition combinations=


As said earlier, LimeSurvey automatically decides which logical operator (AND or OR) should be applied between conditions depending on the 'context'.
As said earlier, LimeSurvey automatically decides which logical operator (AND or OR) should be applied between conditions depending on the 'context'.
Line 149: Line 325:
Note also that '''the order in which you define your elementary conditions is not relevant''' as LimeSurvey will automatically reorder them according to its own logic.
Note also that '''the order in which you define your elementary conditions is not relevant''' as LimeSurvey will automatically reorder them according to its own logic.


Let's study this in detail.
Let's study this in detail. Two rules should be always remembered:
* [[Setting conditions#First rule: conditions having the same tested value are ORed together|First rule]]: conditions having the same ''tested value'' are ORed together
* [[Setting conditions#Second rule: conditions having different tested value are ANDed together|Second rule]]: conditions having different tested value are ANDed together
 
 
===First rule: conditions having the same ''tested value'' are ORed together===
 
 
When you have several conditions, they are '''ORed''' together if they share the same '''tested value'''. This is the case if the condition applies to several answers belonging to one single question. For example, a condition was applied below to three answers belonging to the same question - if answer to Question 'FavColour' equals 'green' '''OR'''  answer to Question 'FavColour' equals 'red'  '''OR'''  answer to Question 'FavColour' equals 'blue', then Question 'BirthDate' will be displayed to the survey respondent:
 
 
<center>[[File:edit-conditions-naturalOr-edit.png]]
 
[[File:edit-conditions-naturalOr-result.png]]</center>
 
 
<div class='simplebox'>[[File:help.png]] Note: To select multiple predefined answers, don't forget to hold the Shift or Ctrl key while selecting the '''tested values'''.</div>
 
 
===Second rule: conditions having different ''tested value'' are ANDed together===
 
 
When you have several conditions, they are '''ANDed''' together if they don't share the same '''tested values'''. For example, you may see below the case for several conditions based on different previous questions - "If answer to Question 'Alcohol' equals 'Y' answer '''AND''' answer to Question 'Gender' equals 'F'", then Question 'Alcoholconsumption' will be displayed to the survey respondent:
 
 
<center>[[File:edit-conditions-naturalAND-editA.png]]
 
[[File:edit-conditions-naturalAND-editB.png]] </center>
 
<center>[[File:edit-conditions-naturalAND-result.png]]</center>
 
 
===The multiple options questions===
 
 
<div class='simplebox'>[[File:help.png]] '''Note:''' This paragraph applies to ''Multiple options'' and ''Multiple options with comments'' questions, and not to ''Array Multiple Flexible (number) with checkbox layout'' questions (in case of the latter, each checkbox is a separate question-entry and is not really handled as other multiple options question-types).</div>
 
 
The ''Multiple choice'' and ''Multiple choice with comments'' question types will be displayed in two flavors:
* a ''Group of checkboxes'' flavor which let you set conditions on all possible answers of the respective question;
* a set of ''Single checkbox'' entries which lets you set conditions on each checkbox individually.
 


==First rule: conditions having the same ''tested value'' are ORed together==
<center>[[File:edit-conditions-MultipleOptions1.png]]</center>


When you have several conditions they are '''ORed''' together if they share the same '''tested value'''
* this is the case for instance for several possible answers of the same previous question: "If answer to Question1 equals 'green' '''OR'''  answer to Question1 equals 'red'  '''OR'''  answer to Question1 equals 'blue'"


[[File:edit-conditions-naturalOr-edit.png]][[File:edit-conditions-naturalOr-result.png]]
====The group of checkboxes flavour====


==Second rule: conditions having different ''tested value'' are ANDed together==


When you have several conditions, they are '''ANDed''' together if they don't share the same '''tested values'''
Now, let's focus on an example to better understand the difference between the two flavours. Let's imagine that we wish to display the 'Pointchoice' Question only if the respondent checks at least one of the ''tested answers'' listed under the 'MultipleOrganizations' Question.
* this is the case for instance for several conditions based on different previous questions: "If answer to Question1 equals '4' '''AND''' answer to Question2 equals 'green'"


[[File:edit-conditions-naturalAND-editA.png]]  [[File:edit-conditions-naturalAND-editB.png]]  [[File:edit-conditions-naturalAND-result.png]]
As mentioned above, the group of checkboxes flavor allows you to set conditions on all possible answers of the respective question. Therefore, only the options that refer to responsibilities are selected as '''comparison values''' below:


==Third rule: ORed elementary conditions take precedence over the other ANDed conditions==


Imagine you define the 3 following sets of conditions:
<center>[[File:edit-conditions-MultipleOptionsOR.png]]</center>
*IF answer to Question "Type !" was 'Green'
*IF answer to question "Type 5" was '4'
*IF answer to question "Type A" was '4' or '5'


[[File:edit-conditions-naturalAND-editA.png]][[File:edit-conditions-naturalAND-editB.png]][[File:edit-conditions-naturalANDandOR-editC.png]]
* Then the resulting conditions will be:


[[File:edit-conditions-naturalANDandOR-result.png]]
As we can observe, the conditions get ORed due to the ''Group of checkboxes'' flavour selected in the beginning.:  
**Note the '''capital 'OR'''' and the '''lower case 'and'''': this means that ORed conditions are evaluated as if prioritized with parentheses
**Note also that the order of the elementary conditions creation is not preserved and has no importance here
** The resulting conditions is: IF (answer to question "Type A" was '4' '''OR  '''answer to question "Type A" was '4') '''AND '''(IF answer to question "Type 5" was '4') '''AND '''(IF answer to Question "Type !" was 'Green')


==The multiple options questions==


Note: This paragraph applies to ''Multiple options'' and ''Multiple options with comments'' questions, and not to ''Array Multiple Flexible (number) with checkbox layout'' questions (for this later question type, each checkbox is a separate question-entry and is not really handled as other multiple options question-types).
<center>[[File:edit-conditions-MultipleOptionsOR-result.png]]</center>


[[File:edit-conditions-MultipleOptions1.png]]


For ''Multiple options'' and ''Multiple options with comments'' questions, in the ''tested value''part of the condition editor this question will appear in two flavors
====ANDing conditions in multiple choice questions====
* a ''Group of checkboxes'' flavor which let you set conditions on all possible answers of this question
* a set of ''Single checkbox'' entries which let you set conditions on each checkbox individually


And now let's test your knowledge of conditions by trying to answer this question:
* I've got a multiple options question:
** Issue A: How can I set ORed conditions between different answers of this question
** Issue B: How can I set ANDed conditions between different answers of this question


...
Now, let's focus on a similar example. However, we are looking this time only for the most active members to ask them further questions. To do this, we make use of the '''Single checkbox''' flavour which allows you to set conditions based on each checkbox individually.  


...
In this example, question X will be displayed if ''A'' and ''B'' are checked:


...


Now the answers...
<center>[[File:edit-conditions-MultipleOptionsAND2.png]]</center>


For Issue A:
<center>[[File:edit-conditions-MultipleOptionsAND3.png]]</center>
* Use the ''Group of checkboxes'' entry as your ''tested value'' and select as much answers you want


[[File:edit-conditions-MultipleOptionsOR.png]][[File:edit-conditions-MultipleOptionsOR-result.png]]


For Issue B:
Once done, you can observe that the two conditions are ANDed now.
* Use the ''Single checkbox'' entry that correspond to the first answer you need to set the condition on and set the condition to the ''checked'' ''comparison value''


[[File:edit-conditions-MultipleOptionsAND1.png]]
* Use the ''Single checkbox'' entry that correspond to the second answer you need to set the condition on and set the condition to the ''checked'' ''comparison value''


[[File:edit-conditions-MultipleOptionsAND2.png]]
<center>[[File:edit-conditions-MultipleOptionsAND-result.png]]</center>
* Enjoy the result:
 
 
This means that your question will not be displayed unless both tested values (the selected subquestions) are met.


[[File:edit-conditions-MultipleOptionsAND-result.png]]


==Verschiedene Szenarien verwenden==
==Verschiedene Szenarien verwenden==
Line 223: Line 414:




[[File:multi_scenario.png]]


==Definition of a scenario==


A scenario is simply '''a manual grouping of conditions''' in which conditions are evaluated independently of conditions from other scenarios. The complex condition resulting in this association of several scenarios will be met if only one scenario is met: in other words scenarios are '''logical grouping of conditions''', respecting the above rules, and '''which are ORed together''' to build complex conditions.
===Definition of a scenario===
 
 
A scenario is simply '''a manual grouping of conditions''' in which some conditions are evaluated independently of other conditions from other scenarios. The complex condition resulting in this association of several scenarios will be met only if one scenario is met. In other words, scenarios are '''logical grouping of conditions''', respecting the above [[Setting conditions#Default condition combinations|rules]], and '''which are ORed together''' to build complex conditions.


All what we described above is true inside a scenario, and by default all new conditions are created inside the "Default Scenario".
Everything described above applies to the conditions located in every scenario. By default, all the new conditions are created inside the ''Default Scenario'', which uses number '1' as its identifier.  When you create new conditions, you can choose whether they are added to the default scenario or not. To change the scenario, just use another identifier.


However, when you create a new elementary condition, you decide to affect it to another scenario than the default one.


Scenarios are identified by a simple number, the "Default scenario" having number '1' as its identifier.
===Adding a question to another scenario===


==Adding a question to another scenario==


When you create (or edit) a condition, you can modify the scenario in which the condition is stored:
When you create (or edit) a condition, you can modify the scenario in which the condition is stored by simply clicking on the add scenario button:


[[File:edit-conditions-EditorView-Scenario.png]]


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]]
<center>[[File:edit-conditions-EditorView-Scenario.png]]</center>


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


[[File:edit-conditions-EditorView-Scenario2.png]]
As you can observe, the default scenario uses as identifier '1'. To add conditions to different scenarios, change the identifier by typing a different number in the box.


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


==Editor overview==


First you access the condition editor:
<center>[[File:Conditions test ids.png]]</center>
* 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]]
You can change the number assigned to a scenario by clicking this Icon [[File:scenario_edit.png]] and assigning the new id to the scenario.


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:
<center>[[File:edit_scenario_conditions.png]]</center>
* edit condition [[File:conditions_edit.png]]
* delete all conditions [[File:conditions_deleteall.png]], delete this condition [[File:conditions_delete.png]], delete all conditions from this scenario [[File:scenario_delete.png]]
* edit scenario [[File:scenario_edit.png]]


[[File:edit-conditions-EditModeButtons.png]]


In Copy mode [[File:conditions_copy.png]], each line is prepended with a checkbox allowing you to select those conditions you want to copy to later questions:
<div class='simplebox'> [[File:help.png]] '''Note:''' 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 scenarios are displayed when using the printable version of a survey
* merge conditions from two scenarios (in order to merge scenario 10 with scenario 1, just renumber scenario 10, so that it is scenario 1).</div>


[[File:copying_conditions.png]]


==Setting new conditions==
===Example: creating three scenarios===


===First select the scenario===


'''If you don't need ORed conditions''' between different question-entries, '''just don't modify the default scenario''' ([[File:default_scenario.png]]) that is automatically selected in the condition edition form.
To create three scenarios, you need at least three conditions and to add to each of them a different scenario id. Once done, the scenarios are going to be connected among themselves via the 'OR' operator. For example, it could look like this:


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.
<center>[[File:edit-conditions-EditorView-Scenario2.png]]</center>


===Select the ''tested value''===
== AND vs OR in the same scenario==


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:
You may end up in certain cases with AND and OR logical operators in the same scenario:
* '''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.
<center>[[File:And vs OR example.png]]</center>


===Select the comparison operator===


[[File:comparison_operators_conditions.png]]
LimeSurvey will always apply first OR. For further details on this, you may check the following Wikipedia article on [https://en.wikipedia.org/wiki/Boolean_algebra Boolean algebra].


Several comparison operators can be used:
However. the order of operations can also be observed in the Relevance equation field. For the above example, the relevance equation is highlighted below:
* 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.


===Selecting an ''comparison value''===


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).
<center>[[File:AND vs OR relevance eq.png]]</center>


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.
As it can be observed, a set of extra parentheses is added for the OR logical operations in order to let the software know that it must be "computed" first.


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.
<div class='simplebox'> [[File:help.png]] '''Help:''' For more information on relevance equations, check the [[Expression Manager]] and [[QS:Relevance|relevance equation]] wiki sections. </div>


==Editing/Deleting conditions==
=How to copy conditions=


Apart from adding new conditions, the Add/Edit can be used to
* edit conditions
* delete conditions
* edit scenario


===Edit conditions===
The copy conditions functionality can be used when you wish to apply the same set of conditions you applied to Question5 to Question10. In this way, you will not have to manually recreate the conditions you applied to the previous question(s).


By clicking on the edit icon [[File:conditions_edit.png]] 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.
To start copying conditions, you first have to select the question the condition(s) is/are applied to (Question 'LowQ' in our case). Then, select the conditions you wish to be copied and select the question you wish to have the conditions added to (Question 'Alcohol' in our case).


Click the update condition button to update this condition.


===Delete conditions===
<center>[[File:Copy conditions panel.png]]</center>


You can:
* delete a single condition by clicking on this icon [[File:conditions_delete.png]]
* delete all conditions within a scenario by clicking on this icon [[File:scenario_delete.png]]
* delete all conditions from this question by clicking on this icon [[File:conditions_deleteall.png]]


===Edit Scenario===
<div class='simplebox'>[[FIle:help.png]] '''Note:''' Conditions can only be set based on questions that appear before the question on which the condition is set.</div>


You can change the number assigned to a scenario by clicking this Icon [[File:scenario_edit.png]] and fill-in the form that appears on the same line.
Please pay attention to how the copy conditions functions work when you wish to copy and apply a set of conditions located under different scenarios to another question which uses the same or different scenario id numbers. To summarise the possible cases you might have, check the following example:


[[File:edit_scenario_conditions.png]]
* you wish to copy Scenario 1 - Condition A, Scenario 1- Condition B, Scenario 7 - Condition C, and Scenario 7 - Condition D from QuestionX into QuestionY
*QuestionY already contains Scenario 1 - Condition A, Scenario - Condition C, Scenario 6 - Condition E, Scenario 8- Condition F.
*Once copied, the following conditions will be applied to QuestionY:
**Scenario 1: Condition A, Condition B, Condition C -> '''Condition A is not copied anymore as it already exists in QuestionY, only condition B being copied.'''
**Scenario 6: Condition E -> not affected
**Scenario 7: Condition C, Condition D -> '''a new scenario is created where the two conditions are added to it'''
**Scenario 8: Condition F -> not affected


Alternatively, you can renumber scenarios by clicking on this icon [[File:scenario_renumber.png]].


As said above, scenario numbers have no impact in the way conditions are evaluated. However, modifying the scenario numbers are needed in order to:
=Reset conditions=
* 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).


==Copying conditions to later questions==


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.
To quickly reset all the survey conditions, click on one survey-related setting, look for '''Tools''' on the top toolbar, and click '''Reset conditions:'''


Switch to the copy mode by clicking the on the Copy conditions icon [[File:conditions_copy.png]].


[[File:copy_conditions_example.png]]
<center>[[File:Reset_conditions_location.png]]</center>


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.
Next, confirm on the next page that you want to proceed and all the conditions will be deleted.  


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


=Things to watch out for=
=Things to watch out for=


==General considerations==
==General considerations==


There are a few basic rules you should keep in mind before setting conditions on a question:
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.
*Once a single condition has been set for a question, that question '''will not be displayed''' unless that condition is met.
*Conditions can only be set based on questions that appear '''before''' the question on which the condition is set.
*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.
*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 any of your conditions. You should always put aside the creation of conditions until you are satisfied 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.
*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==
==Conditions using the 'no answer' predefined answer==


[[File:noanswer_conditions.png]]


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"
<center>[[File:noanswer_conditions.png]]</center>
 
 
Setting the following condition "Show question 'FavColour' if the answer to the question 'Gender' is 'no answer'" really means "show question 'FavColour' if question 'Gender' was displayed to the survey participant who did not submit answer".
 
 
{{Hint|Text=To have the no answer option displayed as a predefined answer, the question cannot be [[QS:Mandatory|mandatory]].}}
 


==Chained conditions==
==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.


[[File:chained_conditions1.png]]
If you set conditions on a question that, itself, has conditions, you could end up with your survey behaving 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, the group header will still be shown unless you correct these conditions as explained below.
 


[[File:chained_conditions2_bad.png]]
<center>[[File:chained_conditions1.png]]</center>


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.
<center>[[File:chained_conditions2_bad.png]]</center>


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:
In the above example, the 'Alcohol' question is displayed if the respondent has previously answered to the 'AAMN' question 'No (N)'. However, the 'AAMN' question might not be displayed at the end if the respondent did not select to the previous question ('Gender') answer 'Male (M)'. In this scenario, no 'Alcohol' question will be displayed if 'Male (M)' was chosen previously.
* on Q2: display question if answer to Q1 is Male
* 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:
To have the 'Alcohol' question displayed, you have to copy the conditions from the earlier question(s) to the one you're editing. To have the 'Alcohol' question displayed, you need to set up the following set of conditions:
* Show 'AAMN' if the answer to 'Gender' is 'Male (M)'
* Show 'Alcohol' if answer to 'Gender' is 'Male (M)' '''and''' if answer to 'AAMN' is No (N)'.


[[File:chained_conditions2_good.png]]
After correction, the correct set of conditions for 'Alcohol' should look like this:
 
 
<center>[[File:chained_conditions2_good.png]]</center>
 
 
So if you are designing a complicated survey with a large number of conditions, make sure you test the survey for as many different combinations of results as you can think of.
 
<div class='simplebox'>[[File:help.png]] To find out more on how you can copy conditions in LimeSurvey, please scroll up or click here to continue reading the dedicates [[Setting_conditions#How_to_copy_conditions|wiki section]].</div>


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==
==Limitations and workarounds==


===Progress-bar===
===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.
If you create a survey where many questions get skipped because of conditions, the progress bar either jumps over a set of questions or the survey ends at 50%.


For Example: based on question one (yes or no question) 14 questions will be asked question 2A to 15A when the answer of question one was yes, 2B to 15B when the answer to question one was no.
To avoid such behavior, the questions that could be skipped should be arranged between the shown questions. In this way, only one or two questions get skipped per answer.
 
For example, based on Question1 (yes or no question), 14 questions (2A to 15A) will be displayed if the answer to Question1 is 'Yes', or 2B to 15B if the answer to Question1 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.


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===
=== 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.
 
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===
=== 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.
 
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 you 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.
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.
However, due to the specific way Multiple choice questions are handled, 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.
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?===
===How to use parenthesis for the boolean expressions?===


'''''You can't!'''''
'''''You can't!'''''
Line 447: Line 611:
If you want to design something like:
If you want to design something like:


 (condition1 OR condition2) AND (condition3 OR condition4)
''(condition1 OR condition2)'' AND ''(condition3 OR condition4)'',


you'll have to set up:
you'll have to set up:


 (condition1 AND condition3) OR
 ''(condition1 AND condition3)'' OR


 (condition1 AND condition4) OR
 ''(condition1 AND condition4)'' OR


 (condition2 AND condition3) OR
 ''(condition2 AND condition3)'' OR


 (condition2 AND condition4)
 ''(condition2 AND condition4)''

Revision as of 15:55, 6 December 2018


Allgemeines zu Bedingungen in LimeSurvey

LimeSurvey hat ein sehr leistungsfähiges Logik-Verzweigungsfeature.

In diesem Kapitel wird beschrieben ...

  • welche Bedingungen es in LimeSurvey gibt.
  • was man mit Bedingungen tun kann und was nicht.
  • welche Schritte erlernt werden müssen, um einfache oder komplexe Bedingungen zu erstellen.

Eine Schritt-für-Schritt Video-Anleitung (Englisch) finden Sie hier oder laden Sie die folgende Beispielumfrage herunter: LimeSurvey_sample_survey_Conditions.lss.


 Hint: The conditions functionalities work like a GUI for the expressions and equations that can be applied to questions, allowing the users to easily increase the complexity of their surveys without getting into expressions and relevance equations. However, the Expression Manager must be studied/known to increase the range of options that is available within LimeSurvey.


Verzweigung mittels Anzeigen/Verbergen oder Springen?

Sie können in LimeSurvey logische Verzweigungen erstellen. Damit können Sie festlegen, dass einige Fragen nur angezeigt werden, wenn bestimmte Bedingungen erfüllt sind, wie z.B. "Zeige Frage X nur dann, wenn Frage Y mit 'Z' beantwortet wurde".

Der zugrunde liegende Ansatz ist eine "Verbergen/Anzeigen-Verzweigungslogik": Sie können für jede Frage eine oder mehrere Bedingungen definieren. Erst wenn diese Bedingung(en) erfüllt ist/sind, wird die Frage angezeigt, sonst bleibt sie verborgen.



Dabei gilt:

  • Eine Frage, für die keine Bedingung definiert ist, wird immer angezeigt.
  • Eine Frage mit einer bzw. mehreren Bedingungen wird erst angezeigt, nachdem die Bedingung(en) erfüllt ist/sind.

Dieser Ansatz unterscheidet sich vom Ansatz der "Sprung-Verzweigungslogik", wie sie gelegentlich von anderer Software verwendet wird. Bei der 'Sprung-Verzweigungslogik' wird bei Erfüllung einer Bedingung zu einer Folgefrage gesprungen und die dazwischen liegenden Fragen ausgelassen werden. LimeSurvey verfolgt einen anderen Ansatz: Wollen Sie eine Reihe von Fragen überspringen, müssen Sie die Anzeigen/Verbergen-Bedingung bei jeder Frage setzen, die Sie nicht anzeigen möchten. Beispiel: Ihr Fragebogen umfasst die Fragen 1 bis 5. Möchten Sie zur Frage 5 springen, wenn die Antwort auf Frage 1 'Ja' ist (also Fragen 2 bis 4 überspringen), so müssen Sie die Bedingung bei Fragen 2, 3 und 4 so setzen, das diese nur angezeigt werden, wenn die Antwort auf die Frage 1 NICHT 'Ja' ist.

  • LimeSurvey erleichtert das Erstellen von identischen Bedingungen (und damit das Nachbilden der "Sprung-Verzweigungslogik") für mehrere Fragen, indem Sie die Bedingung einer Frage auf andere Fragen übertragen bzw. kopieren können.

Im obigen Beispiel könnten Sie die Bedingung für Frage 2 erstellen und dann auf Frage 3 und 4 kopieren.

To find out more details on how you can copy conditions within LimeSurvey, please continue reading the following wiki section.


In LimeSurvey unterstütze Bedingungen

Eine 'Bedingung' kann 'Werte' vergleichen und eine Antwort in Form von 'Richtig' (true) oder 'Falsch' (false) zurückgeben. Auf dem Rückgabewert 'Richtig' oder 'Falsch' basierend kann danach eine bestimmte 'Aktion' ausgelöst werden.

Werte, die verglichen werden können sind:

  • Antworten auf frühere Fragen
    • Zum Beispiel: "Wenn die Antwort bei Frage 1 mit 'Ja' war"





An dieser Stelle ist es wichtig zu verstehen, welche Antworten auf frühere Fragen im Bedingungseditor verwendet werden können:

Verarbeitbare Antworten werden geliefert von:

  • Einfachen Frage, wo die Antwort ein einzelner Wert (atomar) ist. Das sind alle Fragetypen abgesehen von Matrix-Fragen.
    • Beispiel: Text-Antworten, Auswahl, Radio- oder Dropdown-Listen und Fragen mit mehreren Text-Antwortmöglichkeiten
  • Einer Zeile einer Matrix-Frage (ausser für Matrix-Doppel-Skala und Matrix - Mehrere Flexible Fragen),
    • Beispiel: Matrix mit 5 Radio-Buttons, Matrix mit Label-Fragen
  • Entweder dem linke oder dem rechte Teil einer Matrix einer Doppel-Skala-Frage
  • Jeder Zelle einer Matrix-Frage
Check the following link to find out more about the available question types in LimeSurvey.

Zur sprachlichen Vereinfachung werden in diesem Handbuch verarbeitbare Antworten als 'Frage' bezeichnet.

  • Konstante Werte
    • Beispiel: "Wenn Sie bei Frage 2 nach einer Dauer 'mehr als 3 Tage' gewählt haben".



  • Umfrageteilnehmer-Attribute: Um darauf zugreifen zu können, muss 'Anonymisierte Antworten" auf AUS gesetzt sein. Diese Option finden Sie in 'Einstellungen -> Teilnehmereinstellungen'.





AM unterstützt diverse Vergleichoperatoren, vom einfachen Test auf Gleichheit bis hin zu komplexen regulären Ausdrücken.

  • Die einfachsten Vergleichopratoren sind 'Gleich' und 'Ungleich'
  • Ebenso verfügbar, wenngleich nur sinnvoll bei numerischen werten, sind 'Größer/Kleiner'-Vergleiche
    • Bitte beachten Sie: bei numerischen Werten gilt die numerische Ordnung, z.B. gilt '2 < 10'
    • Bei Textantworten (Strings) würde hingegen '2' > '10' gelten - hier wird alphabetisch sortiert!
    • Bei numerischen Fragen - und wenn bei Textfragen das "Nur Zahlen:"-Attribut gesetzt ist - wird die numerische Ordnung verwendet
  • Erweiterte Vergleichsoperatoren mit regulären Ausdrücken sind ebenso verfügbar
  • Bei regulären Ausdrücken (wenn Sie nicht wissen, was das ist: keine Panik, dann benötigen Sie sie auch nicht!)
    • darf das Suchmuster nicht in '/' eingeschlossen werden
    • Beispiel:
      [a-zA-Z]$


Verknüpfung von Bedingungen

Man kann komplexe Bedingungen aus einfachen Bedingungen zusammensetzen, indem man sie mit den logischen Operatoren AND und OR verknüpft.



Dabei ist zu beachten, dass LimeSurvey automatisch festlegt, welcher der beiden Vergleichsoperatoren zur Anwendung kommt, d.h. es gibt eine kontextabhängige Priorität, ob OR oder AND stärker bindet.

Bevor wir zu den komplexen Bedingungen kommen, sollen zunächst einfache Bedingungen behandelt werden.

Aufruf des Bedingungs-Designers

First, you need to access the conditions designer. To do that, click on the question you wish to apply the condition to:



Now, look for the Set conditions button located on the top question bar:



Once accessed, the following page will be displayed:



The conditions designer panel can be divided into three sections:


The conditions designer toolbar

You may find on the toolbar the following options:



  • Show conditions for this question: Click on this button to get a quick overview of the current existent conditions that are applied to your question.
  • Add and edit conditions: It represents the default page that opens automatically once you click the Set conditions button. It is divided in two parts: (1) a table displaying all the existent conditions and scenarios, and (2) the add/edit conditions menu.
  • Copy conditions: Sometimes, you wish to apply the same condition to X questions in order to get questionY displayed at the end. For this, click on Copy conditions. A new window will open displaying the current existent conditions added to your question (let's call it question3). To add them to question5, check the desired conditions you wish to be copied, select question5, and click on the Copy conditions button located on the bottom left part of the panel. For further information, please continue reading the following wiki section.
  • Save and close: Once you are done with the changes, click Save and close to get your conditions saved.
  • Move to question: In order not to leave the conditions designer panel while moving to another question, use the following option to select from the dropdown list the next question you wish to apply conditions to. Please note that the dropdown list displays the questions that are displayed in the survey before and after the current question.
  • Close: If you wish to exit the panel without performing any changes, you can either go straight to the settings/structure tab and select the desired option or click Close, which is located in the upper right of the screen.


Overview of the existent conditions

This section displays a table that contains all the existent scenarios and conditions of a question. Certain actions can be performed from here:



  • In the top right part, three actions are available:
    • Quick-add conditions - it fastens the process of adding conditions (read below to learn about all the options)
    • Renumber scenarios - if clicked, the scenarios will be renumbered with incremental numbers beginning from one. Please note that this option is displayed only if two or more scenarios are applied to your question.
    • Delete all conditions - you can delete via this action all the current existent conditions and scenarios applied to your question.



  • Besides the id number of each scenario there are three buttons that allow you to perform the following actions:
    • Delete scenario
    • Change scenario number
    • Add condition to this scenario - click on this button to add another condition to the desired scenario



  • Two actions can be performed on each condition:
    • Delete condition
    • Edit condition - if clicked, you will be able to edit the condition from the conditions menu


Add/Edit conditions

The bottom part of the screen is allocated to the Add/edit conditions menu:



You can also edit the condition from the same location if you pressed before on the green pencil that corresponds to the question you wish to be edited (see the conditions and scenarios table).

To understand how the conditions feature works in LimeSurvey, we will first present the elementary conditions.


Note: For the moment don't modify the default scenario () that is automatically selected in the condition addition form. It will be covered later within this wiki section.


Definition of elementary conditions

An elementary condition is simply a single condition without any OR or AND logical operators.

It is composed by:

  • a left operand: the tested value. You can choose the tested value type by selecting the appropriate tab in the condition editor. It can either be a previous question or a survey participant attribute.



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 under the Predefined tab of the comparison value selection.


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


  • a comparison operator. Choose the comparison operator you want to apply from the dropdown list (less than, less than or equal to, equals, not equal to, greater than or equal to, greater than, regular expression).


  • a right operand: the comparison value. You can choose the comparison value type by selecting the appropriate tab in the condition editor. When you create a condition, you can select as the comparison value a predefined value (answer), a constant, a question, a survey participant attribute, or a regular expression:


Example of elementary conditions and how to create them

  • Show Question 'AAMN' if "the answer to Question 'Gender' is the predefined answer 'Male'"
    • tested value = answer to Question 'Gender'
    • comparison operator = equals
    • comparison value = predefined answer code (the 'Male' answer in this case)



  • Show Question 'Alcohol' if "the answer to Question 'Age' is greater or equal than the numerical value '18'"
    • tested value = answer to Question 'Age'
    • comparison operator = greater than or equal to
    • comparison value = the constant value '18'



  Attention : When using a constant 'comparison value' for a date question, regardless of the date format set in your survey, you must use the YYYY-MM-DD date format.



  • Show Question 'Alcohol' if "the answer to Question 'BirthDate' is greater than 2000-01-01"
    • tested value = answer to Question 'BirthDate'
    • comparison operator = Greater than or equal to
    • comparison value = '2000-01-01' (the format in the constant field: 2000-01-01)



  • Show Question 'Alcohol' if "the the 'DrinkingHistory' participant's attribute" matches the 'Yes' string.
    • tested value= the 'DrinkingHistory' value taken from the survey participants table
    • comparison operator = equals
    • comparison value = the constant value 'Yes'


Conditions and scenarios in LimeSurvey

Default condition combinations

As said earlier, LimeSurvey automatically decides which logical operator (AND or OR) should be applied between conditions depending on the 'context'.

Note also that the order in which you define your elementary conditions is not relevant as LimeSurvey will automatically reorder them according to its own logic.

Let's study this in detail. Two rules should be always remembered:

  • First rule: conditions having the same tested value are ORed together
  • Second rule: conditions having different tested value are ANDed together


First rule: conditions having the same tested value are ORed together

When you have several conditions, they are ORed together if they share the same tested value. This is the case if the condition applies to several answers belonging to one single question. For example, a condition was applied below to three answers belonging to the same question - if answer to Question 'FavColour' equals 'green' OR  answer to Question 'FavColour' equals 'red'  OR  answer to Question 'FavColour' equals 'blue', then Question 'BirthDate' will be displayed to the survey respondent:



Note: To select multiple predefined answers, don't forget to hold the Shift or Ctrl key while selecting the tested values.


Second rule: conditions having different tested value are ANDed together

When you have several conditions, they are ANDed together if they don't share the same tested values. For example, you may see below the case for several conditions based on different previous questions - "If answer to Question 'Alcohol' equals 'Y' answer AND answer to Question 'Gender' equals 'F'", then Question 'Alcoholconsumption' will be displayed to the survey respondent:



The multiple options questions

Note: This paragraph applies to Multiple options and Multiple options with comments questions, and not to Array Multiple Flexible (number) with checkbox layout questions (in case of the latter, each checkbox is a separate question-entry and is not really handled as other multiple options question-types).


The Multiple choice and Multiple choice with comments question types will be displayed in two flavors:

  • a Group of checkboxes flavor which let you set conditions on all possible answers of the respective question;
  • a set of Single checkbox entries which lets you set conditions on each checkbox individually.



The group of checkboxes flavour

Now, let's focus on an example to better understand the difference between the two flavours. Let's imagine that we wish to display the 'Pointchoice' Question only if the respondent checks at least one of the tested answers listed under the 'MultipleOrganizations' Question.

As mentioned above, the group of checkboxes flavor allows you to set conditions on all possible answers of the respective question. Therefore, only the options that refer to responsibilities are selected as comparison values below:



As we can observe, the conditions get ORed due to the Group of checkboxes flavour selected in the beginning.:



ANDing conditions in multiple choice questions

Now, let's focus on a similar example. However, we are looking this time only for the most active members to ask them further questions. To do this, we make use of the Single checkbox flavour which allows you to set conditions based on each checkbox individually.

In this example, question X will be displayed if A and B are checked:



Once done, you can observe that the two conditions are ANDed now.



This means that your question will not be displayed unless both tested values (the selected subquestions) are met.


Verschiedene Szenarien verwenden

Definition of a scenario

A scenario is simply a manual grouping of conditions in which some conditions are evaluated independently of other conditions from other scenarios. The complex condition resulting in this association of several scenarios will be met only if one scenario is met. In other words, scenarios are logical grouping of conditions, respecting the above rules, and which are ORed together to build complex conditions.

Everything described above applies to the conditions located in every scenario. By default, all the new conditions are created inside the Default Scenario, which uses number '1' as its identifier. When you create new conditions, you can choose whether they are added to the default scenario or not. To change the scenario, just use another identifier.


Adding a question to another scenario

When you create (or edit) a condition, you can modify the scenario in which the condition is stored by simply clicking on the add scenario button:



As you can observe, the default scenario uses as identifier '1'. To add conditions to different scenarios, change the identifier by typing a different number in the box.

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



You can change the number assigned to a scenario by clicking this Icon and assigning the new id to the scenario.



Note: 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 scenarios are displayed when using the printable version of a survey
  • merge conditions from two scenarios (in order to merge scenario 10 with scenario 1, just renumber scenario 10, so that it is scenario 1).


Example: creating three scenarios

To create three scenarios, you need at least three conditions and to add to each of them a different scenario id. Once done, the scenarios are going to be connected among themselves via the 'OR' operator. For example, it could look like this:


AND vs OR in the same scenario

You may end up in certain cases with AND and OR logical operators in the same scenario:



LimeSurvey will always apply first OR. For further details on this, you may check the following Wikipedia article on Boolean algebra.

However. the order of operations can also be observed in the Relevance equation field. For the above example, the relevance equation is highlighted below:



As it can be observed, a set of extra parentheses is added for the OR logical operations in order to let the software know that it must be "computed" first.


Help: For more information on relevance equations, check the Expression Manager and relevance equation wiki sections.

How to copy conditions

The copy conditions functionality can be used when you wish to apply the same set of conditions you applied to Question5 to Question10. In this way, you will not have to manually recreate the conditions you applied to the previous question(s).

To start copying conditions, you first have to select the question the condition(s) is/are applied to (Question 'LowQ' in our case). Then, select the conditions you wish to be copied and select the question you wish to have the conditions added to (Question 'Alcohol' in our case).



Note: Conditions can only be set based on questions that appear before the question on which the condition is set.

Please pay attention to how the copy conditions functions work when you wish to copy and apply a set of conditions located under different scenarios to another question which uses the same or different scenario id numbers. To summarise the possible cases you might have, check the following example:

  • you wish to copy Scenario 1 - Condition A, Scenario 1- Condition B, Scenario 7 - Condition C, and Scenario 7 - Condition D from QuestionX into QuestionY
  • QuestionY already contains Scenario 1 - Condition A, Scenario - Condition C, Scenario 6 - Condition E, Scenario 8- Condition F.
  • Once copied, the following conditions will be applied to QuestionY:
    • Scenario 1: Condition A, Condition B, Condition C -> Condition A is not copied anymore as it already exists in QuestionY, only condition B being copied.
    • Scenario 6: Condition E -> not affected
    • Scenario 7: Condition C, Condition D -> a new scenario is created where the two conditions are added to it
    • Scenario 8: Condition F -> not affected


Reset conditions

To quickly reset all the survey conditions, click on one survey-related setting, look for Tools on the top toolbar, and click Reset conditions:



Next, confirm on the next page that you want to proceed and all the conditions will be deleted.


Things to watch out for

General considerations

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 be displayed 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 any of your conditions. You should always put aside the creation of conditions until you are satisfied 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 'FavColour' if the answer to the question 'Gender' is 'no answer'" really means "show question 'FavColour' if question 'Gender' was displayed to the survey participant who did not submit answer".


 Hint: To have the no answer option displayed as a predefined answer, the question cannot be mandatory.


Chained conditions

If you set conditions on a question that, itself, has conditions, you could end up with your survey behaving 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, the group header will still be shown unless you correct these conditions as explained below.




In the above example, the 'Alcohol' question is displayed if the respondent has previously answered to the 'AAMN' question 'No (N)'. However, the 'AAMN' question might not be displayed at the end if the respondent did not select to the previous question ('Gender') answer 'Male (M)'. In this scenario, no 'Alcohol' question will be displayed if 'Male (M)' was chosen previously.

To have the 'Alcohol' question displayed, you have to copy the conditions from the earlier question(s) to the one you're editing. To have the 'Alcohol' question displayed, you need to set up the following set of conditions:

  • Show 'AAMN' if the answer to 'Gender' is 'Male (M)'
  • Show 'Alcohol' if answer to 'Gender' is 'Male (M)' and if answer to 'AAMN' is No (N)'.

After correction, the correct set of conditions for 'Alcohol' should look like this:



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

To find out more on how you can copy conditions in LimeSurvey, please scroll up or click here to continue reading the dedicates wiki section.


Limitations and workarounds

Progress-bar

If you create a survey where many questions get skipped because of conditions, the progress bar either jumps over a set of questions or the survey ends at 50%.

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

For example, based on Question1 (yes or no question), 14 questions (2A to 15A) will be displayed if the answer to Question1 is 'Yes', or 2B to 15B if the answer to Question1 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 you 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 Multiple choice questions are handled, 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)