Welcome to the LimeSurvey Community Forum

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

I have an array and want it to total the scores and give it to the participant

  • celeste_1234
  • celeste_1234's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 3 weeks ago #266891 by celeste_1234
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)(Write here your question/remark)Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.44+231107
Own server or LimeSurvey hosting:
Survey theme/template: 
==================

Hello! I am very new to limesurvey and I would like some help trying to make my array total responses and providing a score that is visible to the person doing the survey. I have looked around on the forums for a while and I found something that I thought would work but it seems to be falling short, I do have the array successfully built but I believe the issue is in the code I am using.

My array is a 10 question scale with 4 total answers, according to the AQ-10 pdf which I am referencing for this, there is no score difference between the definitely option and the slightly option. Therefore both the definitely and slightly options are both worth one point and since certain questions are reverse coded, whether or not it is the agree option or the disagree option being worth one point is dependent on the question.

 
I had tried two options, one where I attempted to calculate the score within the question itself and the other where I created a separate equation type question, put the code in there, and then used a text display question to try and call the response of the equation question. I kept having the same issue where the score would always be 0 which points to an issue in the code I am using.

Basically I want the score to be calculated and displayed below but I am uncertain how to do that, I did manage to get the code to display something but it would not show any other number for the score other than 0. 

I appreciate any help I can get, I have done my best based on what others have said in the forums but I am lost.


Code:{sum(countif("Slightly agree",AQ_SQ001.NAOK,AQ_SQ007.NAOK,AQ_SQ008.NAOK,AQ_SQ010.NAOK), countif("Definitely agree",AQ_SQ001.NAOK,AQ_SQ007.NAOK,AQ_SQ008.NAOK,AQ_SQ010.NAOK), countif("Slightly disagree",AQ_SQ002.NAOK,AQ_SQ003.NAOK,AQ_SQ004.NAOK,AQ_SQ005.NAOK,AQ_SQ006.NAOK,AQ_SQ009.NAOK), countif("Definitely disagree",AQ_SQ002.NAOK,AQ_SQ003.NAOK,AQ_SQ004.NAOK,AQ_SQ005.NAOK,AQ_SQ006.NAOK,AQ_SQ009.NAOK))}

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 3 weeks ago #266894 by holch
It is always helpful to provide a lss file with only the relevant questions in it (copy your survey, delete everything irrelevant, export it as LSS file and upload it here).

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 3 weeks ago - 1 month 3 weeks ago #266896 by Joffm
Hi,
yes there are a lot of misunderstandings.

1. countif is defined as countif(matches, arg1, arg2, ... argN)
And "matches" is the code of the answer option, not the text.

2. Your function to calculate. Did you think it over?
What do you do?
First you count the number of subquestions that are answered with "1".
Then you count the number of subquestions that are answered with "2".
And so on.
Then you sum these four values.
So in reality you only count the number of answered questions.

3. What should you do.
Send the lss export (only the relevant questions), as @holch

Therefore both the definitely and slightly options are both worth one point

If two options have the same value "both the definitely and slightly options are both worth one point" you have to use "assessment values".

since certain questions are reverse

This is not really difficult. Easily done by coding of the subquestions, like
N01, N02,... for "normal" items
R01, R02 for "reverse" items
Now you can use the real power or the "that" variable,like
{sum(that.AQ_sq.N) to sum all "normal" items and
{sum(that.AQ_sq.R) to sum all "revers" items.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 month 3 weeks ago by Joffm.

Please Log in to join the conversation.

  • celeste_1234
  • celeste_1234's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 weeks ago #266905 by celeste_1234
I have attached the .lss file below, I appreciate your help.
 

Attachment not found

Please Log in to join the conversation.

  • celeste_1234
  • celeste_1234's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 weeks ago #266908 by celeste_1234
I realized I forgot to specify, the items that are reversed for this are:

Question 2 (I usually concentrate more on the whole
picture, rather than the small details),

3 (I find it easy to do more than one thing at
once),

4 (If there is an interruption, I can switch back to
what I was doing very quickly ),

5 (I find it easy to ‘read between the lines’ when
someone is talking to me ),

6 (I know how to tell if someone listening to me
is getting bored) ,

and 9 (I find it easy to work out what someone is
thinking or feeling just by looking at their face)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 weeks ago #266916 by Joffm
Hi,
change the subquestion codes as I advised yesterday.
"normal" items "N01, N02,...
"reverse" items: R01, R02,...

Then in a question of type "equation" only this
 {sum(that.AQ.sq_N.valueNAOK,(count(that.AQ.sq_R)-sum(that.AQ.sq_R.valueNAOK)))}
This stores the pure value in your database
And to understand: Read the manual about the variable "that"
Though it is simple arithmetic as we learned at school.

And use a question of type "text display" to show a message like
"Your score is: {numScore}."

And again I say: You'd better use numerical codes for your answer options.

Last: How do you handle not answered subquestions.
Two participants may get the same score while one answered all questions the other only a few.

Unfortunately I can't upload things at the meoment.
Therefore I try to provide the lss later.

Joffm
 

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 weeks ago #266920 by Joffm
And here the lss.
 

File Attachment:

File Name: limesurvey...20-4.lss
File Size:38 KB


When there is some time later I will explain the equation better.

Joffm

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

Please Log in to join the conversation.

  • celeste_1234
  • celeste_1234's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 weeks ago #266925 by celeste_1234
thank you for your help!
I want to disable the no answer section entirely and have now just figured out how to do that! So that should be dealt with now as participants are unable to leave a question unanswered (at least from what I gathered)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 weeks ago #266926 by Joffm
Only "Don't show NA" is not sufficient

The participants still can leave the subquestion empty.

Make the question mandatory.

Joffm 

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

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
1 month 2 weeks ago #266929 by tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl

Please Log in to join the conversation.

  • celeste_1234
  • celeste_1234's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 weeks ago #266930 by celeste_1234
Fantastic, I made sure to do that! thank you

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 weeks ago - 1 month 2 weeks ago #266935 by Joffm
Hi,
as promised the explanation of this equation
 {sum(that.AQ.sq_N.valueNAOK,(count(that.AQ.sq_R)-sum(that.AQ.sq_R.valueNAOK)))}

But first let's see how to handle the "reverse" items.
In your case the assessment value "1" has to be converted to "0" and "0" has to be converted to "1".
You do this by subtracting the value from 1:
If the value is 1: 1 - 1 = 0
If the value is 0: 1 - 0 = 1

Now the rough equation to calculate the score would be
{AQ_SQ001.valueNAOK+(1-AQ_SQ002.valueNAOK)+(1-AQ_SQ003.valueNAOK)+(1-AQ_SQ004.valueNAOK)+(1-AQ_SQ005.valueNAOK)+(1-AQ_SQ006.valueNAOK)+AQ_SQ007.valueNAOK+AQ_SQ008.valueNAOK+(1-AQ_SQ009.valueNAOK)+AQ_SQ010.valueNAOK}

To make the whole explanation shorter I replace
AQ_SQ001.valueNAOK by x1
AQ_SQ002.valueNAOK by x2
...

So it is
x1+(1-x2)+(1-x3)+(1-x4)+(1-x5)+(1-x6)+x7+x8+(1-x9)+x10
Let's order a bit
x1+x7+x8+x10+(1-x2)+(1-x3)+(1-x4)+(1-x5)+(1-x6)+(1-x9)
But this is equal to
x1+x7+x8+x10+1+1+1+1+1+1-x2-x3-x4-x5-x6-x9
Equal
x1+x7+x8+x10+1+1+1+1+1+1-(x2+x3+x4+x5+x6+x9)
Equal
x1+x7+x8+x10 + 6 - (x2+x3+x4+x5+x6+x9)

Now there is
x1+x7+x8+x10 : The sum of the values of "normal" items
6: To convert the value we subtract from 1, and we do it for each "reverse" subquestion. So here it is just the number of subquestions with "reverse" items, count(x2,x3,x4,x5,x6,x9)
x2+x3+x4+x5+x6+x9: The sum of the values of "reverse" items

Till now it is simple arithmetic.

Shorter:
sum(x1,x7,x8,x10),(count(x2,x3,x4,x5,x6,x9) - sum(x2,x3,x4,x5,x6,x9)))

If we now replace the x1,x2,... by the original AQ_SQ001,...
sum(AQ_SQ001.valueNAOK,AQ_SQ007.valueNAOK,AQ_SQ008.valueNAOK,AQ_SQ010.valueNAOK),(count(AQ_SQ00",AQ_SQ003,AQ_SQ004,AQ_SQ005,AQ_SQ006,AQ_SQ009) - sum(AQ_SQ002.valueNAOK,AQ_SQ003.valueNAOK,AQ_SQ004.valueNAOK,AQ_SQ005.valueNAOK,AQ_SQ006.valueNAOK,AQ_SQ009.valueNAOK)))

That's fine.
But let's make this formula independent from the total number of items, from the number of "reverse" items - a general solution.

We do the trick with the "that" Variable.
Example:
What does "{sum(AQ.sq_X)}" mean.
You see it when you enter this in your question text and save the question.
It is expanded to
{sum(AQ_X001,AQ_X002,AQ_X003,AQ_X004,...)}
to all subquestions where the code contains an "X"

Therefore I advised to code the "normal" items "N01", "N02",... and the "reverse" items "R01", "R02",... - to distinguish between "normal" items and "reverse" items.

Then we can write the equation as
sum(AQ_N01.valueNAOK,AQ_N07.valueNAOK,AQ_N08.valueNAOK,AQ_N10.valueNAOK),(count(AQ_R02,AQ_R03,AQ_R04,AQ_R05,AQ_R06,AQ_R09) - sum(AQ_R02.valueNAOK,AQ_R03.valueNAOK,AQ_R04.valueNAOK,AQ_R05.valueNAOK,AQ_R06.valueNAOK,AQ_R09.valueNAOK)))

And using "that" it is only:
sum(that.AQ.sq_N.valueNAOK),(count(that.AQ.sq_R) - sum(that.AQ.sq_R.valueNAOK)))

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 month 2 weeks ago by Joffm.
The following user(s) said Thank You: tpartner

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose