Welcome, Guest
Username: Password: Remember me

TOPIC: Just show one question from randomized group, hide the others

Just show one question from randomized group, hide the others 2 years 7 months ago #78437

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
Im guessing I should use the Relevance field for each question, in combination with the random_group command somehow?

How can I show just one randomized question, out of the five Ive got in the same group?
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78438

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
In "Relevance equation:" field Im trying:

'rand_dim1'==25659X12X76

..where rand_dim1 is the Randomization group name for the selected group. Not working though.
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78481

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
I found the answer here, under Random question sets.

However it does not seem to work when I use Survey format All in One, instead of Group by Group. When I do, only one of the groups get properly randomized.

I'm trying to get 1 random question displayed per group, on the same page.
(I have 3 different groups each containing five questions)

Thanks.
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78650

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5426
  • Thank you received: 307
  • Karma: 252
TRy the following workaround:
1. Create an additional question for each group.
2. Use Javascript to fill the question with a random number between 1-X. There are several examples at the forums and maybe also at manual -> workarounds ->JavaScript. X is the number of questions at your group.
3. Hide the question using Javascript by adding this to the question text in source code mode of the editor:
<script>
$(document).ready(function()
{
$('#question4444').hide();
});
</script>
-> replace 4444 with your question ID

4. Set conditions to each question of the group to only show up "IF question X (this we fill with the random number) equals Y".

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78686

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
Thankyou, I have followed your steps closely, and added an extra question to each group. To add a random number to that extra question I followed these instructions, however for some reason that code didnt work, but this does:

<script>
$(document).ready(function()
{
// Find a random number between 1 and 3
var randNumber = Math.floor(Math.random()*3 + 1);
// Populate and hide the hidden question
$('input#answer12739X17X94').val(randNumber);
$('#question94').hide();
});
</script>

It populates the question with random number between 1 and 3, so far so good. It fills in the number in a short text field so I can see it. (as long as I dont hide the question)

Now I try to create conditions for the rest of the questions in the group, depending on the random number I created in the first (hidden) question. I use "Set conditions for this question", choose from "Previous questions" the first hidden question, then "Equals", as an Answer I choose "Constant" and enters the value 1 for the first question.

My logic here being that the random numbers 1-3 corresponds to questions 1-3.

When saved I can see in Relevance for the question: ((G1RAND.NAOK == "1")) (G1RAND being the hidden question) However this doesnt work. Somehow the conditions doesnt get recognized, and the questions never show up.

I am stuck at the last step, what am I doing wrong?
Thanks!
Last Edit: 2 years 7 months ago by mr2jswe. Reason: spelling
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78687

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
In a subsequent question, I try to reproduce the randomized number from the earlier question through {INSERTANS:12739X17X94} but nothing shows up. Also when I use button "LimeSurvey replacement field properties" and insert from "Previous answer fields" I get {Null} as a result.

I should be able to reproduce it right?
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78688

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
You can do it this way, using built-in Expression Manager functionality and not requiring any custom JavaScript.

This sample survey has 5 groups of questions with 6 questions each. In G0, the first group, there are 5 hidden equation questions, called ask1-ask5, each of which sets a random variable using
{floor(rand(1,6.9999))}

to get a random number between 1 and 6. Then, the relevance for each question in the group is something like:
ask1==3

So, this survey pre-randomizes which questions should be shown, and each time you visit a group (e.g. if you use the navigation index to return to a question), you'll see the same randomized question; but each person who completes the survey will have a different set of random questions.

File Attachment:

File Name: limesurvey_survey_55164.lss
File Size: 113 KB


This survey is in group-at-a-time format, but it works just fine in all-in-one mode and question-by-question mode too.
Last Edit: 2 years 7 months ago by TMSWhite.
The administrator has disabled public write access.
The following user(s) said Thank You: mr2jswe

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78689

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
I just checked it out, and it looks like you solved it spot on! Its a MUCH cleaner solution aswell. My hat goes off for you Mr. White, thank you so much!

Johnny
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78690

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
You are welcome. Mazi, I added this example to the documentation here.
The administrator has disabled public write access.

Re: Just show one question from randomized group, hide the others 2 years 7 months ago #78691

  • mr2jswe
  • mr2jswe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 22
  • Karma: 0
Here is my smaller survey, same solution as yours, referring to the PM and email I sent you.

File Attachment:

File Name: limesurvey_survey_65363.lss
File Size: 31 KB
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.236 seconds
Donation Image