- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Scoring Array responses with different weight
- captainwalker
- Topic Author
- Offline
- New Member
Less
More
1 month 4 days ago #258941
by captainwalker
Scoring Array responses with different weight was created by captainwalker
I have an array with 4 sub-questions. I want to create an assessment based on scores from the array sub-questions. My attached screenshot shows what I'm trying to do
I have 'Assessments' enabled but can't figure out how to pull the scores from the array sub-questions to show a rating of mild, moderate or severe.
I'm pretty new to Limesurvey. I am grateful for any ideas or suggestions.
=================
LimeSurvey version: Community Edition Version 6.5.1+240320
Own server on XAMPP
Survey theme/template: Fruity twenty-three
==================
I have 'Assessments' enabled but can't figure out how to pull the scores from the array sub-questions to show a rating of mild, moderate or severe.
I'm pretty new to Limesurvey. I am grateful for any ideas or suggestions.
=================
LimeSurvey version: Community Edition Version 6.5.1+240320
Own server on XAMPP
Survey theme/template: Fruity twenty-three
==================
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
1 month 4 days ago - 1 month 4 days ago #258942
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Scoring Array responses with different weight
Hi,
the first thing you do: Forget "assessment rules".
Since there is ExpressionScript (since version 2.0) it is outdated.
While assessment values may still be important; in case you have negative weights or several answer options have the same weight.
Well, in your case the answer options have different weights among the subquestions.
Here you have to sum each outcome.
I'd advise to calculate the score separately and than display the result.
Reason: To display the result you need a nested if. And the separated calculation avoids that the same is calculated several times.
So.
Create a (hidden) question of type equation (call it as you like; here I used "numScore")
and enter this
{sum(countif("2",Q1_Y004.NAOK), countif("3",Q1_Y002.NAOK,Q1_Y003.NAOK), countif("4",Q1_Y001.NAOK,Q1_Y002.NAOK), 2*countif("3",Q1_Y004.NAOK), 2*countif("4",Q1_Y003.NAOK,Q1_Y004.NAOK), 2*countif("5",that.Q1.NAOK))}
You see we sum the number of answer options that are weighted 1 and twice the answer options that are weighted 2.
And in a question of type "text display" or wherever you want - even in the question itself, you show the result with this nested IF
{if(numScore<4,'mild',if(numScore<8,'moderate','severe'))}
Here I assume that there were some typos in your requirement
a. you didn't define a result for "4"
b. you didn't define a result for "8"
c. a score >8 is impossible
Joffm
Edit:
{sum(if(Q1_Y001.NAOK>4,2,if(Q1_Y001.NAOK>3,1,0)), if(Q1_Y002.NAOK>4,2,if(Q1_Y002.NAOK>2,1,0)), if(Q1_Y003.NAOK>3,2,if(Q1_Y003.NAOK>2,1,0)), if(Q1_Y004.NAOK>2,2,if(Q1_Y004.NAOK>1,1,0)))}
Maybe this is easier
The values are summed up row by row (with nested IFs).
the first thing you do: Forget "assessment rules".
Since there is ExpressionScript (since version 2.0) it is outdated.
While assessment values may still be important; in case you have negative weights or several answer options have the same weight.
Well, in your case the answer options have different weights among the subquestions.
Here you have to sum each outcome.
I'd advise to calculate the score separately and than display the result.
Reason: To display the result you need a nested if. And the separated calculation avoids that the same is calculated several times.
So.
Create a (hidden) question of type equation (call it as you like; here I used "numScore")
and enter this
{sum(countif("2",Q1_Y004.NAOK), countif("3",Q1_Y002.NAOK,Q1_Y003.NAOK), countif("4",Q1_Y001.NAOK,Q1_Y002.NAOK), 2*countif("3",Q1_Y004.NAOK), 2*countif("4",Q1_Y003.NAOK,Q1_Y004.NAOK), 2*countif("5",that.Q1.NAOK))}
You see we sum the number of answer options that are weighted 1 and twice the answer options that are weighted 2.
And in a question of type "text display" or wherever you want - even in the question itself, you show the result with this nested IF
{if(numScore<4,'mild',if(numScore<8,'moderate','severe'))}
Here I assume that there were some typos in your requirement
a. you didn't define a result for "4"
b. you didn't define a result for "8"
c. a score >8 is impossible
Joffm
Edit:
{sum(if(Q1_Y001.NAOK>4,2,if(Q1_Y001.NAOK>3,1,0)), if(Q1_Y002.NAOK>4,2,if(Q1_Y002.NAOK>2,1,0)), if(Q1_Y003.NAOK>3,2,if(Q1_Y003.NAOK>2,1,0)), if(Q1_Y004.NAOK>2,2,if(Q1_Y004.NAOK>1,1,0)))}
Maybe this is easier
The values are summed up row by row (with nested IFs).
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 month 4 days ago by Joffm.
The following user(s) said Thank You: tpartner, captainwalker
Please Log in to join the conversation.
- captainwalker
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
1 month 3 days ago - 1 month 3 days ago #258954
by captainwalker
Replied by captainwalker on topic Scoring Array responses with different weight
Wow!! That's put me lime-years ahead in survey development. You are priceless - and thanks for including the .lss file.
Claude.ai did an analysis to explain more. Do add to the following if it would benefit others.
The code uses the
function to add up the results of several
functions. Each
function counts the number of occurrences of a specific answer code in the specified subquestions.
function adds up all the counts and weighted counts to calculate the total score.
Claude.ai did an analysis to explain more. Do add to the following if it would benefit others.
Code:
{sum( countif("2",Q1_Y004.NAOK), countif("3",Q1_Y002.NAOK,Q1_Y003.NAOK), countif("4",Q1_Y001.NAOK,Q1_Y002.NAOK), 2*countif("3",Q1_Y004.NAOK), 2*countif("4",Q1_Y003.NAOK,Q1_Y004.NAOK), 2*countif("5",that.Q1.NAOK) )}
Code:
sum()
Code:
countif()
Code:
countif()
-
Code:
countif("2",Q1_Y004.NAOK)
-
Code:
countif("3",Q1_Y002.NAOK,Q1_Y003.NAOK)
-
Code:
countif("4",Q1_Y001.NAOK,Q1_Y002.NAOK)
-
Code:
2*countif("3",Q1_Y004.NAOK)
-
Code:
2*countif("4",Q1_Y003.NAOK,Q1_Y004.NAOK)
-
Code:
2*countif("5",that.Q1.NAOK)
Code:
sum()
Last edit: 1 month 3 days ago by captainwalker.
Please Log in to join the conversation.