Actions

StatFunctions: Difference between revisions

From LimeSurvey Manual

m (Some text changes for better readability)
m (Add example)
Line 1: Line 1:
{{FeatureStarting|4.1.0}}  
{{FeatureStarting|4.1.0}}  
=Usage=


Functions for the expression manager to count some statistics data :
Functions for the expression manager to count some statistics data :
Line 13: Line 15:


{{Alert|Before using these functions : the plugin must be activated in [[Plugin_manager#General|Plugin Manager]].}}
{{Alert|Before using these functions : the plugin must be activated in [[Plugin_manager#General|Plugin Manager]].}}
=Example=
* count number of submitted response : {statCount("id")}
* count number of responses (submitted or not) : {statCount("id", 0)}
* number of responses where respondent stopped at page 1 : {statCountIf("lastepage", 1, 0)}
* number of submitted responses with startlanguage "en" : {statCountIf("startlanguage", "en", 1)}
* number not completed responses to this survey : {sum(statCount("id", 0),statCount("id")*-1}


[[Category:Plugins]][[Category:Core Plugins]]
[[Category:Plugins]][[Category:Core Plugins]]

Revision as of 09:43, 17 January 2022

 Hint: This features is available starting in version 4.1.0


Usage

Functions for the expression manager to count some statistics data :

  • statCount(QuestionCode.sgqa[, submitted = true]) : count the number of already submitted answered questions by QuestionCode. You can count the number of submitted (= completed) surveys with statCount('sid') for example.
  • statCountIf(QuestionCode.sgqa, value[, submitted = true]) : count the number of responses where answer to question QuestionCode equals value. The comparison uses Yii compare, you can use <, >, >=, <=, <> operator at start of your value.

You can find an example of the usage of these 2 functions in: survey_archive_statCountFunctionsTest inside the test directory.

This plugin uses the ExpressionManagerStart plugin and it creates two functions. These 2 functions don't use javascript, so the check is done only when the respondent moves ahead in the survey.

  Before using these functions : the plugin must be activated in Plugin Manager.


Example

  • count number of submitted response : {statCount("id")}
  • count number of responses (submitted or not) : {statCount("id", 0)}
  • number of responses where respondent stopped at page 1 : {statCountIf("lastepage", 1, 0)}
  • number of submitted responses with startlanguage "en" : {statCountIf("startlanguage", "en", 1)}
  • number not completed responses to this survey : {sum(statCount("id", 0),statCount("id")*-1}