- Posts: 23
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Pipe random store name to a set of questions from a list of store name
- saifshaikh
- Topic Author
- Offline
- Junior Member
Less
More
8 months 4 weeks ago #245920
by saifshaikh
Pipe random store name to a set of questions from a list of store name was created by saifshaikh
Please help us help you and fill where relevant:
Your LimeSurvey version: [2.73.3-1]
Own server or LimeSurvey hosting: hosted
Survey theme/template: default
==================
Hi,
I would like to pipe random store name to a set of questions from a list of stores
eg.
Q1 - Store List (Hidden)
store 1
store 2
store 3
store 4
store 5
Q2 - Have you heard of {store 3}?
Thank you in advance,
Saif
Your LimeSurvey version: [2.73.3-1]
Own server or LimeSurvey hosting: hosted
Survey theme/template: default
==================
Hi,
I would like to pipe random store name to a set of questions from a list of stores
eg.
Q1 - Store List (Hidden)
store 1
store 2
store 3
store 4
store 5
Q2 - Have you heard of {store 3}?
Thank you in advance,
Saif
Please Log in to join the conversation.
- saifshaikh
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
- Thank you received: 0
8 months 4 weeks ago #245921
by saifshaikh
Replied by saifshaikh on topic Pipe random store name to a set of questions from a list of store name
I was able generate random name from the thread below, but was unable to pipe that into another question
forums.limesurvey.org/forum/can-i-do-thi...m-name-out-of-a-list
forums.limesurvey.org/forum/can-i-do-thi...m-name-out-of-a-list
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13063
- Thank you received: 4023
8 months 4 weeks ago - 8 months 4 weeks ago #245922
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Pipe random store name to a set of questions from a list of store name
Hi,
did you import the sample survey?
So, what is your problem to show the randiom name?
I think you did not and missed to insert the <span> element.
Please show what you did!
lss export of this relevant question.
But you know that this solution does not store the selected name.
If you want to store the name, please tell us.
In this case the solution is nearly the same, but only nearly.
Joffm
did you import the sample survey?
So, what is your problem to show the randiom name?
I think you did not and missed to insert the <span> element.
Please show what you did!
lss export of this relevant question.
But you know that this solution does not store the selected name.
If you want to store the name, please tell us.
In this case the solution is nearly the same, but only nearly.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 8 months 4 weeks ago by Joffm.
Please Log in to join the conversation.
- saifshaikh
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
- Thank you received: 0
8 months 4 weeks ago #245924
by saifshaikh
Replied by saifshaikh on topic Pipe random store name to a set of questions from a list of store name
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13063
- Thank you received: 4023
8 months 4 weeks ago - 8 months 4 weeks ago #245925
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Pipe random store name to a set of questions from a list of store name
Hi,
as I see you do not store the name.
Therefore you can't access anything by {q1.shown}
This you see easily when you activate the survey and enter some data.
Okay either you change the first quuestion to your desired type, like
or (if you want to store the name) use a first question of type "short text" in a different group which you hide by the css class "hidden"
Here you enter this javascript snippet
You see it is nearly the same, but you do not insert the selected store into the <span> element, but into the text.
And the result you can pupe into the next question
"Have you ever heard of {q1}?"
And the solution without javascript.
Generate a random number (1-5
{if(is_empty(randnum),rand(1,5),randnum)}
and display the store with a nested IF
{if(randnum==1,"Store 1",if(randnum==2,"Store 2",if(randnum=,"Store 3",if(randnum==4,"Store 4","Store 5"))))}
Joffm
as I see you do not store the name.
Therefore you can't access anything by {q1.shown}
This you see easily when you activate the survey and enter some data.
Okay either you change the first quuestion to your desired type, like
or (if you want to store the name) use a first question of type "short text" in a different group which you hide by the css class "hidden"
Here you enter this javascript snippet
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Define the names var names = ['Store 1', 'Store 2', 'Store 3', 'Store 4', 'Store 5', 'Store 6']; // Randomize the names shuffleArray(names); // Load the <input> element with the random name $('#question{QID} input[type="text"]').val(names[0]); }); function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } </script>[/i][/i]
And the result you can pupe into the next question
"Have you ever heard of {q1}?"
And the solution without javascript.
Generate a random number (1-5
{if(is_empty(randnum),rand(1,5),randnum)}
and display the store with a nested IF
{if(randnum==1,"Store 1",if(randnum==2,"Store 2",if(randnum=,"Store 3",if(randnum==4,"Store 4","Store 5"))))}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 8 months 4 weeks ago by Joffm.
Please Log in to join the conversation.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11713
- Thank you received: 2756
8 months 4 weeks ago #245926
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Pipe random store name to a set of questions from a list of store name
First of all a couple of things:
You really shouldn't run such an old and outdates version of Limesurvey in production. 2.73.x was released at the end of 2017 (I don't think a 2.73.3-1 has ever existed though) , so almost 6 years ago and is not supported anymore for quite while now. It hasn't received any updates, bug fixes, security patches for almost 6 years now.
Given the age of your installation it is save to say that your installation is NOT hosted by Limesurvey GmbH but must be an own server of your company, institution, etc.
Of course I don't have such an ancient installation running to test it with 2.73.x but I have opened it with LS 3.x, which is the closest supported version to your outdated version (we are at LS 6.x right now).
I'll try to have a look at your LSS and see what might be wrong.
Your LimeSurvey version: [2.73.3-1]
You really shouldn't run such an old and outdates version of Limesurvey in production. 2.73.x was released at the end of 2017 (I don't think a 2.73.3-1 has ever existed though) , so almost 6 years ago and is not supported anymore for quite while now. It hasn't received any updates, bug fixes, security patches for almost 6 years now.
Own server or LimeSurvey hosting: hosted
Given the age of your installation it is save to say that your installation is NOT hosted by Limesurvey GmbH but must be an own server of your company, institution, etc.
Of course I don't have such an ancient installation running to test it with 2.73.x but I have opened it with LS 3.x, which is the closest supported version to your outdated version (we are at LS 6.x right now).
I'll try to have a look at your LSS and see what might be wrong.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: saifshaikh
Please Log in to join the conversation.
- saifshaikh
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
- Thank you received: 0
8 months 4 weeks ago #245946
by saifshaikh
Replied by saifshaikh on topic Pipe random store name to a set of questions from a list of store name
Thank you for the solution, I will try out the above solution
Please Log in to join the conversation.
- saifshaikh
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
- Thank you received: 0
8 months 3 weeks ago - 8 months 3 weeks ago #246243
by saifshaikh
Replied by saifshaikh on topic Pipe random store name to a set of questions from a list of store name
Thanks Joffm, that worked as per my requirement.
I have duplicated the question Q-BE2, to generate additional random store name. is it possible that the same store name is not randomly selected as in Q-BE.
Both BE & BE2 should be unique.
I have attached sample survey.
Thanks & advance
I have duplicated the question Q-BE2, to generate additional random store name. is it possible that the same store name is not randomly selected as in Q-BE.
Both BE & BE2 should be unique.
I have attached sample survey.
Thanks & advance
Last edit: 8 months 3 weeks ago by saifshaikh.
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13063
- Thank you received: 4023
8 months 3 weeks ago #246244
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Pipe random store name to a set of questions from a list of store name
1. Remove BE2
2. Change BE to "multiple short text" with two subquestions
3. Change this part of the script
that the first randomized brand is stored int the first subquestion, the second in the second.
And I advice to change these four "text display" questions to only one with a nested IF, as I showed before
Insted of this
{if(randnum==1,"Store 1",if(randnum==2,"Store 2",if(randnum=,"Store 3",if(randnum==4,"Store 4","Store 5"))))}
use this
{if(BE_SQ001=="Douglas","Douglas is a European beauty retail chain...",if(BE_SQ001="Ulta","Ulta: Ulta is a beauty retailer in the United States ...",if(...))))}
Joffm
2. Change BE to "multiple short text" with two subquestions
3. Change this part of the script
Code:
// Load the <input> element with the random name $('#question{QID} input[type="text"]:eq(0)').val(names[0]); $('#question{QID} input[type="text"]:eq(1)').val(names[1]);
that the first randomized brand is stored int the first subquestion, the second in the second.
And I advice to change these four "text display" questions to only one with a nested IF, as I showed before
Insted of this
{if(randnum==1,"Store 1",if(randnum==2,"Store 2",if(randnum=,"Store 3",if(randnum==4,"Store 4","Store 5"))))}
use this
{if(BE_SQ001=="Douglas","Douglas is a European beauty retail chain...",if(BE_SQ001="Ulta","Ulta: Ulta is a beauty retailer in the United States ...",if(...))))}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.