Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Show survey data total

  • flasher44
  • flasher44's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 7 months ago - 5 years 7 months ago #173940 by flasher44
Show survey data total was created by flasher44
Hello, I need help.

I would like to display at the end of the survey for each person it's total of points from it's first entry.

For example :

Entry 1:

Question : how many frog seen ?
Answer : 2

Question : how many bird seen ?
Answer : 7


Displayed at the end of the survey :

Total frogs : 2
Total Bird : 7

Total animals : 9


Entry 2

Question : how many frog seen ?
Answer : 5

Question : how many bird seen ?
Answer : 12


Displayed at the end of the survey :

Total frogs : 7
Total Bird : 21

Total animals : 28


I already created the survey, but I dont know to use in the text element box, {FROGS.shown}, only display the number just entered not all number of FROGS from the begining.


Thanks for your help...
Last edit: 5 years 7 months ago by flasher44.
The topic has been locked.
More
5 years 7 months ago #173948 by jelo
Replied by jelo on topic Show survey data total
That would mean you need access to the responses of all respondents at the end of each survey.
ExpressionManager (will become ExpressionScript) isn't having access to the responses of all respondents. The common approach is via an external script which accesses the database.

What version of LimeSurvey is used? Perhaps someone can provide you a workaround.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • flasher44
  • flasher44's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 7 months ago #173963 by flasher44
Replied by flasher44 on topic Show survey data total
I'm using V3.6.1-0073, could help me with this kind of script, I'm unable to do it myself ?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #173989 by holch
Replied by holch on topic Show survey data total
Is this one questionnaire with different sections (one response) or would this be respondents filling the questionnaire on different occasions (different responses):

In the first case, you can access all answers given in the same response via Expression manager and add things up in an equation type question.

In the second case: Not possible, because you can't access the answers from other responses/filled questionnaires.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • flasher44
  • flasher44's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 7 months ago #174022 by flasher44
Replied by flasher44 on topic Show survey data total
The respondents fill the questionnaire every day. So there is no solution ?
The topic has been locked.
More
5 years 7 months ago #174026 by jelo
Replied by jelo on topic Show survey data total
LimeSurvey isn't offering the functionality out of the box.
There might be a plugin or a workaround (which would involve coding with external scripts), but I'm not aware of one.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 7 months ago #174028 by LouisGac
Replied by LouisGac on topic Show survey data total
It should be possible to do via a custom survey theme, and by adding the dynamic survey model object inside the twig sand box (via internal.php).
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 7 months ago #174035 by LouisGac
Replied by LouisGac on topic Show survey data total
ok I did it for you:
github.com/LimeSurvey/LimeSurvey/commit/...bda5204cdcc8750efe16

This feature has been requested a bunch of times in the forum, and it's very easy to add, so here we go. Also, it shows what can be done via twig and custom functions.

It will be available in next release, you can still implement the commit in your local version.

To use it: turn on quota, public statistics, then in submit.twig view add something like:
Code:
{% set aResponses = getAllTokenAnswers(aSurveyInfo.sid) %}
  {{ dump(aResponses) }}

You'll see that aResponses contains all the responses of the current token.
Just loop throught it to do what ever you want.
The topic has been locked.
  • flasher44
  • flasher44's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 7 months ago #174051 by flasher44
Replied by flasher44 on topic Show survey data total
Thank you LOuis, but I would need a step by step explanation, I don't know what to do with your coding …

Sorry ;)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago - 5 years 7 months ago #174083 by tpartner
Replied by tpartner on topic Show survey data total
Some assumptions for the example below:

In the theme editor, select the Completed screen, then edit the submit.twig part file, adding code something like below and save it to your local theme.


Code:
<div> 
    {% set aResponses = getAllTokenAnswers(aSurveyInfo.sid) %}
    {% set responseSum = 0 %}
    {% set responseCount = 0 %}
    {% set responseToken = '' %}
 
    {% for response in aResponses %}
        {% if (response['111111X22X33'] != '') %}
            {% set responseSum = responseSum + response['111111X22X33']|number_format %}
            {% set responseCount = responseCount + 1 %}
        {% endif %}
 
        {% if (loop.index == 1) %}
            {% set responseToken = response['token'] %}
        {% endif %}
    {% endfor %}
 
    {% if (responseCount > 0) %}
        There are {{ responseCount }} valid responses for Q1 with token value {{ responseToken }}.
        <br />
        The sum of all valid responses  is {{ responseSum }}.
        <br />
        The average of all valid responses is {{ (responseSum/responseCount) }}.
    {% endif %}
</div>

After several responses by a given token, you should see something like this in the completed screen.


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 7 months ago by tpartner. Reason: Fix bug in code
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #174084 by tpartner
Replied by tpartner on topic Show survey data total
LouisGac, would it be possible to get all responses, regardless of token? If, for example, you wanted a total for a question answered by all respondents.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 7 months ago #174085 by jelo
Replied by jelo on topic Show survey data total
Nice and no modifications to corefiles.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose