Actions

Bedingungen setzen

From LimeSurvey Manual

Revision as of 10:48, 15 April 2013 by C schmitz (talk | contribs) (Blanked the page)


Grundlagen

Eine Frage kann so konfiguriert werden, dass sie nur angezeigt wird, wenn eine bestimmte Bedingung erfüllt wird. Bedingungen können in allen Umfragetypen verwendet werden: Frage-für-Frage, Gruppe-für-Gruppe und Alles-auf-einer-Seite Umfragen. Bei den Fragetypen Gruppe-für-Gruppe und Alles-auf-einer-Seite werden die Bedingungen teilweise im Browser des Benutzers ausgewertet (durch Javascript). In diesem Fall werden die betreffenden Fragen abhängig von den vorhergehenden Antworten dynamisch ein- und ausgeblendet.

Sie können komplexe Bedingungen erzeugen, indem Sie sie miteinander kombinieren. Hierfür müssen Sie verstehen, wie verschiedene Bedingungen kombiniert und ausgewertet werden (ob sie ODER bzw. UND-verknüpft sind).

Ein englischer Beispielfragebogen, der die Verwendung von Bedingungen demonstriert, kann hier heruntergeladen und zum Testen in Limesurvey importiert werden (Tab "importieren" beim Anlegen eines neuen Fragebogens): Limesurvey_sample_survey_Conditions.lss

Der einfachste Fall: das Default Szenario

Lassen Sie uns zu Beginn das Default Szenario erklären:

  • wenn Sie verschiedene Bedingungen haben, werden diese miteinander UND-verknüpft, wenn die zu prüfenden Werte unterschiedlich sind
    • Dies ist zum Beispiel der Fall bei verschiedenen Bedingungen die von unterschiedlichen Antworten der vorhergehenden Fragen abhängen: "Wenn Antwort Frage1 entspricht 'Sehr glücklich' UND Antwort Frage2 entspricht 'Glücklich'"
  • Verschiedene Bedingungen werden ODER-verknüpft, wenn ihre zu prüfenden Werte gleich sind
    • Dies ist zum Beispiel der Fall bei verschiedenen möglichen Antworten auf die gleichen vorhergehenden Fragen: "Wenn Antwort Frage1 entspricht 'Sehr glücklich' ODER Antwort Frage1 entspricht 'Glücklich'"

Im "Fragen Fenster" haben Sie verschiedene Optionen zur Auswahl.

  • Wenn Sie eine ODER-verknüpfte Bedingung zwischen Fragen erzeugen möchten, wählen Sie eine entsprechende Zeile mit dem Vermerk "[Gruppe von Ankreuzfeldern]". Anschließend wählen Sie diejenigen Fragen, die ODER-verknüpft werden sollen, aus dem "Antworten Fenster".
  • Wenn Sie eine UND-verknüpfte Bedingung zwischen Fragen erzeugen möchten, wählen Sie eine entsprechende Zeile mit dem Vermerk "[Einfaches Ankreuzfeld]" und anschließend im "Antworten Fenster", ob die Antwort angekreuzt sein soll oder nicht.

Nun möchten Sie vielleicht auch ODER-verknüpfte Bedingungen erzeugen, auch wenn diese die gleichen Werte für die Bedingungen nutzen: hier kommt die Szenario-Funktion ins Spiel.

Verschiedene Szenarien verwenden

Standardmäßig werden alle Bedingungen, die Sie hinzufügen, zum gleichen Default Szenario (Szenario Nummer 1) hinzugefügt und Bedingungen die zu diesem Szenario gehören, werden nach der oben beschriebenen Logik miteinander kombiniert.

Sie können aber auch Bedingungen in anderen Szenarien definieren. In diesem Fall werden die Bedingungen wie folgt ausgewertet:

  • innerhalb eines Szenarios werden mehrfache Bedingungen wie im Default Szenario beschrieben ausgewertet: dies hilft, um jedes Szenario unabhängig voneinander auszuwerten
  • anschließend wird das komplexe Mehrfach-Szenario als "Wahr" ausgewertet, wenn mindestens eines der Einzel-Szenarien das Ergebnis "Wahr" zurückliefert

Sie können nun nachvollziehen, wieso das Wort "Szenario" verwendet wird: eine komplexe Mehrfach-Szenarien Bedingung liefert dann "Wahr" zurück, wenn mindestens ein ausgewertetes Szenario "Wahr" zurückliefert.

File:Multi scenario.png

Ein Fragen-Eintrag ist entweder:

  • eine einfache Frage (alle Fragentypen, außer Matrix-Fragen)
    • zum Beispiel: Text-Fragen, Optionsfelder oder Auswahllisten, and natürlich Multiple-Choice-Fragen
  • oder eine Zeile in einer Matrix-Frage (außer Dual-Matrix-Fragen und Matrix (Multi-Flexible) Fragen,
    • zum Beispiel: Matrix mit 5 Optionsfeldern, Matrix mit flexibler Beschriftung
  • oder entweder der linke Teil oder der rechte Teil eine Dual-Matrix-Frage
  • oder jede Zelle einer flexiblen Matrix Frage

Zur Vereinfachung werden Fragen-Einträge einfach "Fragen" genannt und als Liste mit dieser Bezeichnung im Formular "Bedingungen hinzufügen/bearbeiten" zu finden.

Sie können diese Bedingungen setzen, indem Sie auf das Bedingungen Symbol in der Fragen Symbolleiste klicken, wenn Sie sich eine Frage anschauen. Sobald Sie Bedingungen für diese Frage setzen auswählen, öffnet sich die Bedingungen Anzeige, mit deren Hilfe Sie Bedingungen für die aktuelle Frage erzeugen oder löschen können. Unten finden Sie ein Beispiel.

Existierende Bedingungen

Der obere Bereich des Fensters zeigt alle Bedingungen, die bereits für diese Frage gesetzt sind:

File:Existing conditions.png

Im obigen Beispiel wird die Frage B nur angezeigt, wenn:

  • die Antwort im Fragen-Eintrag FBI der vorhergehenden Frage A eine "1" ist
  • UND
    • ENTWEDER die Antwort im Fragen-Eintrag CIA der vorherigen Frage A eine "5" ist
    • ODER die Antwort im Fragen-Eintrag CIA der vorherigen Frage A eine "3" ist

Sie können diese Bedingung durch Drücken des "Löschen" Knopfes entfernen.

Im Bearbeiten/Hinzufügen Modus File:Conditions add.png sind einige spezfische Aktionen für jede anzeigte Zeile möglich, wie z.B.:

  • Bedingung bearbeiten File:Conditions add.png
  • alle Bedingungen löschen , diese Bedingung löschen , alle Bedingungen dieses Szenarios löschen
  • Szenario bearbeiten

Im Kopiermodus ist jede Zeile mit einem Ankreuzfeld versehen, mit dessen Hilfe Sie diejenigen Fragen auswählen können, die Sie zu einer späteren Frage kopieren möchten:

File:Copying conditions.png

Neue Bedingungen

Auswählen des Szenarios

Zuerst wählen Sie das Szenario aus, in dem Sie eine neue Bedingung erstellen möchten.

Wenn Sie keine ODER verknüpften Bedingungen zwischen verschiedenen Fragen benötigen, verändern Sie das Default Szenario, das automatisch im Bedingungseditor ausgewählt ist, einfach nicht ()

Im Gegenzug dazu müssen Sie den Knopf "Neues Szenario" File:Plus.png drücken, um eine Bedingung in einem anderen Szenario zu erzeugen. Geben Sie die Szenarien-Nummer ein: File:Default scenario edit.png

Die Szenarien-Nummer ist nicht wichtig und verschiedene Szenarien müssen keine fortlaufenden IDs haben.

Frage auswählen

Wählen eine Frage aus der 'Fragen' Box aus, die Sie in Ihrer Bedingung verwenden möchten.

Beachten Sie, dass (wie oben beschrieben) eine einfache Matrix-Frage aus mehreren Zeilen in der Fragen-Box bestehen kann: dies wirkt sich darauf aus, wie Bedingungen ausgewertet werden.

Wenn eine Frage selektiert wurde, werden die vordefinierten Antworten für diese Frage in der unteren Antworten-Liste angezeigt. Wenn die gewählte Frage keine vorgegebenen Antworten enthält, wird stattdessen der Tab "Erweitert" angezeigt.

Den Vergleichsoperator auswählen

Es können verschiedene Vergleichsoperatoren verwendet werden:

  • Die grundlegenden sind "Entspricht" und "Entspricht nicht"
  • Die Größer / Kleiner Operatorenfamilie ist ebenfalls verfügbar und ist dann sinnvoll, wenn numerische Frageneinträge verglichen werden
    • Bitte beachten Sie, dass der Vergleich von numerischen Felder die Größe der Zahlen verwendet (nicht deren ASCII-Werte), z.B. 2 < 10
    • Wenn Sie einen Frageneintrag vom Typ "Text" verwenden, wird die Bedingung ergeben: "2" > "10" (Vergleich der ASCII-Werte zweier Strings)
    • Numerische Fragen und Textfragen mit dem aktivierten Attribut "Nur Zahlen erlaubt", werden numerisch verglichen
  • Ein erweiterter Vergleichsoperator mit regulären Ausdrücken ist ebenfalls verfügbar. Wenn dieser ausgewählt ist, schaltet der Eingabebereich automatisch in den erweiterten Modus.

Eine Antwort auswählen

'Vordefinierte Antworten' verwenden

Hier können Sie eine oder mehrere vordefinierte Antworten auswählen:

  • die möglichen Antworten für diese Frage
    • Wählen Sie die Antwort, die Sie verwenden möchten
    • Sie können mehrere Antworten auswählen, in dem Sie beim Klicken die CTRL-Taste gedrückt halten

Den 'Erweiterten TAB' verwenden

Geben Sie den Text ein, den Sie für den Vergleich als Operanden auf der rechten Seite verwenden möchten:

  • einen einfachen Text
  • eine Zahl (der Vergleich wird auf Basis des numerischen Wertes durchgeführt, wenn der gewählte Frageneintrag einen numerischen Typ besitzt)
  • ein SGQA tag Verweis auf eine vorhergehende Frage. In diesem Fall wird diese Bedingung gegenüber einer älteren Frage (z.B.: zeige diese Frage an, wenn die Antwort der vorhergehenden "Datum-2 Frage" größer ist als die Antwort der vorhergehenden "Datum-1 Frage")
  • Wenn der Vergleichs-Operator regulärer Ausdruck gewählt wurde, dann muss dieses Eingabfeld mit einem gültigen regulären Ausdruck gefüllt sein

Klicken Sie anschließend auf den Knopf "Bedingung hinzufügen".

Bedingungen bearbeiten/löschen

Neben dem Hinzufügen von neuen Bedingungen kann der Hinzufügen/Bearbeiten Knopf verwendet werden um

  • Bedingungen zu bearbeiten
  • Bedingungen zu löschen
  • Szenarien zu bearbeiten

Bedinungen bearbeiten

Durch das Anklicken des Bearbeiten-Symbols in einer Bedingungs-Zeile wird das Formular zur Bearbeitung der gewählten Bedingung unten eingeblendet. Beachten Sie, dass Sie in diesem Modus nur eine vordefinierte Antwort wählen können. Klicken Sie auf den Knopf "Bedingung aktualiseren", um die Änderungen zu übernehmen.

Bedingungen löschen

Sie können:

  • eine einzelne Bedingung löschen, indem Sie das Symbol anklicken
  • alle Bedingungen innerhalb eines Szenarios löschen, indem Sie das Symbol anklicken
  • alle Bedingungen der Frage löschen, indem Sie das Symbol anklicken

Szenario bearbeiten

Die dem Szenario zugewiesene Nummer können Sie über das Symbol verändern. Bearbeiten Sie den Wert einfach im daraufhin eingeblendeten Formular in der gleichen Zeile.

Alternativ dazu können Sie die Szenarien durch Anklicken des Symbols neu numerieren.

Wie bereits erwähnt, haben die Szenario-Nummern keinerlei Einfluss auf die Art und Weise, wie Bedingungen ausgewertet werden. Trotzdem kann das Verändern der Szenario-Nummern wichtig sein um:

  • zu entscheiden, in welche Reihenfolg das Szenario angezeigt wird, wenn die Druckversion der Umfrage ausgewählt wird
  • Bedinungen aus zwei Szenarionen zusammenzuführen (um z.B. das Szenario 10 mit dem Szenario 1 zu verschmelzen, geben Sie dem Szenario 10 einfach die neue Szenario-Nummer 1)

Bedingungen zu späteren Fragen kopieren

Es ist nicht ungewöhnlich, dass eine Gruppe von Fragen die gleiche Bedingung besitzt. Glücklicherweise können Sie diese Bedingung zu jeder nachfolgenden Frage im Bedingungs-Designer kopieren, sobald sie zum ersten mal gesetzt wurde.

Wechseln Sie in den Kopiermodus, indem Sie das entsprechende Symbol anklicken .

File:Copy conditions example.png

Die Bedingungen, die der aktuellen Frage zugewiesen wurden, werden mit einem Ankreuzfeld auf ihrer linken Seite angezeigt. Sie können damit:

  • jede einzelne Bedingung individuell selektieren, indem Sie das Ankreuzfeld neben der gewünschten Bedingung ankreuzen
  • oder alle Bedingungen eines Szenarios auf einmal auswählen, indem Sie das Ankreuzfeld neben dem Szenario aktivieren

Anschließend selektieren Sie alle darauffolgenden Fragen der Umfrage, in die Sie die selektierten Bedingungen kopieren möchten, indem Sie die gewünschten Fragen in der unteren Liste selektieren (durch gleichzeitiges Drücken der STRG-Taste können Sie mehrere Fragen auswählen). Anschließend klicken Sie auf den "Bedingungen kopieren" Knopf, um das Kopieren der Bedingungen durchzuführen.

Sie sollten dies erst tun, wenn Sie alle Ihre Fragen erstellt haben und mit der Reihenfolge der Fragen zufrieden sind.

Dinge die beachtet werden sollten

Generelle Abwägungen

Es gibt einige grundlegende Regeln, die Sie im Hinterkopf haben sollten, bevor Sie Bedingungen für eine Frage definieren:

  • Sobald auch nur eine einzige Bedingung für eine Frage gesetzt wurde, wird die Frage nicht angezeigt bist die Bedingung erfüllt ist
  • Bedingungen können nur auf Fragen basieren, die vor der Frage erscheinen, für die die Bedingung gesetzt werden soll
  • Sie können Bedingungen auch noch nach Aktivierung einer Umfrage bearbeiten. Dies sollte aber mit größter Vorsicht geschen, da es hier keinen Konsistenz-Check gibt.

Bedingungen die die vordefinierte Antwort "Keine Antwort" verwenden

Die Bedingung "Zeige Frage Q20 wenn die Antwort zu Frage Q1 ist gleich 'Keine Antwort'", meint dies wirklich "Zeige Frage Q20 wenn Frage Q1 angezeigt wird und keine Antwort eingegeben wurde". Dies ist nicht das gleiche wie "Zeige Frage Q20 wenn Frage Q1 nicht angezeigt wird".

Verkettete Bedingungen

Wenn Sie Bedingungen auf Fragen setzen, denen bereits andere Bedingungen zugeordnet wurden, kann es zu Situation kommen, dass Ihre Umfrage sich nicht so verhält, wie Sie es erwartet hätten.

Im obigen Beispiel wird eine Frage angezeigt 'Mögen Sie es ein Mann zu sein?", welcher eine Bedingung zugeordnet wurde, die besagt, dass die Frage nur angezeigt wird, wenn auf die Frage Wie ist Ihr Geschlecht? mit M geantwortet wurde. Wenn Sie nun einer späteren Frage eine Bedingung zuweisen, die eine bestimmte Antwort auf die Frage Mögen Sie es ein Mann zu sein? überprüft, so wird diese Frage niemals angezeigt werden, da die Frage Mögen Sie es ein Mann zu sein? niemals angezeigt wird, wenn als Geschlecht W eingegeben wurde.

Es wird dringend angeraten, dass Sie die Bedingungen der vorhergehenden Frage zu der gewünschten Frage kopieren.

Im obigen Beispiel möchten Sie das folgende erreichen:

  • Q1 ist eine Frage nach dem Geschlecht
  • Q2 ist eine Ja/Nein-Frage und wird angezeigt, wenn Q1 gleich "Männlich" ist
  • Q3 ist eine Ranglisten-Frage und wird angezeigt, wenn Q2 mit Ja beantwortet wurde

Was Sie dagegen wirklich als Bedingungen hinterlegen sollten ist folgendes:

  • auf Q2: zeige Frage, wenn Antwort Q1 ist "Männlich"
  • auf Q3: zeige Frage, wenn Antwort Q1 ist "Männlich" UND Antwort Q2 ist "Ja"

Nach der Korrektur sollte die richtige Bedingung für Q3 folgendermaßen aussehen:

Wenn Sie also eine komplizierte Umfrage mit einer großen Zahl an Bedingungen entwerfen, so testen Sie sie bitte mit allen nur erdenklichen Kombinationen an Antworten.

Grenzen und Workarounds

Fortschrittsbalken

Wenn Sie eine Umfrage erstellen, bei der viele Fragen aufgrund von Bedingungen übersprungen werden, so wird der Fortschrittsbalken in großen Schritten voranschreiten, oder die Umfrage endet schon bei 50%. Um ein solches Verhalten zu verhindern, sollten die Fragen, die übersprungen werden können, so zwischen den angezeigten Fragen platziert werden, so dass nur ein oder zwei Fragen pro Antwort übersprungen werden können.

Zum Beispiel: basierend auf Frage 1 (Ja oder Nein Frage) werden 15 Fragen gestellt (1A bis 15A), wenn die Antwort der Frage 1 "Ja" ist, 1B bis 15B wenn die Frage 1 die Antwort "Nein" enthält.

Wenn Sie die Fragen in eine Gruppe aufnehmen und sie in der Reihenfolge 2A, 2B, 3A, 3B usw. anorden, so werden Sie einen nahezu geradlinigen Fortschrittsbalken erhalten, anstatt die Fragen in der Reihenfolge 2A, 3A, 4A, ..., 2B, 3B, 4B,... zu hinterlegen. In diesem Fall würde der Fortschrittsbalken sofort von 0 auf 50% oder von 50% auf 100% springen, abhängig von der Frage 1.

UND Bedingungen in Multiple-Choice Fragen

Da Multiple-Choice Fragen wie ein einzelner Frageneintrag behandelt werden, können Sie nur ODER-verknüpfte Bedingungen zwischen den vordefinierten Antworten erstellen.

Benötigen Sie UND-verknüpfte Bedingungen zwischen den möglichen Antworten einer Multiple-Choice Frage, so können Sie folgenden Workaround probieren. Da beim Fragetyp "Matrix (Multi Flexible) (Zahlen)" jede Zelle ein separater Frageeintrag ist, können Sie:

  1. eine Frage vom Typ "Matrix (Multi Flexible) (Zahlen)" definieren, die nur eine einzige Antwort enthält (es wird eine Zeile angezeigt) und ein Beschriftungs-Set zuordnen (dies führt dazu, dass die möglichen Multiple-Choice Antworten als Spaltenüberschriften angezeigt werden).
  2. anschließend definieren Sie die Frageattribute, so dass das Ankreuzfeld-Layout verwendet wird

Nun sind Sie in der Lage, Bedingungen auf Basis jedes einzelnen Ankreuzfeldes zu definieren und diese UND zu verknüpfen. Achten Sie darauf, dass die möglichen Antworten nicht Ja oder Nein, sondern 1 oder 0 erzeugen, da dieser Fragetyp numerische Antworten verwendet.

Bedingungen für "Andere" Optionen im Fragetyp "Mehrfachoptionen"

Beim Fragetyp "Mehrfachoptionen" können Sie die Antwort "Andere", die in diesem Fragetyp angeboten wird, als gültige Antwort verwenden, allerdings können Sie keine Bedingungen hierauf definieren. Zum Beispiel: Frage 1 lautet "Welche Farbe bevorzugen Sie?", als Antworten stehen zur Verfügung Blau, Schwarz oder Andere. Wenn der Umfrageteilnehmer die Antwort Blau wählt, so können Sie eine Bedingung hinterlegen. Basierend auf der Antwort Schwarz können Sie eine andere Bedingung definieren. Wenn der Teilnehmer aber "Andere" auswählt und etwas in das Textfeld einträgt, haben Sie KEINE Möglichkeit, eine Bedingung darauf zu setzen. Limesurvey begreift es nicht, wenn der Teilnehmer die Option "Andere" auswählt. Dies ist KEIN Fehler, sondern eine existierende Einschränkung.

Die Antwort "Andere" wird in keinem realen Datenfeld hinterlegt, so dass sie auch nicht ausgewertet werden kann. Die einzige Möglichkeit besteht darin zu prüfen, ob der Benutzer etwas in das Textfeld eingegeben hat, oder ob es leer ist.

Wie dem auch sei: aufgrund der Art und Weise, wie Multiple Choice Fragen verarbeitet werden, wurde eine Überprüfung des Textfeldes "Andere" nie für die Typen "M" und "P" implementiert.

Als Workaround verwenden Sie einfach nicht die Option "Andere" bei diesem Fragetyp. Ergänzen Sie stattdessen eine explizite Antwort mit dem Namen "Andere" und fügen Sie ein weiteres kurzes Textfeld hinzu, das angezeigt wird, sobald "Andere" ausgewählt ist.

Wie kann man Klammern in logischen Ausdrücken verwenden?

Dies ist nicht möglich

Wenn Sie eine Bedingung erzeugen möchten, wie

 (bedingung1 ODER bedingung2) UND (bedingung3 ODER bedingung4)

so müssen Sie dies folgendermaßen umsetzen:

 (bedingung1 UND bedingung3) ODER

 (bedingung1 UND bedingung4) ODER

 (bedingung2 UND bedingung3) ODER

 (bedingung2 UND bedingung4) ODER

Starting in Version 1.92, all navigation and branching is controlled by Expression Manager (EM).  You can still use the Conditions Editor as described below.  However, internally, Expression Manager converts the Conditions to a relevance equation.  LimeSurvey only reads the relevance equations during survey-taking, thereby eliminating the need for multiple database reads against the conditions table.

However, you do not need to use the Conditions editor.  If you prefer, you can hand type relevance equations, using qcode naming.

Everything you can do in the Conditions editor is forward-compatible with relevance equations.  However, EM gives you access to over a hundred functions and mathematical and logical operators, so you can create complex relevance equations that could never be back-ported to the Conditions editor.

Note:  We currently assume that if you have entered values in the Conditions Editor, you want them to trump anything you manually edit in the Relevance Equation.  If you want to use the Conditions Editor to create the first draft relevance equation and then customize it, you must currently do the following:
  1. Create your conditions using the Conditions editor as you are used to doing
  2. Save the conditions - this will show you a syntax-highlighted relevance equation for the question
  3. Select and copy that syntax-highlighted equation, pasting it into a text editor like NotePad
  4. Open the Conditions editor again, and delete all conditions for the question (and save) - the relevance equation will disappear
  5. Edit the question, and paste in the old relevance equation from Notepad, then save the question (or edit the relevance equation further and then save it)

The Expression Manager documentation compares/contrasts conditions and relevance, especially #How should I choose between Conditions and Relevance?|this table.


Eine Frage kann so konfiguriert werden, dass sie nur angezeigt wird, wenn eine bestimmte Bedingung erfüllt wird. Bedingungen können in allen Umfragetypen verwendet werden: Frage-für-Frage, Gruppe-für-Gruppe und Alles-auf-einer-Seite Umfragen. Bei den Fragetypen Gruppe-für-Gruppe und Alles-auf-einer-Seite werden die Bedingungen teilweise im Browser des Benutzers ausgewertet (durch Javascript). In diesem Fall werden die betreffenden Fragen abhängig von den vorhergehenden Antworten dynamisch ein- und ausgeblendet.

Sie können komplexe Bedingungen erzeugen, indem Sie sie miteinander kombinieren. Hierfür müssen Sie verstehen, wie verschiedene Bedingungen kombiniert und ausgewertet werden (ob sie ODER bzw. UND-verknüpft sind).

Ein englischer Beispielfragebogen, der die Verwendung von Bedingungen demonstriert, kann hier heruntergeladen und zum Testen in Limesurvey importiert werden (Tab "importieren" beim Anlegen eines neuen Fragebogens): Limesurvey_sample_survey_Conditions.lss

Hide/Show Branching Versus Jump Branching

You can design logical branching with LimeSurvey, this means that you can decide that some questions will be displayed only if some conditions are met like "Show question X if question Y was answered 'Z'".

Our approach is to implement a Hide/Show Branching Logic:

  • you can define a condition or a set of conditions on each question of your survey: if the condition is met, the question will be displayed

Simply put:

  • a question without a condition defined on it will always be displayed
  • a question with a condition defined on it will not be displayed unless the condition is met

This approach is different from the Jump Branching Logic that is sometimes implemented by other software. In the Jump Branching Logic, the resulting action of a met condition would be to jump to another question (that is to say hide all questions in between). Limesurvey doesn't implement this Jump Branching Logic method. Instead if you wish to jump a series of questions, you would simply set the same condition on all the questions you do not wish displayed. For example if the jump condition you want to set on Question2 is "Jump to Question5 if the answer to Question1 is 'Yes'", you can simply:

  • set a condition on questions 2, 3 and 4 to only display "if the answer to Question1 was NOT 'Yes'"

  • LimeSurvey makes setting the same condition on multiple questions (and thus implementing Jump Branching Logic) easy by allowing you to "copy" a condition from one question to a series of others. In the above example you would begin by setting the condition on Question2, then from the same screen you would copy that condition to Question3 and Question4.

Supported Types of Conditions

Basically, a condition can compare values and returns true or false.

Values that can be compared are:

  • answers to previous questions
    • for instance: "IF you answered 'Yes' to Question1"

It is important at this point to understand what is considered as an eligible question-entry for the condition editor:

A question-entry is either:

  • a simple question (for all question types apart from Array questions)
    • for instance: text questions, radio or dropdown lists, and even multiple choices questions
  • or a row in Array questions (except for Array dual scale and Array Multiple Flexible questions),
    • for instance: Array of 5 radio buttons, array with label questions
  • or either the left part or the right part of an Array dual scale question
  • or each cell of an Array Flexible question

As a matter of simplification, question-entries are just called "Question" in this document and the condition editor.

  • constant values
    • for instance: "IF you answered more than 3 days to Question2"

  • 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.

Several comparison operators are supported from the simple "equals", to the advanced "Regular Expression":

  • 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
      [a-zA-Z]$

How can I combine conditions

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.

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

Understanding Simple conditions: elementary conditions

Accessing the editor screen

First you need to access the condition editor:

  • open the condition menu by clicking on the conditions icon in the question button bar, when viewing a question.
  • then click on the Set Conditions icon File:Conditions add.png , the edit conditions screen will appear allowing you to create, edit or delete conditions for the current question.

The following screen will appear:

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

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

  • a comparison operator
    • Choose the comparison operator you want to apply in the dropdown list

File:Conditions-operators.png

  • a right operand: the comparison value
    • you can choose the comparison value type by selecting the appropriate tab in the condition editor

Example of elementary conditions and how to create them

  • Show question IF "the answer to Question1 was the predefined answer 'Male'"
    • tested value = answer to Question1
    • comparison operator = equals
    • comparison value = answer code of the 'Male' answer

  • 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

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.

  • 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

  • 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'

Detailed instructions on how to set up the above example can be found at this blog post: "Conditions based on token attributes"

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.

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 for instance for several possible answers of the same previous questions: "If answer to Question1 equals 'green' OR  answer to Question1 equals 'red'  OR  answer to Question1 equals 'blue'"

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

  • this is the case for instance for several conditions based on different answers from previous questions: "If answer to Question1 equals '4' AND answer to Question2 equals 'green'"

   

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

Imagine you define the 3 following sets of conditions:

  • 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'

  • Then the resulting conditions will be:

    • 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).

For Multiple options and Multiple options with comments questions, in the tested valuepart of the condition editor this question will appear in two flavors

  • 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 the answers...

For Issue A:

  • Use the Group of checkboxes entry as your tested value and select as much answers you want

For Issue B:

  • 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

  • Enjoy the result:

Verschiedene Szenarien verwenden

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.

All what we described above is true inside a scenario, and by default all new conditions are created inside the "Default Scenario".

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

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.

Using the editor

Editor overview

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

Setting new conditions

First select the 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.

Select the tested value

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.

Select the comparison operator

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.

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).

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.

Editing/Deleting conditions

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

  • edit conditions
  • delete conditions
  • edit scenario

Edit conditions

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.

Delete conditions

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

Edit 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).

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.

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.

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 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)