Can I select a random answer from a multiple choice question

Más
1 año 8 meses antes #161791 por davebostockgmail
I have a survey that has the following requirements

1) Survey is displayed question by question
2) I have a list of 20 brands with an other specify at the end in a multiple choice question
3) I need to ask a respondent about a randomly answered brand for a series of subsequent questions

So for example
B5a Which of the following have you heard of
apples
banana
pears

E1 What do you like about [Random from B5a]

I have looked through the solutions that have been provided in the past but these all include group by group with a hidden text question ... this will not work for me as we have over 100 questions so each would have to be moved into its own group.

Is this even possible?

Thanks in advance

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

LimeSurvey Partners
Más
1 año 8 meses antes #161799 por holch
First of all: I assume that the random brand should be chosen from the ones answered, right? So only from the ones they have heard of?

Problem with question by question is where to "hide" the question that creates the randomness.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 8 meses antes #161804 por davebostockgmail
That's correct Holch ... I have thought the best way to do this would be to create an array in JQuery using the answers given then create a random number from the number of answers given and then use that to select from the array and push that into a single choice question.
Unfortunately my Jquery skills are not that advanced.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 8 meses antes - 1 año 8 meses antes #161810 por Joffm
Hi,
you can do this with some equations.
I did this some time ago. Maybe not the best, but working.

1. Equation "eqmyString"
I create a string with the "join"-function.
{join(if(Q01_SQ001=="Y","01",""),if(Q01_SQ002=="Y","02",""),if(Q01_SQ003=="Y","03",""),if(Q01_SQ004=="Y","04",""),...)}
You see if the brand was selected the code is added to the string.
You will get something like "0306111417"

2. Equation "eqnBrands"
{count(that.Q01)}

I count the number of entered brands and get "eqnBrands". In this case 5.

3. Equation "eqRandom"
I create a random number (1-numberBrands)
{rand(1,eqnBrands)}
Let's say: 4

4. Equation "eqmyBrand"
I get the substring of my string depending on the random number (eqRandom)
{substr(eqmyString,2*(eqRandom-1),2)}.
In this case substr(eqmyString,6,2) and you get "14".

You have to set (eqRandom-1) because substr starts at position 0.

And in your next question you pipe in the name.?
What do you like about {if(eqmyBrand=="01","Apples",if(eqmyBrand=="02","Bananas",if(eqmyBrand=="03","Pears","")))}?


Best regards
Joffmn


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Última Edición: 1 año 8 meses antes por Joffm.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 8 meses antes #161811 por davebostockgmail
Amazing ... thank you so much ...

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 8 meses antes #161816 por holch
Joffm, looks good. But where do you hide those equation type questions in a question by question environment?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 año 8 meses antes - 1 año 8 meses antes #161821 por Joffm
Have a look at the sample.

Here it is question by question , and I did it group by group as well.

Archivo Adjunto:

Nombre del Archivo: limesurvey...2-18.lss
Tamaño del Archivo:22 KB


Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Adjuntos:
Última Edición: 1 año 8 meses antes por Joffm.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186363 por Nighthawlk
Hi there,
I tried to addapt Joffms solution for a question including text as answers
Everything is working for me, exept step one:
"1. Equation "eqmyString"
I create a string with the "join"-function.
{join(if(Q01_SQ001=="Y","01",""),if(Q01_SQ002=="Y","02",""),if(Q01_SQ003=="Y","03",""))}
"

My first addaption is looking like this:
{join(if(!is_empty(NW1_SQ001),
if(!is_empty(NW1_SQ002),
if(!is_empty(NW1_SQ003))))}

Here, limesurvey doesn't accept the commas

Afterwards, I tried out an other addaption like this:
{ ... if(!is_empty(NW1_SQ003),3,
if(!is_empty(NW1_SQ002),2,
if(!is_empty(NW1_SQ001),1))))}

This was working yesterday. Today it is only working when I have NW1_SQ018 answered.

Can you help me finding the mistakes?

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186391 por Joffm

{join(if(!is_empty(NW1_SQ001),
if(!is_empty(NW1_SQ002),
if(!is_empty(NW1_SQ003))))}
Here, limesurvey doesn't accept the commas


LimeSurvey does accept comma, but your usage of the if-statements seems to be wrong.
We don't see your sample.

Remember:
if(condition,what if true,what if false)

Joffm


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

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186397 por DenisChenu

Joffm escribió: Remember:
if(condition,what if true,what if false)

Just a correction :
if(condition,what if true)
OR
if(condition,what if true,what if false)
Since 3.0.2 LimeSurvey version :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186439 por Nighthawlk
Thank you very much for your answers.

Remember:
if(condition,what if true,what if false)

that would mean, my example 2 should work properly although it doesn't, right?

We don't see your sample

I also attached my sample for a better comprehensibility of the appearing errors

It would be very nice, if you could find the time for a deeper look inside the code

Archivo Adjunto:

Nombre del Archivo: limesurvey...5926.lsg
Tamaño del Archivo:19 KB
Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186443 por Nighthawlk
PS: see question COUNT1

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes - 1 mes 1 semana antes #186456 por Joffm

that would mean, my example 2 should work properly although it doesn't, right?


No, because there are only if-statements but nothing what you want to join.

And, please, send a whole survey (*.lss) with only the relevant questions.

lsq and lsg are language dependent.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Última Edición: 1 mes 1 semana antes por Joffm.

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes - 1 mes 1 semana antes #186461 por Joffm
Hi, here your survey back.

There was an error in the join-statement. (no brackets in front of the "if")
join(if( ! is_empty(NW1_SQ001), "01", ""),(if( ! is_empty(NW1_SQ002), "02", ""),(if( ! is_empty(NW1_SQ003), "03", ""),...
The bracket in front of the first "if" is the bracket of the join function.

And I set subquestion relevance to zhe first question so that one row after the other is displayed.
And the equations have to be on a different page.
I explained it already in a different post with the same approach.
https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/118275-children-randomization
If the random-function is on the same page it will be fired each time and each time you will get a new value.
To avoid this we use "if(is_empty(random),rand(1,5),random).
But in this case the random function will fire after your first entry, selects "1" as random value, which never is changed.





Best regards
Joffm

Archivo Adjunto:

Nombre del Archivo: limesurvey...3929.lss
Tamaño del Archivo:33 KB


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Adjuntos:
Última Edición: 1 mes 1 semana antes por Joffm.
El siguiente usuario dijo gracias: Nighthawlk

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 1 semana antes #186475 por Joffm
Furthermore: remove the equation "JOIN".
It is not used ib your survey.
You see, you use all filled fields of your first question.
The "trick" to create a string by joining characters was used if you'd only consider entries that have to fulfill a condition.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
El siguiente usuario dijo gracias: Nighthawlk

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

¡Comenzar ahora!

Simplemente cree una cuenta y comience a usar LimeSurvey hoy mismo.

Registrarse ahora
¡Únase a nuestro boletín informativo!

Iniciar sesión