Actions

Expression Manager sample surveys/nl: Difference between revisions

From LimeSurvey Manual

(Created page with "Validatie kan worden toegepast op afzonderlijke cellen in een array, zoals in dit voorbeeld, waarbij validatie met reguliere expressies ervoor zorgt dat elke vermelding een co...")
(Created page with "Soms heb je aangepaste validatie nodig die niet kan worden bereikt met behulp van de traditionele min/max-criteria. Dan moet je de opties em_validation_q en em_validation_sq g...")
Line 247: Line 247:




Sometimes you need custom validation that cannot be achieved using the traditional min/max criteria. For this, you will need to use the em_validation_q and em_validation_sq options which let you construct complex validation equations at the question and subquestion level, respectively.  
Soms heb je aangepaste validatie nodig die niet kan worden bereikt met behulp van de traditionele min/max-criteria. Dan moet je de opties em_validation_q en em_validation_sq gebruiken, waarmee je complexe validatievergelijkingen kunt maken op respectievelijk vraag- en subvraagniveau.  





Revision as of 21:15, 28 September 2018


Inleiding

De beste manier om Expressiebeheer te leren te gebruiken is door werkende voorbeelden uit te proberen en die aan te passen naar wat je nodig hebt.

Hieronder hebben we voorbeelden verzamelt om uit te leggen hoe je Expressiebeheer (EM) kunt gebruiken en testen om je enquête te verbeteren. De voorbeelden staan in de map /docs/demosurveys van de installatie op je server.


Relevantie, maatwerk en vergelijkingen

Overzicht

De volgende functies worden gebruikt in dit voorbeeld:


Functies gedemonstreerd

  1. Relevantie : ondersteuning met krachtige conditionele logica.
  2. Maatwerk : de mogelijkheid om antwoorden en metadata van vragen aan te passen.
  3. Dynamisch maatwerk : Rapporten worden bijgewerkt op de pagina na het beantwoorden van een vraag.
  4. Klein maatwerk : conditioneel bijwerken zinnen en rapporten met gebruik van if-statements.
  5. Vergelijkingen : een nieuw vraagtype waarmee je kunt rekenen en resultaten kunt vastleggen in de database, ook al is de berekening verborgen.
  6. Conditionele validatie : validatiecriteria, zoals een minimumwaarde, eventueel conditioneel gebasseerd op vergelijkingen.


Schermafdruk

In dit voorbeeld wordt de BMI bepaald (Body Mass Index), een berekening op grond van je gewicht en je lengte. Een norm om te bepalen of je bijvoorbeeld overgewicht hebt. Standaard zijn er 4 verplichte vragen.



Na het invullen van de informatie (waaronder het selecteren welke eenheden je gebruikt) zie je een maatwerk rapport met je invoergegevens en het resultaat:



Een ander voorbeeld met andere eenheden, de resultaten worden vanzelfsprekend met die eenheden weergegeven:



Er zijn verborgen vragen van het vraagtype Vergelijking waarmee intern de eventuele benodigde omzettingen vanwege de gekozen eenheden worden gedaan. Dit hoeft dus niet in JavaScript te worden gedaan.

In de volgende set voorbeelden zie je hoe je mathematische en andere functies kunt gebruiken bij maatwerk rapporten. Voor het invoeren van gegevens ziet de pagina er als volgt uit. Er is conditionele logica om blanco gegevens te tonen als er geen of een niet-numeriek gegeven is ingevoerd, dit voorkomt het tonen van "NaN" en "Divide by Zero".



Bij numerieke invoer wordt het rapport aangepast om de berekening te doen en het resultaat te tonen.



In deze enquête staan veel andere voorbeelden. In onderstaande afbeelding wordt een van de vele manieren om de pagina Dynamische relevantie te vullen, getoond. Probeer, zoals de helptekst aangeeft, rustig verschillende waarden uit, ook als ze onlogisch zijn om de verschillende genereerde antwoorden te bekijken. Merk ook op dat de teksten afhankelijk zijn van je antwoorden, bijvoorbeeld of je 1 of meer kinderen hebt. Een stukje maatwerk. Dit kan ook voor afwijken op geslacht, of voor het gebruik van werkwoordsvormen.



Download

Voorbeeld downloaden.


Voorbeeld telling

Overzicht

In dit voorbeeld vragen we hoeveel mensen er zijn in je huishouden.

We demonstreren hoe groepsrelevantie het gemakkelijk maakt om een aantal vragen een aantal keer te stellen (een loop, de vragen worden per lid van het huishouden gesteld). Na het aanmaken van de groep voor de eerste persoon wordt de groep door ons geëxporteerd. Als variabele-naam is p1_name gekozen in plaats van de SGQA-code. Je kunt natuurlijk de vraag dan simpel een aantal keer kopiëren in een tekstverwerker en dan importeren nadat je de variabele-namen uniek hebt gemaakt.

Je kunt hiervoor ook, al zal dat wel iets langer duren, de functie vraag kopiëren gebruiken.

We tonen ook hoe je het tonen van het afsluitbericht kunt voorkomen totdat alle verplichte groepen afgerond zijn.


Functies gedemonstreerd

  1. Groepsrelevantie: De groepen per personen in het huishouden (1 tm 5) worden getoond afhankelijk van het opgegeven aantal leden van het huishouden.
  2. Maatwerk: Het eindrapport bevat demografische gegevens voor elk lid van het huishouden.
  3. Progressief tonen van vragen: Of per groep of alles tegelijk, vervolgvragen worden pas getoond als de voorafgaande vraag is beantwoord.


Schermafdruk

De enquête maakt een rapport aan waarin met maatwerk de demografische gegevens van de leden van het huishouden worden getoond.



Als je kiest voor een vraag per keer dan kun je de vragen met maatwerk mooier maken. Omdat je weet dat het een vrouw is, vraag je naar haar naam. Vervolgens vraag je hoe oud zij is, waarbij je dan de net ingevulde naam gebruikt.



Download

Voorbeeld downloaden.


Cascading arrayfilters

Overzicht

Deze enquête is gebaseerd op een enquête van Joy Lane Research, LLC.


Schermafdruk

Hierbij staat:

  • Q02 voor de verzameling geselecteerde producten in vraag Q01 (gebruik van een array_filter).
  • Q02 toont ook "Another product", de ingevulde tekst bij het veld "Other electronic" in Q01.
  • Q04 voor de verzameling geselecteerde producten in Q02 (dus een herhaald filter).
  • Q05 voor de verzameling niet in Q02 geselecteerde producten (gebruik van het array_filter_exclude).




Download

Voorbeeld downloaden.


Maatwerk met gebruik van vraagtypes en attributen

Overzicht

Je bent niet alleen als je de naamgeving van je variabelen moeilijk vindt (SGQA of Qcodes). In de documentatie beschrijven we hoe een Qcode-naam wordt opgebouwd, maar vermoedelijk is een werkend demo gemakkelijker te volgen.  In deze enquête tonen we hoe je vraagattributen en reacties kunt benaderen met Expressiebeheer.


Voor dit voorbeeld raden we aan de ingebouwde HTML-editor uit te schakelen (of de pop-upmodus te kiezen) bij het bewerken van deze enquête. Het kan een minuut of wat langer duren voordat de HTML-editor een groter HTML-rapport weergeeft in de bewerkingsmodus.


Inhoud

  • Voorbeelden van elk vraagtype.
  • Inclusief alle vraagtypes die "anders" kunnen gebruiken, zodat je kunt zien hoe dat van invloed is op de naamgeving van de variabelen.
  • Standaardwaarden voor alle vraagtypen die standaardinstellingen accepteren.
  • Maatwerk : On- en off-pagina rapporten met alle 16 beschikbare Expressiebeheer notatie-achtervoegsels.
  • Deze rapporten tonen alle ingevoerde gegevens (je ziet hoe je eigen afdrukbare rapporten kunt genereren voor gebruikers in plaats van het afdruk- antwoordscherm)
  • Goede Qcode en SGQA-naamgeving van alle variabelen.


Schermafdruk

Geen screenshot, want dit is een lange enquête. Probeer de download uit.


Download

Voorbeeld downloaden.


Traditionele validatie, opnieuw gebruiken

Overzicht

Hier zien we alle validatietypes die gebruikmaken van expressies en hoe deze van invloed zijn op elk van de vraagtypes die validatie ondersteunen. In veel gevallen zijn de validatietips eerst verborgen en verschijnen ze alleen als een antwoord niet voldoet aan de validatiecriteria (ze verdwijnen zodra het antwoord voldoet).


Validatie types gedemonstreerd

  1. min_num_value_n : minimumwaarde van een antwoord.
  2. max_num_value_n : maximumwaarde van een antwoord.
  3. min_answers : minimum aantal vereiste antwoorden.
  4. max_answers : maximaal aantal toegestane antwoorden.
  5. multiflexible_min : minimum toegestane waarde voor een antwoord (vraagtype multiflexi-nummers).
  6. multiflexible_max : maximum toegestane waarde voor een antwoord (vraagtype multiflexi-nummers).
  7. min_num_value : minimum toegestane som voor alle antwoorden op de vraag.
  8. max_num_value : maximum toegestane som voor alle antwoorden op de vraag.
  9. equals_num_value : de som voor alle antwoorden op de vraag moet gelijk zijn aan deze waarde.
  10. validation : dit is de reguliere expressievalidatie van de vraag, deze kan op individuele cellen van toepassing zijn.


Schermafdruk

Met behulp van nieuwe CSS-styles verschijnt bij elk validatietype een afzonderlijke tip. Als ze worden getoond, kunnen ze worden verborgen via de optie hide_tip. De standaardoptie is om ze met een rood lettertype weer te geven als het antwoord niet aan de validatiecriteria voldoet en groen als het voldoet.



Een gebruiker zal direct worden gewaarschuwd als hij verkeerde informatie heeft ingevoerd. De gegevens worden niet vastgelegd.



Validatie kan worden toegepast op afzonderlijke cellen in een array, zoals in dit voorbeeld, waarbij validatie met reguliere expressies ervoor zorgt dat elke vermelding een correct opgemaakt Amerikaans telefoonnummer is, inclusief een area-code.



Download

Voorbeeld downloaden.


Validatie vergelijkingen

Overzicht

Soms heb je aangepaste validatie nodig die niet kan worden bereikt met behulp van de traditionele min/max-criteria. Dan moet je de opties em_validation_q en em_validation_sq gebruiken, waarmee je complexe validatievergelijkingen kunt maken op respectievelijk vraag- en subvraagniveau.


At the subquestion level, we also introduce the "this" variable to make it easy to validate each cell in an array without needing to know its variable name. For more details about it, click here.


Functies gedemonstreerd

  1. em_validation_q - this is an equation that determines whether the whole question is valid
  2. em_validation_q_tip - this is the message to show if the question fails em_validation_q criteria
  3. em_validation_sq - this is the equation that determines whether each subquestion (array cell) is valid
  4. em_validation_sq_tip - this is the message to show if any of the subquestions is invalid.

In general, when em_validation_sq is used, if any cell is invalid, the background color for that cell turns red to indicate that there is an error.


Schermafdruk


This question ensures that you enter the ages of your children in descending order by applying this validation equation:

q1_sq1 >= q1_sq2 && q1_sq2 >= q1_sq3 && q1_sq3 >= q1_sq4





In the below example, the validation ensures that no more than 3 questions are answered on any given row by applying this validation equation:

(sum(Test_A_1, Test_A_2, Test_A_3, Test_A_4, Test_A_5) <= 3) && (sum(Test_B_1, Test_B_2, Test_B_3, Test_B_4, Test_B_5) <= 3) && (sum(Test_C_1, Test_C_2, Test_C_3, Test_C_4, Test_C_5) <= 3)

You can also write this as follows, LimeSurvey automatically converting it at run-time to the above-listed expression.

(sum(self.sq_A) <= 3) && (sum(self.sq_B) <= 3) && (sum(self.sq_C) <= 3)



Download

Voorbeeld downloaden.


Subvraag relevantie

Overzicht

This shows how array_filter and validation criteria can interact. For validations that apply to sums, only relevant (visible) values are considered.


Functies gedemonstreerd

  1. array_filter
  2. array_filter_exclude
  3. min_num_value
  4. max_num_value
  5. equals_num_value

It also shows dynamic reporting of the numbers of questions answered in the core questions.


Schermafdruk

Changing the number of visible rows dynamically changes the sum. Marking a subquestion as being irrelevant doesn't clear its value. Rather, if it is irrelevant, its values don't contribute to any equation.



Note what happens when we check the "Fifth subquestion" for the first question "Which rows should appear below". Note that the sum for the second "Enter some numbers" question is now 5. Even though subquestion 5 for that question still has the value 14 (e.g., if you un-check the fifth subquestion, you will see the value of 14 again), that value does not contribute to the sum since it is currently irrelevant. All irrelevant data is cleared (NULLed in the database) on submit, but it stays available on the page in case users want or need to change their minds about answers.



Download

Voorbeeld downloaden.


Gebruik van een komma in getallen (Decimale punt)

Overzicht

The Expression Manager ensures that only valid numbers can be entered into numeric fields. If you enter an invalid number, you will be warned that something is wrong (e.g., in the case of the fruity theme, the whole question is "red-ed").

Note that the numeric values are always converted to using a period as the radix separator within the database. In this way, the statistical analyses will work appropriately.

To change the radix separator, access the Text elements options located under the Settings tab, and look for the decimal mark functionality.


For more information on what a radix separator is, click [https://en.wikipedia.org/wiki/Radix_point


Vraagtypes met decimale getallen

  1. Numerical input [N]
  2. Multiple numerical input [K]
  3. Array (Numbers) [:]
  4. Array (Texts) [;], when using the numbers_only attribute
  5. List (radio) [L], when using the other_numbers_only attribute
  6. Short free text [S], when using the numbers_only attribute
  7. Multiple short text [Q], when using the numbers_only attribute
  8. Multiple choice [M], when using the other_numbers_only attribute
  9. Multiple choice with comments [P], when using the other_numbers_only attribute


Schermafdruk

You may note in the below screenshots that comma can be used as a radix separator.



Download

Voorbeeld downloaden.


Randomisatie groepen

Overzicht

This survey demonstrates how to make use of the random_group attribute.

If this attribute is used, each time you start the survey, the question order is randomized. However, once the survey is started, the randomization order remains fixed, even if you change languages.


Schermafdruk

Let's check together the below example. The first random question on the page will either be Q1 , Q4, or Q7. The second randomized question on the page will either be Q2, Q5, or Q8.



Here is the randomization generated the first time I tested this survey.



A different randomization was generated the second time I tested the survey.



But, when I switched to French (without re-starting the survey), the randomization order remained intact.



Download

Voorbeeld downloaden.


Willekeurig een vraag stellen per groep

Overzicht

This survey shows how you can configure a survey to randomly display one question per group. In it, there are 5 groups of 6 questions each. At the outset, in Group 0, five hidden Equation questions, called ask1-ask5, are populated. Each one has the value of {floor(rand(1,6.9999))} in the question text field, which means that the variables ask1-ask5 will each have a value between 1 and 6. Then, each question in the group has a relevance equation like "ask1==N" where N is the Nth question in the group (so the third question in group 1 has the relevance equation  "ask1==3").

This survey works equally well in survey-at-a-time, group-by-group, and question-by-question modes. Since the randomization is set in the first group, and that group is effectively hidden (since all of the ask1-ask5 questions are hidden), the randomization stays the same for the subject; but each different subject will have a distinct randomization.


Functies gedemonstreerd

  1. Equation question type
  2. Randomization functions
  3. Conditional (if) function


Schermafdruk

This is Group0, which uses the Equation question type to select random values from 1 to 6 for each group (except the last group, which has only 4 questions).  Note that the "if()" function first checks whether ask1 has already been set, and if so, uses that value. If the value hasn't been set, then it uses a random value to set the value of ask1.



This Group shows how the variable (ask4) from Group0 is used to control which question is visible within the fourth group.



Download

Voorbeeld download.


Willekeurig een bepaald aantal vragen stellen uit een groep (een subset van de vragen)

  This applies only to all random questions from one group and only if the Group by group or All in one format is used.



Overzicht

This survey shows how to ask a random subset of questions in a group. For example, show 5 random questions out of 10 questions located within a group.

The survey has one group containing 10 questions. All questions are assigned the same randomization group name. As a result, they will be displayed in a random order on page load. Each question is given a relevance equation that the sum of the "relevanceStatus" of all other questions in the group is less than the number of questions you want to show. Since relevanceStatus is assigned as questions are rendered, this effectively totals the number of preceding questions.

So, in our 5 out of 10 example, the equation for Q1 would be:

sum(Q2.relevanceStatus, Q3.relevanceStatus, Q4.relevanceStatus, Q5.relevanceStatus, Q6.relevanceStatus, Q7.relevanceStatus, Q8.relevanceStatus, Q9.relevanceStatus, Q10.relevanceStatus) LT 5

For Q2, it would be:

sum(Q1.relevanceStatus, Q3.relevanceStatus, Q4.relevanceStatus, Q5.relevanceStatus, Q6.relevanceStatus, Q7.relevanceStatus, Q8.relevanceStatus, Q9.relevanceStatus, Q10.relevanceStatus) LT 5

And so on...


Functies gedemonstreerd

  1. relevanceStatus variable
  2. Randomizing


Download

Voorbeeld downloaden.


Beoordelen door gebruiker geselecteerde producten

Overzicht

The below example shows how you can ask users to list a set of products that interest them, and then have them rate those products.


Functies gedemonstreerd

  1. Tailoring answers - when rating products, the labels come from the comment field of the preceding multiple choice question
  2. Tailoring scales - many advanced questions options, like scale headings, can also be tailored.


Schermafdruk

This image shows that even though only products 1,3, and 5 were selected, only those 3 are displayed (using the array_filter attribute). Moreover, the row labels in the second question are either the product numbers (if nothing is entered into the comment field) or the contents of the comment fields.



This image shows how the tailored answers are specified:



Here is the Show Logic File for that question, which lets us verify that the conditional logic works as desired (e.g., to see whether there are any syntax errors):



The next image shows a group in which you specify a 5 point rating scale (Options 1-5), the title of the scale, and the products you want to rate. The final question shows that each of the parts of the array question can be tailored:



The next image shows the logic file view of the last question. As you can observe, the subquestions, answers, and scale headers can be tailored.



Download

Voorbeeld downloaden.