0 votes
in SoSci Survey (English) by s198815 (155 points)

Hi everyone.

I'm creating an online study in which I have 4 conditions. In each condition, I have 3 pictures. I would like each participant to be randomly exposed to 2 of the 3 pictures in each condition. A participant, therefore, sees 8 of the 12 existingpictures. The same participant cannot be exposed to the same picture twice.

I'd like to randomize both the order of the conditions and the order of the pictures within the conditions.

To do this, I imagined creating four random generators presenting the pictures, one for each condition. Each random generator contains 3 codes, one per picture. I then ask to draw 2 codes per interview (draw without returning).

My plan was then to insert each randomizer twice into the questionnaire (given that participants have to be exposed to 2 of the 3 pictures of each condition), each time on a different page, and then randomize the order of presentation of the pages.

I face a first problem, however: when I insert the random generator two times into the questionnaire, it shows me the same picture twice, even though I've specified that it should draw 2 different codes (given that I specified "without returning").

How do you get the randomizer to show two different pictures (on two different pages)? I thought I had to insert the randomizer twice in the questionnaire to draw two codes, but this doesn't seem to be the case.

I'd also like to point out that to show the pictures thanks to the randomizer I used the following htlm code in "display contents" :

Thank you very much!

1 Answer

+1 vote
by SoSci Survey (327k points)
selected by s198815
 
Best answer

Drawing 2 of 3 pictures, there are 6 possible combinations (including the image order).

I would suggest NOT to draw the pictures randomly, but to make sure that all images are drawn equally often. That would mean to place 4x6 = 24 codes in the random generator, something like

1 = A1,A2
2 = A2,A1
3 = A1,A3
4 = A3,A1
5 = A2,A3
6 = A3,A2
7 = B1,B2
...
24 = D3,D2

The function value(..., 'csv') helpfs to separate the two values.

Another option would be to create 5 random generators. One for the condition, and 4 for the pictures in each condition. Then you would draw from one of the 4 random generators, depending on what was drawn in the first random generator.

You would not let the random generator(s) present the images directly, but would use a bit of PHP code to show the appropriate image. See Randomization with PHP-Code.

by s198815 (155 points)
Thank you for your reply.

However, I would like each participant to see 2 pictures of each condition. So the same participant sees two of the three images in condition A, two of the three images in condition B, two of the three images in condition C and two of the three images in condition D. And all this in a totally random order (e.g. B1, D2, D1, A1, C3, A2, C1, B3). So there are far more than 24 possible codes.  If I understand your proposal correctly, the participant still sees only two images, not 8 (4*2).

What's the easiest way to implement this on soscisurvey?

Thanks in advance!
by SoSci Survey (327k points)
Alright, we're getting closer :)

If you have that many (not only two) images per inteview, the exact combination is much less important. In that case, I would recommend 4 random generators with 3 codes in each:

First one:
A1, A2
A1, A3
A2, A3

Second one, the same but with the B-images.

> And all this in a totally random order

Draw from each random generator, use valueList() to get the images, and merge these arrays together, using array_merge(). Then you have an array with all the 8 images to show, and you just need to shuffle() this, and then preset the images, for example using loopPage().
by s198815 (155 points)
Many thanks for this quick feedback! :)

However, some things remain unclear to me (sorry, this is the first time I'm doing a design like this and I'm not used to PHP codes...)

So I did create 4 randomizers, RG01, RG02, RG03 and RG04. One code drawn per interview, without returning. So far, they all look like this (I created a few more codes than you suggested)  :

1 = A1, A2
2 = A1, A3
3 = A2, A1
4 = A2, A3
5 = A3, A1
6 = A3, A2

First of all, these codes refer to pages, correct? Not to the pictures directly. To refer to the pictures directly I'd have to enter the picture name (e.g. 1 = name_A1.png, name_A2.png) and add the htlm code to display the picture in "display contents". But here I suppose it refers to the pages named A1, A2 and A3 (which will contain the picture accordingly)?

After this, I put all these random generators on a same page, and added a PHP code looking like this :

$code1 = valueList ('RG01');
$code2 = valueList ('RG02');
$code3 = valueList ('RG03');
$code4 = valueList ('RG04');
$allImages = array_merge($code1, $code2, $code3, $code4);
shuffle($allImages);

I hope I managed to write it correctly! But I'm a bit stuck on how to actually display these pictures, each time on a different page. I guess I'll have to add a PHP code on each of the 8 pages that follow to display one of the images each time. But I don't really know what that would look like... You mentioned the loop option. I understand that this option repeats the page - starting with the start value - in a loop until the end value is reached. But I don't want the participants to see the pages more than once, so I don't know if repeating the pages makes sense? I just need each of the 8 pictures to be shown once, on different pages, so I can add questions to this page.

I hope my questions are clear and thanks again for taking the time to answer! :)
by SoSci Survey (327k points)
> I created a few more codes than you suggested

Yeah, I had these as well, bute removed half of them, because we will rotate the options anyway.

> First of all, these codes refer to pages, correct?

No, this is about images. You can either "decode" the image names later, acutally using A1 to D3 oder you can place the filenames of the images instead of the A1, A2, ...

I think replacing them later is the more elegant solution.

> and added a PHP code looking like this :

Ah, I told you something wrong. You do not need valueList() but value(..., 'csv'), so

$code1 = value('RG01', 'csv');
$code2 = value('RG02', 'csv');
$code3 = value('RG03', 'csv');
$code4 = value('RG04', 'csv');
$allImages = array_merge($code1, $code2, $code3, $code4);

> I hope I managed to write it correctly!

Add this line to get an impression:

debug($allImages);

> how to actually display these pictures

First, make sure not to shuffle this again, and again. Replace the shuffle() line as follows:

if (!isset($allImages)) {
  shuffle($allImages);
  registerVariable($allImages);
}

Then we need a replacement for the images:

$images = [
    'A1' => 'firstimage.jpg',
    'A2' => 'secondimage.jpg',
    ...
    'D3' => 'lastimage.jpg'
];

Then let's just walk the array:

$imageID = loopPage($allImages);
$image = $images[$imageID];

html('<div><img src="'.$image.'" alt="" style="max-width: 100%"><&/div>');

That would be the appropriate code to just display the images.

> so I can add questions to this page.

If you want to show the images with questions, then actually create 12 pages with the images and questions, given them page IDs A1, A2, ... D3, and instead of defining the $images array (and everything else) just show the images.

setPageOrder($allImages, 'SD');

'SD' would be the page ID of the page that follows the D3 page.
by s198815 (155 points)
I finally have a code that works, thank you for that!

In order to randomly present the conditions as well, and therefore not always start with condition A, I finally wrote my code this way :

$code1 = value('RG01', 'csv');
$code2 = value('RG02', 'csv');
$code3 = value('RG03', 'csv');
$code4 = value('RG04', 'csv');

shuffle($code1);
shuffle($code2);
shuffle($code3);
shuffle($code4);

$allCodes = array_merge($code1, $code2, $code3, $code4);

shuffle($allCodes);

setPageOrder($allCodes, 'SD')

Thank you again for taking the time!
by SoSci Survey (327k points)
Looks good.

In my opinion, the four shuffle() in the middle are superfluous, because the complete list will be shuffled again in the second line from the end. That, of course, will not pose a problem.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...