0 votes
ago in SoSci Survey (English) by s331826 (120 points)
edited ago by SoSci Survey

In my questionnaire I want to show the participants a selection of stimuli depending on the socio-demographic group that they are in (gender, age group, educational level = 2x4x5 = 40 categories). The goal of this is to realize equal testing of all stimuli across all different socio-demographic groups.

To realize this I collect their information on the first page of the questionnaire. Then I place the following part of PHP-code on the same page:

(disclaimer: to make it easier to test the functionality of this, I opted for only 2 urns. For the actual code implementation I would need an urn (and internal variable) for all 40 categories - I think)

if ((value('SD01') == 1) && (value('SD03') == 1) && (value('SD10') == 1)) {
    urnDraw('testurn', 'IV01', 'end');
} else {
    urnDraw('testurn2', 'IV02', 'end');
}



After that I put the following PHP-code on the next page of the questionnaire to show the randomized stimuli to the respective socio-demographic group:



if (value('IV01') > 0) {
    switch (value('IV01')) {
        case 1:
            html('<img src="pro://6.jpg" alt="Stimulus 1">');
            break;
        case 2:
            html('<img src="pro://9.jpg" alt="Stimulus 2">');
            break;
        default:
            html('<p style="color:red">Kein Stimulus verfügbar.</p>');
            break;
    }
}
elseif (value('IV02') > 0) {
    switch (value('IV02')) {
        case 1:
            html('<img src="pro://7" alt="Stimulus 3">');
            break;
        case 2:
            html('<img src="pro://8.jpg" alt="Stimulus 4">');
            break;
        default:
            html('<p style="color:red">Kein Stimulus verfügbar.</p>');
            break;
    }
}
else {
    html('<p style="color:red">Fehler: Kein Stimulus gezogen.</p>');
}

My problem no is that this is not working. It does not show me any stimuli in the questionnaire when I test it, only a red error message. Could anybody help me with this problem please?

Best regards

1 Answer

0 votes
ago by SoSci Survey (348k points)

40 categories

You should make sure to have at least a dozen respondents per group before such a complex design makes sense. You may even result in experimetnal groups of very different size, if there are too few respondents per-group. So, if you have less than 480 respondents, please reconsider your plan.

For the actual code implementation I would need an urn (and internal variable) for all 40 categories - I think)

That is correct. You may, however, consider using random generators instead of the (older) groups. If you stay with the urns, use the same internal variable in each case:

if ((value('SD01') == 1) && (value('SD03') == 1) && (value('SD10') == 1)) {
    urnDraw('testurn', 'IV01', 'end');
} else {
    urnDraw('testurn2', 'IV01', 'end');
}

only a red error message

It is super-helpful to read and post the exact wording of the messages.

However, in you case I'm quite sure it tells that there is no IV01, because the variable name is IV01_01. Also do not use the switch, please. Try this:

if (value('IV01_01') == 1) {
  html('<img src="pro://6.jpg" alt="Stimulus 1">');
} else {
  html('<img src="pro://9.jpg" alt="Stimulus 2">');
}

General note on the use of AI tools: Your question indicates that you may have asked ChatGPT or another tool for a solution instead of reading the instructions. Know, that ChatGPT has not read the SoSci Survey manual, either. Therefore, ChatGPT is essentially just giving you hallucinations on how to use SoSci Survey. If you want to work with generative AI: Gemini at least knows the instructions for SoSci Survey. Please note, however, that even then the answers from generative AI are only correct with a chance of approx. 65%.

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

...