Actions

Bedingungen setzen

From LimeSurvey Manual

Revision as of 14:43, 19 October 2020 by Mabo (talk | contribs) (Created page with "*Neben der ID-Nummer jedes Szenarios gibt es drei Schaltflächen, mit denen Sie die folgenden Aktionen ausführen können : ** Szenario löschen! ** Szenarionummer ändern **...")


Allgemeines zu Bedingungen in LimeSurvey

LimeSurvey verfügt über eine sehr leistungsstarke logische Verzweigungsfunktion. Sie können darauf zugreifen, indem Sie auf die Schaltfläche 'Bedingungen festlegen' - - klicken, die sich auf jeder Frageleiste befindet.

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_Survey_Setting_Conditions.zip.


 Hint: Die Bedingungsfunktionalitäten funktionieren wie eine GUI für die Ausdrücke und Gleichungen, die auf Fragen angewendet werden können, sodass die Benutzer die Komplexität ihrer Umfragen auf einfache Weise erhöhen können, ohne auf Ausdrücke und Relevanz zugreifen zu müssen. ExpressionScript sollte jedoch erlernt werden, um die Auswahl an Optionen zu erweitern, die in LimeSurvey verfügbar sind.


Verzweigung mittels Anzeigen/Verbergen im Vergleich zum Springen

Sie können mit LimeSurvey eine logische Verzweigung entwerfen. Dies bedeutet, dass Sie entscheiden können, dass einige Fragen nur angezeigt werden, wenn bestimmte Bedingungen erfüllt sind, z. B. "Frage X anzeigen, wenn Frage Y mit Z beantwortet wurde".

UNser zugrunde liegende Ansatz ist eine "Verbergen/Anzeigen-Verzweigungslogik": Sie können für jede (Teil-)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.

Mit LimeSurvey können Sie auf einfache Weise dieselbe Bedingung für mehrere Fragen festlegen (und damit die Sprungverzweigungslogik implementieren), indem Sie eine Bedingung von einer Frage in eine Reihe anderer Fragen "kopieren" können. Im obigen Beispiel würden Sie zunächst die Bedingung für Frage 2 festlegen und dann auf demselben Bildschirm diese Bedingung zu Frage 3 und Frage 4 kopieren.

Datei:help.png Um weitere Informationen zum Kopieren von Bedingungen in LimeSurvey zu erhalten, lesen Sie bitte den folgenden Abschnitt.


In LimeSurvey unterstütze Bedingungen

Grundsätzlich kann eine Bedingung Werte vergleichen und entweder wahr oder falsch zurückgeben.

Werte, die verglichen werden können sind Antworten auf frühere Fragen. Zum Beispiel, wenn die Antwort bei Frage 1 'Ja' war, wird Frage 2 dem Umfrageteilnehmer angezeigt:





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

Ein 'Frageneintrag' ist entweder :

  • Eine einfache Frage (für alle Fragetypen außer Matrix-Fragen)
    • zum Beispiel: Textfragen, Radio- oder Dropdown-Listen und sogar Mehrfachauswahl Fragen
  • oder eine Zeile in Matrix-Fragen (außer Matrix Doppelskala)
    • Zum Beispiel: Matrix mit 5 Optionsfeldern
  • oder entweder der linke Teil oder der rechte Teil einer Matrix-Doppel-Skalenfrage
  • oder jede Zelle einer Matrix-Frage
Besuchen Sie den folgenden Link, um mehr über die verfügbaren Fragetypen in LimeSurvey zu erfahren.

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

Zunächst müssen Sie auf die Optionen Bedingungs-Designer zugreifen. Klicken Sie dazu auf die Frage, auf die Sie die Bedingung anwenden möchten:



Suchen Sie nun in der oberen Fragenleiste nach der Schaltfläche "Bedingungen hinzufügen".



Folgende Einstellungen stehen zur Verfügung:



Das Bedingungsdesigner-Bedienfeld kann in drei Abschnitte unterteilt werden :


The conditions designer toolbar

In der Symbolleiste finden Sie möglicherweise folgende Optionen:



  • Show conditions for this question: Klicken Sie auf diese Schaltfläche, um einen schnellen Überblick über die aktuell vorhandenen Bedingungen zu erhalten, die auf Ihre Frage angewendet werden.
  • Add and edit conditions:
Dies stellt die Standardseite dar, die automatisch geöffnet wird, sobald Sie auf die Schaltfläche Set conditions klicken. Es ist in zwei Teile unterteilt: (1) eine Tabelle mit allen vorhandenen Bedingungen und Szenarien und (2) das Menü add/edit conditions menu.
  • Copy conditions:

Manchmal möchten Sie dieselbe Bedingung auf X Fragen anwenden, damit die FrageY am Ende angezeigt wird. Klicken Sie dazu auf "Kopierbedingungen". Es öffnet sich ein neues Fenster mit den aktuell vorhandenen Bedingungen, die Ihrer Frage hinzugefügt wurden (nennen wir es Frage3). Um sie zu Frage 5 hinzuzufügen, überprüfen Sie die gewünschten Bedingungen, die kopiert werden sollen, wählen Sie Frage 5 aus und klicken Sie auf die Schaltfläche "Bedingungen kopieren" unten links im Bedienfeld. Für weitere Informationen lesen Sie bitte die folgenden wiki section.

  • Speichern und schließen: Wenn Sie mit den Änderungen fertig sind, klicken Sie auf 'Schließen' , um Ihre Bedingungen zu speichern.
  • Move to question:

Um das Bedingungsdesigner-Panel beim Wechseln zu einer anderen Frage nicht zu verlassen, wählen Sie mit der folgenden Option aus der Dropdown-Liste die nächste Frage aus, auf die Sie Bedingungen anwenden möchten. Bitte beachten Sie, dass in der Dropdown-Liste die Fragen angezeigt werden, die in der Umfrage vor und nach der aktuellen Frage angezeigt werden.

  • Schließen:

Wenn Sie das Bedienfeld verlassen möchten, ohne Änderungen vorzunehmen, können Sie entweder direkt zur Registerkarte Einstellungen / Struktur gehen und die gewünschte Option auswählen oder auf 'Schließen' klicken oben rechts auf dem Bildschirm.


Übersicht über die bestehenden Bedingungen

In diesem Abschnitt wird eine Tabelle angezeigt, die alle vorhandenen Szenarien und Bedingungen einer Frage enthält. Bestimmte Aktionen können von hier aus ausgeführt werden:



  • Im oberen rechten Teil stehen drei Aktionen zur Verfügung :
    • Schnelles Hinzufügen von Bedingungen - beschleunigt das Hinzufügen von Bedingungen (lesen Sie below , um alle Optionen zu erfahren )
** Szenarien neu nummerieren - Wenn Sie darauf klicken, werden die Szenarien mit inkrementellen Zahlen ab eins neu nummeriert. Bitte beachten Sie, dass diese Option nur angezeigt wird, wenn zwei oder mehr Szenarien auf Ihre Frage angewendet werden.
    • Alle Bedingungen löschen - Sie können über diese Aktion alle aktuell vorhandenen Bedingungen und Szenarien löschen, die auf Ihre Frage angewendet wurden.



  • Neben der ID-Nummer jedes Szenarios gibt es drei Schaltflächen, mit denen Sie die folgenden Aktionen ausführen können :
    • Szenario löschen!
    • Szenarionummer ändern
    • Bedingung hinzufügen - klicken Sie darauf Schaltfläche, um dem gewünschten Szenario eine weitere Bedingung hinzuzufügen



  • 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 ExpressionScript - Presentation 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)