How to write code to randomly display photos, meeting the given conditions | XM Community
Solved

How to write code to randomly display photos, meeting the given conditions

  • 5 September 2018
  • 9 replies
  • 160 views

Hi, I got 80 pictures split in 2 groups ( groups 1 and 2 ) which are also split in 10 categories from "a" to "j" ( each category contain 4 pictures ).
I need to randomly show 40 pictures, 20 pictures from group 1 and 20 pictures from group 2. Whats important is if picture number 1 from category "a" is showed i also need to show remaining 3 pictures from category "a". So basically i need to randomly display pictures from each 5 categories from grup 1 and group 2. The more randomized display of pictures is then beter. I also need to set time limit for display ( 4 s ) for each picture. Have anyone done something similar before? I am open for any ideas.
icon

Best answer by Anonymous 5 September 2018, 15:09

View original

9 replies

Hello @Laura_Kulak ,

The answer is attached. Please see
Userlevel 7
Badge +33
Better create 10 categories of 4 images each for both groups and apply randomizer or these 10 categories like only 1 category to be picked out of the 10 category.
Hello @Laura_Kulak ,

Also you can create 20 blocks each containing 4 questions.
Apply Randomize advanced element to 10 blocks i.e to group 1 and set randomly present 5 blocks i.e the respondent will see 20 questions(pictures) in the survey from first randomizer
Similarly, set Randomize advanced element for next 10 blocks i.e for group 2.
Apply auto advance to every question, so that respondent can only see picture for 4 seconds
I can't mess up with those categories, that was set up by my supervisors. About that Javascript code i need some time to proces it 🙂
Randomization at each image level is difficult to implement
> @Shashi said:
> Hello @Laura_Kulak ,
>
> Also you can create 20 blocks each containing 4 questions.
> Apply Randomize advanced element to 10 blocks i.e to group 1 and set randomly present 5 blocks i.e the respondent will see 20 questions(pictures) in the survey from first randomizer
> Similarly, set Randomize advanced element for next 10 blocks i.e for group 2.
> Apply auto advance to every question, so that respondent can only see picture for 4 seconds

I did it that way already, but it is not randomized enough for my supervisor.
They want me to make it work like that:

1. Select 5 categories from group 1 (20 pictures)
2. Select 5 categories from group 2 (another 20 pictures)
3. Display those 40 pictutres (20 from group 1 20 from group 2) complitly random
4. Each respondee should see different combination of pictures from different categories.
Points 1 and 2 should also be randomized.
> @Laura_Kulak said:
> > @Shashi said:
> > Hello @Laura_Kulak ,
> >
> > Also you can create 20 blocks each containing 4 questions.
> > Apply Randomize advanced element to 10 blocks i.e to group 1 and set randomly present 5 blocks i.e the respondent will see 20 questions(pictures) in the survey from first randomizer
> > Similarly, set Randomize advanced element for next 10 blocks i.e for group 2.
> > Apply auto advance to every question, so that respondent can only see picture for 4 seconds
>
> I did it that way already, but it is not randomized enough for my supervisor.
> They want me to make it work like that:
>
> 1. Select 5 categories from group 1 (20 pictures)
> 2. Select 5 categories from group 2 (another 20 pictures)
> 3. Display those 40 pictutres (20 from group 1 20 from group 2) complitly random
> 4. Each respondee should see different combination of pictures from different categories.
> Points 1 and 2 should also be randomized.

The JS solution will work according to your requirement then.
But if you want those 40 picture question to completely randomize then please note that Timer question for auto advance will not work instead use js for auto advance as below
You can put js(onready) in each question:
`setTimeout(function () {jQuery('#NextButton').click();},4000);`
Ok, then in 2-nd part od survey I need to display randomly all 80 pictures and after each picture i need to ask (show) 3 questions is it posible to use that js code to do it?
> @Laura_Kulak said:
> Ok, then in 2-nd part od survey I need to display randomly all 80 pictures and after each picture i need to ask (show) 3 questions is it posible to use that js code to do it?

1. Are you asking same question or almost same question type with few changes after each image, if yes then Loop and merge is best option.

2. Even if you are not asking same question then too that js code will work

Leave a Reply