Welcome to the LimeSurvey Community Forum

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

appear randomly and arranged them in random order

  • RitaShen
  • RitaShen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 1 month ago - 1 year 1 month ago #241077 by RitaShen
Please help us help you and fill where relevant:
Your LimeSurvey version:  5.6.8
Own server or LimeSurvey hosting:LimeSurvey hosting
Survey theme/template: bootswatch
==================
Hi there,

If I have 10 pictures, but I just want to appear 8 of 10 pictures randomly, but also those 8 pictures need to appear in random order.
(randomly pick 8 sets of paired profiles out of all the 10 possible sets and arranged them in random order)
How could I present or what could I do?

Thank you in advance
Last edit: 1 year 1 month ago by RitaShen.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago - 1 year 1 month ago #241079 by Joffm
Hi, Rita,
you may use this javascript to select the 8 out of 10
Insert it into a question of type "shorttext" (eqImage)
Code:
<script type="text/javascript" charset="utf-8">
 
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
  // While there remain elements to shuffle...
  while (0 !== currentIndex) {
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
 
    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
  return array;
}
 
$(document).on('ready pjax:scriptcomplete',function(){
// Fill the array
      var arr = ["A","B","C","D","E","F","G","H","I","J"];
// Shuffle the array
      arr = shuffle(arr);
      anumbers = arr.slice(0,8).join('');
      $('#question{QID} input[type="text"]').val('#'+anumbers);
      $('#question{QID}').hide();
   });
</script>

You will get something like #CEFAHBDJ

Your questions all get the same randomozation group name and the conditions
strpos(eqImage,"A")>0
strpos(eqImage,"B")>0
...


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 1 month ago by Joffm.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago - 1 year 1 month ago #241081 by Joffm
Or you use the property ".gseq"
 

File Attachment:

File Name: limesurvey...7477.lss
File Size:77 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 1 month ago by Joffm.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241082 by DenisChenu
Replied by DenisChenu on topic appear randomly and arranged them in random order
Hi @Joofm : why not 10 Dispaly text question (with the picture) in same random group and 2 in a «hidden» group ?

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241084 by Joffm
Because this obvious way to do it didn't come to my mind this morning. I am an old man.

Maybe I was a bit confused about it because

(randomly pick 8 sets of paired profiles out of all the 10 possible sets and arranged them in random order)

So I thought there might be more than one question in a group.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #241088 by holch
It all comes down to how these 8 images should be presented. If they should be presented in one question it is different to 8 out of 10 questions with different pictures.

So I think we need some more information from OP about how the images should be presented in the first place.

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: DenisChenu

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose