Actions

Setting conditions/sl: Difference between revisions

From LimeSurvey Manual

(Updating to match new version of source page)
(Updating to match new version of source page)
Line 5: Line 5:




LimeSurvey has a very powerful logical branching feature. It can be accessed by clicking on the '''Set conditions''' button - [[File:conditions_icon.png]] - located on each [[Question bar options|question bar]].
LimeSurvey has a very powerful logical branching feature. It can be accessed by clicking on the '''Set conditions''' button - [[File:conditions_icon.png]] - located on each [[Question toolbar options|question bar]].


In this chapter we will describe:
In this chapter we will describe:
Line 104: Line 104:




Zavedati se moramo, da '''LimeSurvey avtomatično določi kateri logični operator uporabiti''': to pomeni, da se uporaba operatorja '''IN''' ali '''ALI''' določi '''glede na kontekst''' pogoja.
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. In the above example, there is only one scenario. This means that LimeSurvey makes use of [https://en.wikipedia.org/wiki/Boolean_algebra Boolean algebra], which means that operator '''or''' is "computed" first.


We'll talk more about complex conditions [[Setting_conditions#The usage of scenarios - Using ORed conditions between different questions|later]]. Let's first focus together on the elementary ones.
We'll talk more about complex conditions [[Setting_conditions#The usage of scenarios - Using ORed conditions between different questions|later]]. Let's first focus together on the elementary ones.


==Dostop do urejevalnika==
==Dostop do urejevalnika==




First, you need to access the [[Question bar options#Set conditions|conditions designer]]. To do that, click on the question you wish to apply the condition to:
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:





Revision as of 09:35, 20 August 2018


Pregled pogojev v LimeSurvey-u

LimeSurvey has a very powerful logical branching feature. It can be accessed by clicking on the Set conditions button - - located on each question bar.

In this chapter we will describe:

  • what conditions you can find in LimeSurvey
  • what you can and can't do with conditions
  • what steps you need to learn to set up simple or more complex conditions

For step-by-step video instructions check out this tutorial or download the condition sample survey: LimeSurvey_Survey_Setting_Conditions.zip.


 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.


Hide/Show Branching Versus Jump Branching

LimeSurvey vam omogoča izdelati logiko razvejanosti. Določite lahko, da bodo nekatera vprašanja prikazana le, če so izpolnjeni nekateri pogoji (primer: Prikaži vprašanje X, če je vprašanje Y bilo odgovorjeno z možnostjo Z).

Ideja je, da izvedemo "Prikaži/Skrij razvejanost podvprašanj":

  • Pri vsakem vprašanju v anketi lahko definirate pogoj ali niz pogojev: vprašanje se prikaže, če je pogoj izpolnjen



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 should simply set the same condition on all the questions you do not wish to be 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.

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


Veljavni tipi pogojev

Basically, a condition can compare values, returning either true or false.

The values that can be compared are answers to previous questions. For instance, if you answer 'Yes' to Question1, Question2 will then be showed to the survey respondent:





Na tej točki je zelo pomembno, da razumemo katero vstopno vprašanje je primerno za urejevalnik pogojev:

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 with 5 radio buttons or 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
Check the following link to find out more about the available question types in LimeSurvey.
  • constant values
    • for instance: "If you answered more than 18 years to the question below"



  • Participants' profile data: To use data from the survey participants table, "Anonymized responses" must be set to NO.  This option can be found in survey participant settings panel.





Several comparison operators are supported - from the simple "equals" to the advanced "regular expression":

  • The basic ones refer to the "equal" and "not equal to" operations
  • The greater/less than operator family is also available, and is usually used when using numeric question-entries
    • Please note that comparisons on numeric fields make use of the numeric order. For instance, 2 < 10
    • If you're using a question entry whose type is text, 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 (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]$


Kako lahko združimo pogoje

Sestavimo lahko kompleksne pogoje s kombinacijo preprostih pogojev z logičnimi operatorji IN in ALI.



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. In the above example, there is only one scenario. This means that LimeSurvey makes use of Boolean algebra, which means that operator or is "computed" first.

We'll talk more about complex conditions later. Let's first focus together on the elementary ones.

Dostop do urejevalnika

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.


Opomba: v tem trenutko ne spreminjajmo privzetega scenarija (), ki je samodejno izbran v tem pogojnem obrazcu; več o tem kasneje.


Opredelitev osnovnih elementov

Osnovni pogoj je edini pogoj brez dodatnih logičnih operaterjev IN ali ALI.

Sestavljajo ga:

  • levi operand: vrednost, ki jo preverjamo
    • vrednost, ki jo preverjamo, označimo tako, da izberemo ustrezen jeziček v urejevalniku pogoja



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

Primer osnovnih pogojev in kako jih ustvariti

  • Prikaži vprašanje v primeru, ČE "je bil odgovor na vprašanje1 v naprej določen odgovor 'Moški'"
    • preizkušena vrednost = odgovor na vprašanje1
    • primerjalni operator = je enako
    • primerjalna vrednost = vrednost primerjamo z odgovorom 'Moški"



  • 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

Privzete kombinacije pogoja

Kot smo že povedali, LimeSurvey samodejno določi kateri logični operator (IN/ALI) bo izbran med pogoji, kar je odvisno od samega 'konteksta'.

Upoštevajte tudi, da vrstni red, po katerem smo definirali osnovne pogoje, ni pomemben. LimeSurvey jih bo samodejno preuredil po lastni presoji.

Poglejmo si to podrobneje.


Prvo pravilo: pogoji z isto preizkušeno vrednostjo so med seboj povezani z ALI

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.


Drugo pravilo: pogoji z isto preizkušeno vrednostjo so med seboj povezani z IN

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:



Vprašanja z več izbirami

Opomba: Ta odstavek se nanaša na vprašanja tipa Več možnosti in Več možnosti s komentarjem in ne na Polja (številke) (pri tem tipu vprašanj je vsako potrditveno polje definirano kot posamezen vnos in se s tem ne obravnava kot preostala vprašanja z več izbirami).


V urejevalniku pogojev se vprašanja tipa Več možnosti in Več možnosti s komentarjem prikažejo na dva različna načina:

  • Prvi način - Skupina potrditvenih polj: vam omogoča določitev pogojev za vse možne odgovore tega vprašanja
  • Drugi način - Nova možnost odgovora: vam omogoča določite pogojev za vsak odgovor posebej



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.


Primer uporabe pogojev ALI med različnimi vprašanji

Now, you may argue that sometimes you need to have ORed conditions even when they are set on different questions (that is to say on different tested values). This is why we got scenarios!


Opredelitev scenarija

Scenarij je ročno ustvarjena skupina pogojev' v katerem so pogoji neodvisno ovrednoteni od pogojev iz drugih scenarijev. Zapleteno stanje, ki izhaja iz prepletanja več scenarijev bo izpolnjeno, če bo izpolnjen le en scenarij. Z drugimi besedami: scenariji so logična skupina pogojev, ki z upoštevanjem zgoraj navedenih pravil in medsebojne ALI povezave predstavljajo zapletene okoliščine.

Celoten zgornji opis velja znotraj posameznega scenarija. Pri tem tudi velja, da so vsi novi pogoji ustvarjeni znotraj "Prvotnega scenarija".


Dodajanje vprašanja v dodaten scenarij

Ko ustvarite (ali urejate) pogoj, lahko spremenite scenarij v katerem je shranjen pogoj:



Če morate določiti pogoj v drugem scenariju kot prvotnem, kliknite na ikono Dodaj scenarij File:Plus.png in vnesite številko scenarija: File:Default scenario edit.png

ID številka scenarija nima večjega pomena zato lahko imajo različni scenariji naključno izbrane ID številke.



Številko dodeljeno scenariju lahko spremenite s klikom na ikono . Nato morate izpolniti obrazec, ki se pojavi v isti vrstici.



Kot smo že omenili, številke scenarijev nimajo nobenega vpliva kako pogoje vrednotimo. Vendar pa je sprememba številke scenarija pomembna, ko želimo:

  • določiti v kakšnem vrstnem redu želimo, da se scenariji prikazujejo v tiskani verziji anketnega vprašalnika
  • združiti pogoje dveh scenarijev (v primeru združevanja scenarija 10 s scenarijem 1 le preštevilčite scenarij 10 z ID številko prvega scenarija).


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

Stvari, na katere morate biti pozorni

Splošni premisleki

Obstaja nekaj osnovnih pravil na katere morate paziti preden določite pogoje v zvezi z vprašanjem:

  • Ko enkrat določimo pogoj za določeno vprašanje, se to vprašanje ne bo prikazalo razen če bo pogoj izpolnjen
  • Pogoje je možno nastaviti le na osnovi vprašanj, ki se pojavijo pred vprašanjem na katerem nastavljamo pogoj
  • Če v anketi spremenimo vrstni red vprašanj, LimeSurvey v primeru prekinitve že nastavljenih pogojev ne prikaže posebnega opozorila. Zato priporočamo, da pogojev ne določate dokler niste povsem zadovoljni z vrstnim redom vprašanj in skupin v vaši anketi
  • Spreminjanje pogojev je omogočeno tudi, ko je anketa že aktivirana vendar je to potrebno narediti previdno, saj ni doslednosti preverjanja


Pogoji, ki uporabljajo prednastavljene odgovore oblike 'brez odgovora'


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.


Verižno pogojevanje

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

Po popravku bi pravilen nabor pogojev za Q3 izgledal sledeče:



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.


Omejitve in bližnjice

Prikaz napredka

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.


Nastavitev konstante pri vprašanju tipa Datum

Uporabiti boste morali interni prikaz vrednosti Datuma, ki je YYYY-MM-DD, da boste lahko opredelili konstanto.


Nastavitev pogojev pri izbiri možnosti "Drugo" v primeru vprašanja tipa Vprašanja z več izbirami

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.

V primeru, da anketiranec izbere odgovor 'Drugo', le to nikjer ni razvidno oziroma posebej zabeleženo. Edini način, da preverimo ali je anketiranec izbral to možnost ali ne je, da preverimo ali je bil vnesen tekst v polje za komentar.

Vendar pa zaradi specifičnega načina obravnave Vprašanja z več izbirami testiranje besedilnega polja pri možnosti 'Drugo' nikoli ni bilo izvršeno.

Vendar lahko zgoraj opisano težavo zaobidemo in sicer tako, da dodamo ekspliciten odgovor, ki ga poimenujemo 'Drugo' in ne že v naprej nastavljeno možnost 'Drugo'. Nato dodamo dodatno polje za vprašanje tipa Kratko besedilo, ki se bo prikazalo v primeru, če je bil izbran odgovor 'Drugo'.


Kako uporabljati oklepaje pri matematičnih izrazih?

Ne morete!

Če želite ustvariti naslednji izraz:

 (pogoj1 ALI pogoj2) IN (pogoj3 ALI pogoj4)

morate narediti sledeče:

(pogoj1 IN pogoj3) ALI

(pogoj1 IN pogoj4) ALI

(pogoj2 IN pogoj3) ALI

(pogoj2 IN pogoj4)