x

Capitoli principali

  1. LimeSurvey Cloud vs LimeSurvey CE
  2. LimeSurvey Cloud - Guida rapida
  3. LimeSurvey CE - Installazione
  4. Come progettare un buon sondaggio (Guida)
  5. Iniziare
  6. Configurazione di LimeSurvey
  7. Introduzione - Sondaggi
  8. Visualizza le impostazioni del sondaggio
  9. Visualizza il menu del sondaggio
  10. Visualizza la struttura del sondaggio
  11. Introduzione - Domande
  12. Introduzione - Gruppi di domande
  13. Introduzione - Indagini - Gestione
  14. Opzioni della barra degli strumenti del sondaggio
  15. Sondaggio multilinguale
  16. Guida rapida - ExpressionScript
  17. Funzionalità avanzate
  18. Domande frequenti generali
  19. Risoluzione dei problemi
  20. Soluzioni alternative
  21. Licenza
  22. Registro delle modifiche alla versione
  23. Plugin - Avanzati
 Actions

Controlla la logica del sondaggio - Avanzato

From LimeSurvey Manual

Revision as of 14:06, 3 August 2023 by Maren.fritz (talk | contribs) (Created page with "Le righe sono codificate a colori come segue: *'''Gruppi''' - sono mostrate con uno sfondo grigio chiaro *'''Domande''' - sono mostrate con uno sfondo verde chiaro *' ''Domand...")


Generale

Un'opzione importante che ti aiuta a creare e mantenere facilmente sondaggi complessi è Check Survey Logic.

Durante lo sviluppo e il test del sondaggio, e prima di attivarlo, è molto importante convalidare la logica del sondaggio. Ciò è particolarmente vero quando si utilizzano complesse equazioni di pertinenza, personalizzazione e convalida: è necessario essere sicuri che nulla si rompa durante l'esecuzione del sondaggio.

Questa funzione ti consente di convalidare rapidamente l'accuratezza del sondaggio, dei gruppi e delle domande. È possibile accedervi dalle opzioni del menu della barra superiore situate sotto le impostazioni relative al sondaggio. È disponibile tramite il menu Strumenti:



Come puoi osservare sopra, puoi eseguire questa opzione quattro volte, per ogni lingua utilizzata all'interno di un sondaggio.

Descrizione

L'opzione Check Survey Logic mostra tutto ciò che hai specificato per ogni domanda e gruppo (es. nome, testo, aiuto, condizioni/rilevanza, regole di validazione, default, sottodomande, risposte) in un comodo formato tabulare. Evidenzia gli errori e ti consente di fare clic sulla domanda e sugli ID di gruppo (o sulle variabili utilizzate all'interno delle equazioni) per aprire nuove schede del browser per modificare tali domande o gruppi. In questo modo è facile modificare rapidamente eventuali errori e aggiornare la pagina di controllo della logica per confermare l'accuratezza del sondaggio prima di attivarlo.

Il display è inoltre progettato per essere leggibile da ricercatori e sponsor dello studio in modo che possano convalidare l'accuratezza del progetto e della logica del sondaggio. Il controllo della logica del sondaggio aggiorna la cache per tutte le espressioni utilizzate all'interno di un sondaggio attivo.

Comprende le seguenti colonne:

  • # - mostra i conteggi della sequenza di gruppi e domande, a partire da 0.
  • Nome [ ID] - mostra il codice della domanda per il gruppo/domanda/sottodomanda. Questi codici possono essere usati come variabili all'interno di espressioni. ID è l'ID della domanda (QID) o l'ID del gruppo (GID). Questo campo mostra anche il tipo di domanda (ad esempio, Scelta multipla [M])).


Template:Nota


  • Rilevanza [ Validation] (Predefinito) - mostra quanto segue:
    • Pertinenza - l'equazione di pertinenza evidenziata dalla sintassi per la domanda o il gruppo. Se è sempre vero (da mostrare in qualsiasi scenario), il valore sarà 1.
    • Validation - ExpressionScript genera automaticamente la convalida equazione in base agli attributi della domanda selezionati (ad es. numero min/max di risposte, valori somma min/max/uguale, valori individuali min/max o convalida dell'espressione regolare). Questa sezione mostra l'equazione di convalida generata in modo da poter rilevare eventuali errori (come variabili non definite).
      • La convalida a livello di domanda mostra l'equazione necessaria per verificare gli attributi della domanda sopra descritti
  • **La convalida a livello di sottodomanda mostra l'equazione necessaria per implementare array_filter, array_filter_exclude e exclusive_option
    • Predefinito - se la domanda ha un valore predefinito, viene mostrato qui, con la sintassi evidenziata (poiché il valore predefinito potrebbe essere un'espressione).
  • Testo [ Aiuto] (Suggerimento) - mostra quanto segue:
    • Testo - il testo del gruppo, domanda, sottodomanda o risposta. La sintassi è evidenziata per mostrare qualsiasi tailoring incorporato, permettendoti così di verificare di aver dichiarato tutte le variabili che intendi utilizzare nel tailoring.
    • Aiuto - questo mostra il testo di aiuto per la domanda, anch'esso evidenziato dalla sintassi.
    • Suggerimento - questo mostra il suggerimento di convalida generato internamente, basato sugli attributi della domanda. Questo stesso suggerimento viene utilizzato in tutti gli stili di indagine, oltre che nelle schermate di indagine stampabili e di immissione dati.
    • Attributi domanda: mostra una tabella di tutti gli attributi della domanda rilevanti per questa domanda. Gli attributi che potrebbero essere equazioni sono evidenziati dalla sintassi in modo da poterne convalidare l'accuratezza.

Le righe sono codificate a colori come segue:

  • Gruppi - sono mostrate con uno sfondo grigio chiaro
  • Domande - sono mostrate con uno sfondo verde chiaro
  • ' Domande secondarie' - sono mostrate con uno sfondo giallo pallido
  • Risposte - sono mostrate con uno sfondo bianco semplice

Le risposte hanno un attributo aggiuntivo nella colonna Rilevanza:

  • Valore - questo è il valore interno predefinito utilizzato dai calcoli. Se stai utilizzando Valutazioni, questo sarà il valore della valutazione. Altrimenti, questo sarà lo stesso del nome della risposta.


The survey description, welcome and end messages, end URL, Survey data policy notice and label are listed within the Cgeck survey Logic (above the table) if their corresponding fields are not empty!

Usage

At the top of the page, there is a summary message. If all is well, it will say "No syntax errors detected in this survey", or "This group" or "This question", "by itself, does not contain any syntax errors". If the opposite is true, it will say "X questions have syntax errors that need to be corrected".

Each question that has syntax errors gets the background of its leftmost column (i.e. #) color-coded red. Also, a warning stating the number of minimum errors of a question will be displayed under the Name [ID] column. The following errors are common:

  • Undefined variable - if you have not defined all of your variables, or mistyped array_filter (or different sets of answer options for array_filter), then some of your validation questions will show errors. Undefined variables are shown in red text, boxed with a red line.
  • Bad syntax - as you start to use relevance equations, you may use too many or too few parentheses. Such syntax problems are highlighted and boxed in red. If you hover the mouse over any such red-boxed text, a tool-tip will describe the error.

Colors in ExpressScript syntax

Conditions and equations are syntaxhighlighted to easier figure out what you are looking at:

  1. Green / Light Blue: A variable that references a question earlier in the survey
  2. Blue: A function
  3. Grey: A string expression
  4. Brown: A TOKEN expression (participant data)
  5. Black: Operator

Things to check:

  1. Purple: A variable that references a question later in the survey. Usually this is an error and needs to be checked.
  2. Red or red frame: A non-existing variable or reference to an earlier question or a syntax error - usually needs to be checked.


Undefined Variables

If undefined variables are used, the respective variable name will be color-coded in red and surrounded by a red line. If you hover your mouse over the variable name, it will say "undefined variable":



  Attention : Please note that LimeSurvey does not allow survey administrators to create questions that use the same question code. However, it could happen to have similar question codes within a survey if you import a question group or a question that uses the same question code as one of your already-defined questions. The question can still be imported because the question ids are different. However, if you wish to export the survey results to further explore the survey results (R or SPSS), be careful because the question code is seen as a variable!



}}

Bad syntax

Most of the expression-related mistakes are related to bad syntax. This is related to the fact that survey administrators usually miss to add a curly bracket, to properly make use of parentheses, or they use expressions wrongly:



Here are many good examples on the usage of syntax highlighting.


Bad custom JavaScript

The JavaScript errors will also be highlighted in the survey logic check:


Speeding editing and validation

All of the syntax-highlighted text has tooltips embedded, which are clickable:

  1. Tooltips
    • Functions - hovering the mouse lets you see the purpose and syntax definition of the function;
    • Variable Names - hovering the mouse lets you see the position (group, question sequence), question text, and allowable answers for the question.
  2. Actions
    • Variable Names - clicking on the variable name opens a new window that allows you to edit the question. This makes it easy to navigate and verify logic - simply keep clicking on variable names of relevance or validation criteria for the question to see where they come from and how they are used.


Examples

The following examples are taken from the ExpressionScript sample surveys. You can find screenshots of running surveys, explanations, and downloads on that page.


Body Mass Index

Here are screenshots of this example.

This is the question-reorder view of the Body Mass Index calculation. You can see the relevance equations for weight, height, and BMI under the Question column:



For a better survey overview, check the survey logic page:



This survey example is also a good example of nested if() statements to generate the "weightstatus".


Cascading logic

Here are screenshots of this example.

It shows the subquestion validation logic that is automatically generated when you use array_filter and array_filter_exclude. This example also shows how you can substitute the tailored "Other" value (the answer for Q02_other is Q01_other).



Q05 in this example shows simultaneous use of array_filter and array_filter_exclude on Q01 and Q02, respectively. This example demonstrates cascading array_filter capabilities. Note that one of the main reasons for showing the question and subquestion level validation criteria is to help ensure you have not made any typos in specifying the array_filter or array_filter_exclude variable names (or in case you use different variable names for your list of filtered subquestions). If you have such typos, all the invalid variable names will appear in red indicating that they are undefined, letting you quickly fix the problem.



Dynamic relevance

This example demonstrates dynamic cascading relevance logic to control display of question visibility. You can download this example here.

Also note that questions are displayed only if certain validation criteria are met. For example, if a person states that she has 2 kids, certain questions have to be filled in by the respondent (kid1 and kid2).


Group-level relevance

This example shows how group-level relevance appears in the logic check. Here are screenshots of the example described below.

As you can see, the group-level relevance equation (cohabs > 1 && p1_rel != "") appear in the grey Person 2 row for G-2.

You may also notice that all of the questions are mandatory. However, if the group is irrelevant, so are all its questions. As a result, those questions are only truly mandatory if the group is relevant.

You may also note that certain questions are displayed only if the answer to the previous question is not empty. You may see below that if p2_sex is not filled in, p2_name is not going to be displayed, even though it is a mandatory questions. The mandatory question p2_age is also not going to be displayed if p2_name is not filled in. These questions can be considered "conditionally mandatory".

Additionally, note that the tip messages are also automatically created for you. They are organized by value range (min/max), sum value range (min/max/equals), number of answers (min/max), etc (it depends on the used question type and active attributes). Sometimes you want to validate an answer range but don't want to display what might appear to be silly validation tips to the user. In such cases, you can use the hide_tip question option (as in this case, to avoid telling the user that the age must be between 0 and 115 unless they try to enter a bad value - see p2_age).


Comma as radix (decimal) separator

Although LimeSurvey fully supports the use of comma as radix (decimal) separator at run-time, you must still use a decimal as the radix separator at the design-time (e.g., when specifying min/max values in advanced question attributes). The working example can be found here.

Also, remember that the validation logic is created for you automatically from the enabled question attributes. The equations may look overwhelming, but you don't need to worry about them.