Welcome to the LimeSurvey Community Forum

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

Calculating the answers

  • Shatha
  • Shatha's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #229283 by Shatha
Calculating the answers was created by Shatha
LimeSurvey version: 3.17.0+190402Own server or LimeSurvey hosting: Own SurveySurvey theme/template: Fruit==================Dears,I want to do a survey that shows the end-users a couple of questions. Depending on his/her answers. An overall score will show up.Below is the draft survey so you can get the idea. Have you ever shared your password with someone else?
  • No
  • Yes
  • It depends
Do you have antivirus software on your mobile?
  • Yes
  • No
  • Sometimes
 If the end-users answer (Yes) for both questions, then a message appears to him/her that the score is Excellent.If the answer to both questions is (No), the score is Bad, and so on. I know there is a condition function, but it can't be done because my survey has more than 10 questions and more than 3 answers to each question.Therefore, I'm seeking your support to advise me on a better way to do this method.Thank you.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago - 2 years 10 months ago #229290 by Joffm
Replied by Joffm on topic Calculating the answers
Hi,
you may use all functions that you find here
[url] www.limesurvey.org/manual/ExpressionScri...mplemented_functions [/url] 
to calculate your score.
Usually you will use the "sum()" function, optionally with some "IFs"

And to calculate you either use the code of the answer options (obviously you have to use numerical codes) or you use the assessment values of the answer options.
Advantage of the second approach: You can use the same value for different options and you can use negative values.
And how you access these values to use them in your sum, read here
[url] www.limesurvey.org/manual/ExpressionScri...#Access_to_variables [/url]
You see, there is
a. QCode, QCode.code, QCode.NAOK with the description "the selected response code for the question"
b. QCode.value, QCode.valueNAOK with the description "the assessment value for the question"

Knowing this, you may create a question of type equation with your desired sum, like
{sum(Q1.NAOK,Q2.NAOK,Q3_SQ001.NAOK,Q3_SQ002.NAOK,Q4.valueNAOK,that.Q5.NAOK)}
You see you can mix codes and assessment values.

And of course you can create more sophisticated ways to calculate your score.
Here an example that uses "multiple" questions
{sum(if(Q1_SQ001.NAOK=="Y",1,0),if(Q1_SQ002.NAOK=="Y",5,2),if(Q1_SQ003.NAOK=="Y",-7,7),if(Q1_SQ004.NAOK=="Y",0,10))}
You see the meaning:
If the first subquestion was selected, add 1 else add 0
If the second subquestion was selected, add 5 else add 2
If the third subquestion was selected, subtract 7 else add 7
If the fourth subquestion was selected, add 0 else add 10
​​​​​​​
But you should always use NAOK.
[url] www.limesurvey.org/manual/ExpressionScri...ion/en#Usage_of_NAOK [/url]
Otherwise the function will fail, if there is a missing element (because of a filter).

Now start to create something.
In case of more questions, send your approach as lss export.

​​​​​​​Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 10 months ago by Joffm.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago #229293 by holch
Replied by holch on topic Calculating the answers
So sharing your password with others gives an excellent score??? ;-)

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • Shatha
  • Shatha's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #229355 by Shatha
Replied by Shatha on topic Calculating the answers
Hi Joffm,
Thank you for your reply.
I want to put a value on each answer. Then in the last question, I will use the sum function, and if the sum is = 10, this text appears. If less then this text.
What is the best approach for that?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago #229358 by Joffm
Replied by Joffm on topic Calculating the answers
Step by step:
1. You want to display a text -> question of type "text display"
2. The text depends on a condition -> Expression Manager/Script  {if(condition, text if condition is true,text if condition is false)}
The always used example
[url] www.limesurvey.org/manual/ExpressionScri...7BMrs.7D_Smith....22 [/url]
3. Your condition is the result of the sum -> sum==10:  true, else false.

How to sum I already showed.

Here is an example about this.
The sum of childrens' age is calculated and a text is displayed that depends on the number of children.
[url] www.limesurvey.org/manual/ExpressionScri...s_in_the_survey_data [/url]

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Shatha
  • Shatha's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 10 months ago #229366 by Shatha
Replied by Shatha on topic Calculating the answers
Dear Joffm,
Thank you for your support.
It worked with me.
Much appreciated.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose