Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

randomize options but in different groups

  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 4 months ago #225111 by john_bons
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]  tueindhoven.limequery.com/
Own server or LimeSurvey hosting: LS hosting
Survey theme/template:
================== fruity
(Write here your question/remark)

Dear team.Four times we want to show a page in which 2 video’s (out of 8) are presented (randomly) and than ask some statement questions about these video’s. So all 8 videos are to be shown but in different and random combinations of two to each respondent.At the end of the page the question is asked which video they want to choose or neither of the two.

Could you let us know on how to approach this?
 thank you.
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #225112 by Joffm
Replied by Joffm on topic randomize options but in different groups
Hi,
I assume tht in the meantime you have a pool of all here given solutions in Eindhoven.

I should do it like this:
In a question of type "short text" you create a string of 8 characters in random order.
Code:
<script type="text/javascript" charset="utf-8">        
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Identify this question
        var thisQuestion = $('#question{QID}');            
    
            // Create an array of possible numbers
            var numbers = [1,2,3,4,5,6,7,8];
     
            // Shuffle the numbers array
            shuffleArray(numbers);
            var n1=numbers.join();
            var n2=n1.replace(/,/g, '');
            $('input:text', thisQuestion).val(n2);
    });
 
    // A function to shuffle arrays
    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>

This will give you a string like "62857341"

Now if you rename your videos to something like "video1.mp4", "video2.mp4" you can select the videos as "video{substr(Q0,0,1)}.mp4" which will result in "video6.mp4".
And the next as "video{substr(Q0,1,1)}.mp4"

Joffm

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #225127 by Joffm
Replied by Joffm on topic randomize options but in different groups
Hi, here a small sample (with images).
Q0 is hidden by css class "hidden".

Q1a, Q2a,... by "always hide this question".
The displayed images/videos are stored in these questions. This will ease your analysis.

 

File Attachment:

File Name: limesurvey...7213.lss
File Size:34 KB

Joffm

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

Please Log in to join the conversation.

  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 4 months ago #225134 by john_bons
Replied by john_bons on topic randomize options but in different groups
Sorry for not mentioning earlier, the videos are not files but youtube links.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #225137 by Joffm
Replied by Joffm on topic randomize options but in different groups
Oh, nice to hear.
But that's not a big difference.
I created a question of type "multiple short text" (P1) where I inserted the embed code of the videos as default answers.

Now I can shpw the videos like (only shown for 4 videos)
Code:
<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315"
src="{if(substr(Q0,0,1)=='1',P1_1.shown, if(substr(Q0,0,1)=='2',P1_2.shown, if(substr(Q0,0,1)=='3',P1_3.shown,P1_4.shown)))}"
title="YouTube video player" width="560"></iframe>

Of course you may hardcode the embed codes in the IF-statement.

Joffm

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

Please Log in to join the conversation.

  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 4 months ago #225411 by john_bons
Replied by john_bons on topic randomize options but in different groups
it worked completely fine. thank you Joffm. Also am creating an example survey with your solutions for future reference.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose