Welcome to the LimeSurvey Community Forum

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

Equation with ASSESSMENT_CURRENT_TOTAL not working

  • Drewskie
  • Drewskie's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #138640 by Drewskie
Good day,

I have a survey with 5 question groups
Each group has a List(radio) question
Based on the answer it it show the second question

I have enabled assessment on the survey and assigned values to the radio selections

Now my problem:
I want to record the value in the database for each question group.
I used a equation question at the end of each question group that displays ASSESSMENT_CURRENT_TOTAL
The problem is that this value increases based on the previous question groups.
I need to get a total just for the current question group only

I tried {ASSESSMENT_CURRENT_TOTAL}-{Tot1.value} but that just shows 3 - 2 in the database instead of 1

Any help will be appreciated.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #138644 by tpartner
The easiest way would be to assign the answer codes as the "score" instead of using assessments. Then your equation would simply be something like:
Code:
{q1.NAOK}

Or, if there are multiple questions on a page:
Code:
{sum(q1.NAOK, q2.NAOK, q3.NAOK)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Drewskie
  • Drewskie's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #138645 by Drewskie
Thanks but this brings in a new issue as I have two answers that get 0 score.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #138648 by tpartner
Then you'll need to use IF statements (line-breaks inserted for clarity):
Code:
{if(q1==1, 0, 
  if(q1==2, 0, 
    if(q1==3, 1, 
      if(q1==4, 2, ''
))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Drewskie
The topic has been locked.
  • Drewskie
  • Drewskie's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 9 months ago #138663 by Drewskie
That worked perfectly, thank you.

Just a quick sanity check, to get the sum of all these I would use the following formula?

{sum(Tot1.value, Tot2.value, Tot3.value)}

(Tot1 etc is my if question code)
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #138667 by DenisChenu
Yes the {sum(Tot1.value, Tot2.value, Tot3.value)} do the trick.

For the 1st issue : can you send a little survey file ? I'm unsure it must do something like this : if your survey is group by groiup and you add an assesment equation : each assesment equation must be different ( 1st is for 1st group, 2nd for 2nd group + 1st group etc ..., EXCEPT is user move previous ....)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #138672 by tpartner
@Denis, the original post said "I need to get a total just for the current question group only. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago - 7 years 9 months ago #138675 by DenisChenu
Yes, i know, but after is just a question of Math :

AssessGroup1: {assessment_CURRENT_TOTAL}
AssessGroup2: {assessment_CURRENT_TOTAL-AssessGroup1}
AssessGroup3: {assessment_CURRENT_TOTAL-AssessGroup1-AssessGroup2}

BUT : there are issue if user move previous back / move next :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 7 years 9 months ago by DenisChenu. Reason: Math
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose