- Posts: 77
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Randomize a mark
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
2 years 2 months ago #223535
by Mon2016
Randomize a mark was created by Mon2016
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:
Theme:
==================
[Write here your question/remark]Hello appreciated forum.
I hope everyone has a great 2022.
Currently I am telling you that I am conducting a satisfaction survey with several brands, but one question is not going well for me.
I have a multiple choice question and let's mention it P01.
where you ask the brands you bought during the last month.
P01. what did you buy in the last month?
Brand1
Brand2
Brand3
Brand4
Brand5
And in the second question let's call it P02
P02. How many days ago was it that you made your last purchase of ____ (INSERT SELECTED BRAND NAME)
Now the problem is the following:
IF YOU PURCHASED ONLY ONE BRAND, THE EVALUATION QUESTIONS WILL BE ASKED REFERRING TO THIS BRAND.
IF YOU PURCHASED MORE THAN ONE BRAND, SELECT ONE OF WHICH I DID BUY RANDOMLY AND HARÁN'S EVALUATION QUESTIONS REFERRING TO THIS RANDOMLY SELECTED BRAND.
To make only the reference of the unique brand that you have selected in P01 it must be something like {P01_1.shown} {P01_2.shown}
{P01_3.shown} etc ...
The dilemma is in performing the randomization of whether you select 2 or more brands.
Hope someone has a better idea how to achieve this.
my version of LS is: Version 3.25.10
I appreciate all your support.
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Theme:
==================
[Write here your question/remark]Hello appreciated forum.
I hope everyone has a great 2022.
Currently I am telling you that I am conducting a satisfaction survey with several brands, but one question is not going well for me.
I have a multiple choice question and let's mention it P01.
where you ask the brands you bought during the last month.
P01. what did you buy in the last month?
Brand1
Brand2
Brand3
Brand4
Brand5
And in the second question let's call it P02
P02. How many days ago was it that you made your last purchase of ____ (INSERT SELECTED BRAND NAME)
Now the problem is the following:
IF YOU PURCHASED ONLY ONE BRAND, THE EVALUATION QUESTIONS WILL BE ASKED REFERRING TO THIS BRAND.
IF YOU PURCHASED MORE THAN ONE BRAND, SELECT ONE OF WHICH I DID BUY RANDOMLY AND HARÁN'S EVALUATION QUESTIONS REFERRING TO THIS RANDOMLY SELECTED BRAND.
To make only the reference of the unique brand that you have selected in P01 it must be something like {P01_1.shown} {P01_2.shown}
{P01_3.shown} etc ...
The dilemma is in performing the randomization of whether you select 2 or more brands.
Hope someone has a better idea how to achieve this.
my version of LS is: Version 3.25.10
I appreciate all your support.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago #223537
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Hi,
here a rather easy to understand sample without any javascript
You may search the forum to find a solution that uses javascript.
I think to remember something some long time ago.
Joffm
here a rather easy to understand sample without any javascript
You may search the forum to find a solution that uses javascript.
I think to remember something some long time ago.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Mon2016
The topic has been locked.
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 0
2 years 2 months ago #223538
by Mon2016
Replied by Mon2016 on topic Randomize a mark
Hi joffm,
Thank you very much for your help,
I will apply this, however I will look up what you mention from Java to try both ways.
I appreciate your valuable help.
Thank you very much for your help,
I will apply this, however I will look up what you mention from Java to try both ways.
I appreciate your valuable help.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago #223551
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Hi,
here a slightly better structured example of the version without javascript
And a version with javascript
Joffm
here a slightly better structured example of the version without javascript
And a version with javascript
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 0
2 years 2 months ago #223611
by Mon2016
Replied by Mon2016 on topic Randomize a mark
Hi Joffm,
Thank you very much for your help,
I have a question, if instead of just using a single letter like this case, you write me the example with A, B, C, D, E etc ...
if instead of using that, I need to use four digits like for example this.
1A01
2A01
3A01
4A01
5A01
Since the way of asking the question was changed and the list of possible answers is very long.
To identify each one of the digits, is it possible to do so ?, since I have tried to change this expression as follows: {substr (eqBrands, eqRand-4,4)}
To identify the length, so far everything works fine,
But the randomization of the marks does not register it for me correctly.
I share an lss file with the structure of my survey
Thank you again for your great help.
Greetings,
Thank you very much for your help,
I have a question, if instead of just using a single letter like this case, you write me the example with A, B, C, D, E etc ...
if instead of using that, I need to use four digits like for example this.
1A01
2A01
3A01
4A01
5A01
Since the way of asking the question was changed and the list of possible answers is very long.
To identify each one of the digits, is it possible to do so ?, since I have tried to change this expression as follows: {substr (eqBrands, eqRand-4,4)}
To identify the length, so far everything works fine,
But the randomization of the marks does not register it for me correctly.
I share an lss file with the structure of my survey
Thank you again for your great help.
Greetings,
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago #223622
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Hi,
I think you did not fully understand the approach.
These characters are only signs to characterize the balls that you put into the box.
Then you draw one of the balls and the sign tells you which brand is chosen.
So one character covers up to 72 options: "A-Z, a-z, 0-9, #+*?)/&%$"
You see with your 4 characters (ONLy capital letters and digits) you get 1679616 options.
Now to your survey:
As far as I see there are only 10 brands.
Why did you create as much separate questions instead of using subquestion relevance?
E.g. Brand 1 (Café Punta del Cielo) is displayed, if
P03.NAOK==1 OR P03.NAOK==5 OR P03.NAOK==10 OR P03.NAOK==11 OR P03.NAOK==13 OR P03.NAOK==15 OR P03.NAOK==16 OR P03.NAOK==18 OR P03.NAOK==20 OR P03.NAOK==21 OR P03.NAOK==23 OR P03.NAOK==24
and Brand 6 (Tim Hortons) is only displayed if
P03.NAOK==8 OR P03.NAOK==18
This means, one question is sufficient with 10 subquestions.
And please read the manual about the if-statement, the implemented functions,
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]
import the sample surveys and study them
[url] manual.limesurvey.org/ExpressionScript_sample_surveys [/url]
Joffm
By the way:
If you join your four characters to something like
1A014B073C021A071A11
you joined 5 elements. Therefore you have to generate a random number between 1 and 5, meaning you have to divide the length of this string by 4 (the length of each element)
{rand(1,strlen(Q1)/4)}
And to grab the desired part with the function "substr(start,length)", it is
{substr(4*(eqRand-1),4)}
I think you did not fully understand the approach.
These characters are only signs to characterize the balls that you put into the box.
Then you draw one of the balls and the sign tells you which brand is chosen.
So one character covers up to 72 options: "A-Z, a-z, 0-9, #+*?)/&%$"
You see with your 4 characters (ONLy capital letters and digits) you get 1679616 options.
Now to your survey:
As far as I see there are only 10 brands.
Why did you create as much separate questions instead of using subquestion relevance?
E.g. Brand 1 (Café Punta del Cielo) is displayed, if
P03.NAOK==1 OR P03.NAOK==5 OR P03.NAOK==10 OR P03.NAOK==11 OR P03.NAOK==13 OR P03.NAOK==15 OR P03.NAOK==16 OR P03.NAOK==18 OR P03.NAOK==20 OR P03.NAOK==21 OR P03.NAOK==23 OR P03.NAOK==24
and Brand 6 (Tim Hortons) is only displayed if
P03.NAOK==8 OR P03.NAOK==18
This means, one question is sufficient with 10 subquestions.
And please read the manual about the if-statement, the implemented functions,
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]
import the sample surveys and study them
[url] manual.limesurvey.org/ExpressionScript_sample_surveys [/url]
Joffm
By the way:
If you join your four characters to something like
1A014B073C021A071A11
you joined 5 elements. Therefore you have to generate a random number between 1 and 5, meaning you have to divide the length of this string by 4 (the length of each element)
{rand(1,strlen(Q1)/4)}
And to grab the desired part with the function "substr(start,length)", it is
{substr(4*(eqRand-1),4)}
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 0
2 years 2 months ago #223643
by Mon2016
Replied by Mon2016 on topic Randomize a mark
Hi joffm,
I did it this way by separating the question because I'm only interested in taking the first 7 strings, so if a participant selects A,B,C,H I'm only interested in taking one string from the first three.
Another example would be if you select A,H,I,J in this case I would only use option A since H, I, J I am not interested in evaluating them.
one more example
C,D,I,J
I just need to randomly pick some of C and D since I and J don't care to evaluate it.
Mon
I did it this way by separating the question because I'm only interested in taking the first 7 strings, so if a participant selects A,B,C,H I'm only interested in taking one string from the first three.
Another example would be if you select A,H,I,J in this case I would only use option A since H, I, J I am not interested in evaluating them.
one more example
C,D,I,J
I just need to randomly pick some of C and D since I and J don't care to evaluate it.
Mon
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago - 2 years 2 months ago #223645
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Okay, then nectlect the other brands in the "join" function
Don't forget to have a relevance equation on the result question if the participant only selects the "not interesting" brands, like"!is_empty(eqBrands)"
Don't forget to have a relevance equation on the result question if the participant only selects the "not interesting" brands, like"!is_empty(eqBrands)"
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 2 months ago by Joffm.
The topic has been locked.
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 0
2 years 2 months ago #223663
by Mon2016
Replied by Mon2016 on topic Randomize a mark
Perfect, Joffm,
Just to have an idea of the examples you share with only A, B, C, D, E...
Can I exclude that it does not ask me for the strings of interest?
It would be great to not make so many variables created.
Greetings,
Just to have an idea of the examples you share with only A, B, C, D, E...
Can I exclude that it does not ask me for the strings of interest?
It would be great to not make so many variables created.
Greetings,
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago #223666
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Sorry I do not understand.
Show what you did -> lss export.
Joffm
Who asks when for a string?Can I exclude that it does not ask me for the strings of interest?
There are only three variables created.It would be great to not make so many variables created.
Show what you did -> lss export.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Mon2016
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 77
- Thank you received: 0
2 years 2 months ago #223671
by Mon2016
Replied by Mon2016 on topic Randomize a mark
hi joffm
attached lss of the created survey,
as I commented I don't want to evaluate H, I, J...
I am interested in evaluating A,B,C,D,E,F,G.
Thanks once again for your great help
attached lss of the created survey,
as I commented I don't want to evaluate H, I, J...
I am interested in evaluating A,B,C,D,E,F,G.
Thanks once again for your great help
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
2 years 2 months ago - 2 years 2 months ago #223674
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Randomize a mark
Hi,
{join(if(P0401_1=="Y","A",""),if(P0401_2=="Y","B",""),if(P0401_3=="Y","C",""),if(P0401_4=="Y","D",""),if(P0401_5=="Y","E",""),if(P0401_6=="Y","F",""),if(P0401_7=="Y","G",""),if(P0401_8=="Y","H",""),if(P0401_9=="Y","I",""),if(P0401_10=="Y","J",""))}
{join(if(P0401_1=="Y","A",""),if(P0401_2=="Y","B",""),if(P0401_3=="Y","C",""),if(P0401_4=="Y","D",""),if(P0401_5=="Y","E",""),if(P0401_6=="Y","F",""),if(P0401_7=="Y","G",""))}
And now I saw that you display this selected nme several times.
Here it is better to calculate the name in an equation (eqBrandName) withe the used code ;{if(eqBrand=="A",P0401_1.shown, if(eqBrand=="B",....
also without the "HIJ" IFs, and use this in the further questions.
Joffm
as I said, Neglect them, don't include them in the join() function.as I commented I don't want to evaluate H, I, J...
{join(if(P0401_1=="Y","A",""),if(P0401_2=="Y","B",""),if(P0401_3=="Y","C",""),if(P0401_4=="Y","D",""),if(P0401_5=="Y","E",""),if(P0401_6=="Y","F",""),if(P0401_7=="Y","G",""),if(P0401_8=="Y","H",""),if(P0401_9=="Y","I",""),if(P0401_10=="Y","J",""))}
{join(if(P0401_1=="Y","A",""),if(P0401_2=="Y","B",""),if(P0401_3=="Y","C",""),if(P0401_4=="Y","D",""),if(P0401_5=="Y","E",""),if(P0401_6=="Y","F",""),if(P0401_7=="Y","G",""))}
And now I saw that you display this selected nme several times.
Here it is better to calculate the name in an equation (eqBrandName) withe the used code ;{if(eqBrand=="A",P0401_1.shown, if(eqBrand=="B",....
also without the "HIJ" IFs, and use this in the further questions.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 2 months ago by Joffm.
The topic has been locked.